Show HN: I made a multiplayer web game with Elm
qdice.wtf
qdice.wtf
Due to issues w/ websockets in Elm 0.19 I went with Angular, resulting bundle is 440k before gzip. Not great, not terrible...
Would you use Elm again?
Are there anythings you wish you knew before you started?
Elm wants to get beginners into functiona programming, it did it for me very well. I've only used C-like languages before, tried Haskell but didn't grok it.
There are a lot of FP tools for JS, but there really is nothing is like being actually pure and typesafe.
I've never been able to modify or add features so fast to a grown project in my life. And with confidence that there will be no runtime errors.
> Would you use Elm again?
Definitely, so much as being willing to fight teeth and nails to be able to use it at work too. I just can't fathom the dread of JS/TS runtime errors anymore.
> Are there anythings you wish you knew before you started?
Do not try to build "components" in React fashion. It pops up every so often in r/elm etc. In my opinion, you can either slice and isolate you UI into components but smearing the state all over (React), or you isolate by state and smear the "components" across (Elm). It's orthogonal to each other and there is no in between.
I wish I had known Elm-UI or Tailwind.css. Now I have a typical mess of half-assed BEM, afraid to touch any line of it.
Also using SVG to draw the game, while it lets get started fast, isn't very performant. It shouldn't be hard to change.
I have almost no unit tests for the frontend part, because the type system covers so much. Then for the "larger" things that aren't really covered by types, they would be awkward as unit tests too, and I dislike integration tests, so I have some end-to-end tests for that.
Ports can be awkward, I wish there were there different kind of ports. Something to synchronously "get" a value, and something to do an async request/response.
Cyclic dependency errors (of modules) can be really irritating. I usually opted for sharing types in a submodule, or in the one global types module.
I just started getting my hands dirty, I used https://guide.elm-lang.org/ IIRC.
Also make sure to checkout the slack channel, especially #beginners, it's very helpful.