[kwlug-disc] Learning Javascript

Mikalai Birukou mb at 3nsoft.com
Sat Mar 13 14:48:19 EST 2021


> Elm is a lovely language. It's a strongly-typed, pure functional programming using the "Elm Architecture" as the framework, and that requires a specific kind of thinking. It's a kind of thinking that I find very easy to deal with as a programmer. Elm has nice error messages and provides a guarantee that clients will never see run-time errors in their web browsers when running your code. Elm compiles into Javascript.

Note. Elm is apparently a language plus architecture, i.e. plus framework.

TypeScript is nice in debugging: you JavaScript looks exactly like you 
TypeScript code. Unlike Java7-8, TypeScript compile does deep type 
inference, ensuring that you don't have too much type definition noise. 
I am adding some of it in my code for human readability and refactoring 
help, as types encapsulate your intentions.

> Javascript is object oriented (forcing you to mentally track shared mutable state) and dynamically typed, the opposite of Elm.

JavaScript got classes, but zen masters see the truth :)

> A lot of industrial shops are switching to Typescript in order to get better compile time checking. Typescript compiles into Javascript and is largely compatible with it.
>
> A lot of Javascript now revolves around "async/await", and there are a lot of blog posts currently being written about what a nightmare this is. (Even though it is supposedly an improvement over earlier frameworks.) Many of the blog posts refer back to this famous post: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/
> I have now classified "async/await" as something to be avoided for my hobby programming. And I have no corporate masters who require me to learn and use it. I understand that async/await is currently essential for industrial programming at a scale where you are dealing with millions of network connections.

It ain't scary. Its a sugar coat around callbacks for chains of 
promises. And mixing of these styles sometimes is very useful, i.e. 
mixing explicit promise and callbacks with async/await code.

> The React framework seems to predate async/await. It is essentially a third way of thinking about how to program, and about what triggers functions to be called. It seems to be an improvement over the previous paradigm of "callback hell". My impression is that the "Elm Architecture" is nicer to work with than React.

React approach is in structuring flow of changes to UI. This is not 
language conceptual level.

There is a react-to-it feel, for which reactive extensions (aka 
observables) can be interesting to discuss. These exists as libraries in 
many languages, e.g. rxjs in JavaScript. Yet again, this isn't a 
language proper level concept.

> I understand that you can combine React with async/await.
>
> I think there are multiple ways of thinking about programming in Javascript depending on which framework and language features you use. I also think that a solo programmer building a low-traffic web site has different requirements for their language and framework than an industrial programmer working in a large team at Facebook.

Agree. Best is not to confuse what is language, and ask your question 
about where control flow starts, what are entry points in your 
particular whatever.

<note>I'd even say that observables encapsulate control flow.</note>





More information about the kwlug-disc mailing list