6 ms·
Source code for Lua 5.3
- sspiff 11y agoWhat's the point of posting this? Pointing out how small and elegant a real world language implementation can be?
- vmorgulis 11y agoYes and the design of the source code browsing (by column).
- mrdrozdov 11y agoWhat's a "real world language"?
- jessegreathouse 11y agoA language that gets widespread usage in projects other than academic.
- sspiff 11y agoAnother definition I could see working: a language that is used in projects bigger/more complicated that its own compiler or standard library.
- Narann 11y agoHahaha! You got me!
- mrdrozdov 11y agoWhat's an example of a "not real language" then? I'm feeling a little hard pressed to find an academic language that is not used in industry. I always thought of Lua as academic because I associated it with Torch, but Facebook and Google are both heavy users of Torch, besides Lua has been heavily used in gaming as an embedded scripting language outside of machine learning applications.
- llull 11y agoIdris. Really interesting language exploring dependent types for practical programming, but not yet production ready.
- cyphar 11y agoNeovim is also working on replacing VimL with Lua (by translating VimL to Lua). I think that'll be pretty cool (you will be able to match the emacs people on having all of your configuration in a full programming language).
- DonHopkins 11y agoLua is widely used and well respected in the game industry (WOW for example [1]), for its efficiency and embeddability. [1] http://wowwiki.wikia.com/wiki/Lua http://wowwiki.wikia.com/wiki/Lua
- scrollaway 11y agoI'm happy with anything that gives Lua more exposure. It's a pretty language and it is so damn small, fast and embeddable. Too many developers are using Javascript in places where Lua would be a far more appropriate option. Embedding, especially.
- nly 11y agoWhy is embedding Javascript inappropriate? Duktape has a similar codesize to Lua 5.3 http://duktape.org/index.html http://duktape.org/index.html
- aleksi 11y agoIn my opinion, Lua is better-designed language. JavaScript has horrible parts.
- patates 11y agoI've been developing game scripts with Lua and I've professional Javascript experience so I'm familiar with both. I actually find Javascript way more readable and easier to work with in general, especially with the new additions. I mean, it's yet another anecdote but just wanted to share.
- luchadorvader 11y agoWhy do you say Lua is better designed? And are you comparing classic JS or ES6 JS? I like Lua but there are some things that just annoy me like indexing an array with 1, smaller standard library, etc. I find JS implementation of inheritance, objects, and prototyping better than Lua due to its simplicity.
- ludamad 11y ago1. Indexing an array with 1 is unfortunate but not a bad design decision in a vacuum, eg for i=1,#size is a very easy to understand loop over valid array indexes. I'll agree that it causes cognitive load in practice. 2. JS has a somewhat broken notion of objects and Lua's implementation is far cleaner while being as powerful. How do you use a JavaScript object as a hashmap? The default try is a potential security hole.
- hathym 11y agoWhy not reimplement lua in lua?
- baldfat 11y agoskip to my lu-lu meet pypy.
- corysama 11y agoIt would be fun to reimplement Lua in http://terralang.org/ http://terralang.org/
- catwell 11y agoIt has been done, several times. A popular version is http://yueliang.luaforge.net/ http://yueliang.luaforge.net/, although it only supports old Luas (5.0 and 5.1).
- fosk 11y agoWhen running Lua, always consider running it on the LuaJIT (http://luajit.org/ http://luajit.org/). It's extremely fast, portable and lightweight JIT compiler for Lua, although it only supports Lua 5.1. The performance improvements are incredible, and it allows you to write inline C code thanks to the FFI library (declaring it like this https://github.com/Mashape/kong/blob/master/kong/plugins/file-log/handler.lua#L21-L25 https://github.com/Mashape/kong/blob/master/kong/plugins/fil..., and invoking it like this https://github.com/Mashape/kong/blob/master/kong/plugins/file-log/handler.lua#L53 https://github.com/Mashape/kong/blob/master/kong/plugins/fil...)
- aleksi 11y agoThere are some Lua 5.2 extensions: http://luajit.org/extensions.html http://luajit.org/extensions.html
- vbit 11y agoSeconded. LuaJIT FFI is just awesome. Check out the motivating examples: http://luajit.org/ext_ffi.html http://luajit.org/ext_ffi.html BTW, does anyone have recent benchmarks comparing LuaJIT against new versions of the Javascript JITs?
- CapsAdmin 11y agoYou are restricted to making C declarations. You can't write inline C code. You can however can create and use C types in Lua.