[kwlug-disc] Fw: Re: Learning Javascript

Paul Nijjar paul_nijjar at yahoo.ca
Sat Mar 13 15:43:48 EST 2021


Not sure why these messages were discarded (probably because Rob's
subscription address does not match the sender address), but they are
valuable. I will forward a second one too.

- Paul

----- Forwarded message from Rob Gilson <thatotherdude at gmail.com> -----

Date: Sat, 13 Mar 2021 13:59:26 -0500
From: Rob Gilson <thatotherdude at gmail.com>
To: KWLUG discussion <kwlug-disc at kwlug.org>
Subject: Re: [kwlug-disc] Learning Javascript

Ooh, a question I can (mostly!) answer!

- How does JavaScript want me to think?
>
In a word: Events. The Javascript run-time differs from most other
languages in that it is at it's core an event loop.

Coming from python you might have used tornado
<https://www.tornadoweb.org/en/stable/> which AFAIK takes inspiration from
the JS event loop or in C++ you might have used libUV
<https://github.com/libuv/libuv> which is at the core of NodeJS's
implementation. Looking into how you would work in these event loop
libraries in languages more familiar to you may give you better insight
into how javascript wants you to think.

Also javascript code in my professional experience (10 years at this point)
tends to be more readable and maintainable if it's written in a functional,
immutable style. So googling functional javascript should push you in a
less bad direction on that front.

Finally you might also check out Javascript the Good Parts. Now I haven't
read this myself so take that recommendation with a grain of salt but it's
generally pretty well regarded.

- What triggers particular functions to be run? I do not really
>   understand the control flow.
>
See previous answer (joking). The serious answer is that your javascript
will initially run through your file to the end and during that run various
event listeners will be registered (but the code inside their callback
functions will not yet run - it's just getting set up for later when the
event actually triggers).

In vanilla javascript registering an event listener looks like this:

window.addEventListener("mousemove", (e) => console.log("mouse move
event:", e))

So there we're adding a really simple callback (aka. event listener) that
will log out to the console every time the user moves their mouse.

- Do the popular frameworks (React, VUE, Angular) mean you have to
>   change the way you think from vanilla JavaScript?
>

I'm not proficient in VUE but I can speak to the other two.

Without getting too much into the details Angular changes how I write JS
dramatically, React feel more like Javascript plus a library.

Don't learn jQuery if you can avoid it.

- Say I want to learn Elm. Does this hurt me or help me when trying to
>   learn JavaScript?
>
I'm not sure. I've worked with an Elm-inspired Javascript library
<https://github.com/redux-loop/redux-loop> a lot and I can say that even
though I don't use it for every project it did change how I thought about
data. So I feel Elm's has concepts in it that can inspire better
programming (not just in JS).

The caveat is I definitely wonder about taking on too many unknowns at once
if you are just starting out in JS.. I'm reminded of the time I tried out
Elixer for a pilot project at work (Elixer runs on Erlang's VM) without
learning Erlang itself first and inevitably became very confused and had to
drop the project because I just didn't have the capacity or time to learn 2
language at once.

If your looking for something which is Javascript but better (without going
as far as Elm which compiles to Javascript but is an extremely different
ML-inspired language) you might check out Typescript
<https://www.typescriptlang.org/> which AFAIK is a strict superset of
Javascript syntax and features.

On the topic of js derivative languages and as a former advocate of both of
these: I would consider both Coffeescript and Flow JS to be outdated and
not worth your time.

Best of Luck!

- Rob

On Sat, Mar 13, 2021 at 1:12 PM Paul Nijjar via kwlug-disc <
kwlug-disc at kwlug.org> wrote:

> I do not understand JavaScript and it is holding me back.
>
> I have basic familiarity with programming in other paradigms (Python,
> Powershell, Java, C, even Scheme) so I understand basic syntax like
> variables and if statements. I do not understand how JavaScript wants
> me to think, and I am looking for some resources to work through so I
> can learn. Questions I have:
>
> - How does JavaScript want me to think?
> - What triggers particular functions to be run? I do not really
>   understand the control flow.
> - Do the popular frameworks (React, VUE, Angular) mean you have to
>   change the way you think from vanilla JavaScript?
> - Say I want to learn Elm. Does this hurt me or help me when trying to
>   learn JavaScript?
>
> Some overview articles would be good to start, followed by some
> hands-on tutorials that illustrate language features step by step. I
> do not think I want to commit to some six month course right now, but
> if you know of good ones then pass them along.
>
> I realize that this is not completely on topic for this forum (and
> maybe I will try KWTechs later) but I thought this is a place to
> start.
>
> - Paul
>
> --
> Events: https://feeds.off-topic.kwlug.org
> Blog: http://pnijjar.freeshell.org
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>

----- End forwarded message -----

-- 
Events: https://feeds.off-topic.kwlug.org 
Blog: http://pnijjar.freeshell.org




More information about the kwlug-disc mailing list