5 ms·
Java may be verbose, but who cares?
- bdavisx 9y agoI'd be interested to see a Kotlin <-> Java side-by-side in the same instance. I don't know if the savings would be as dramatic, but it's a lot easier for devs (especially typical "enterprise" devs) to learn Kotlin.
- hex13 9y ago> IDEs generate 90% of my Java code; It's not generating code that is costly, but reading it. Understanding 100 lines of code is usually easier than understanding 1000 lines of code, understanding 1000 lines of code is usually easier than understanding 10000 lines of code etc. So generally it pays of to keep codebase small and simple.
- gozur88 9y ago>It's not generating code that is costly, but reading it. Understanding 100 lines of code is usually easier than understanding 1000 lines of code, understanding 1000 lines of code is usually easier than understanding 10000 lines of code etc. That's not at all true. The costly part is the complexity. You could spend half a day puzzling over ten lines of cleverly written Lisp and just breeze through 100 lines of Java that do the same thing.
- hex13 9y agoYeah, this is also true. But "it depends" anyway. BTW author of article mentions also incidental complexity of Java classes. It's worth consider too and maybe it's more accurate picture of problems with Java (and many other languages, it's more like poor design and "cult of complexity" than technology problems). There are too many abstractions, classes, interfaces, inheritance, needless design patterns... it kills productivity and maintainability and ability to understand such codebases.
- watwut 9y agoOnly god and author knows what exactly was complex about those classes. I would guess that closure have good support for csv parsing, json integration, probably easier to read files? Or he used libraries in closure? Or maybe he used apache like every sane java project and something else was complicated? If 90% of that java code was generated, then what exactly were they doing? Also, there is such a thing as too much abstraction, but there is also such a thing as too little abstraction and refusal to use design pattern where it fits, because "it would be too complicated" alias someone was scared and lazy to learn. Neither is good. The projects I have seen that refused these "advanced" techniques all ended like hard to maintain and makes sense of mess of special exceptions to special situations - hard to reason about code. Design patterns are not hard and abstract thinking is as useful as good memory. Refusal to learn either is not mark of good developer.
- stouset 9y agoIf 90% of that code was generated, that's absolutely horrifying too. Code is read ten times more often than it's written. And you're forcing every poor fool who has to come in and maintain that code base to understand how five classes interoperate with and delegate responsibility to one-another and gloss over reams of unnecessary boilerplate (that under careful inspection might not actually be boilerplate, but have a subtle change).
- watwut 9y agoI never generated 90% of my java code and I code in java for years. That is why I am asking - it is suspicious. Maybe, maybe if all you do is parse one complex xml from schema and decided to go jaxb way. Then again, such generated code tend to be tucked somewhere in the ../generated/ and then linked to class path - it is clearly separate from the rest and you dont review it. Basically, you read stuff it is generated from, and you dont read generated part unless you suspect bug in generator. The other occasionally generated stuff is syntactic sugar - hashCode, equals or delegate methods. That is quick to read once you get used to how it looks. More importantly, if that sort of thing is 90% of the code, then there is something wrong.
- stouset 9y agoYou're comparing 10 lines of "clever" Lisp to 100 lines of (presumably boring) Java. In reality, it's more likely that those 100 lines of boring Java are easily written in 10 lines of just as boring Lisp, the only difference being the removal of 90 lines of boilerplate getters and setters, iteration logic, exception declarations, class definitions and instantiation, and so on. You can explain to someone (or learn on your own) "fancy" functional constructs like map, fold, and select in about ten minutes. And then they can be part of your vocabulary for an entire career. It is absolutely unfathomable to me that this is not a complete no-brainer. Imagine a novelist who replaced every instance of ten common English words with their literal dictionary definition every time they came up in a book. That's the level of incredulity I personally experience every time I see someone write the same implementation of `map` for the tenth time in a single source file.
- gozur88 9y ago>In reality, it's more likely that those 100 lines of boring Java are easily written in 10 lines of just as boring Lisp, the only difference being the removal of 90 lines of boilerplate getters and setters, iteration logic, exception declarations, class definitions and instantiation, and so on. I hear this sort of thing from Lisp advocates all the time, but have never seen it in practice. Understandable Lisp isn't that compact.
- lispm 9y agoThe idea is that special constructs and a special machine in the problem domain will be used to write and execute dense code. This then tends to be VERY understandable in the domain, but brings the developer away from the low-level execution machine. Thus it is more understandable and less understandable, both at the same time, but on different levels. Much more understandable for the domain-level programmer. Much less understandable for the low-level execution-level programmer.
- stouset 9y agoI'm guessing you easily have 100x or more experience with Java than you do Lisp. Do you suspect that this might have something to do with it? Lisp has a very different syntax from C-style languages, and this seems to trip people up much much more than the functional components of it. Not being familiar with the idioms of another language doesn't mean those idioms are hard. It just means you aren't familiar with them.
- skybrian 9y agoWhere is the source code being compared? It's hard to say whether this is a fair comparison without seeing it.
- draw_down 9y agoRemember: you read code a lot more than you write it.
- deleted 9y ago[deleted]
- NTDF9 9y agoAm I the only one who likes verbosity while reading code? When I stumble upon a codebase that looks like the following: def unzip(tuples): if tuples: return [tuple(t[i] for t in tuples) for i, _ in enumerate(tuples[0])] <-------------------------WTF IS THIS LINE DOING???? else: return [] It takes too much mental energy if the code is littered with the WTF-like statements above.
- danielvf 9y agoYeah, that's horribly ugly. But that is because list manipulation was hacked onto the Python language. The fault is more Python's than anything else. In other languages that same idea could be fairly clearly expressed.
- Doxin 9y ago> that is because list manipulation was hacked onto the Python language. No. It's because whoever wrote that doesn't understand what list comprehensions are for.
- dragonwriter 9y agoI don't think verbosity helps that; I means, to me that's clear, idiomatic Python code except that “for i, _ in enumerate(tuples[0])” would more clearly state it's intent as “for i in range(len(tuples[0]))” [0] which, unless I miscounted, is actually one character shorter. I'd also break the list (outer) comprehension into two lines for readability, but that doesn't really affect verbosity. [0] replace range with xrange in Python 2.x to avoid allocating an unnecessary intermediate list.
- NTDF9 9y agoYou're not getting the point. In a large codebase, I want to be able to skim code. I don't want to parse idiomatic code. I literally want to be able to read it like a novel and get down to the lines that I'm interested in. Granted Java is not the best. But Python-like languages (with no static typing and "tricky idiomatisms") make it so hard to parse a 10,000 lines100,000files.
- abc_lisper 9y agoThis jibes with my experience - After doing 10 years of Java, a year with Clojure seems like heaven. I actually have brain space now to think about the problem than the mechanical details of the solution. In fact btw terseness, simplicity and immutability I stopped caring about the language for the most part and am able to concentrate on the problem at hand.
- peterashford 9y agoI think this is a reflection of the fact that FP is better at straight data processing than OOP (which, conversely is better for simulation). Using Java8, you could likely have done something similar to the Clojure solution using Streams. Using objects to model the data is a choice, not a requirement.