5 ms·
On the other hand, just two days ago I had to implement my own string.split method to split on some delimiter. Lua is tiny and fast, but that's not without its
by diarrhea 6y ago
On the other hand, just two days ago I had to implement my own string.split method to split on some delimiter. Lua is tiny and fast, but that's not without its downsides.
- aasasd 6y agoThankfully the Penlight lib has many functions such as that. Lua's speed means that having library functions written in the language itself is alright for business-logic programs. My main beef with Lua is the absence of ‘null’, which means I can't write middleware doing transformations on data without a schema—i.e. API requests and processing, for which Lua would be great otherwise.
- pansa2 6y ago> My main beef with Lua is the absence of ‘null’ Lua’s equivalent is `nil` - I assume that doesn’t do what you need? How would the behaviour of `null` differ from Lua’s `nil`?
- aasasd 6y agoHeh, someone shows up to remind me of ‘nil’ each time I say that. Lua's ‘nil’ is not a value, it's a void in which all undefined variables swim. Specifically, if you assign nil to a table field, you can't know what fields the table has unless you have that schema beforehand.
- gnramires 6y agoWhat about a special string, i.e. "null" (literally) in the table?
- aasasd 6y agoFirstly, consult any number of articles on what happens when computer systems can't handle ‘null’ as a string, e.g. these two from the past month on HN: https://www.theverge.com/tldr/2019/8/14/20805543/null-license-plate-california-parking-tickets-violations-void-programming-bug https://www.theverge.com/tldr/2019/8/14/20805543/null-licens... and https://www.wired.com/2015/11/null/ https://www.wired.com/2015/11/null/ There was even something in this vein on the front page. Secondly, even if there's another, more special value, that can't be conflated with a string (Lua does support some kind of user-values that are distinct from any built-in types)—it still leaves a question of how different modules handle that. In fact, different modules like CJSON already do this—but what if I decode JSON with CJSON's null value and need to encode XML when the XML module has its own null value? I'd need to walk the data and convert from one to the other. Well, some modules do support a common value denoting null: https://github.com/moteus/lua-null https://github.com/moteus/lua-null But by now why not just have this value in the language, since various modules need it anyway for interoperability with other systems? I heard even that there were attempts at deciding on such a value for a new version of Lua, only with some bunk name like ‘undefined’, which is actually the opposite of what ‘null’ is.