Live data from Hacker News

Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

kylecordes.com

51–60 of 61 posts

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#51
post #26

Earlier quoted context omitted.

Is Unicode something that needs to be in the core of a language, or is it sufficient to leave it to libraries, if the language's design doesn't prevent it? On this computer (OpenBSD/i386), icu has over 1 MB of libraries and a 15 MB data file. The whole Lua distribution fits in one 200k library. Bloating the core language with that seems impractical.

In my opinion, it needs to be in the core. Imagine you need to go through a library every time your string includes or might include the letter "s" or "v". Basically you'd need to use this library for all your strings. But then you lose compatibility with 'normal' string type and need to be constantly aware of the difference. You might want to use some other library that doesn't support this Unicode library at all, e…

I think we have slightly different ideas about the language core vs. library distinction. In C, for example, printf and strlen are library functions (stdio.h and string.h), while structs are part of the core language.

All the language core needs for Unicode is reasonable support for tagging string literals (i.e., U"blah") and a binary-safe string type. It's best if there's either a standard or de facto community standard library for doing Unicode string ops, but it doesn't need core support anymore than the Linux kernel needs to know about parsing HTTP.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#52
post #33

I've sat down to learn Lua a number of times because on the I really like the idea of it (small, fast, safe, etc). It really has quite a beautiful minimalism to it. But each time I try I get to the part where I learn that array indices start at 1 and I get annoyed. Have we not learned anything since BASIC? Sigh.

I found that adopting the native idioms meant never having to notice the 1- based indexing. Everything is a hash table, and if you find yourself using literal numeric keys, there's probably a nicer way to do it. The lua users wiki is full of interesting ideas for tackling the basics in ways that leverage lua's simple flexibility.

Actually, Lua's table object is split into two parts. The array part, which is accessed using numerical indices, and the dictionary. It's done like that to enable fast array access, and I do find it an incredible useful feature in Lua.

In my experience 1-based indexing is not a problem when you're just writing Lua code. I've sometimes been frustrated when creating Lua bindings to C-modules which involved some kind of array access though.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#53

I haven't seen the video [do they discuss this?], but the biggest problem I have with Lua is its lack of good unicode support. The Lua wiki suggests slnunicode and ICU4Lua, but neither library has been updated for a year. I'd love to use Lua instead of Python for some tasks, given that LuaJIT kicks ass. But poor support for something as important as unicode is a deal breaker. Am I just missing some information in thi…

> I haven't seen the video [do they discuss this?], but the biggest problem I have with Lua is its lack of good unicode support.

Hear hear. I too don't care much for the argument that Lua doesn't have unicode because C doesn't have unicode. For two reasons. First of all, Lua can be straightforwardly embedded into a host of other languages (for example, http://tinyurl.com/39qhxzw). Second, who in their right mind thought that a language designed for embedding into commercial applications shouldn't have good I18N? (And honestly, how in the world could someone from Brazil develop a programming language that doesn't even support their own spoken language? It's as if Ruby was developed by someone in Japan.)

A bit of history. From what I have gathered in its documentation, Lua steals quite unabashedly from NewtonScript. NewtonScript was a proto-style OO language developed in a hurry for the Newton when the Dylan language wasn't going to deliver. Like Lua, it's a language designed originally for an interpreter, which runs embedded in an outer C++ environment and must interoperate with it. But NewtonScript doesn't just use Unicode pervasively: it was the first major language to do so. And C++ interoperability with the language is just fine. So this Lua-needs-to-work-with-C-and-thus-can't-do-unicode thing is nonsense both in fact and precedent.

And while we're on the subject of NewtonScript: Lua's let's-almost-do-proto-style-OO-but-require-the-user-to-do-extra-work is really incredibly annoying. Lua should have had proto OO built into the language, like NewtonScript, and not just "available", in a hacked way, through its meta model. Lua wants to be more "general" than NewtonScript, but it just winds up being (IMO) rather less usable.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#54

