← Back to context

Comment by paulddraper

3 years ago

Because Worse is Better [1]

Lua is technically superior, but JavaScript is practically superior due to its ubiquitous platform the web browser.

Similar but different to C "beating" Lisp.

[1] https://en.wikipedia.org/wiki/Worse_is_better

I strongly disagree. Lua somehow maintains a positive reputation, but it’s extremely quirky and weird in many ways. It has some Perl-esque rough edges (#array for length), and some “let’s be different” design decisions that are counterintuitive and unnecessary (arrays starting at the 1 index instead of 0).

JavaScript as it is today is a vastly more ergonomic and fluid experience, and I am saying this as someone that has written tons of both.

The embedding experience with Lua is likely much more form fit than JavaScript (sandboxing, etc). I’m strictly speaking about syntax and language features.

  • I don't want to start a 0-index war, but there is a great argument I read once and wave to share. Indexing can be tough as two different things, selecting or offsetting. When selecting you start from the first (1) option. When offsetting you move zero (0) from the first option.

    0-index arrays express offsets, 1-index arrays express index selection. In C (and family) arrays start at zero because they offset, `a[i]` literally means `* (a+i)` (you actually can write `i[a]`, it will work and be valid). For other language selecting 1 base indexing is not a weird option, I'd argue.