- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
And TRWTF is (as usual) the horribly bloated MS coding style...
Admin
Admin
Hey, my name is Carl, you insensitive clod!
And, if I recall my Dilbert correctly, the recovery project should be "TTP" which stands for "The TTP Project." Recurse enough times and you might find "TCPRP" in there somewhere.
Admin
Admin
No.
[image]We can see in the right bars that the changes displayed are the only ones with whitespace changes. All the other modifications (1 & 2) contain several removal without add counterpart, and possibly few add without a removal counterpart.
Maybe the consultant is an asshole. Changing indentation without referring to the developpers is not nice and might break automatic checks or editors expectations. But he didn't just do that.
Admin
Notice that FORI is a valid variable name, and FORI=1 executed successfully before the syntax error occurred. If you saved that program and opened it in a text or hex editor, you'd see that "FORI", "TO3", and "NEXTI" were not tokenized as "FOR I", "TO 3", or "NEXT I", but were tokenized as if they were variable names.
Admin
It would make sense if you wanted a compiler agnostic form of precompiled headers.
Admin
So, I wouldn't feel safe assuming that just because there are removes without add counterparts (or adds without remove counterparts), that the other changes didn't just change the whitespace.
Admin
They do... it's called a Compiler.
Admin
Admin
This
Even the SelectedValue property returns a string. I find it funny that the System.String class inherits the ToString() method from System.Object.
Admin
Admin
Reminds me of a project I was on at a large computer company where we were porting a large Unix project to Windows. The remote Windows team was noticing that their build results were HUGE compared to the builds our team was doing (both on Windows) and they were trying to figure out why.
The lead engineer at the remote site posited that the difference in the size of the build results was because of Windows systems using CR LF instead of LF in the source.
<facepalm />Admin
True.
But, in a program I have to maintain I found the following gem:
Admin
Admin
Yup, always a bunch of that.
Admin
If you actually MUST change the overall formatting of a code file while also making code changes, the best approach is to check the file out, reformat, and immediately check it back in. This way, version 12 (new formatting) is code-identical to version 11 (old formatting), and then 12 can be compared to 13 to see what the actual code changes were without all the formatting changes showing up as well.
Admin
Yes, that really was the only change committed for the "performance optimization", a whole bunch of files (20+) that had the whitespace consolidated!
Admin
Admin
You'd think with 17576 possibilities there'd be a few that haven't been used yet...
Admin
(They revert back to the unoptimized bytecode when a new 'shape' is encountered though, which means type stability of a parameter or variable has a significant impact on performance.)
The removal of whitespace speeds up the parsing phase of the code slightly.
A proper minifier will need to follow the algorithm for automatic semicolon insertion (ASI) and insert missing semicolons or code may break when folded onto a single line. If the minifier pre-applies ASI, it means the JS parser will not run into situations where it has to run those rather expensive checks itself anymore, again saving on a little bit of parse time.
Ofcourse, both are hardly significant on powerful hardware. They do tend to become noticeable on slower mobile devices processing in the megabytes of JS code for web applications though.
Admin
Course it's more efficient....it uses less code
Admin
Reason #2139 that I hate how loose the web is.
Admin
Depends on the context, which we don't definitively get in the story here. If the TCP team is presenting these as real optimization improvements, that's TRWTF. But if Carl is only checking the latest check-in, and he's assuming that it is meant as an optimization, then he's TRWTF.
Admin
Admin
Admin
Though it also makes me sad. Shouldn't our tools make it easier to not have to deal with stuff like that? I mean, it's not hard now with many tools, but you still have to take an explicit "ignore whitespace changes" step, and other tools don't support it. Though I'm not sure what I'd recommend.
(Actually what I think would be kind of neat but probably wouldn't work is to run every commit through a formatter to change it to a canonical layout, and then on every checkout run it through another formatter to set it to whatever you as the developer likes to see. Sort of like how CRLF conversion works with some version control tools. Though I hate CRLF conversion, so maybe that's not a good idea. :-))
Admin
$250/hr 4 hours of deleting whitespace
"I did a grand job of optimizing your code!"
Admin
In all fairness, it may not run any more efficiently, but it'll at least compile faster, by virtue of having to read fewer bytes of source code from the disk.
Admin
This is a start:
[image]Admin
Sometimes it's easier to read well seperated text than large chunks of prose (ie sometimes whitespace readability - who would've thunk it).
Scrolling takes very little time, unless you're on a terminal where one scroll > size of page. Most people are adept at scrolling while they read.....
Admin
Admin
Admin
Admin
Admin
For any optimizing compiler on any modern system, parsing is not a large part of the compile time. One 3,000 line C file takes 0.26 seconds to compile with GCC without optimization, and 1.10 seconds with -O2. So parsing the file is less then a quarter of the time of optimized compilation, probably much less.
Admin
Admin
Admin
Unfortunately .Net 1.0/1.1 did not have TryParse, and some people never upgrade (mentally).
Admin
I'll bet a good number of the Daily WTF readers don't even know what the image is of.
Admin
I'm guessing they figured that comments would slow it down too. Come to think of it, I'll also keep this comment short so as to not slow the reader down too much.
Admin
Admin
What's the name of that diff-engine? It looks great!
Admin
It does (is it windiff?), but isn't TRWTF the posting of a blurry screenshot of a GUI diff tool instead of just a (possibly colorized) plaintext diff?
Admin
oh, you obviously do not work in the IT industry.
I've seen this kind of crap first-hand, and several times. Its always done by some mumpty who thinks he's somehow better than everyone else, yet is invariably incapable of working with others or providing actual solutions either.
There again, most of them would simply point to the changelogs and say "but look at all the work I've done, I am amazing, I must be in line for a bonus".
Admin
True. There still are better ways. For example: Only allow numbers to be inserted in the Textbox? Plus, you really don't need a "ToString" there. The text already IS a string, why on earth would you want to cast a string to a string?
Admin
To really make sure that it's a string!!
Also, are you going to filter by character, or use a regex. Hopefully not the former, unless you disallow negative numbers, or plan to support "-243-2-34"
Admin
As a developer, I have quite strong opinions about the right way to format code.
But my opinion of people who gratuitously change the formatting of code, is even stronger.
By committing a change that changes every line of a source file, forever breaks any attempt to merge or diff across that revision. It will make routine maintenance tasks much more difficult, in perpetuity.
Simply because you couldn't resist your need to impose your own preferences on something that didn't need to be fixed.
Admin
really... silly...
The WTF seems silly too.
Submit your performance changes separate of your formatting changes.
Woopdie doo. :|
Admin
I worked on a project once. I had a computer in the lab and one at my desk ( pre laptop days ). One was windows, one was Unix. I wanted to make quick fix and checked out several files. I never realized the system would do the CRLF conversion and blithely committed.
Had to explain to change control why every line of code was changed. Sigh. I did the reverse of what was suggested above. Checked out the previous version, checked it back in unedited and then made the changes.