Live data from Hacker News

Small Assets without the Headache in Elm 0.19

elm-lang.org

81–90 of 129 posts

Re: Small Assets without the Headache in Elm 0.19

#81
post #3

I'm so glad to see this, congrats to Evan and everyone who helped get 0.19 out the door! I've been working in Elm for about a year now and it is a joy to work with, moving from vanilla JS/Angular/React to Elm has been a boon to productivity and I actually have confidence that when I refactor something and have fixed any compiler errors that it is going to work.

One more point. Writing something like the MiniLatex parser would be somewhere between impossible altogether and nightmarish without an expressive type system. Below is the definition of the type of the abstract syntax tree (AST) for MiniLatex. Just eleven lines of code. Yes, I know. No typeclasses in Elm. But Elm's type system is surprisingly expressive, and with it one can do some rather sophisticated work. I've been very happy with it.

    type LatexExpression
        = LXString String
        | Comment String
        | Item LatexExpression
        | InlineMath String
        | DisplayMath String
        | SMacro String (List LatexExpression) (List LatexExpression) LatexExpression 
        | Macro String (List LatexExpression) (List LatexExpression) 
        | Environment String (List LatexExpression) LatexExpression 
        | LatexList (List LatexExpression)
        | LXError (List DeadEnd)

Re: Small Assets without the Headache in Elm 0.19

#82
post #34

Earlier quoted context omitted.

