6 ms·
Fake Operator Overloading in JavaScript (2011)
- TazeTSchnitzel 12y agoThis is complete insanity, but I love it.
- lucio 12y ago"Authentic Operator Overloading" is already a bad idea, so a "Fake Operator Overloading" will be a bad implementation of a bad idea. You may better title the article "Casual inadvertent code obfuscation c++ tools fake-implemented in javascript: enjoy!" :)
- blubbi2 12y ago> While fake operator overloading is a fun hack, you probably shouldn’t use it in production code. > But at the very least, fake operator overloading allows you to impress your friends by unusual-looking code. Couldn't agree more. Please, please don't use this in production. Edit: Just wrote the following piece of code: coors[0] = ~~cors[0]; Damn.
- inglor 12y agoI totally get why people _want_ operator overloading - it is immensely useful when performing arithmetic. Writing `x+y*z` is easier vs `x.add(y.mul(z))` and I think everyone who had to do statistical analysis agrees. However - I totally agree that this hack shouldn't be put to real use. ES7 gets value objects with proper operator overloading that shouldn't suck.
- bobdetemple 12y agoin case you don't make it to the end, the closing line is "But at the very least, fake operator overloading allows you to impress your friends by unusual-looking code."
- leeoniya 12y agowhy use this when there's already a perfectly good Brainfuck[1] to impress your friends. [1] http://en.m.wikipedia.org/wiki/Brainfuck http://en.m.wikipedia.org/wiki/Brainfuck
- edibleEnergy 12y agoWhy use Brainfuck when you can use SNUSP - http://rosettacode.org/wiki/FizzBuzz#SNUSP http://rosettacode.org/wiki/FizzBuzz#SNUSP
- mikeash 12y agoI think Malbolge is the winner in the field of crazy programming languages. It has no entry on that page, presumably because nobody has managed to write FizzBuzz in it yet. There is at least a Hello World: http://rosettacode.org/wiki/Hello_world/Text#Malbolge http://rosettacode.org/wiki/Hello_world/Text#Malbolge A choice quote from Wikipedia: "Weaknesses in the design have been found that make it possible (though still very difficult) to write useful Malbolge programs." Many languages are deliberately made to be difficult to use, but in the end they're always made to be used. Malbolge is the only one I'm aware of where the ability to write programs at all is a "weakness."
- peterashford 12y agoFor the love of God, NO!
- vkjv 12y agoI've read this article a few articles and it keeps hooking me with a certain math puzzle. Is it possible to identify an arbitrarily long string of operations when you can only control side effects and the return value? I haven't been able to come up with anything.
- pluma 12y ago> You probably shouldn't use this in production. Yeah, that's probably an understatement.