
Show HN: I made a multiplayer web game with Elm - the_gipsy
https://qdice.wtf
======
winrid
Kudos. I really wanted to learn Elm to have a type safe way to write widgets
that third parties would run on their sites. Seemed like Elm would have given
me type safety + small bundle size.

Due to issues w/ websockets in Elm 0.19 I went with Angular, resulting bundle
is 440k before gzip. Not great, not terrible...

~~~
the_gipsy
I'm using MQTT over websockets, so I had to use ports anyway. IMHO, it would
be nice to have websockets integrated, but wiring a bunch of ports is no big
deal.

~~~
winrid
Nice. It was too much work compared to using Angular. Hope you had fun with
it.

------
xupybd
How did you find it?

Would you use Elm again?

Are there anythings you wish you knew before you started?

~~~
the_gipsy
> How did you find it?

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.

~~~
bingerman
What resources you used to learn elm? I'm looking for a good book on 0.19 elm
that is written to folks who can already program (probably even in functional
style and just want to learn the specific tricks of elm).

~~~
the_gipsy
I'm not a book person, so I can't help you with that.

I just started getting my hands dirty, I used [https://guide.elm-
lang.org/](https://guide.elm-lang.org/) IIRC.

Also make sure to checkout the slack channel, especially #beginners, it's very
helpful.

------
aurelius12
My first reaction was, "How do you make a game using an email client?"

~~~
empath75
There have been approximately zero posts about elm the email client in the
last ten years and probably close to a thousand about the front end frame
work. Further more, the elm email client last had a stable release 15 years
ago. And also this same “joke” has been made in every thread about elm and it
is beyond tired.

