Re:Recursive raytracer in 35 lines of JavaScript
by choult on Tuesday November 19, 2013 @04:10AM
(#6760038)
Capital letters are bigger, and therefore take up more space.
Re:Recursive raytracer in 35 lines of JavaScript
by stickupkid on Tuesday November 19, 2013 @04:15AM
(#6760051)
No.
Re:Recursive raytracer in 35 lines of JavaScript
by ggambetta on Tuesday November 19, 2013 @04:20AM
(#6760080)
For minification, as someone else said. I originally wrote this for a JS1K competition some years ago, so it's not geared towards readability, but towards small code size.
I had a really, really ugly trick that saved me a couple of bytes which I removed before posting to HN. I figured out I was using canvas.getImageData() and canvas.putImageData(). So I did this: var tID = "tImageDatA"; canvas["ge"+tID](); canvas["pu"+tID"](); You can see that in the original source: http://gabrielgambetta.com/tiny_raytracer_full.js
Not my proudest hack :D
Re:Recursive raytracer in 35 lines of JavaScript
by merkitt on Tuesday November 19, 2013 @04:29AM
(#6760108)
I just looked at this childhood drawing of yours: http://www.gabrielgambetta.com/img/1986-listado.jpg
Is that BASIC CODE mixed in with bugs bunny??! Raytracer or no raytracer, this is exceedingly cool.
Re:Recursive raytracer in 35 lines of JavaScript
by ggambetta on Tuesday November 19, 2013 @05:34AM
(#6760310)
Yes, that is (my 5 year old idea of) ZX Spectrum Basic. It follows the format of the listings published in Microhobby (http://microhobby.speccy.cz/mhf/031/MH031_08.jpg - in particular, look at the "NOTAS GRAFICAS" sidebar). I grew up with that :) My programming has improved, my drawing abilities not so much.
Re:Recursive raytracer in 35 lines of JavaScript
by davidpardo on Tuesday November 19, 2013 @05:56AM
(#6760365)
I remember typing that listing, almost thirty years ago. I owe a lot of what my life is now to Microhobby.
Re:Recursive raytracer in 35 lines of JavaScript
by ggambetta on Tuesday November 19, 2013 @07:58AM
(#6760815)
Microhobby FTW. I have the exact same feeling, but more generally about the Spectrum.
Re:Recursive raytracer in 35 lines of JavaScript
by jamiek88 on Tuesday November 19, 2013 @09:08AM
(#6761203)
Me too but more about the BBC B and the Amstrad CPC 464!
BBC Basic was amazing in hindsight.
Bugs Boni !
Re:Recursive raytracer in 35 lines of JavaScript
by minikomi on Tuesday November 19, 2013 @04:09AM
(#6760033)
Because when it's run through the Google closure compiler it becomes
E=Math,F=E.sqrt,G=E.max
Re:Recursive raytracer in 35 lines of JavaScript
by rejschaap on Tuesday November 19, 2013 @04:11AM
(#6760040)
That is before minifying. The variable name "math" was chosen for readibility in the non-minified version. The variable math can be renamed during the minifying process to a short identifier, in this case "E". Since the Math object is used quite a lot, it is worth the assignment to rename it.
// Shorten some names. var math = Math;