5 ms·
The Six Most Common Species Of Code
- vezzy-fnord 13y agoI feel sorry for that Math Ph.D. writing in Java.
- angersock 13y agoI feel sorry for that Java.
- mtdewcmu 13y agoI like the large-company version with baroque OO/Java appendages hanging off of everything. Those flourishes make it feel safer and more reassuring, I guess. The math PhD one seemed possibly unfair. It looked more like something that would come from a CS PhD who did his thesis in PL. It's hard to judge what the right solution would look like. You could go many careers without ever having a real reason to write that function outside of an interview. Fibonacci numbers occasionally come about as a by-product of doing something interesting and useful; in cases where they would be interesting in and of themselves, you would probably be using a library or language, like Mathematica, that would have that built-in.
- prateekj 13y agoAlthough the large-company version looks overwhelming to an onlooker, it actually starts from a simple version and then keeps growing as more bugs and compatibility issues are reported. Hilarious though!
- mtdewcmu 13y agoPossibly. OO theory and Java (I don't really distinguish the two) actively encourage creating lots of classes to do simple things. I think a lot of people would look at that style and nod approvingly at the use of design patterns and correct use of OO idioms. They wouldn't see much wrong with it. OO theory also promotes good, commonsense ideas, like limiting the number of classes and the limiting the complexity of the interactions among them. But they contradict themselves, because lots of classes and complex designs are the inevitable consequence of the style they preach. Objects can be considered a bad idea on their face, because they are made up of code wrapped tightly around state variables that are supposed to be secret and hidden. The functional style preaches the exact opposite: functions should not have side effects; all their state is either passed-in or returned. The more state your program keeps, and the greater the number of types of transitions that are possible, the greater the number of ways that the overall state can become inconsistent and cause an error. The way to keep the problem in check is to try to make state and state transitions simple and clear. I'm not a functional absolutist -- I don't use functional languages very often, and I see nothing wrong with doing simple things in the most natural style and language -- but I think the point is valid about how to deal with state.
- xux 13y ago"//good enough for the demo, lol" Killed it. This is hilarious.
- prateekj 13y agoTotally! The large company version is hilarious too.
- jfasi 13y agoDon't forget the tests of each. The startup's tests are all commented out because they failed at some point or another, the large company's tests are five times as long as the actual code they test, and all other categories consist of the stubs provided by the IDE.
- Buge 13y agoThe math PH.D takes a double parameter for b in exponentiate, but the way it functions actually only works for ints.
- debal 13y agoWhy is this wall of text an image? It's not even an svg with text. F for accessibility.
- oakwhiz 13y agoThe Math PhD one reminds me of the sorts of symbolic algebra systems that you find in Haskell and Scala.