Elm instead of Javascript

I’m a little embarrassed by this question, but here it goes. I’m coming from a 3rd generation programming environment with very little knowledge of JS or html. I am wondering if I can gain some insight into these languages through the higher level of Elm? So far so good actually, but I know that for some of the advanced issues I will have to gain an

2 Likes

Elm is very different from Javascript in a lot of ways; If you want to learn Javascript, I’d say “go write some Javascript” :slight_smile: There’s definitely some shared concepts and ideas in there, but the quirks you have to be mindful of are very different in JS-land, and vice-versa.

I find it really fun to write javascript and run code through Node.js; it’s incredible how fast you can get something up and running. My Elm code is much more reliable and beautiful in comparison, but also takes some more up-front thought to get something on-screen.

You can certainly write plenty of simple-to-intermediate Elm code without much knowledge of JavaScript. When you get to some advanced things, knowledge of JavaScript will become rather helpful.

That being said, you will have to learn the basics of HTML though, because the View code in Elm has a one-to-one mapping to HTML.

For example, an HTML name input:

<div class="name-input-wrapper">
  <label for="name-input">Enter Your Name</label>
  <input id="name-input">
</div>

The same name input, in Elm:

div [ class "name-input-wrapper" ]
    [ label [ for "name-input" ] [ text "Enter Your Name" ]
    , input [ id "name-input" ] []
    ]

For simple Hello World stuff in Elm you won’t need JS but any kind of real life application will require interaction with outside JavaScript via ports, and JS is relentless if you don’t know what you’re doing. As much as I support Elm as the language of choice right now it is probably not a good fit for real world usage if you don’t have any prior knowledge of the web-platform in general. Just my 2c

Yep, I’d say knowing JS is not particularly important but you still have to know some of the web platform, including at least the main DOM tags, minimal CSS, and events handling in a browser. In any case, using Elm or JS, you need to know about MDN Web Docs :wink: Best up to date resources for almost all technical questions you will encounter along the way.

1 Like