3 ms·
...I know it's the fashion to write compile-to-js languages and js-VMs for other languages, but I really have to ask: WHY? I mean, Lua is a dynamic language wit
by nnq 13y ago
...I know it's the fashion to write compile-to-js languages and js-VMs for other languages, but I really have to ask: WHY? I mean, Lua is a dynamic language with first class functions just like Javascript is, no big difference here.
I understand clojurescript, parenscript and haskell to js compilers, because these languages are really different from javascript, so they offer you a very different way of working and different tradeoffs (Clojure, CL, Haskell offer you the ability to choose a programming style that is just not possible in Javascript). Maybe even Opal or Amber - rubyan/smalltalkian oop semantics really are very different from Javascript's and you end up using very different design patterns. And I understand the wish to have static typing for large projects/teams, ergo TypeScript or Dart.
But I really don't understant why would anyone go through such pain (by pain I mean not writing the transcompiler/vm, this is the fun part, I know, but debugging it, maintaining it and debugging the code you use it on), to use a language so similar to Javascript, like Lua or Python, instead of using just plain Javascript and making some minor effort to 'use strict', avoid some dark corners and get used to living with a little less syntactic sugar?
- stcredzero 13y agoWHY? I mean, Lua is a dynamic language with first class functions just like Javascript is, no big difference here. You can use objects as keys in Lua. This makes a lot of code in Lua a pain to port to JavaScript. I have Lua code I would like to port to JavaScript that this applies to.
- nnq 13y agoGot some sample code or a link to it? I really like figuring out ways to express existing code in a different style/pattern/language :)
- Excavator 13y agoMap¹ might've been an option, excepting no support in Safari and IE < 11. Although I dunno about the performance hit, if any. ¹ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- fit2rule 13y agoRefactor once: the object key. To a function returning the value of the object. Refactor a second time: function all the object things. Whats not to like?
- MattJ100 13y agoFor the people that wrote Moonshine, it was the ability to use the same language across all platforms[1]. They already have a lot of Lua code on other platforms that was unable to run on the web (without using Flash, which also has a Lua VM available for it). Lua is very portable, I wouldn't choose Javascript to replace it for multi-platform game development. However Javascript has a monopoly on the web. I don't see why this ought to be. [1]: Source: https://skillsmatter.com/skillscasts/3820-developing-a-lua-vm-in-javascript https://skillsmatter.com/skillscasts/3820-developing-a-lua-v...
- fit2rule 13y agoBecause they were already using Lua as a cross-platform killer language, and wanted to just be able to share game-content with a slick, slimy, javascript layer?