Hacker News new | ask | show | jobs
by placeybordeaux 3928 days ago
It's sad to see lua get slowly replaced by javascript.
6 comments

I think is is sad to see anything replaced by Javascript. Unpopular opinion I guess.

So many better choices out there.

> So many better choices out there.

For now. I get the feeling that soon enough a lot of them will start dying out. Trying to "sell" some language other than JS in a mostly-JS shop is already an impossible battle. Popularity is used as a counter-argument for everything.

I was just thinking that the Javascript community saw that the Ruby community were both snobs and well respected, assumed a causal link, and thought they just needed to be snobs for people to respect Javascript.
I for one like seeing Javascript replaced by better Javascript.
Better javascript would be incompatible with javascript - best you can get will be "less sucking javascript". And you'll be able to use it somewhere in the far future, after four competing companies have implemented enough of it in a way that mostly works, their browsers have reached most of the internet and the brave open source community has developed the polyfills needed to fix the incompatibilities.

I'm not holding my breath. Javascript sucks, it will be everywhere and we are stuck with it.

I'm totally with you. JS is such a bad language, might get better in the future with ES<X> but I guess not. It has many quick hacks (in the bad sense), admitted by it's author.

Interesting pattern I see lately is industry pundits on the CIO side advocate Javascript for inhouse tooling. I guess they have not much experience with programming languages.

With JS making inroads into CIO territory, we'll see a much higher usage in the future. And a much larger fallout with tons of unmaintainable legacy code.

It's like the times when everything needed Java, like Oracle added Java into their DBs for stored procedures. I guess Oracle will add JS too (or have they already?).

By better choices you mean better languages or other methods of achieving the same flexibility without the complexity of a language like JS? Can you reply with examples? I am interested in alternatives to JS and LUA.
Well, it's a popularity contest. Lua is certainly a great language, it's fast and it works well with C. I guess that nginx team thinks that js will bring more users therefore more business. If I were to develop a product and add a scriptable layer, i'd certainly use JavaScript. Even if it is not the best language out there, it's about growing an ecosystem.
Ecosystem isn't the only thing to think about, but I agree that is almost certainly why they chose js.
I'm willing to bet it won't bring them any new business. And in the long run, it will encourage their existing users to dump nginx and use Node.
If you think people will dump nginx for Node (which has totally different use cases) then I'm not sure how qualified the business estimation is...
Isn't Node more of an Application server though? I don't see Node replacing Nginx in the roles it's normally used for (serving static resources, reverse-proxy). I can't think of a single upside
Agreed... I don't want the effort and complexity it would take to offer a lot of what's pretty easy with nginx inside a node app. As much as I really like node, I think it's generally nginx in front of node to offset what it does better... I think people make applications complicated enough as it is...
Lua and JavaScript are very similar languages and share the basic problems. I'm indifferent.
I like and use both. I think Lua is a better language and I have a hard time seeing otherwise. Lua has some warts too, it's not about warts, but Lua got enough right from the beginning, is small enough to be crazy fast, and is not continually adding new large features. This is the key thing to me. JavaScript is designed by committee and has too many features in ES6.
That's a good point, Lua is smaller than JS. It does have that going for it.
Exactly.
I have been playing around with Lua in Openresty for the last few nights. I haven't had any Lua experience before but it seems to be a good language for Nginx, and it has been fun to learn.
It is. But JavaScript is the new assembly language, all you need is a Lua to JS compiler or a whatever to JS compiler.
Last I checked Javascript implementations were slower than LuaJIT. Cost of implementing Lua tables, meta-tables, co-routines, etc. in Javascript will be rather high. Anywhere between 2-50x. If native Lua engine is removed, you can just forget about it then.

So what you're saying doesn't make any sense for anything remotely performance sensitive.

It's a joke. Like haha, but serious, because some people actually believe this.
lua compiled to asm.js is 64% of the speed of lua native

https://kripken.github.io/lua.vm.js/lua.vm.js.html

... which is about 10 times slower than the LuaJIT compiler used by OpenResty.
So that might be good enough in the browser but on the server where an optimized Lua engine exists, why?
That's not compiling lua to asm.js; it's running the lua vm in asm.js.

A straight up transpilation is other projects like lua.js. But you loose really nice core lua features like coroutines...

> Cost of implementing Lua tables, meta-tables

Tables and meta tables are nearly identical to objects and prototypes in javascript. Why would the cost of implementing them be high?

JavaScript objects are indexed by strings. Lua tables are indexed by arbitrary objects. In JS a[1] and a["1"] are the same element but they are different in Lua. In Lua a[{}] is a new element indexed by the identity of the new object literal, and will be a different element every time the expression is evaluated.
I genuinely can't tell whether you're joking.
Not joking, just dying a little inside.
I have tried so hard to like Lua, but I prefer 0-indexed arrays and curly braces.
The comment syntax is really what gets me.
Oh right, when you try to disable code with a block comment and an array says "not today".

Although the same happens in JS with Regular Expressions :P