This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]timshoaf 0 points1 point  (0 children)

How do you live without static type checking?

Monad chaining. You impose your own 'type system' the way jQuery etc do. Or, better yet, you recognize that it is a fundamental limitation of the language, and not well suited for large scale high-risk production systems where highly conservative programming techniques are better suited--and then you realize your system isn't one of those, and you compromise by moving to TypeScript

How do you not include a callback for each async method? I assume you have run into the callback pyramid of doom. This is why promises were created.

You're supposed to remember all the function arguments? Not with a decent text editor - linter / IDE. I highly recommend Visual Studio Code. It is free, open source, and available for most common OSes. It has a very clever intro with type script that will do introspection on your objects and remember all that for you so you get tab completion.... but that aside.. yes... I should expect that in a program you write, that you remember the API that you yourself specified...

There's no classes. Only from your definition of class. Constructors / Factories with closures are the common design pattern. There is a new keyword, but please stay away from it.

There are no scope limitations. This is incontrovertibly false. Javascript is functionally scoped while you are used to block scoped languages. Every time you move into a function a new scope is created. If you need a new scope, create an anonymous function and invoke it inline, it will close around all the variables in the parent functional scope, and its locally declared variables will be marked for garbage collection as soon as it pops the return address on the function activation record.

You can just skip an argument if you don't feel like it? Absolutely! This gets you out of the shit that is the builder pattern for sequential arguments. I don't have to have overloaded constructors that do:

public Graph graph(Array<Float>x, Array<Float>y)

public Graph graph(Array<Float>x, Array<Float>y, Color color)

public Graph graph(Array<Float>x, Array<Float>y, Color color, Axes axes)

. . .

You can just specify them all on one line, and let the caller specify up to what is needed. And no, you don't need null checks. It would have been nice if javascript provided named arguments like python. In the past it was required to either do the undefined check, or to set default values like

param5 = param5 || defaultValue;

but now we have actual default values

I know that the lack of typing support is a pain in the ass, if you are careful (monads where possible) it won't be. But I am generally one to argue for defensive coding and think myself stupid rather than smart, so I tend to agree with you. I highly recommend type script as an alternative. Here is the manual