Inspired by a conversation on #lobsters, I was wondering what sorts of tiny projects fellow Lobsters might have for getting comfortable in a language or learning a particular technique.
Ideally, something that should take maybe a free evening or two to get finished.
I like implementing some of the smaller RFCs (FTP, POP3, TFTP, SSH). Since they are widely used, you will be able to find a client or server to test against.
I’d strongly advise against FTP. While the protocol in general seems to be ok, every client seems to be a lot of hacks on top of other hacks to play nice with different servers.
So yeah, if you ever want to test against one implementation, it might work…
fingerto be quite nice for this, also my default for learning languages is an IRC bot.
For a slightly longer project, you could probably do Minecraft classic or maybe even Mumble…
I feel like there are a few orders of magnitude of complexity between FTP and Minecraft, even in the most basic premise and feature set of a Minecraft clone.
I’ve never done it personally but I’ve been told that writing a basic IRC client is a lot of fun and not overly difficult.
From my experience, the greater problem with writing an IRC client is getting to understand how RFCs are written and to be read. I wrote a kind of IRC library for AWK a few weeks back, and most of the time was spent trying to understand ABNF and other peculiarities, unrelated to the immediate implementation.
So if someone does this, it’s probably not bad to also have a few implementations in other languages one understands a bit better to help you along.
text analysis (counting most common N-grams) and markov chain model building + text generation.
Fun algorithm that fits in my head, touches I/O, munging strings, nested data-structures, and demonstrates both abstraction capabilities and performance characteristics of a language.
plus it’s always new because there’s a probabilistic component to it and you can run it against new sources of data.
My goto exercise is writing an irc bot. It allows you to start simple (sockets and strings) but you can iterate further and add other things on top like try async io or natural language parsing.
Writing irc bots helped me learn asynchronous IO using python twisted and rust’s tokio.
I’ve taken to reimplementing
cat(1), to the end that I wrote a linter script to double check the new implementations against the old ones.
They’re all implemented to varying amounts. I think gocat, excat, rscat and rbcat are the most feature complete.
Some examples of tiny projects I’ve done:
To learn some Rust, I ported most of picol. Can recommend it. It was more like three or four evenings though.
Oh that is neat!
I tend to go for making websites and/or APIs or cmd line tools.
My goto learning project these days is a parser combinator library. It’s big enough to exercise most parts of the language but small enough to be manageable in a weekend or two. The most recent one I worked on and finished was in typescript. Most of the time I’ll start and not finish but that’s fine because the goal is to just get over the initial learning hump.
Not precisely what you asked but exercism is amazing for this.
Advent of Code is great for this.
I have to say that I totally hated every single task of the 2018 edition.
So, it might not be a suggestion for everyone.
Interesting! What did you hate about them, and if you liked 2017 and previous years what made them different?
That was my first time, I had never heard of AoC before then :D
That’s cool. So, the question still stands - what didn’t you like about the puzzles?
For me, it was day 15, which was basically a huge pile of busy-work.
This year is the first where the project creator didn’t also create all the puzzles, and I think it shows.
Yeah I can see that. I rather wish the past year’s puzzles were viewable for comparison
Even though they were shrouded in little bits of story, which was okay, I found them to be the usual and tedious puzzles they give you on every other website.
Initially I saw them as somewhat realistic problems solvable via programming but they were more like algorithmic problems with some story slapped on top.
And there were very few moments of cleverness, like cutting out absolutely all the boring stuff and find a good enough approximation. All results had to be perfect, nothing just “good enough”, as it would be in real life.
Maybe it’s just me going in with the wrong expectations :D
+1 - the puzzles are fun and ramp up in difficulty :)
Thanks for the link, but I mean little projects that you personally have done. Posting a link to a collection of puzzles is neat and all but not really what I’m looking for.
I mean, I’ve personally learned two languages with AoC, so I’m not talking in the abstract. :)
Before I came across AoC, I had a couple web projects I would rewrite every few years. One is a scoreboard for a Nethack tournament and the other is a scoreboard for a dice-rolling tournament (of sorts). I’ve found AoC to be a better way to see more of a language in a shorter time period.
To some extent it is driven by the language niche. But for generic answers…
For the basics, I find Conways Game of Life is a good hygiene exercise.
Implementing a scheme is always fun. You can size it accordingly (a no-macro interpreter is a smaller time commitment, adding richer features (compile to llvm, compile to asm, proper quasiquoting macros) adds more depth.
A simple (made up) register machine is fun. If you base it on an existing instruction set (z80, risc-v) then you have an emulator.
Another puzzle site (which you don’t want, but which is awesome) is cryptopals.com.
+1 to AoC as a learning tool - I started working through the advent of code problems the other day with the goal of becoming productive in rust. They are nicely bite-sized, with the extra benefit that you can compare your code against more experienced rustaceans, e.g. https://github.com/BurntSushi/advent-of-code
I discovered a bunch of nice patterns like FromStr this way, and was impressed at how concise solutions could be!
Graphics projects like a ray tracer/fractal viewer/rasteriser can be tiny and fun.
Or an LZ4 decoder without no error checking or optimisations is like a page of code.
If the language has easily used GUI bindings, then I’ll mess with a 4-function calculator. If I’m testing out a video game library, then it’ll be a twin stick shooter, as they are rather easy to make. (I’ve done calculators in TCL, VB.NET, and Factor, and shooters in Pygame, Love2D and Godot). Otherwise it varies. With Go, I’ve done mostly websites, with Lua, I almost exclusively do video games, except when using it as a scripting interface to Go.
If you want to exercise a very foreign language, writing a CSV parser can be educational. (I wrote on early on when I was working on PISC). And if you want something slightly more involved, a stack calculator can be handy.
I usually try some kind of command line tool that interacts with a http API so I can get a feel of the package management if any, the libs available, how to read the stdlib and libs documentation… or a basic http/gopher/irc server.
There’s plenty of raw math, but also plenty of opportunities to implement algorithms and really get a feel for how any particular language handles most basic things that many languages are expected to handle (IO, loops/recursion, threading, inheritance, OOP, memory allocation, etc). Your thing produces an answer to a problem that you can instantly check for correctness.
I like Project Euler but I thought it ended up being too Mathy (maybe that’s the purpose). The solutions often involve understanding particular aspects of number theory, which are fun to read up, but I found them hard to understand. Sometimes you can brute force the thing, but often you have to know these results - at least for the later problems.
Word finder game. (The one where you have a 4x4 grid of letters and find words in adjacent letters.)
All those are stuff that help you to learn new languages but at the same time new concepts and technologies.
Writing a small IRC client, if going for smaller then a reddit client or a bot for discord/telegram/whatever you like. Fun and simple but doesn’t cover much for a language.
If you’re going bigger - I think writing a text editor is nice and challenging enough, to the level you want to extend it…
📃 A list of practical projects that anyone can solve in any programming language.
1: Dist-O-Matic finds the closest professional teams to you/your location. Source
2: Typing Keyboard is a JS synthesizer that you can use with your keyboard. Source
This blog post outlines a technique for learning new programming languages. TL;DR you build a quick tool to connect to the RhymeBrain API and return some (very bad) puns based on a keyword. It’s simple enough to fully wrap your head around but complex enough to touch many parts of any language. It’s even got implementation steps you can use as goal posts!
I always end up writing tiny raytracers. I never get too far, but I like the task because it provides opportunity to:
I’ve done this for Haskell in the past, and most recently with Rust a few years ago at this point. I never did get shading or any of the more interesting aspects completed for Rust, but the default scene does draw 3 spheres. :)
TinyWM is a pretty cool way to learn to write a window manager for X :)
It really depends on the language. If this is something that lives in the browser, I like something visual that plays with the canvas or generative art. If it’s something on the terminal, I like replicating classic Unix commands. For more specialized languages I try to do a task that leans into their strengths, so with R maybe I try to do a time series model on a tiny dataset.
We use AWS a lot at work, and I frequently need to write small programs to do things in it. I’ll often implement them in a language I haven’t used much, and sometime re-implement one of my old ones in a new language. It’s something actually useful, and gives you an idea of how the basics work, though part of it is how well the AWS libs for that language happen to work.
Chip-8 emulator or a web api :)
Many people suggest using a repeatable toy project as a basis for learning. I would argue this is no good because simply transferring the domain knowledge to a new language or technique also transfers your bias on how to solve the problem using your previous language/technique.
What I recommend is simply doing a project you would have done anyway, that you are passionate about and use that as an excuse to learn the new language. You learn not only how to solve a new problem but solve it using new ideas. It’s doubly motivating!
So a better question for you is, not what is a toy project, but what is a project you would love to do for yourself that isn’t a toy, that satisfies a real need or solves a problem.
Porting is different than implementing. Porting is much different than implementing, and with the burden of learning the domain lifted, one can concentrate on the implementation but still have it be concrete enough to move forward while not getting stuck learning two things.
In the Tiny-C program I linked, even just porting it to a new language allows one to learn a significant portion of the problem domain, so porting too has benefit.
Toy has a bad connotation, how about Model?
You can only learn through a process of getting new information. Fortunately we have information theory to tell us what that is. We must go through a process that creates surprise, because otherwise you aren’t, by definition, getting new information. Getting stuck is part of learning and should be an exciting event because that means you are maximizing your learning.
Solving a new problem is exciting, learning a new language is exciting, putting them together is just so so fun.
Tiny projects aren’t toy projects…
Totally agree! Many tiny projects satisfy a need, solve a problem, or are just plain fun. If I said tiny anywhere I meant toy.
Implementing a roguelike game is a neat excercise.
I’ve enjoyed reimplementing the smallpt path tracer in various languages, particularly if they are high performance (although I did write a version in Python… It took something like a few seconds to render a 2x2 pixel image…).
Step 1: Try to write something against project Euler questions I have previously solved, to get an idea of datatypes, and data-, compute- and control-structures.
Step 2: Re-implement a version of the xxd command, to get familiar with IO and it’s specifics.
(Optional) Step 3: Write a few classes to implement timeout timers which can be used to answer questions like “how long until some given resource expires” etc.
Step 4: Something that connects to IRC, says “Hello World!” in a temporary channel and then disconnects. When that works, make it stick around and reply to a given message.
Web crawlers. You can test graph traversal algorithms, I/O, and parsing.
Maybe write a mini-Ansible tool for running tasks on remote hosts in parallel. Here’s my take on it: https://github.com/mihaitodor/wormhole Through this exercise, I explored the following topics:
Whenever I sit down to learn a new computer language I like to make it a fun task.
Therefore to begin with, I take a few small programs from the book Computer Spacegames. Being that the book was published in 1982 the games within are both simple and written in BASIC, the first language I learnt.
On my end, I don’t have an answer off top of head but do have ingredients. As in, it should be one or more projects that touch on various parts of the language: use of scalar and compound datatypes; different structuring a la programming in the large; different types of control flow; error handling; I/O (esp files and networking); concurrency and parallelism; wrapping existing code; anything that highlights language-specific advantages (eg macros for building DSL’s). Probably best to have a few, small apps plus maybe one, mid-sized one.
This probably won’t help much, but since almost all of the projects I make for fun are pretty small, maybe a few thousand lines, when I want to learn a new language I’ll either recreate a recent project in the new language, or if I haven’t got very far I’ll just stop work on the original and restart in the new language.
It does depend on the language and why I’m learning it, though. It’s nice if the project will show off features of the language.