WebAssembly is still far away from being any sort of default for web development yet (if only because IE11 doesn't support it). I also wouldn't be surprised if Elm compiled to wasm in the future.

It's openly a desired/considered goal for Elm to compile to wasm.

I know, I'm one of the people looking into it.

Re: Small Assets without the Headache in Elm 0.19

#83

Since there are some Elm users in this thread, I'll ask here: What's currently the best way to integrate an interactive map (i.e. zoom, pan, draw polygons, etc.) into an Elm application (something like leafletjs)? If I search for it, I find https://package.elm-lang.org/packages/kennib/elm-maps/latest but the examples are not working for me, it feels like some mouse events get missed? E.g. here: https://kennib.github.…

Custom Elements!

Check out this talk about how to do it: https://www.youtube.com/watch?v=tyFe9Pw6TVE

For future reference, the quickest way to get questions like this answered is in the #beginners channel on Elm Slack:

http://elmlang.herokuapp.com

Tons of super helpful people there!

Re: Small Assets without the Headache in Elm 0.19

#84
post #34

Earlier quoted context omitted.

WebAssembly is still far away from being any sort of default for web development yet (if only because IE11 doesn't support it). I also wouldn't be surprised if Elm compiled to wasm in the future.

Most compilers that target WebAssembly can also target asm.js, which is compatible with IE. AFAIK it's more about missing stuff like DOM access and GC that stands in the way.

> Most compilers that target WebAssembly can also target asm.js, which is compatible with IE.

asm.js is different enough that it's just not about adding a seperate asmjs "compatibility" target. On the top of my head you don't have 64-bit ints or floats and I believe the way you call asm.js fns from/to JS is different from wasm. Adding asm.js support just for IE 11 wouldn't be worth the effort.

Re: Small Assets without the Headache in Elm 0.19

#85
post #32

Earlier quoted context omitted.

What is classless JavaScript? I don't understand how you had trouble doing things without typesafety but found that going from JavaScript to Elm is a step backwards? Maybe I'm missing something here?

https://web.archive.org/web/20151029152324/http://ericleads.... https://weblogs.asp.net/bleroy/crockford’s-2014-object-creat... Once you start doing this, most other languages become obsolete. Because you avoid most of the problems of JS that things like elm try to fix, while maintaining the freedom and also writing a lot less code because you don’t have to write a “recipe” for half the things you write. The disadvan…

JS vs Elm simply cannot be reduced to "classes".

Classes is only a tiny part of what's broken in JS.

TS (coupled to "JS, the good parts") saves the day though, but I have no idea how avoiding classes also somehow made you abandon the usage of a type system (whether Elm's or TS's) It all seems so unrelated.

Re: Small Assets without the Headache in Elm 0.19

#86

Since there are some Elm users in this thread, I'll ask here: What's currently the best way to integrate an interactive map (i.e. zoom, pan, draw polygons, etc.) into an Elm application (something like leafletjs)? If I search for it, I find https://package.elm-lang.org/packages/kennib/elm-maps/latest but the examples are not working for me, it feels like some mouse events get missed? E.g. here: https://kennib.github.…

Custom Elements! Check out this talk about how to do it: https://www.youtube.com/watch?v=tyFe9Pw6TVE For future reference, the quickest way to get questions like this answered is in the #beginners channel on Elm Slack: http://elmlang.herokuapp.com Tons of super helpful people there!

Thank you for the quick response. Just out of interest are the examples working for you? E.g. Leaflet's Hello World is just ridiculously simple and short (if you check out the source): https://leafletjs.com/examples/quick-start/example.html

I am searching for something similar in Elm. I'll head over to other channels for more questions, thanks.

Re: Small Assets without the Headache in Elm 0.19

#87

Congrats on the release! I have very high hopes for Elm in the future, and I think it truly shifts the paradigm of frontend development. On an attempt to use Elm in production I ended up switching back to Javascript. The biggest issue I faced was lack of type-classes, which made certain parts of the code feel like I was pulling teeth to get Elm's type system to be happy. Perhaps this is more of an issue of expecting…

FWIW you may be interested in Purescript, it's less developed than Elm but is more on-board with abstractions & the like.

It's more accurate to say PureScript has Haskell-like (or category-theoretic, if you prefer) abstractions.

All high-level programming languages are on board with abstractions, pretty much by definition!

Re: Small Assets without the Headache in Elm 0.19

#88
post #66

Earlier quoted context omitted.

> Once people start using Elm the way it was designed to be used, things become simple and start to flow. But how will anyone ever get anything done, when they can't make everything in their code exceptionally clear by wrapping it all up in a 15 monad thick monad-combinator? /s But yes, I totally agree. Elm is a simpler, safer and easier Haskell for the front-end. I just love it :)

The idea that wanting to use typeclasses in Elm is an impedance mismatch would be more convincing if Elm and its standard library truly did everything without them, using alternate approaches like explicit dictionary passing. But as you probably know, they don’t. Instead, the language has special syntax for three builtin “typeclasses”: comparable, appendable, and number. And the standard library uses them: its Dict,…

I agree with you.

Elm is not going to change, however fortunately there are alternatives. Pick something like PureScript or GHCJS and move on like I did.

I now write Haskell professionally[1] both for frontend and backend, something that you'd be hard-pressed to achieve with the likes of Elm.

[1] https://www.youtube.com/watch?v=riJuXDIUMA0

Re: Small Assets without the Headache in Elm 0.19

#89

Earlier quoted context omitted.

Custom Elements! Check out this talk about how to do it: https://www.youtube.com/watch?v=tyFe9Pw6TVE For future reference, the quickest way to get questions like this answered is in the #beginners channel on Elm Slack: http://elmlang.herokuapp.com Tons of super helpful people there!

Thank you for the quick response. Just out of interest are the examples working for you? E.g. Leaflet's Hello World is just ridiculously simple and short (if you check out the source): https://leafletjs.com/examples/quick-start/example.html I am searching for something similar in Elm. I'll head over to other channels for more questions, thanks.

I honestly have never used LeafletJS, so I'd be the wrong person to ask - I'm just familiar with the technique to embed things like that in Elm applications. :)

Re: Small Assets without the Headache in Elm 0.19

#90
post #24

They forgot Mithril[0] in the size comparisons -- I haven't seen anything useful beat it in size/value ratio. [0]: https://mithril.js.org/

Out of curiosity, I've downloaded the Mithril implementation of Conduit from https://realworld-mithril.netlify.com/ I have minified and gzipped `main.js` and it end up around 26k.

It's apparently not feature complete yet.

https://github.com/barryels/realworld-mithril/projects/1

It's safe to assume it will be bigger when it's done, but who knows how much?

Post reply on HN