← Back to context

Comment by morshu9001

1 day ago

This is also what I like about JS, except it's even easier than Go. Meanwhile Python has a surprising number of random features.

ECMAScript is an order of magnitude more complicated than Go by virtually every measure - length of language spec, ease of parsing, number of context-sensitive keywords and operators, etc.

Sorry, hard disagree. Try to understand what `this` means in JS in its entirety and you'll agree it's by no stretch of the imagination a simple language. It's more mind-bending and hence _The Good Parts_.

I think JS is notoriously complicated: the phrase “the good parts” has broad recognition among programmers.

Just so we're on the same page, this is the current JS spec:

https://262.ecma-international.org/16.0/index.html

I don't agree. (And frankly don't like using JS without at least TypeScript.)

  • While I might not think that JS is a good language (for some definition of a good language), to me the provided spec does feel pretty small, considering that it's a language that has to be specified to the dot and that the spec contains the standard library as well.

    It has some strange or weirdly specified features (ASI? HTML-like Comments?) and unusual features (prototype-based inheritance? a dynamically-bounded this?), but IMO it's a small language.

    • Shrugging it off as just being large because it contains the "standard library" ignores that many JS language features necessarily use native objects like symbols or promises, which can't be entirely implemented in just JavaScript alone, so they are intrinsic rather than being standard library components, akin to Go builtins rather than the standard library. In fact, in actual environments, the browser and/or Node.JS provide the actual standard library, including things like fetch, sockets, compression codecs, etc. Even ignoring almost all of those bits though, the spec is absolutely enormous, because JavaScript has:

      - Regular expressions - not just in the "standard library" but in the syntax.

      - An entire module system with granular imports and exports

      - Three different ways to declare variables, two of which create temporal dead zones

      - Classes with inheritance, including private properties

      - Dynamic properties (getters and setters)

      - Exception handling

      - Two different types of closures/first class functions, with different binding rules

      - Async/await

      - Variable length "bigint" integers

      - Template strings

      - Tagged template literals

      - Sparse arrays

      - for in/for of/iterators

      - for await/async iterators

      - The with statement

      - Runtime reflection

      - Labeled statements

      - A lot of operators, including bitwise operators and two sets of equality operators with different semantics

      - Runtime code evaluation with eval/Function constructor

      And honestly it's only scratching the surface, especially of modern ECMAScript.

      A language spec is necessarily long. The JS language spec, though, is so catastrophically long that it is a bit hard to load on a low end machine or a mobile web browser. It's on another planet.

The Javascript world hides its complexity outside the core language, though. JS itself isn't so weird (though as always see the "Wat?" video), but the incantations required to type and read the actual code are pretty wild.

By the time you understand all of typescript, your templating environment of choice, and especially the increasingly arcane build complexity of the npm world, you've put in hours comparable to what you'd have spent learning C# or Java for sure (probably more). Still easier than C++ or Rust though.