Very unscientific but hopefully interesting: $ time php -r 'echo "Hello, world!";' # smaller php binaries can be compiled real 0m0.555s $ time perl -e 'print "Hello, world!";' real 0m0.385s $ time ruby -e 'puts "Hello, world!"' # mri real 0m0.073s $ time python -c 'print("Hello, world!")' real 0m0.067s $ time lua -e 'print "Hello, world!"' real 0m0.013s $ time js -e 'print("Hello, world!")' # spidermonkey real 0m0.01…

Also interesting is how much memory is allocated running the empty program (detected with Valgrind):

    Lua 5.1.4: 34k allocated, all memory freed.
    Perl 5.10: 195k allocated (140k leaked!)
    Ruby 1.8.7: 670k allocated (665kb still reachable at exit)
    OpenJDK 6: 1.5M allocated (1M in use at exit).
    Python 2.6.5: 3M allocated (1.2MB in use at exit)

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#55

Earlier quoted context omitted.

What do you object to in counting from 1? (Other than it's not traditional.) In C, it's an offset into a typed block of memory, so 0 indexing makes sense. But lua does not deal directly with memory.

It has nothing to do with indexing memory--it has to do with 1 based arrays causing "+1" and "-1" to be sprinkled all oever the place. I find Dykstra's argument to be compelling: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...

My experience with Lua hasn't seen this problem materialize.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#56

I haven't seen the video [do they discuss this?], but the biggest problem I have with Lua is its lack of good unicode support. The Lua wiki suggests slnunicode and ICU4Lua, but neither library has been updated for a year. I'd love to use Lua instead of Python for some tasks, given that LuaJIT kicks ass. But poor support for something as important as unicode is a deal breaker. Am I just missing some information in thi…

> I haven't seen the video [do they discuss this?], but the biggest problem I have with Lua is its lack of good unicode support. Hear hear. I too don't care much for the argument that Lua doesn't have unicode because C doesn't have unicode. For two reasons. First of all, Lua can be straightforwardly embedded into a host of other languages (for example, http://tinyurl.com/39qhxzw ). Second, who in their right mind tho…

Lua is as old as NewtonScript. Its authors have mentioned Scheme, SNOBOL, awk, bibtex, Icon, and (IIRC) Self as influences, but I don't recall them mentioning NewtonScript. Javascript also has a lot in common with Lua. I think it's because the trade-offs inherent in embedded scripting languages are making them converge on a similar overall language design, rather than plagiarism.

If you're putting Lua in a commercial application, the commercial application itself will provide the i18n, and Lua can use it with very little trouble. Lua's strings are raw byte arrays - you can load arbitrary binary data in them. A library that reads UTF-8 strings (say) can work with them just fine. (And while I don't speak Portuguese, there are examples in PiL that use it without problems.)

I disagree with you about whether metatables are annoying, but it's a matter of taste. I haven't ever used NewtonScript, but I do use metatables for quite a bit more than just prototype OO - it's easy to turn a table into a proxy + cache to a function, for example. Also, my Lua redis library (http://github.com/silentbicycle/sidereal) turns table reads and writes into syntactic sugar for redis db key, list, and set operations.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#57

Earlier quoted context omitted.

> I haven't seen the video [do they discuss this?], but the biggest problem I have with Lua is its lack of good unicode support. Hear hear. I too don't care much for the argument that Lua doesn't have unicode because C doesn't have unicode. For two reasons. First of all, Lua can be straightforwardly embedded into a host of other languages (for example, http://tinyurl.com/39qhxzw ). Second, who in their right mind tho…

Lua is as old as NewtonScript. Its authors have mentioned Scheme, SNOBOL, awk, bibtex, Icon, and (IIRC) Self as influences, but I don't recall them mentioning NewtonScript. Javascript also has a lot in common with Lua. I think it's because the trade-offs inherent in embedded scripting languages are making them converge on a similar overall language design, rather than plagiarism. If you're putting Lua in a commercial…

I'll have to look up the specific direct references I saw that the Lua authors made to NewtonScript which prompted this: though note that the sole reference to Self in Programming in Lua is made in the same breath as NewtonScript. At any rate, I very strongly disagree with you about the 18n. Let's say you're making a video game. Let's call it, oh, I dunno, how about "World of Warcraft". You've decided to craft much of the level design in Lua so you don't have to write it in C++. Now you want to port it to the Mongolian market, complete with Mongolian storyline, instructions, character dialogue, you name it. All this stuff was in Lua strings in English. If you had a decent 18N system in your scripting language you'd just type Mongolian in those strings instead. This is a real problem.

> I disagree with you about whether metatables are annoying, but it's a matter of taste.

I didn't say metatables are annoying in and of themselves. I said they're annoying as a hacked-together substitute for a true proto OO.

Lua has many good things. But 18N and a usable OO ain't among them.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#58

Earlier quoted context omitted.

Lua is as old as NewtonScript. Its authors have mentioned Scheme, SNOBOL, awk, bibtex, Icon, and (IIRC) Self as influences, but I don't recall them mentioning NewtonScript. Javascript also has a lot in common with Lua. I think it's because the trade-offs inherent in embedded scripting languages are making them converge on a similar overall language design, rather than plagiarism. If you're putting Lua in a commercial…

I'll have to look up the specific direct references I saw that the Lua authors made to NewtonScript which prompted this: though note that the sole reference to Self in Programming in Lua is made in the same breath as NewtonScript. At any rate, I very strongly disagree with you about the 18n. Let's say you're making a video game. Let's call it, oh, I dunno, how about "World of Warcraft". You've decided to craft much o…

Lua "strings" are raw byte arrays with a saved length. You can store JPEG data in Lua strings. Storing Mongolian is not a big deal. You'll need a lib to e.g. calculate UTF-8 lengths, but all that needs to happen is the Lua community (or a project's company) agreeing on a specific Unicode library. There are no technical limitations there.

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#59

Earlier quoted context omitted.

I'll have to look up the specific direct references I saw that the Lua authors made to NewtonScript which prompted this: though note that the sole reference to Self in Programming in Lua is made in the same breath as NewtonScript. At any rate, I very strongly disagree with you about the 18n. Let's say you're making a video game. Let's call it, oh, I dunno, how about "World of Warcraft". You've decided to craft much o…

Lua "strings" are raw byte arrays with a saved length. You can store JPEG data in Lua strings. Storing Mongolian is not a big deal. You'll need a lib to e.g. calculate UTF-8 lengths, but all that needs to happen is the Lua community (or a project's company) agreeing on a specific Unicode library. There are no technical limitations there.

> Storing Mongolian is not a big deal.

...

> You'll need a lib to e.g. calculate UTF-8 lengths,

...

> There are no technical limitations there.

You cannot be seriously making this argument. Why not just code everything in assembly?

Re: Lua Doesn't Suck – Strange Loop 2010 20-minute talk video

#60

Earlier quoted context omitted.

Lua "strings" are raw byte arrays with a saved length. You can store JPEG data in Lua strings. Storing Mongolian is not a big deal. You'll need a lib to e.g. calculate UTF-8 lengths, but all that needs to happen is the Lua community (or a project's company) agreeing on a specific Unicode library. There are no technical limitations there.

> Storing Mongolian is not a big deal. ... > You'll need a lib to e.g. calculate UTF-8 lengths, ... > There are no technical limitations there. You cannot be seriously making this argument. Why not just code everything in assembly?

I understand it's annoying that Lua doesn't have a a single, officially recommended Unicode library* (in the core distribution or otherwise), but as problems go, it's easily solved by loading an existing, freely available library and getting on with life. It's much less trouble than (say) removing the GIL from Python or retroactively fixing weird operator precendence in C.

* Though there are recommendations at http://lua-users.org/wiki/LuaUnicode .

In practice, it could look like this:

   U = require "unicode"
   s = U"some unicode"      -- using a library sure is hard
   length = s:len()
   replaced = s:gsub("thing1", "thing2") -- global substitute
   etc.
You can add regular expressions and bignums to Lua pretty painlessly, too.
Post reply on HN