3 ms·
Here is some detail on the kind of stuff Wasabi does: "[H]ow to translate [this bit of VBScript] a(1), which could mean "look up the 2nd element of array a" or
by shawndumas 14y ago
Here is some detail on the kind of stuff Wasabi does:
"[H]ow to translate [this bit of VBScript] a(1), which could mean "look up the 2nd element of array a" or "call the default method of the object a passing the argument 1" depending on what type a contains at runtime? This really matters, because we use arrays, and because we use the built-in class RecordSet all over the place, doing things like rs(1) which is short for rs.Item(1).Value, and since VBScript is latebound there is no way to know what code to generate in PHP until runtime, and that's too late! The only correct thing to do in PHP would be to generate code that checks the type of a, and decides, at runtime, whether to do an array lookup or a method call. This is messy and slow and would suck big rocks in the kinds of tight loops where you tend to be using arrays.
How did we fix it? Well, thanks to Hungarian notation, so callously dissed by developers who do would not recognize a superb coding convention if it walked up to them on the Shanghai Maglev train and shook their pants leg, every recordset at Fog Creek starts with the letters "rs". And Thistle looks for the rs and say, "ah, this is a recordset, you're not looking for an array value, you're calling the default method," and generates fast code. Based on your age you will either call this an evil hack (if you're young) or an elegant hack (if you're old); in either case it's a huge optimization made possible by the fact that Thistle only has one program to compile. Outside of Fog Creek it wouldn't work. All hail Hungarian notation!"
http://www.joelonsoftware.com/articles/FogBugzIII.html http://www.joelonsoftware.com/articles/FogBugzIII.html
- mikeash 14y agoI like how making it so that variable names determine whether or not the compiler generates correct code is labeled an "elegant hack". To borrow his phrasing, this makes me wonder if Joel would recognize an elegant hack if it walked up to him on the Shanghai Maglev and shook his pants leg.
- cpressey 14y agoI would barely call this a hack at all; it's only a hack under the view that it feels icky to evolve a programming convention into a language construct. Languages have been treating (parts of) variable names as part of the type system for ages: Fortran, BASIC, Perl, ...
- plaguuuuuu 14y agoWhat could possibly go wrong I wonder if any of his intern developers switched career after working there :|
- snogglethorpe 14y agoI feel dirty after reading that... oO;