Anyone who looks at this code instantly becomes insane
github.com
github.com
You may not like it, but this is peak programming. A level of perfection attainable only by undergoing the rite of writing a single if statement with 100+ conditions.
A coder strives to write the longest and most impressive code.
A programmer strives to write the code that solvers the problem at hand at the simplest and most reliable way.
Certainly, a great meme to use but also indicative of the divisive nature of some discussions, often without any sarcasm.
What does this function do? Oh the power matrix? Oh it resolves that? Cool.
For example, line 5284 has a 8 inequality operators checking every 4th element (140. 144, 148,...). A single "blocks[1][y][x] % 4 != 0" would remove them all. There also appears to be 3 main segments in that huge block of code (111-118, 119-126, 137-168) which would allow it to be simplified.
A second question: Why is there no comments? Is this common?
It's frighteningly common, and more likely if only 1 developer is working on something. CS students comment far too much, but I would expect a monstrous chain like this to have at least -some- documentation.
Man I remember being this naive once :(
In the beginning of learning to program it’s easy to get stuck on the “clever” side of programming, but a lot of the time it can remove readability. The earlier you learn this, the more your future coworkers will appreciate you.
Good luck!
Iirc that particular bit of code is the power logic. You can file an issue on my fork if ys like me to write more on this when im not on a broken phone.
"Back when I was first learning to program in Java, I decided to try to make a clone of the excellent PC game Terraria. Of course, I was convinced that my version would have many more features than the official one.
But before I realized how silly that idea was, I produced 11,000 lines of, to date, the most atrocious code I have ever seen in my life. I make it available here mostly as a cautionary tale of what can happen if you don't pay attention to the quality of your code. (Lesson learned, in my case!) Here are some of the highlights..."
Reminds me of the video driver (forget card) some Linux developers wrote that was ~30k lines of code. OpenBSD wanted to use it because the HW manufacturer wouldn't release the specs, but because the Linux code was GPL, the OpenBSD guys re-wrote it from scratch in less than 1/4 of the code.
Further, that the code probably would not really be hideously miserable for a more experienced coder to refactor(it's just very duplicated) shows that copy-paste is reasonable for deferring some kinds of architectural decisions. It's not what you would bias towards if you have a whole team pounding away at the same file and rapidly evolving it, but as a solo practitioner who wants to get the feature out and put it away for the day, this style is convenient for letting the code as a whole develop some maturity and functionality before it gets refactored with abstraction.
yup. reminds me of: "Write Code Like You Just Learned How to Program" -- https://prog21.dadgum.com/87.html
The code was actually very simple, it consisted of for loops over a bunch of element nodes in which child nodes had to be compared with child nodes in other element nodes, or in which attribute nodes needed to be compared with other attribute nodes, whenever one of these nodes that needed to be compared with other nodes was found a new for loop would be started to loop over the whole set of nodes once again to find the attribute or element with children that needed to be compared with the currently selected attribute or element. I am describing this so succinctly and clearly for you so that you may experience a deeper understanding of just how succinct and clear the code itself was.
Whenever values where found that matched they were added to an array that was later looped over to get the values to actually doing something with them. They had printed out the oode, it was nearly 100 pages - I was pretty sure I could have done it in less than 2 pages (it was in C# and I sucked at C#), I mean the actual XML that was being analyzed would be less than 5 pages if printed.
After looking at it for a few minutes I announced that it should be rewritten. The other developers wanted to continue on with it to find the bug. I think they had been driven insane.
on edit: by less than 2 pages I mean that it might be more than 1 page but I suppose not 2 full pages.
For example, they needed to get a numeric value from a dropdown box that got several text options. The way they did it was:
fieldVal = textField.gsub('text string 1',0).gsub('another string 2',1).gsub('anotherstring3',3).....
and so on with all the options. And in theory they looked for a 0, 1, 2... etc.
Another WTF was that, when we told them we would be upgrading from Ruby 1.8 to 2.0, they told us that they were not sure, because 2.0 did not work that well... As it happens, at some point in the code they were using the .object_id property of a boolean value and testing it == 2 or 0. Well... ruby 2.0 made true.object_id == 20 , so things did not work as expected.
There was a requirement that we had to deliver all validation code in VBScript that would run in the ASP but also should handle possible future changes to the request, and I had examples of all valid possible requests (which as I said had just been changed a couple days before), so I wrote an XSLT that went over all the XML templates and generated a bunch of VBScript if statements and for loops for each possible valid request and if it didn't find it returned an error message that it was invalid.
So anyway based on the theory that I can understand any stupid coding wtf I myself have done - if the wtf code is generated by some other better code I understand why the code is so awful, but if it is handwritten I still don't understand. And my guy handwrote his code. I'm guessing yours too. crazy.
Terraria extensively used God objects with hundreds or thousands of properties, and used naive C# serialization for its netcode. This meant that sending the state of a single object would take over 1KB, leading to truly outrageous network requirements for a 2D platformer game, on the order of >100KB/s/player.
But neither the C# compiler nor the ILSpy decompiler moves code to different methods/classes (only the JIT does stuff like inlining), so yes it's really a single enormous class handling every possible item in the game via cascading if statements.
Oh, and that stream of comments by polytomous. That's... something.
public static void print(String text) {
System.out.println(text);
}
This person cares enough about brevity to make little wrapper functions like this, but at the same time everything is very procedural and monolithic. This gives a vague, weird sense of refined taste, despite some obvious problems with the artifact as a whole.I'm going to go out on a limb and guess that the programmer came from a C background (where brevity tends to be valued and abstractions tend not to be) and used Java because it's cross-platform.
What I'm seeing is where frameworks are becoming the new "programming languages". People now bicker over what framework to use rather than first master the language they are using for a task. I tend to favor the method of "do the simplest thing that works".
If that’s not some very clever trolling, I’m not sure what is.
And what dedication! Pretty funny.
I found this in the readme, hilarious (not in a mean way).
Didn't Facebook and other major app developers run into issues with having too many classes for Android's JVM?
Don't do that kids
In my estimation, the sin is the cyclomatic complexity.
Object Class: Keter
Infohazard, Cognitohazard
Special Containment Procedures: Do not look at this code
[1] - https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
HN's font saves you this time...
[0] https://en.wikipedia.org/wiki/The_Funniest_Joke_in_the_World
This is at least obvious and easy to explain badness... And the lesson was learned. Some people don't learn it or are forced to ignore it all the time by middle management.
(This is how you go grey haired from stress.)
- 9.5k lines of code
- 333 bugs
- 2 vulnerabilities
- 6 security hotspots
- 56 days of technical debt
- 2172 code smells
- 0.0% coverage
- 21.5% duplications
- 117 duplicated blocks
I might be masochistic enough to try to fix these issues with a merge request.
as an aside, i have never seen short used in java code until today after like 10 years
Is it really ableist to think that sanity is objectively better than insanity?
> ins*ne
This is peak wokeness. We can’t even spell out the word “insane” for fear of offending someone.