Hacker News new | ask | show | jobs
by SkiFire13 405 days ago
To be fair Lua also made some bad decisions, though maybe not as bad as javascript:

- tables being used for both objects and arrays can create a lot of confusion, especially when you have some integer keys, but not all, and especially when they are not consecutive or one of them is 0 - indexes start at 1 - assigning nil deinitializes variables/entries instead of assigning the value `nil` (this becomes especially bad if you mistakingly try to use nil as a value in an array/table) - nil and false are falsy, but not 0, which instead is truthy

2 comments

No disagreement here; I also fundamentally question the cardinal indexing and conflation between table and array. But it's at least internally consistent and certainly makes more sense than mandatorily indexing arrays with floating point.
Tables being dual purpose is fine. The real problem is that assigning nil deletes the table field. Unfortunately, fixing that now would cause Python3 levels of breakage.
I've never had an issue with =nil being delete. What problem does it cause?
If you accidentally store nil in an array it creates "holes" inside an array, which breaks the length (#) of the array.