← Back to context

Comment by wruza

1 year ago

JavaScript has very nice scoping compared to Lua.

Js needs no forwards which in Lua turn into ugly “local foo; … … … foo = function()…end”. All functions are “hoisted” by default.

Js also uses “export”s or “module.exports[…]” instead of returning a symbol table, which allows cross-referencing.

Js has a function scope (var) together with local scoping.

Js doesn’t allow accidental shadowing in the same scope. Lua: local x; local x; silently creates two variables, good luck debugging that closure.

Js type coercion is only insane in the parts where operation itself makes zero sense. Please don’t tell me that ![0] or [] + {} makes sense to you or that you use them in other languages. Or that s+n and n+s seems safe everywhere except in js.

Js has a ternary operator and ?? ?. ??= operator group. Lua only has that “and-or” crutch and “not X” which returns true only for nil and false.

Js “…arr” is a first class citizen while in Lua “…” decays into its last value if you want to follow it.

Js (normally) ordered properties system is much more convenient in dev and debug time than an unordered mess of meta-hashtables.

Js doesn’t require you to

  {
    myPropertyHere = gotSomeObject.myPropertyHere,
    …
    IllRepeatThisAsManyTimesAsNeeded = gotSomeObject.causeWhyNot,
  }
  gotSomeObject.someNumericField = gotSomeObject.someNumericField + 1

which is extremely abhorrent DX in 2024.