Ask HN: What projects are perfect for learning a new language?

85 points by curiousgal ↗ HN
I get that the best way of learning is to try to build something but is there a list of projects that accentuate a language's purpose/paradigm in a way that building said project has the best time to learning ratio?

59 comments

[ 2.7 ms ] story [ 122 ms ] thread
The list will depend on the language, platform and your interests. Build something that interests you and challenges you a little but isn't too overwhelming.
I vote for a little webby something. Get the lowest-level web framework you can find for the language, and then make a hello world. You're bound to learn strings, functions, processes and types, at the very minimum, and a web-based something is also a very easy platform from which to expand incrementally into new territory.
I think that depends on the language. A couple of ideas: Copycat standard unix tools such as grep, ls, dd. Implement an economy simulator. Implement a simple neural network (you can find the formulas for backprop online). A tennis tournament planner. A Sudoku solver using SAT constraint propagation. Invent a simple layout language and implement an interpreter/renderer which renders text and images in a pdf file.
I would extend "standard unix tools" to (old) "standard unix services". I learned a lot from the final project in "Haskell Programming from First Principles", which was to implement a server for the finger protocol.
A game of Snake, a simple database, a little web server, a small compiler.
For golang kubernetes is pretty good, i learnt a lot of tricks just reading code, but you quickly learn it was the wrong language on so many fronts.
You mean it was a mistake for kubernetes to be written in go? If so, I would love to hear a bit about it.
I think so. The lack of parametric types leads to an explosion of types for each concept, and where they don't do this a load of casting from runtime.Object and interface{}. The lack of exhaustive pattern matching is responsible for many bugs, oh we forgot to add a case for runtime.InternalEvent etc... However our project will be using Kubenetes library and thus we're also doing it in Go. MetaAccessor another eye sore. It's all a trade-off I guess..
For go kubernetes is pretty good, but you quickly learn it was the wrong language.
A personal project that's been frustrating you and could be solved better in the new language/framework. This gives (a) motivation to do something in the new language (b) gratification from the new language/framework's new features (c) low risk since it's not work.

Almost everything I have picked up by myself over past few years has been this way. Golang (frustration with concurrency in Python), JavaScript/React/Redux (frustration with "native" GUI frameworks), Android SDK (Speed, sensors pre-html5-webview), GraphViz (frustration with "project management") etc.

I have a friend who likes to write fractal generators when he starts looking at a new language because it gives him a sense of what it can do and how it does it in terms of loops/recursion, data structures, math, and visualisation.
Any project that you want to do right now and that you think the language can handle properly. The most important part is motivation, and a project-at-the-gates is one of the best drivers. This not only works for languages, but also frameworks and tools.
I am not sure if this will be considered as self-promotion, but if you are trying to learn something related to web, feel free to borrow from my list of projects:

http://vikaslalwani.com/projects/

All the source is available on GitHub and I am sure you will have lot of fun creating these :) Feel free to contact me if you need any help.

I always start out with a simple raytracer / path tracer (spheres only).

It's always nice to see visuals appear (in a file or on screen). It's like a compliment for the work done.

And you will learn a lot of basic stuff like loops, scope, types, and so on.

I recommend you to build a content management system for a desktop environment.
For a desktop environment? What do you mean by that?
An IRC bot is always fun to write.
Don't want to hijack this thread, however, it is mildly related:

What projects are perfect for learning Erlang (which might involve both the functional and concurrent aspects of the language)?

If you like math at all, www.projecteuler.net/problems is worth a look. They pose math related problems that are intended to be solved programmatically. Once you've solved a problem correctly you are given link to the problem's forum page, where others people have posted their solutions.

