[kwlug-disc] Learning Javascript

Mikalai Birukou mb at 3nsoft.com
Sat Mar 13 14:29:05 EST 2021


> 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?

It is like Python. You have closures in both, just checked it with python:

 >>> a=3
 >>> def foo():
...     return a
...
 >>> foo()
3

that in node cli looks like:

 > let a=3;
undefined
 > function foo() {
...   return a;
... }
undefined
 > foo()
3

Since there was nothing else in JavaScript, remember the legend of 2 
weeks, the rest of the world was built out of first-class functions and 
closures. These days we have classes with classy scars from Java and C++ 
:) .

Parenthesis is the difference with Python. You don't have to have 
semi-column, but they give clarity, besides of one liners. People don't 
use them, till they get burned.

> - What triggers particular functions to be run? I do not really
>    understand the control flow.

The question is what are control entry points. Code is always single 
threaded. Your relinquish execution control with await, or when your 
code ends.

Overall event loop triggers entry of execution of control:

- browser's callbacks are triggered following user events.

- timeout and interval callbacks triggered when time comes.

- await implicitly has a callback that returns some result into your 
code at await point, when that promise is done.

- node triggers a callback when data-gram comes, or when data from disk 
is ready.

> - Do the popular frameworks (React, VUE, Angular) mean you have to
>    change the way you think from vanilla JavaScript?
Nope. You add an additional structure with framework. Arguably Vue is 
most JS-y (haven't looked at version 3).
> - Say I want to learn Elm. Does this hurt me or help me when trying to
>    learn JavaScript?

What is Elm? :)

TypeScript is your ticket to build big. And it is JavaScript with 
compiler that helps you and any other human.

> 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.
Play in node cli. With Python experience, node should come easier for 
tactile feel.




More information about the kwlug-disc mailing list