7 ms·
If programming can be described as "making programs", metaprogramming could be described as "making programs making programs" - or something. You probably use m
by current_call 11y ago
If programming can be described as "making programs", metaprogramming could be described as "making programs making programs" - or something. You probably use metaprogramming every day perhaps without even noticing it.
Compared to other languages like Ruby or Python, JavaScript's metaprogramming features are not yet as advanced - especially when it comes to nifty tools like Operator Overloading, but ES6 is starting to level the playing field.
What isn't metaprogramming now?
This feels very relevant. http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt-scheme/ http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...
- thomasfoster96 11y agoI think that link needs a bit of updating - JS has lexical scoping and tail call elimination now.
- epidemian 11y ago> JS has [...] tail call elimination now. In a very narrow hay of "has", as in "ES2015 the spec has it, but no JS runtime implements it yet": http://kangax.github.io/compat-table/es6/#proper_tail_calls_%28tail_call_optimisation%29 http://kangax.github.io/compat-table/es6/#proper_tail_calls_... I'm not trying to be a contrarian. It's just that i see lots of JS developers excited about superfluous things like class syntax or symbols, whereas real game changing additions like proper tail calls seem to pass by unnoticed, and unimplemented by JS runtimes :(
- current_call 11y agoI tried to create an infinite loop in Firefox and got a "InternalError: too much recursion". Then when I tried it in Chrome I got "Uncaught RangeError: Maximum call stack size exceeded". function x() { return x(); }
- Kiro 11y agoI think you misunderstood "now". It's "now" as in ES6/ES2015, not ES5 which the browsers are running by default.
- thomasfoster96 11y agoThat's still expected?
- current_call 11y agoIt's a recursive tail call. It should run forever, like the following Scheme code. (define (foo) (foo)) (foo)
- thomasfoster96 11y agoAh, right, yes I get what you mean. The main problem is still that Chrome and Firefox don't support tail call elimination. Babel (6to5) and Traceur do.
- strmpnk 11y agoThey don't. They support an optimization for self recursive calls but not general tail call elimination.
- AdieuToLogic 11y agoIf I could up-vote recursively until the Inter-tubes segfaulted, I would on that link you provided. A couple quotable lines from the article I have to throw out there are: > One day, Netscape woke up from a truly epic bender to discover it had jammed a scripting language onto the web and millions of people were using it. Literally none of them liked it. Not one. > Lots of programmers believe JavaScript is “basically” Scheme because it gives them something they want to believe: that the language they choose to use has some cachet and they don’t have to feel bad about it anymore.
- jstuxx 11y agoLots of languages claim they are Scheme or Lisp dialects (JavaScript, Python, Ruby, Lua and others) in order to boost their popularity even though they have none of Lisp's unique features but just the general features you would expect to find in any dynamically typed languages.
- Retra 11y agoPython claims it's a Scheme/Lisp dialect? Where?