Whats truly great is that you are forced to solve the problem on your own, and then you can see how others did it, both in your chosen language(assuming it's a somewhat common language), but also a myriad of other languages.

For getting into new web-dev frameworks/languages I often do these three steps:

1. hello world (simply getting something on the screen)

2. todo list (display a simple data-set and interact with it)

3. blog (display a relational data-set and interact with it, maybe some auth stuff)

But I would like to know how these steps would look for embedded stuff.

If you mean embedded systems, this is what I would do when working with a new microcontroller:

1. Make a LED blink - the Hello World of embedded.

2. Output a PWM signal from a pin to control a motor or to a speaker output.

3. Read an analog signal using the onboard ADC. A temperature or luminosity sensor is a good start.

4. Write a light OS that can execute multiple tasks simultaneously - take user input, read analog sensor values, perform a calculation, keep track of time, etc. This will need all of the above + interrupt handling.

Nice thanks :D

I already imagined that the hello world of embedded is a blinking LED , haha.

So these things (PWM, ADC) are "standard" to all embedded systems?

> So these things (PWM, ADC) are "standard" to all embedded systems?

Not really. PWM is more common (and "can" be done in SW or using other tricks if needed)

The well-known microcontrollers do have both built-in - Arduino and MSP430 are two of the popular ones.
I am of the firm belief that Arduino's are great to get those who aren't already motivated into learning EE/CE. Seeing a responsive blinking LED or whatnot is great to get people to the 'oh man, how does this work?! I want to learn more!!'. You're already at that phase. You presumably have a baseline of CS knowledge. Do it the 'right' way, and use a PIC or an AVR. (I don't care which, no holy wars, avr fans ;))

This[1] is a great place to start. I keep on meaning to write a 'hardware for CS guys' guide, that'll suffice for now.

[1] http://umassamherstm5.org/tech-tutorials/pic32-tutorials/pic...

A friend told me PIC and AVR have different purposes.

AVR for controlling and PIC for computing.

Implement the common search and sort algorithms, solve a few Project Euler challenges, and build a full-fledged todo-list or photo sharing application.
I will second the first part of this - algorithms and data structures. You have to hit the middle ground for those as the language may provide some. So try implementing binary search trees or splay trees and some graph algorithms. You should not pick too many - perhaps 2 from each genre.

At some point you will put these behind you, use pre-written libraries and graduate to an application.

I like to build something that I've programmed before in another language. Maybe this seems redundant. But if you have the problem fresh in your mind, it leads to asking the kinds of (Googleable) questions that get you very quickly to a base-level understanding of the new language. It also sheds light on the areas where the language is better/worse at specific things than the lang you are used to working with.
I used to use this method, but I've started to back away from it, because I often find that it encourages my own Blub programmer nature. Re-implementing an old project immediately shows me the ways in which the new language is worse, but often obscures the benefits.

As a personally embarrassing example, I once returned to Python after three years of heavy Scheme usage. I spent a week porting an almost trivial application and it felt like Python was fighting me every step of the way. Had I not had past pleasant practice with Python, I would have abandoned the language as useless.

Finally, at the end of the week. I realised that I was trying to write Scheme in Python, which work about as well as writing Python in Scheme. Python has for loop and I should be using them.

About twenty minutes later, the app was ported. It wasn't my finest hour.

I sometimes see the opposite.

    We took an app written and maintained for the last 10 years in language A, and re-wrote it from scratch in language B.

    The new codebase is smaller, more maintainable, and runs faster!!!
One answer to that question, which I have bookmarked: http://blog.fogus.me/2009/05/29/pet-projects/

· Lisp interpreter

· Lexer generator

· Knuth's Pac-Land

· Linear Algebra library

· Workflow engine

· m-ary tree

· Now Do This app

· Project Scaffolding generator

· Gap buffer

I always end up rewriting Tetris and a basic MUD in whatever language I'm learning.
IMHO the best way to learn any language is to build its compiler.
(comment deleted)
Would you clarify what you mean?

Are you saying to compile the source of the compiler, or write a compiler for that language (in that language)

I mean, write a compiler for a reasonable subset of a language you're learning. You can use the language itself to do so, yet most languages are not necessarily designed for writing compilers, so it's ok to use something else instead.

This way you'll quickly understand the semantics of the language and will get an early exposure to its dark corners.

I always like writing a small calculator (takes stuff like 1 + 1.5 and outputs 2.5) using a top-down parser. They're relatively easy to make if you're comfortable with top down parsers. It makes for an nice couple-hours project to wet your beak with the language.
For interpreted languages like Perl, Ruby, R, Python, etc., I usually write a C extension. Usually C extensions have to communicate with the runtime using their internal data structures, and those data structures determine how everything else works.

That and glancing at the AST if the language is open source.