TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Switching from imperative to functional programming with games in Elm

13 pointsby Dobiasdover 11 years ago
This is the first time I wrote an article not in my native language. If something sounds stupid or the content is nonsense in your opinion, I would be glad if you let me know. :)

1 comment

quchenover 11 years ago
(I posted this same answer in the r&#x2F;Haskell crosspost, I think it may be useful here as well.)<p>I&#x27;m the &quot;David&quot; the article talks about. The backstory is this:<p>I spent a year abroad, but we were regularly talking over XMPP. One day, Dobi gave me a link to an online book that has a sun saying &quot;holy shit&quot; on the front page. It was <a href="http://learnyouahaskell.com/" rel="nofollow">http:&#x2F;&#x2F;learnyouahaskell.com&#x2F;</a>, and it spoke of some obscure language I had never heard of. But I found the pictures funny so I started reading the first chapter.<p>A month later, Dobi had long lost interest in Haskell himself, but I was hooked. Every &quot;wow FP is awesome moment&quot; was forcibly shared with him. I soon began to talk about ApplicativeMonoidMonadFunctor and how neat these abstractions are.<p>Since that one day when I received the LYAH link, it&#x27;s marked &quot;Dobi shows David Haskell day&quot; in my calendar, this has continued: I&#x27;m learning Haskell, and everything cool is thrown at Dobi. He even made a second attempt at learning Haskell, but due to its inaccessibility (relative to Elm), he lost interest again.<p>Then, a couple of weeks ago, he asks me whether I knew Elm. I said yes, but as someone who now uses Haskell as his main language, I thought of Elm as a toy. Today I see how this was wrong: Elm is an excellent language, maybe not to write a scalable webserver, but it gets a few things right that Haskell doesn&#x27;t:<p>- Elm is very accessible.<p>- Even simple and small programs can have cool output, and by that I don&#x27;t mean conceptually cool but you-can-show-your-friends cool. Getting positive feedback is really motivating in the beginning when you&#x27;re not quite sure whether the language is useful yet.<p>- Elm has Haskell-like syntax, and is of similar semantic structure. It has recursive lists, fold, map, Maybe and all those other Haskell Prelude things.<p>- No category-like abstractions (as a result of not having typeclasses, mostly). Monads are pretty abstract, and are pretty infamous among people that don&#x27;t know them. This significantly lowers the barrier of entry.<p>The crucial thing is the similarity to Haskell: Elm is a much better gateway drug to Haskell-like languages than say XMonad (which is pretty geeky) or other nice little things. Once you can write Elm, a Monad is just another addition to a language you already know how to move in, and you can learn to include it in your programming instead of requiring it in the first place. I think instead of having a &quot;beginner-friendly monomorphic Prelude&quot; we should have generalized the crap out of Prelude (Foldable, Traversable, all those things go in) and recommended Elm to newcomers if they have problems with Haskell.