|
Flobbster posted:Not only that, but even in the case of appending a bunch of string constants and string variables together, the Java compiler is smart enough (that's a phrase you don't hear too often!) to compile that into a StringBuilder construction and sequence of append() calls. I never knew this until I had to decompile a class for something and saw that. Actually, this (1) is mandated by the language specification and has nothing to do with the quality of the compiler, (2) applies to any value that you concatenate into a string, not just string values, and (3) works only within a single expression. Also, weren't we talking about JavaScript, not Java?
|
# ? Nov 20, 2008 00:29 |
|
|
# ? May 16, 2024 19:05 |
|
rjmccall posted:Actually, this (1) is mandated by the language specification and has nothing to do with the quality of the compiler, (2) applies to any value that you concatenate into a string, not just string values, and (3) works only within a single expression. Well yeah, anything that's not a string would get toString()'d first so that's a non-issue. That's cool though, I didn't know it was part of the language spec itself -- I just assumed it was an optimization in the compiler for large expressions. quote:Also, weren't we talking about JavaScript, not Java? JavaScript code that was being generated on the server (in, as it turns out though, C# and not Java). It's a code horror that generates another code horror In the interest of full disclosure, I've done the very same thing in two of my projects (generating JS code with a StringBuilder in one, generating C++ in the other). I replaced the whole thing with Velocity templates (for the JS) and StringTemplate (for the C++ -- this code needed to be generable in both Eclipse and VS.NET plugins, so I needed a library with both Java and .NET versions), and I can't believe I didn't do that from the outset.
|
# ? Nov 20, 2008 01:03 |
|
Flobbster posted:JavaScript code that was being generated on the server (in, as it turns out though, C# and not Java). It's a code horror that generates another code horror
|
# ? Nov 20, 2008 10:29 |
|
Haven't posted in this thread in a while, mostly because the WTF-inducing guys have all left the company, and the entire codebase has cleaned up quite nicely. However today I had to go through some old (unused) code and found this beauty: code:
|
# ? Nov 20, 2008 13:39 |
|
The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL: throw new Exception("hahaha, I bet you did not understood the code"); http://www.urubatan.info/2008/11/commenting-source-code-is-only-for-the-weak/ He turns some clear straightforward code into...I don't know
|
# ? Nov 20, 2008 17:57 |
|
If he thinks that this:code:
code:
|
# ? Nov 20, 2008 18:08 |
|
Fib posted:The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL: throw new Exception("hahaha, I bet you did not understood the code"); readFileContetIntoBuffer(buffer,readerForFile); readFileContet Contet edit: code:
ymgve fucked around with this message at 18:29 on Nov 20, 2008 |
# ? Nov 20, 2008 18:23 |
|
^^^ Haha, we even highlighted it the same way.quote:readFileContetIntoBuffer(buffer,readerForFile); quote:readFileContetIntoBuffer quote:Contet IF I EVER MEET YOU I WILL PULL OUT YOUR EYES AND DRIVE NAILS INTO THE SOCKETS, YOU MOTHERFUCKER. Sorry. I HATE mispelled constants.
|
# ? Nov 20, 2008 18:23 |
|
code:
code:
|
# ? Nov 20, 2008 18:41 |
|
To elaborate more on my question, which of these are good/bad?code:
ymgve fucked around with this message at 19:07 on Nov 20, 2008 |
# ? Nov 20, 2008 18:42 |
|
code:
Also, why the hell is the filename a string builder?
|
# ? Nov 20, 2008 18:46 |
|
... and why is a function for reading called 'write' at one point?
|
# ? Nov 20, 2008 19:14 |
|
And why are all variable names only three letters long? fle? file! lin? line!
|
# ? Nov 20, 2008 19:25 |
|
TSDK posted:... and why is a function for reading called 'write' at one point? It's obviously writing the file to the buffer you big noob ugh it's like you've never seen real code before There's probably a write(StringBuffer con,StringBuilder fle) that writes the buffer back to the file ymgve posted:To elaborate more on my question, which of these are good/bad? I like the third and first ones (in that order), myself.
|
# ? Nov 20, 2008 20:25 |
|
Munkeymon posted:It's obviously writing the file to the buffer you big noob ugh it's like you've never seen real code before I've always felt the third one is a bit iffy because you have the same call twice, so if you ever change the code around, you have two locations that you need to change. Not so hard in this simple example, though. I feel better about the first one, but it does seem a bit "unclean" to do an assignment inside the while() evaluation. (Then again, this comes from someone who prefers break...)
|
# ? Nov 20, 2008 20:34 |
|
TRex EaterofCars posted:Sun's javac is probably one of the best compilers on earth. I have no idea what you're talking about. It produces pretty much a direct translation from Java to bytecode with no optimization or anything. It's easy to be the "best" in a nearly completely trivial process. EDIT: I just realized I skipped a page in my rush to yell at Java, oh well.
|
# ? Nov 20, 2008 20:57 |
|
TSDK posted:... and why is a function for reading called 'write' at one point? Clearly he's programming in lower-level terms than our puny little minds can handle, since obviously every operation on a computing machine is a "write" -- even if you're reading from a file, you have to WRITE those bits to memory or a register to use them
|
# ? Nov 20, 2008 21:06 |
|
ymgve posted:I've always felt the third one is a bit iffy because you have the same call twice, so if you ever change the code around, you have two locations that you need to change. Not so hard in this simple example, though. True, but how often would you expect a read call to change form in a signifigant way? Did you recently change your username?
|
# ? Nov 20, 2008 21:08 |
|
Munkeymon posted:I like the third and first ones (in that order), myself. I prefer the original one then the third.
|
# ? Nov 20, 2008 23:57 |
|
Munkeymon posted:True, but how often would you expect a read call to change form in a signifigant way? Nope, same username since registration. Why?
|
# ? Nov 21, 2008 00:09 |
|
Campbell posted:I just got done debugging a custom javascript image rotator that was spawned in hell. There was a basic javascript error, which wasn't a big deal. What was the big deal was that the rotator was a custom control project that existed only on that ex-employee's machine. (I'm going to assume this is C# here.) In pretty much every online tutorial about registering javascript, they put the javascript code in between the C# code, and gently caress around with StringBuilders or whatever. It looks horrible and I always make functions in separate .js-files instead, and just put a single function call in the C# registerscript function call. However, I recently discovered that if you put an @ sign in front of the string, you can include line breaks in strings, and it just works. So this: code:
(Putting it in separate files is still better, because there you get syntax coloring and junk.)
|
# ? Nov 21, 2008 00:31 |
|
Painless posted:I have no idea what you're talking about. It produces pretty much a direct translation from Java to bytecode with no optimization or anything. It's easy to be the "best" in a nearly completely trivial process. When javac's hands aren't tied by inter-class abstraction boundaries, it can actually do quite a lot; but of course that's a huge limitation.
|
# ? Nov 21, 2008 00:32 |
|
rjmccall posted:When javac's hands aren't tied by inter-class abstraction boundaries, it can actually do quite a lot; but of course that's a huge limitation. You might mean it could do. It doesn't actually do poo poo. This code:
code:
|
# ? Nov 21, 2008 02:49 |
|
The real WTF is that Java doesn't provide single, simple methods to read/write all text/lines, like .NET does. Hmmmm, maybe just wanting to get a file's contents without caring about how is a common enough operation to provide a shortcut in the standard library? P.S. Another problem with calling readLine in two places is that continue will screw you over.
|
# ? Nov 21, 2008 02:57 |
|
Painless posted:You might mean it could do. It doesn't actually do poo poo. Bah, you're right. Apparently I haven't looked at this since they decided to deprecate -O.
|
# ? Nov 21, 2008 03:10 |
|
Painless posted:You might mean it could do. It doesn't actually do poo poo. What if b[] is being modified in a different thread?
|
# ? Nov 21, 2008 03:15 |
|
tef posted:What if b[] is being modified in a different thread? Then the results are undefined, because Java's volatile is only usable as a field attribute? And also, the length of an array will never change, so this question is pointless? Perhaps I have owned you goon sire?
|
# ? Nov 21, 2008 03:27 |
|
tef posted:What if b[] is being modified in a different thread?
|
# ? Nov 21, 2008 03:30 |
|
Recently I found acode:
But also I had to hunt down one of the senior dev's anonymous enumerations, because he thought int was a good enough data type to represent it. I should bother him about where that darn enumeration is every time I have to use his functions. Speaking of misspelled constants, we've got one somewhere that is hilariously and obviously misspelled. I wish I could remember what it was.
|
# ? Nov 21, 2008 05:18 |
|
Today I saw something that made me cry since I'm pretty sure the guy that's writing this is getting paid more than me. This guy spent four days writing an app in .NET which allowed you to put an x and y value in two textboxes and click "Plot" and it would plot a point at those values on another control. And his code didn't even work. So today I gave him a story for "parsing" log files retrieved from a machine. The first iteration of this is simply "look for {FAIL!} in the log, if it's there, the test failed." His solution looks something like this (he hasn't checked it in yet and I'm just going off memory of what I saw over the shoulder) code:
When I left today he was "stuck" on a compiler error which said "You can't have a method with the same name as its containing type". How is this a hard error to interpret? edit: Oh, also, at one point he wanted to make a flag "WaitForFinishTrueOrFalse", and also changed a boolean field from "WillCheckReturnValue" on an object to "IsCheckReturnValue". And then used it in a if (IsCheckReturnValue == true) statement as justification for why "is" was better. Dessert Rose fucked around with this message at 05:32 on Nov 21, 2008 |
# ? Nov 21, 2008 05:28 |
|
Ryouga Inverse posted:So today I gave him a story for "parsing" log files retrieved from a machine. The first iteration of this is simply "look for {FAIL!} in the log, if it's there, the test failed." A "story"?
|
# ? Nov 21, 2008 16:43 |
|
shrughes posted:A "story"? I assume he means something like a user story
|
# ? Nov 21, 2008 17:08 |
|
No Safe Word posted:I assume he means something like a user story Correct. It's a Scrum/Agile term. Here's what he checked in: code:
(It doesn't work, so I think he removed it from the project file so that the project still built)
|
# ? Nov 21, 2008 22:33 |
|
ymgve posted:Nope, same username since registration. Why? Memory corruption on my part, I guess. I mostly remember avatars, anyway. Ryouga Inverse posted:I think I want to kill myself. Just kill the guy who turned that poo poo in and maybe his job could be filled by someone who doesn't leave the # out of C#.
|
# ? Nov 21, 2008 23:46 |
|
Munkeymon posted:Just kill the guy who turned that poo poo in and maybe his job could be filled by someone who doesn't leave the # out of C#.
|
# ? Nov 21, 2008 23:51 |
|
Jethro posted:I think he's programing C♭ instead. I'm not musical enough to know what the hell that thing is
|
# ? Nov 21, 2008 23:56 |
|
Munkeymon posted:I'm not musical enough to know what the hell that thing is "flat" instead of "sharp". Yeah, I replaced the code with about three lines of "actual" code (the rest being whitespace and return {constant} statements) ... oh, and mine worked.
|
# ? Nov 22, 2008 00:06 |
|
code:
|
# ? Nov 26, 2008 19:03 |
|
.
|
# ? Nov 26, 2008 19:21 |
|
|
# ? May 16, 2024 19:05 |
|
A colleague and I were looking through a ray-tracer that someone released as we were implementing one of our own algorithms in it in order to see if the gains we were seeing were peculair to our own code. We came across a piece of code like this... code:
|
# ? Nov 26, 2008 20:02 |