Live data from Hacker News

Ask HN: Projects for learning a language?

news.ycombinator.com

11–20 of 61 posts

Re: Ask HN: Projects for learning a language?

#11
Sometimes I’ll write a unit testing library with a terse syntax/DSL to learn a new language. That pushes me to learn how to bootstrap tests to test the testing framework :) It usually helps me get into some of the more advanced language features. After that, most things I do in the language feel relatively easy by comparison.

Re: Ask HN: Projects for learning a language?

#12
I always go for a simple lisp interpreter. I think this covers a good range of techniques and gives you a pretty good feel for what is/isn't ergonomic in the language.

I don't generally bother with features like macros etc, I just get enough going to define and evaluate functions in a repl. When you keep the scope small like this it doesn't take very long, and it can be broken up into a few fairly well defined evenings - e.g. lex, parse and eval.

One caveat is that if you haven't written a toy interpreter before then it will take you a bit longer. Once you know a little about the common techniques and patterns it's easy though.

edit: grammar

Re: Ask HN: Projects for learning a language?

#13
It's not the best project for your requirements (seeing the big picture and thinking deeply), but my go-to project for general-purpose languages is to implement a Markdown static site generator with a simple plugin system.

It allows me to test a few things I care about: filesystem operations, templating engine, reflection (or lack of), string parsing, testing, build systems. It also gives me a feel on the ecosystem (e.g. how many good quality Markdown parsers? Do I have to write my own).

Also, because I have a few of them I can make something of a comparison between languages for this particular use case (how long did it took me? how fast does it process the sources?)

Re: Ask HN: Projects for learning a language?

#16
Games of course! Doesn't have to be fancy with graphics at first but the beauty here is graphics/frontend/UI is definitely on the table if you want to pursue it later. In the same spirit, it's very easy to add features/mechanics to it. Get creative!

- Simplest game ever is a number guessing game. Obviously solvable by binary search on the player side. It's like an exciting counterpart for Fibonacci for learning PL flow-control structures. Additional features: limit number of guesses, make players guess floats instead of just ints. Latter will obviously teach you about FP handling in your language of choice.

- Next up, make that two dimensional, so the player is now guessing coordinates instead of numbers. Needs more math, you will definitely implement the distance formula. You can add a backstory if you like (are you bombing enemies in stealth perhaps?) and add mechanics based on that backstory.

- For something more complex---and I think this is your level now---people might suggest a constrained DF/Rogue-like. But me, that always grows more complex than a pedagogical device when I do it. So I stick to boring text games, sometimes inspired by game shows. Quizmaster-types (ala Who Wants to be a Millionaire), hangman-types (ala Wheel of Fortune), would force you to create structures for abstraction, all staying within complexity budget.

Happy hacking!

Re: Ask HN: Projects for learning a language?

#18
I usually rewrite software I use at home:

- a monitoring system for my home automation devices, the checks go from generic (is the site up?) to specific (are the water leak sensors up?)

- a program to keep track of the chores my children are supposed to do (a backend with an API, a mobile application and a hook into the home dashboard)

- my note taking program, because the world absolutely needs one more

I use a bus for communication (MQTT) but also APIs, so the rewrite quickly brings me into the technicalities of the language as I do not have th reinvent how the programs work. On the other hand, these rewrites led to plenty of improvements.

Re: Ask HN: Projects for learning a language?

#19
I would work backwards from why you want to learn a new language in the first place. Definitely spend some time on that. Usually the reason will lead directly to a project that you want to work on. Otherwise it will be hard to follow through.

Ex: I wanted to learn C, but my reasoning was only that it seemed like "real" programmers knew it. But that's not a good reason. Instead what I really wanted was to get closer to hardware and build software that did low-level operations. So I learned objective C and build audio-processing software for iOS that I actually wanted to work on. So I was able to learn a bit of the language and a bunch of other cool things that I still use today.

Post reply on HN