Back in my school days, when my friend and I were first learning C++,
we were voracious readers and exhausted our school’s programming
curriculum very quickly. Our teacher challenged us to make something
larger so we’d stop playing Tribes all
the time. It worked: I spent the rest of the term building a text-mode
platformer using <conio.h>
, and he spent the rest of
the term building and tweaking a small text-mode dungeon crawler.
Many new Haskellers make it through initial material (everything up
to and including the Monad
typeclass, let’s say), write a
couple of “Hello, world!”-tier projects that use the IO
type, but struggle to make the jump to industrial libraries and/or find
projects that excite them. I think text-mode games can grow very
smoothly alongside a programmer learning a new language, so here’s some
thoughts on how to get started, how you might extend a game, and some
advice for Haskell specifically.
I find Haskell a fantastic language for almost all of the programming I want to do: a (reasonably) expressive type system, a (reasonably) good library ecosystem, and (reasonably) good tooling together give me a very satisfying local maximum for getting stuff done. I can’t see myself giving up libraries for a more powerful type system, nor giving up Haskell’s guarantees for a larger library ecosystem.
Scripting a larger program is one of the few areas where Haskell
struggles. Despite some very impressive efforts like dyre
, I
think it’s a bit much to require a working Haskell toolchain and a “dump
state, exec, load state” cycle just to make a program scriptable. This
post discusses why Lua is a great
scripting runtime for compiled programs, its shortcomings as a
scripting language, how Fennel addresses many of these
shortcomings, and demonstrates a Haskell program calling Fennel code
which calls back into Haskell functions.