Hacker News new | comments | ask | show | jobs | submit login

Can anyone recommend exercises for learning a new language. For example, something like "implement a class with these methods", or implement a function that does this. Something that is realistic, should only take an hour or two to implement for a competent programmer, requires you to learn more complicated features of a language, yet I can finish before getting bored or frustrated?



Advent of Code[1] - A set of 50 tasks, released annually, with increasing difficulty. Each task is a short, Christmas related, funny story which makes it easier to follow and complete. You can track your progress so it'll give a sense of completion and satisfaction. The drawback may be that challenges are language agnostic so they aren't crafted for learning specific features of any language.

[1] https://adventofcode.com/2017/events (3 editions has been released so far)


For Rust I've seen people reference Rust Koans (https://github.com/crazymykl/rust-koans), but I haven't looked at that myself. I wanted a project that was sizeable enough to force me to use a good number of language features (but not all). I think the interpreter was a pretty good balance there, but it definitely took a time investment.


I'd also like to hear what others do to learn languages. I like to write a little RPN calculator. The program's interface might vary depending on the language: to learn browser JS, you might do a DOM-based UI; for Rust it might be a CLI; for Go or Erlang maybe a line-oriented network service.

Depending on the interface, this tends to exercise language and runtime features like: string handling and parsing, event handling, conditionals / pattern matching, etc. "Calculator" is also a big enough problem space that you can come back to it to try out more interesting language features (e.g. using Rust enums to model your calculator's operations).


I usually write data structures like Linked Lists when learning a new programming language.

This was a critical mistake for me when learning Rust and led to many, many stumbling blocks


Things like Cryptopals (https://cryptopals.com/) are good.

But surely it's going to depend somewhat on the language and what things are easy/hard to do in that language?


I think you can find koans for a lot of languages (mostly pre written tests, where you write code to make those tests pass. Some examples:

1. Kotlin Koans (https://play.kotlinlang.org/koans/overview) 2. Ruby koans (http://rubykoans.com/)



Peter Norvig has a repo of such problems / solutions (he solves them in Python, and calls them "pytudes" = "python" + "etudes", although they should be solvable in any language) https://github.com/norvig/pytudes

Rosetta code also has a great selection of problems / solutions in various languages: http://rosettacode.org/wiki/Category:Programming_Tasks


Rosalind is a good platform to learn a new language. Not the best to discover the most advanced features, but enough to ensure you know your structures and algorithms.

http://rosalind.info/


Maybe replace something you would write as a shell/perl/python script for automation with a rust binary.




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: