The Reason For Java's Staying Power: It's Easy To Read
jfruh writes: Java made its public debut twenty years ago today, and despite a sometimes bumpy history that features its parent company being absorbed by Oracle, it's still widely used. Mark Reinhold, chief architect for the Oracle's Java platform group, offers one explanation for its continuing popularity: it's easy for humans to understand it at a glance. "It is pretty easy to read Java code and figure out what it means. There aren't a lot of obscure gotchas in the language ... Most of the cost of maintaining any body of code over time is in maintenance, not in initial creation."
Solving problems can be done quite quickly with Java as a lot of the frameworks/tooling for solving common problems have already been built. Including:
- Distributed Configuration
- MapReduce
- Spark
- Large portion of the NS math libraries have been ported (think of all the Fortran libraries)
- Networking
- Embedded devices
- First-class support for many app hosts
- Concurrency libraries (including standard)
- World-class web application serving (Jersey, DropWizard, etc.)
These are things that are proven and enterprise ready with large communities supporting them.
I am tired of hearing languages are "easy to read". If a piece of code is well written and identifiers are well named anyone who is accustomed to the syntax or syntax that is SIMILAR will be able to read it. The point is that C style syntax have been what the majority of programmers have been used to so it has become a staple. However, if it was down to pure logic and an understanding of the English language Ada, Pascal, and (Visual) Basic would be the most readable.. and who here thinks that -- we've all been brainwashed by CS101.
Not as easy to read as Python though
And that's a good thing.
Yes, while verbose, i find Java easy to read - and i think its verbosity helps in this (after a while you know what/how to read Java code, and your reading becomes "smooth").
Antisthenes: "Wisdom begins by examining the words/names." - excuse my English, i am (slightly...) better with my Greek!
The popularity of Java is not because of it's "easy to read" nature, but because it is fairly forgiving for programmers that don't really know what they are really doing.
I programmed in Java for 15+ years and it is not the best language now (more of a legacy language) that tends to get riddled with boilerplate code which requires code generation and produces an outcome that is not as clear and concise as it could be.
It is however a forgiving language where if you don't understand memory management -- it is not a big problem. For example I remember a system written by programmers in another language that was riddled with memory leaks because of cylindrical references. The code was literally translated into java and all the problems disappeared. The programmers on that project just figured that the language that they programmed in was the problem -- but in reality java saved them from their inability to understand the basics of what they were doing.
Maybe it's improved with the new versions of C++, but I coded in C++ for many years before transitioning to iOS development, and I never wrote my own templated classes, mainly because I would never be able to understand what any kind of semi-complicated template would do. So, I just used STL and Boost, and only with the templates I was comfortable with.
A huge standard library that has been stable for 20 years (backward compatible as much as humanly possible) has a lot to do with it as well.
In other languages, I feel like I have to re-learn basic elements every decade to "how it's done now"...
Really? Having a pile of needless verbosity makes it more difficult to read in the long run simply because one needs to figure out what exactly is being done even for the most trivial client application. To do even just simple fetch of some resource over HTTP requires rather laborious conversion routine from a stream to a string type before most common JSON libraries would be able to use it. In any more modern language it can simply be used right away rather than having to figure out which JSON libraries to use or why toString() doesn't seem to work on InputStream (I mean intuitively shouldn't toString() on a stream get back a string?).
Granted the Apache commons can make this a bit easier, I find it extremely annoying to have to cast things into the right object type just to access some simple JSON object, instead of just doing something like result['collections']['links'][0] which is much easier to understand. Dumbing things down does not necessary make better programmers.
Please direct all bug reports to
Java's readability is part of its staying power, which is part of the reason that Java is able to overcome its severe age and lack of features. As a software developer, I spend 90% of my time reading other peoples' code and 10% of the time writing my own. I also need to read code that I read over 6 months go, which I largely won't remember writing.
This is a major part of the reason why languages such as Scala haven't taken off. Scala, Perl, and other similar languages are largely "write-only" in my opinion. Newer languages must be designed primarily for readability.
Just like IE 6 it is so engrained into our business processes that it won't ever leave. At least here in the office which greatly angers web developers greatly, but operations doesn't care.
Java is around for no technical reasons. It is here because it is already here. Why change for the sake of change and .NET wasn't worth the effort in 2005 as IIS was a steamy piece of poo back then. So now no one wants to take the risk and $$$$ for something that already works. Yes we stayed on XP too until 2014 but my employer is not alone.
My post melts the brains on hipsters lucky enough to be working at .COMs in SV or still in school tinkering. Your souls havent been left yet for the real world yet
http://saveie6.com/
That's what I thought.
It was purely serendipity, and now the install base is so large you can;t get rid of it.
I am very small, utmostly microscopic.
I could sure do without the { }.
But you'd think the fact that it works the same on a Mac, Linux, Android or Windows would have something to do with its popularity as well, no?
Almost all programming languages are easy to read. This is not the reason of Java's success at all. A complicate algorithm in first place will not make a program easy to read whatever the language you pick to program it. If you find Java easy to read, it is only because you cope with trivial algorithms.
Achille Talon
Hop!
final T up = (T) throwable;
throw up;
I'll see your senator, and I'll raise you two judges.
I am sorry but can I just say:
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
input = bufferedReader.readLine();
number = Integer.parseInt(input);
In Pascal (1960's) you could just do something like:
integer number;
read(number);
See if the compiler knows number is an integer do I really have to tell it to create a stream and parse it as an int? seriously?
Java is an abomination.
Well if there's one thing programmers hate more than unreadable code, it's typing shit, and COBOL was an awful lot of typing shit. And for some reason, even though the individual lines were easy enough to read, something about the language made it very difficult to follow overall. Since the language was so overly verbose, functions usually ended up being pretty long, and it was very easy to get lost in them, in any COBOL code I was exposed to anyway. I'm sure there was probably some clean, well written COBOL code in the industry, but I never got a look at it.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
Libraries tools and 3rd party support in the form of books, articles developer know how, WORA, etc. It's very very fast no matter what people around in the 90s may still think, it has an unbelievable number of extremely high quality, battle proven open source libraries for highly specialized and useful functions and of course the tools supporting it like IDEs are out this world good. So I can do anything I want, I can run in most anywhere, I have vast libraries at my disposal and best in class documentation from multiple independent sources.
Pretty much sums it up.
I use other languages, sure, but I get sick when I see people (evangelists, consultants) ushing some new "better" language because frankly they have positioned to make a ton of money off it shuld demand for it sky rocket. It's software engineering's own secret sin- people reinvent a non-broken wheel in order to profit. It happens all the time. There's gold in them thar hills if you can just "create a buzz" and reach enough developers by co-opting enough "thought leaders" to create a "tipping point" in demand for your new "break-through language / platform / way of programming".
James Gosling recently said it best when he said that new important innovations aren't going to come from inventing new computer anguages, they're going to come from the world IoT and how create devs use languages.
Yes, I am posting the AC for a reason. Let the onslaught begin...
Most of the cost of maintaining any body of code over time is in maintenance ...
It little behooves the best of us to comment on the rest of us.
"the cost of maintaining any body of code over time is in maintenance"
No, really? The cost of maintaining is in maintenance? Well, now that's some earth shattering surprise.
Anyway, the intention was probably to say that maintaining is more costly than creating. However, since it says "any body of code" I'll just call it the deepest bullcrap. I've seen and heard lots of people talking out of their behinds over the years dismissing the effort going into creating some really nice algorithms and realizing them in applicable and useful code, simply thinking about the whole process as "coding" which is usually the easiest part. Also, maintenance costs a lot mostly when the coder monkeys hacking the code together were crap in the first place. Just stop paying outrageous amounts of money to idiots who put together unmaintainable code and then leave to another company to do this again and again, and by the time their code needs "maintenance" they're already gone and couldn't care less.
I am putting myself to the fullest possible use, which is all I can think that any conscious entity can ever hope to do.
If your going to put in that hack, you might as well just include lombok into your annotation processing and just put @SneakyThrows everywhere. If only Java had gone with real generics like c#, we wouldn't have had all these erasure hacks.
Serendipity could also mean that it was in the right place, at the right time, and that is why the base of code written in Java become so huge. It solved a problem. And did so better than other solutions at the time. And arguably, still does.
Other solutions may look sexy. And for smaller projects, they probably are.
But long term maintainability is important. Does your project still need to work in ten years? Twenty?
Having a compiler is also probably a major factor to Java success. If I make a typo in my code that breaks something, red flags start appearing on files in the source code tree all over the project for files that no longer will be able to compile. Lots of things that dynamic languages don't discover until runtime (or hopefully unit testing) are immediately discovered by the compiler. In a sense, the compiler is the zeroth step of unit testing before you even run the unit tests. The compiler effectively provides the first most basic set of 'tests' on the codebase.
People who don't understand why Java sticks around also don't comprehend the sheer size of some Java code bases. I would like to see what would happen if a dynamic language were used to write a system that had hundreds of different forms or over a thousand; and maybe thousands of different reports it could produce.
I'm not saying there is anything wrong with other languages. Just that Java does have a place. It is a solution to a real problem.
If there were one perfect programming language, then everyone would already be using it.
I'll see your senator, and I'll raise you two judges.
Yes -- You have to be clever about being clever.
I just had a quick look at it and it looks like C to me. Really ugly.
Why do this:
public class HelloWorld
{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
When you can do this:
Print "Hello World"
What's with all the horrible curly brackets everywhere? What's wrong with endif, next, etc? Bring back BASIC, it what I say!
If I want to write something for myself to use I use Blitz Basic.
At work I've use COBOL quite a bit, and that's nice to read. Full stops are okay. Not as hideous as curly brackets.
I am really sorry to hear about your working conditions, but with todays possibilities as a programmer, why do you even put up with that shit? You are supposed to have a boss to take those battles for you. Where I live they would have no people left if they stuck to their ways like that. Training new employees is expensive, and that is a language your accountists understand. Three months after finishing uni and getting my first job, recruiters started calling me (ooh, experience!). Maybe you are stuck in the only place in rural Kansas that employs programmers, but we leave in a global economy with remote working possibilities, so no excuses.
It is, just as long what you are doing is similar to what everyone else is doing. Sometimes, you may need to break the mold. But that is actually very rare. And you need decades of experience to really know when you really should break the mold.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
But a more convoluted, heavy weight Scheme? If we adopted Lisp 20 years ago the world would be a better place.
#1. Java is nothing like Scheme, it's a fundamentally different language.
#2. Scheme is a Lisp, so if Java were a heavy weight one, we would have a widely adopted Lisp.
#3. Why would having Lisp being a widely adopted "make the world a better place"? Does it donate to charity?
And frankly, I personally consider the Lisps to be heavily overrated to begin with.
"Set a man a fire, he'll be warm for the rest of the night. Set a man afire, he'll be warm for the rest of his life."
Like most people I thought pythons enforced white space and avoidance of braces and elimination of semicolons was constricting. Then I realized how easy it was to read other people programs. Python used to be even simpler to read when it only provided one idioms for one job (avoiding a dozen way to do the same thing resulting in dialects). Now it's adding new idioms and genres so it's a little more opaque. But it's still easier to read than any language with comparable expressiveness. (Lua is refreshing for similar reasons).
Some drink at the fountain of knowledge. Others just gargle.
serendipity
serndipd/
noun
the occurrence and development of events by chance in a happy or beneficial way.
I am very small, utmostly microscopic.
Ah yes, the old COBOL justification. It was BS then and it is BS now when applied to Java. The hacks at Oracle would have been better off sticking to "write once, run anywhere."
You do not know what you are talking about.
Java has not stagnated. It is one of the top programming languages. You would know this if you had looked at the article. You might not like Java, and that is fine. But at least get your facts right.
Write once run anywhere is also true for large projects. You could move a major web server project between OSes without even recompiling it. I have personally moved installed my employer's web application on a different OS than it is officially deployed on just for amusement. Because it could be done. I also tried it on a Raspberry Pi (prior to the 2) and it 'ran' (in the sense of how a snail can 'run'). But it actually worked and connected to a database server running on a big box running a different OS.
GC on Android is not a problem. Billions of devices are in daily use. What kind of 'problem' are you talking about? Something hypothetical?
Java at Google may be a fork, but it can't be any worse the the multiple dialects of other languages and compilers like C / C++ or Python 2 / 3 and other examples.
Java is not perfect for every problem. If there were a perfect programming language, everyone would already be using it. But at least get your facts right. Java is going to be around for a very long time. The language has just gotten some major new features in the last couple releases. More major improvements are on the horizon. The sheer size of Java codebases alone is proof enough that it will be around for a long time.
I'll see your senator, and I'll raise you two judges.
I'd agree with the ecosystem being a huge factor in Java's success.
More than that, it is a relatively closed ecosystem. Tools like JNI are available, but in practice few projects seem to use them. Mostly, either you're working in JVM world or you're working somewhere else. That's a lot of momentum to overcome for any long-standing project or development team to move to another language, tool chain, standard library, and so on.
I also think the summary's claim that Java is easy for humans to understand at a glance because of its simplicity is a mischaracterisation. Java is a relatively verbose, inexpressive language, so actually it can take quite a long time to figure out how any given piece of code works. What Java does offer is that an average developer can reliably figure out how any given piece of code works, even if it takes a while. For long-running, large-scale projects that is a valuable attribute for a programming language.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
Yes, Java is pretty easy to read. It contains all the standard control structures, and not a lot more. Aside from inheritance (which, by now, pretty much all developers understand), there isn't a lot of hidden functionality: See the code, understand what it does.
This is one reason that I object to the introduction of Lambda's in Java 8. Lambdas belong in functional languages, where they make sense in the context of the language. Java is not functional, so lambdas break the paradigm. Moreover, they are unfamiliar to most developers, and they are cryptic in a way that hides functionality.
Enjoy life! This is not a dress rehearsal.
I think you are not understanding the insight behind the maintenance remark.
Tools that work on the Java source code can be exact in what they do. No ambiguity exists. A method call foo() is understood by the compiler to be exactly one certain method. It doesn't matter how many other foo() declarations there are, or that there may also be variables and classes named 'foo'. The tooling makes maintenance tasks like refactoring very easy.
If I am reading some dynamic languages, I might have to do some searching or research to determine exactly what is being called by this foo() function call. Java tools can tell you exactly, prior to compile time, what method is being called -- and that it is declared, and where it is. The tooling doesn't get confused no matter how badly the code might be structured.
Maintenance becomes a big factor on a huge code base. The cost of maintenance can truly dwarf the cost of initial development.
I'll see your senator, and I'll raise you two judges.
...says its maintainer. Story at 11. This is bollox.
obligatory webcomic to explain difference between hand holding (implicit) and hand forcing(explicit)
This is an article about why Java has decent staying power, not about why it is the perfect language, nor most readable language possible. The article does not say people will be using Java in 1,0000 years. But Java became popular and continues to have strong staying power for an old language. There are reasons for that, even if it isn't your cup of tea.
Democracy Now! - your daily, uncensored, corporate-free
Java was the first language on the scene that came with a top-to-bottom marketing rollout. They had certification, training, professional tutorials and classes, sponsored competitions, commercials and corporate branding, full page ads in trade magazines, and a one-size-fits-all modular system of components to mix and match and fit every need, and you could even become certified as a java evangelist - that used to be a real job at some corporations.
Once they got solid buy-in, well, companies are loathe to change unless there's either a pain point or a generational technology gap, and sometimes not even for the latter (see batch processing mainframes running cobol and RPG programs).
So that's what it is. If anything, as the language matures many people actually want to get away from readability; they want annotations and dependency injections controlled by some non-centralized mechanism, such that you must either rely on everyone else who worked on the product getting things 'right' and just magically working without your understanding of other processes (a theoretical goal of good OO development), or more often, you must understand all the code running at all times. Try doing a manual analysis of a good sized project that relies heavily on Spring, or worse, an OSGi project.
Projects using those features are not self-documenting code. Tracing execution or data flow is extremely difficult. All I can say is at least it's not Ruby, Objective C, or Smalltalk.
So, no, it's not readability. There's a good subset of programmers who are strongly against readability. It's money, plain and simple. It's a corporate investment, and that's all there really is to it.
What makes "Java" or anything object oriented difficult to read is that objects tend to produce more spaghetti code and have a ton of easily overlooked side effects. Debugging can be a nightmare. I see more "pitch till you win" code maintainers.... so much so, that some consider it normal to just keep trying stuff until it "works". I'm not saying you can't create "good" object oriented code.... I just haven't seen any yet.
It's difficult to be "clever" in Java
To the contrary, Java's lack of expressiveness resulted in people writing tons of external XML files, code generators, DI frameworks, and build tools to glue the whole mess together. Instead of small, judicious bits of cleverness in the main language/runtime, it's been pushed to very clever tools on the periphery that come with relatively large learning curves. That's not really a win from the readability standpoint.
-1, Too Many Layers Of Abstraction
Honestly,I have seen many, and this one about been readable must be the more strange argument I have seen lately.
It is pretty easy to read Java code and figure out what it means.
Many who deal with the "enterprise" software would simply laugh at the statement.
But hey, the same argument was often made about the BASIC. And I always said that Java and BASIC users are very similar.
All hope abandon ye who enter here.
It is not difficult to be "clever" at all. Look at various "bean" frameworks. Use their object marshaling features. Throw in some of their aspect-oriented programming features.
Now you usually have a bloated, incomprehensible mess. Sure you can easily read any couple of lines of code in isolation. But the system as a whole is a huge pile of gratuitous redundant layers of abstraction and confusing action-at-a-distance creepiness.
True, we tried to build in obsolescence with two digit dates to force the banks to upgrade by 2000, and they rather liked forcing COBOL programmers back in at a premium to fix the issue. Even the screams of a coming apocalypse couldn't get rid of it.
The last two major releases (7 and 8) have been awful. I think the only reason why Java still gets so much attention is because there's a lot of time and money already invested on Java applications. As a Java developer and FOSS advocate myself, I have to confess that I'm closely following the results of Microsoft flirting with the open source community. I never thought I would say such thing, though.
Open Source Network Inventory for the masses! Kuwaiba
Nowadays to be part of a Java project you have to speak not only Java, but all the vertical and horizontal layers that are the frameworks. Spring, Struts, Hibernate, Spark, Tapestry ..........
Slashdot, fix the reply notifications... You won't get away with it...
What amuses me is that many people rave on about how great C# is, while denouncing Java. Yet other than a few minor syntax tweaks (like the way you write getters/setters and the "?" indicator for nullable attributes), they are virtually identical right down to the API.
They're both very easy to read and code with, and if you know the packages/libraries of one you'll find the equivalent in the other in short order, with very, very few differences in the details of the APIs.
Yet C# is "great" and Java "sucks".
Go figure.
I do not fail; I succeed at finding out what does not work.
I've watched experienced and skillful Java programmers struggle for days "wiring up the beans" and then spending the rest of the project trying to get it to work.
Any one line of Java is readable, but when you pile libraries on top of jars on top of frameworks it degrades into a mess. And lets not talk about Exceptions.
Yeah... it's a pretty genius tautology.
In related news, the major cost of creating new software is in the creation, and the major cost in deploying new software is in deployment.
Python's no fun to work in at all. But it's the right choice for business coding for precisely this reason.
Boring is good. Rigid is good. The next person who works on your code is not going to understand anything you did. He/she will need to pore over your code and figure it out. The easier you make that, the more you can accomplish and walk away from -- leaving a trail of success in your path. Otherwise, you're either bound to the code and swamped with old projects, or trivial issues you missed never get fixed, leaving a trail of unhappy clients/users behind you.
You can look very busy having to deal with all the overhead and boilerplate to get trivial stuff done in Java. Programmers will feel needed and busy, while the superiors can avoid being bombarded by tasks, because everything takes ages.
Another good reason is that non-programmers have very weird metrics for productivity. I remember studies being linked here on /. that measured a programmers productivity by the amount of lines comitted to github projects. This of course makes Java an inherently more productive language than languages where you can simply get shit done.
Java lacks high-level control structures written in simple, understandable ways. This means that java programs are longer than they need to be. YES, you can look at three lines of java code and know just what they do. CONGRATULATIONS. But when the java program is 300+ lines long and only needed to be 30 in R, for example, which one will a person with any competence in a language understand faster?
C# (an MS trap language you shouldn't use) is better than java. It has better syntax and makes things cleaner and shorter.
Java is getting praise here because of its success. If it were put out today, it would be ignored. The fact that we would not have the VM-based code world we have without java is immaterial to an evaluation of the language. We should not lie to ourselves. Java programs are too long. This makes them hard to read and hard to pass on to other programmers. Period.
Actually, it's easy to read because it is verbose and inexpressive as you put it. Generally speaking, the more information you pack into a sequence of characters, the harder it is to understand. There are also relatively few syntactic constructions to get your head around and tokens are not usually overloaded with different meanings. It doesn't take long to learn the whole language, which means that even a newbie has a good chance of reading a piece of code without coming across something they haven't seen before.
All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
I guess we're not talking about working with Java Struts. When you do, turn on mysql logging, and then tail -f mysqld.log, you'll see garbage like this: select column_623 from table_943 where column_142='xxx'; ---- is that readable to you? Is that supposed to improve readability by abstracting so far away from the database that no one can understand what is going. I basically have to grep for values inserted or updated or selected from tables in order to figure out what table stuff is being written to. It's not ugly, its an abomination. Who ever thought up the idea doesnt know what they are doing. Easy to read..... YEAH RIGHT -- its a joke. It takes 5 times longer to reverse engineer this spaghetti mess than any other languages. Straight Java code is easy to read, if you don't intrude abstraction layers on top of the language, like Struts.
Won't be needed. They all own 14 inch dishes.
Their children watch MTV middle east and will behave in ways so gay that they would make emo kids blush. Two generations and it's all over. Right about the same time their oil money will end.
John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
I wonder if with Java 8 and the ability to do lambdas and more complex functional programming techniques will hurt Java in the long run. I do Java as my day job, and have only recently finally been able to do Java 8 at work in the past few months. I am a big proponent of functional programming practices, and we do a lot of Javascript front end.
Pre-Java 8 I was always concerned that the language would decay since it is syntatically decades old, and become the COBOL for the new millenium. I know I can jump into whatever the flavor of the month is, but I have always been happy doing this. Of course, flavor of them month became flavor of the year, then flavor of the decade... and now I have been doing Java for over 15 years. It sill might become the next COBOL, but it is flexible enough that you can do pretty much any business programming you ever need, while being interesting enough to bring in new programmers out of school.
But my work has a small number of highly experienced developers. If I was still working at a big soulless corporation with dozens of bottom tier developers mixed in with the seasoned pros, I wonder if this would result in the code being unreadable? I have seen some terrible code in java 4 and 5, I can only imagine the horrors an idiot could wreak with lambdas. Granted, I am sure most of them are still doing java 6 compatible code, since only small companies can afford to change momentum and upgrade.
I'm a good cook. I'm a fantastic eater. - Steven Brust
Totally agree. The expressive languages that let you do a lot with relatively few lines often count on implicit behaviours that are not at all obvious unless you are familiar with them. It's a drag on coming into someone else's codebase and understanding what's going on. "Oh, I see, you're counting on this to fail in *this* certain way such that *that* happens."
I did a very large COBOL port a few years ago, and I must say it was very well written. We were increddibly lucky that the developers were maintaining the project for decades and wrote their code very consistently (though they significantly lacked in comments) and were quite comfortable with helping learn the in-s and outs of the system. The actual business logic of the product was factors more difficult to grasp than any simple technical issues with COBOL itself.
Much in the same veign as C, COBOL's whole memory model is like a big block of crap, being able to remap memory blocks willy nilly over existing ones, sending memory blocks across programs, etc.. makes tracing memory much more difficult unless you had some sort good static analysis tools for tracing (which we didn't). The processing code was straight forward but obviously very simple, which meant that there was a lot of boiler plate (but completely drop dead simple since the same code was used consistently throughout the project).
Bye!
You're mixing verbosity with understandability. Yeap, of course repeat the type of the object twice, the ugly diamond operators, use else if instead of elif, etc, produces verbosity, but this is not related to be easy or not to understand.
COBOL was relatively readable when it was invented, compared to the other languages of the time. The purpose was to be so readable that even managers could understand it
Well written COBOL is understandable. The biggest complaint is that it's overly verbose (other problems like "no re-entrant functions" aren't problems anymore). In many ways Java seems like a modern version of COBOL.
"First they came for the slanderers and i said nothing."
Generally speaking, the more information you pack into a sequence of characters, the harder it is to understand.
By that argument, doesn't any powerful abstraction make code harder to understand? Similarly, doesn't any verbose style make code easier to understand, even if the boilerplate contributes no additional meaning? Sorry, but I can't agree with this sort of reasoning at all. If it was that simple, we'd still be writing large software systems in assembly language and no-one would use any sort of libraries or modular design.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
throw up;
That one never gets old. My favorite is:
public void loveYou(long time);
You can add an extra pun by adding a comment // this function takes a long time.
I'm a good cook. I'm a fantastic eater. - Steven Brust
Well the last few places are run the same. If you are not an IT company the MBAs will fight tooth and nail not to touch what works as IT employees are plumbers. A cost center where data moves through pipes. Just reality and consider myself happy to have a job. Some don't or work minimum wage trapped.
One client uses a pre sql database called pic from 1972. It won't ever be upgraded because it works and is too important to change
Java is here because that's what's in house and work's
http://saveie6.com/
Yeap, of course repeat the type of the object twice, the ugly diamond operators, use else if instead of elif, etc, produces verbosity, but this is not related to be easy or not to understand.
The thing is, I think it is related to how easy something is to understand.
If I can express an algorithm as a single function of 10 lines then, other things being equal, that will be easier to understand than distributing the same algorithm across 5 functions each of 20 lines. You can see the whole thing at once, instead of jumping around within or between files. You don't have overheads of passing around and returning values.
Similarly, if I can express a simple bit of logic as a clean one-liner, while a verbose style requires 6 lines of manual loop/conditional logic and maybe a function wrapped around it, then I'm thinking about what that logic is doing and it how it fits in with the other logic around it while you're still worrying about loop counters.
Here's a version of finding all the items less than 10 in a list, written in Haskell, a relatively powerful language:
Here's a slightly more verbose version, written in Python, also a language known for being clean and expressive:
And in contrast, here is the best Stack Overflow has to offer about implementing this sort of requirement in Java.
Spoiler: There are basically three kinds of replies. Some write out entire functions to implement the filter using a manual loop. Some use a third party library to do a more clumsy variation of the Python and Haskell examples above. And a few recent ones use Java 8 to do a slightly less clumsy variation of the Python and Haskell examples above. The clear trend is to try to get away from classical, verbose Java to something more powerful and expressive. Like Scala, according to the first comment on the original question...
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
...if you have vision impairment and you're using some sort of screen reader, the python whitespace syntax rules are completely lost on the screen reader software.
When the object oriented craze took off in 1990s, we were joking, next thing you know you would have OO-COBOL. And next thing we knew we had OO-COBOL.
All of us know the staying power and entrenchment of that language designed specifically for readability.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
I strongly agree with the parent. My favorite language implements this in a similar way to the parent's favorite:
:-) get my thoughts into code. I used to enjoy coding in Lisp for the same reason (still would, if I could use Lisp at work these days). I enjoy coding in Java also, but the difference is noticeable.
my @items = (1, 15, 27, 3, 54);
my @result = grep { $_ > 10 } @items;
I appreciate coding in a language that allows me to quickly and understandably (yes, Perl can be understandable... or not
In a band? Use WheresTheGig for free.
I think that's one thing that makes Java both desired and despised. There are a lot of "clever" code chunks in other languages that are short AND easier to read. Even if it's not as easy to read, it's much nicer to decipher 4 lines of "clever" code than 100 lines of enterprise code spread over multiple files. To find out what a function does, you sometimes have to dig down through several layers of classes and compare across files. It's straightforward if you have the time to deal with it and you don't have to know too much about complicated theories to do it.
Totally disagree. If I see
I know exactly what it does. Anyone who has done any programming in any language can guess what it does. Its simple, easy to read, and if you want can be pulled into a function. Your haskell and Python implementations are unreadable and requires the user to think about each line. They're inferior to straight forward programming by orders of magnitude and should never be used.
I still have more fans than freaks. WTF is wrong with you people?
With a few exceptions such as assembly if your code is not readable you are doing it wrong. Code needs to be maintainable. The maintenance costs and lifespan of code often far exceed development cost and time span. If you are not writing clear code you are writing crappy code.
putting the 'B' in LGBTQ+
Now you can basically officially do your own pre-compilation (check -processor option on javac) if you so wish.
Tons of XML weren't really caused by Java's problems (do you actually remember what was put in them??), more of a fashion thing, now mostly replaced with annotations / cleverly chosen defaults.
Most stuff you were doing with monstrous (my personal opinion) frameworks like Spring are part of the standard Java for quite a while (since 2009).
All I had to do was glance at the haskell to know what it was doing. The python was a liittle hinky, but I got it easily enough.
It really depends on how much experience you have with rich languages. If all you ever talk is C/Pascal/Fortran anything else will be harder to read.
This goes for natural languages too, as well as cultural references. It's Joe Bauers' plight.
The simple fact is that there are times to talk really slow with small words for a large audiences and times to use expressiveness to get thing done fast in a professionally erudite environment. Often, complex software design is a case of the latter, not the former. Management would like it to be the former, because H1B, of course, but that is a short sighted strategy destined to leave the company in the dirt.
Someone had to do it.
There's a difference between abstracting complexity away; and relying on a cute, obscure, not-quite-feature of a syntax in your program because it saves a few characters.
When I open a TCP stream to another system, I don't muck around with any details of the features negotiation, speed... I just do it. When I write to the stream, it's a one-line operation, and the system takes care of retransmission for me, and when I read, the system takes care of packet ordering for me. I don't even need to know what a packet is. That's good abstraction.
or
var doubled = numbers.map(function(v){
return v*2;
});
See, I can read that.
The bad abstraction is the one that still exposes little-known things to the programmer.
@error_or_die(50)
function connect(**options):
or
if(~q.indexOf("=")){
Like, what the hell is going on here?
Wonder what the public key field is for?
Are you saying that
256 * 2 = 512
is harder to understand than
two hundred fifty six multiplied by two is five hundred twelve
Most of those are libraries. Thus they've been solved with any language with similar libraries. Ie, networking - it's sort of there in Java, however there's no control over the networking and how it's implemented and it reflects a small subset of what you may want networking to do (it's good at web oriented stuff basically). Meanwhile just about any language that allows using POSIX libraries can do your basic networking that Java can do. For embedded devices, Java is still very high level, it does not give you register access to the machines for example, so where it is used most typically in embedded systems is as an application layer with the layers underneath written in other languages.
I agree a lot has been added to solve problems. Which means I meet a lot of Java programmers who don't really program, they just tie together pieces of existing code.
No, it comes down to explicitness is always better than explicitness. There is no case in which yours is better, or even usable code.
I still have more fans than freaks. WTF is wrong with you people?
For C users:
// makes code faster // makes data use less memory
#define while if
#define struct union
I'll see your senator, and I'll raise you two judges.
I've never used any of the three languages in discussion here, and would barely count myself as a programmer at all, and upon initial reading of each of these routines this was my interpretation:
Java (I assume yours is): For every integer (call it "i") in the set "items", if "i" is less than ten, do whatever the 'add' function of the 'results' object does to it. (No idea what that function is, but my first guess would be to do the math of "results" + "i". Upon reflection after seeing the other languages' versions of this routine, I get now that it means "put 'i' as a member into the set 'results', or more loosely, "add 'i' to the set 'results'".)
Haskell: The set "items" contains members 1, 15, 27, 3, and 54. The set "results" contains every member of that set ("items") that passes the filter of being less than 10. (This is the clearest to me, and the one that shed light on the purpose of the other two).
Python: The set "items" contains members 1, 15, 27, 3, and 54. The set "results"... uhh.... assuming this does the same thing as the Haskell function, I'd guess it means that "results" contains every "item", where "item" is any item in the set of items, but only if "item" is less than ten; a roundabout way of saying, in a more Java-like fashion, "for every item (call it 'item') in the set 'items', if 'item' is less than ten [then that is part of what the set 'results' equals]".
-Forrest Cameranesi, Geek of all Trades
"I am Sam. Sam I am. I do not like trolls, flames, or spam."
There's a sweet spot for conciseness versus verbosity. If something gets overly concise, then what you say is true. However, there's a such thing as too verbose as well, where it's so indirect that it becomes difficult to read.
Not to mention, Java has a lot of things that are absent from other languages due to being relatively pointless or having better alternatives like public vs private things. On top of that, the fact that Java best practices dictate using getters and setters whenever possible mean lots of additional code. What's easier to read, "object.x = 5" or "object.setX(5)" plus the boilerplate function that actually does the setting? Yes, I'm aware that IDEs can take care of this, but when a language has so much copy-and-paste boilerplate code that an IDE can eliminate a huge chunk of it, that doesn't exactly reflect well on the language.
He's probably a COBOL programmer.
Your haskell and Python implementations are unreadable and requires the user to think about each line.
Maybe you personally aren't familiar with higher order functions or comprehensions. However, millions of programmers are, and would read and understand those lines without a second thought.
Using filter in Haskell or a list comprehension in Python is as routine as using your for-loop is in Java, and the associated syntax is similarly familiar to anyone who's ever done a significant amount of programming in those languages.
Moreover, these tools are declarative, which means you can use them in languages that better control side effects for safety, and you can use them in languages that optimise based on that extra knowledge for faster performance, and you will be able to use them in the data parallel languages of tomorrow to make more efficient use of modern processing hardware. In other words, in languages designed to take advantage of them, these styles immediately convey more information than the imperative style required by your for-loop version.
Perhaps it was the filter function that confused you, if you aren't familiar with that particular terminology? If so, I would remind you that you just wrote a code example full of integers and an add function that has nothing to do with calculating the sum of those integers. (At least, I think you did. I notice that you missed out several lines of initialisation and type declarations for those variables, making your example code considerably shorter than it otherwise would have been if you'd actually written a like-for-like equivalent.)
They're inferior to straight forward programming by orders of magnitude and should never be used.
I honestly don't understand how any programmer, whatever their preference of language, can claim that an expression that says filter (<10) items and means choose the items that are less than 10 isn't straightforward. I think you're just trolling here.
As for never being used, you're welcome to stick with yesterday's programming tools if you like. No doubt there will be plenty of need for programmers to maintain legacy systems for a long time to come. But tomorrow's programming tools will let us build bigger, more efficient, safer programs, and we'll be doing it faster and with fewer resources. If you're not familiar with these idioms yet, you might want to consider broadening your knowledge, because before long every 21-year-old kid who learned programming by messing around with JavaScript in their browser is going to be using them.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
There's a difference between abstracting complexity away; and relying on a cute, obscure, not-quite-feature of a syntax in your program because it saves a few characters.
Of course there is, but at no point have I (or anyone else I've seen in this discussion) suggested doing the latter just to make the code shorter. The point is that there are plenty of languages that can say in one clean, readable line of code what takes half an editor window in Java. I gave some typical examples in my reply to another post.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
object.x = 5 isn't overridable in Java, but it is in other languages like Python.
Refactoring is much easier when the language is actually conducive to refactoring. Java isn't conducive to refactoring at all, so as a result you have to always plan for the worst case scenario (e.g. use getters and setters for everything). Contrast to Python, which makes refactoring objects quite easy due to the amount of control you have over every aspect of your object.
It was designed for the mediocre programmer and that is what enterprises hire.
Something I don't hear mentioned a lot is that Java is exceptionally easy to debug. Each statement does so little that it is very easy to step through code in a debugger and pinpoint the place that something has gone wrong.
The problem with object.x=4 is that it not overridable, the therefore interferes with both the encapsulation and the specialization concepts within the OO world.
For starters, as noted, it's strictly a language issue - there's no reason why property-style access cannot be made customizable, and it is in C# (just to pick something that's relatively close to Java).
Furthermore, there's no particular reason why you'd really want object.x=4 to be overridable in general. In a language that is designed well, there's simply no observable difference in that operation (and other treatment of 'x') regardless of whether it's a simple field or a code-backed property. Even C# gets it wrong (can't use properties as 'out' or 'ref' arguments of a function, for example), but other languages do it right. In that case, you always start with a field, and you change it to property accessors if and when you actually need it.
You're awfully confident about your subjective judgments. I don't see anything non-explicit about his code, and it's perfectly usable.
The simple fact is that there are times to talk really slow with small words for a large audiences and times to use expressiveness to get thing done fast in a professionally erudite environment. Often, complex software design is a case of the latter, not the former. Management would like it to be the former, because H1B, of course, but that is a short sighted strategy destined to leave the company in the dirt.
I always believed this, combined with the fact that schools kept churning out zombies that had never touched another language, was the main reason for the popularity of Java. It's an excellent language for teaching OO concepts as it is an exceptionally complete and verbose implementation, but it is an absolutely awful language to use in a business setting. This is why people kept coming up with more and more elaborate ways to work around all of the shortcomings involved in using it for anything more than a school project.
Only very small programs have less time invested in development than maintenance. Most code has at least 10 times more invested in maintenance than the initial development.
There was an idiom the escapes me that one of my professors used to use (this was almost 20 years ago) that succinctly explained this. It has been well documented for at least 40 years now. Write programs with the realization that they will need to be maintained for perhaps decades on end, because if the code and company are successful, it will be.
Whooosh... the code example is in C/C++, not Java.
The former is obviously much better. It's not just better to read but also to write without the mind veering off from solving the problem at hand.
Those who harp on about verbosity being a good thing don't realize how good things can be.
Why OpalCalc is the best Windows calc
I've often thought about a programming language where you only need to write the smallest possible amount of code to achieve what you're trying to do. And have it clear too (so not Perl style).
No bloat, no header files, no semicolons at the end of lines, swap functionality of && with & and || with | (colour coding them too), power-of symbol (^), terse Haskell-style functionality, and even no forced declarations (the IDE can colour code variables according to whether they're int, double, string etc. automatically, and the scope is automatically defined as the outermost appearance of the variable). The compiler would do ALL the hard work to optimize the program.
Why OpalCalc is the best Windows calc
Having not yet touched Haskell, I love the terseness of the Haskell example. To me it feels like a high level function, like as if it could be rewritten:
items = [1, 15, 27, 3, 54]
result = items.filter(<, 10)
Perhaps all Haskell functionality can be converted like this?
Why OpalCalc is the best Windows calc
Comment removed based on user account deletion
Java's cross-platform support is mentioned in passing in the article. But they fail to recognize its importance in a key setting: the academic environment. Not only is Java available for all the important platforms that students may own (Windows, Mac, and Linux), the SAME implementation of it is on all those platforms. That means that students can use any of those platforms to do their assignments, and be confident that their programs will run correctly on the systems used by the graders. That is a key advantage over using C or C++.
Python is also cross-platform, and it has seen substantial growth in academic use in recent years. Vendor-bound languages like Swift and C# aren't in the running for general academic use, though schools offer courses that are specifically about them. (C# may become more usable in the future now that Microsoft is opening up parts of .NET but it has to be considered a Windows-only language for now.) The next frontier may be browser-based programming environments using Javascript; those will offer excellent cross-platform compatibility so long as all students use the same browser (which means one that is available on multiple platforms such as Chrome or Firefox), and probably an acceptable level even if they use a different one.
Quote about filters in Java from this link:
Filter in place or into another collection?
Haskell programmers are crying.
The colon is no longer used, we only put one at the end of each paragraph (procedure).
Parsing XML in COBOL is very easy. You use the XML PARSE command in a loop. Each time the parser finds an XML tag it return control to your program, giving you the tag name, attribute(s) and value. You process it, then call the parser again until the end of the document.
Likewise, generating a complex XML document in COBOL is done by defining the hirarchical structure in a copybook, assigning values, and then calling a single command: XML GENERATE.
It's very easy, and very fast.
Try it! Library of Babel
Yes, but you have a very narrow view, here. If I change the name of 'x' in the class, I have to change it /everywhere/, unless the language has a way for me to say "by the way, if someone assigns to 'x', really assign to 'y' instead.
And how is this different from setX?
Reading from standard input does not mean "reading from the command line". Standard input is often redirected from a file, from another program's output (called a "pipe"), or from data provided by the client that connected to a running server.
Foo foo = new Foo()
Which isn't necessarily good style.
First, the type name in a declaration can and often should be more generic than the constructor. It could be an interface that the constructed class implements or an abstract class that the constructed class extends. For example, you can do Map map = new TreeMap() if you're not going to call any tree-specific methods later on.
Second, why name the variable similarly to the class? Map enemies = new TreeMap() makes the variable's purpose easier to understand.
Java is not functional
Only because Oracle keeps breaking it. The Java virtual machine's security has proven to be Swiss-cheese enough that Oracle is falling back on the traditional video game console security paradigm (reliance on commercial code signing certificate authorities) rather than actually restricting what a program module can do.
#2. Scheme is a Lisp, so if Java were a heavy weight one, we would have a widely adopted Lisp.
We do have a widely adopted Lisp. But it's not Java; it's JavaScript. JavaScript implements Lisp-like semantics, and its syntax is a C-colored fulfillment of the "M-expression" syntax concept originally envisioned for Lisp.
colon? I meant the period!
Sorry for my poor english.
Try it! Library of Babel
if you took someone that never read or wrote code before and showed them 100 line, idiomatic programs in Java, Javascript, Python, Ruby, PHP, Perl, Lisp, Haskell, C, Fortran, COBOL, Basic, and a few other languages that Java would not top the list for readability. My guess is that the winners would be Basic, COBOL, and Python.
Depends. My bet is that it entirely depends on the background of the "someone" you've taken.
- english speaker ? mostly used to litterature and philosophical logic ? yes, maybe as you list them.
- background in mathematics ? The order will probably be reversed, with probably Haskell, C and Fortran near the top. And probably APL topping them all. And the guy complaining that most of them still miss support for greek alphabet.
some people are used to see things written down in plain text, other are better used to see things written with symbols.
plain text has the advantage of being a little bit clearer for a person who happens to be fluent in the language which was used to create the language (say hello to dialects of Logo and Excel macros translated into various languages). Otherwise it's completely useless (most of the language you mention are based around english. useless non-english speakers. when I was a kid, I started learning to code in basic before I knew english).
symbolic notation has the advantage of being more compact (requires less typing, quicker to read)
cf. the well know geeky joke of "add 1 to cobol giving cobol" vs "C++"
And well, Perl, let's forget about Perl. It's a write-only language. :-D
The only language your cat can write legal code in just by walking across the keyboard.
(Disclaimer: I used to code a lot in Basic as a you kid. Started C a bit later, and learned english about this time. I code also regularily in Perl, C++, awk, php, 386 assembler, etc. I know bits of R, javascript, python, FORTRAN, did some Logo in french in school as a kid, etc.)
"Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
Ah.. the word "filter" again.
filter (10)...
What does it mean?
1) Filter out every item matching the criteria (ie, discard every item less than 10)
2) Filter out every item not matching the criteria (ie, keep every item less than 10)
In this case, "filter" means select only those items that match the criteria, i.e., where the given predicate is true.
This usage is about as consistent as anything you'll find in the programming world: languages using it this way include Python, PHP, JavaScript, Java, D, and many well-known functional programming languages including Haskell, several of the ML family, Erlang, Scala and Clojure. Some other well-known languages have related algorithms under other name, but I know of no counter-examples that use "filter" in the opposite sense.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
Once when I was teaching Python, it amused me to notice a beginner try to write a function in a way that would be valid Haskell, but wasn't valid in Python. Your own post also seems to find Haskell more natural. I wish I could spend more time with Haskell, it seems very interesting.
Depends on how the language does comments. I think it wouldn't work on either Perl or Haskell.
I started learning Java at the university and found it to be the most complicated and convoluted way of programming. There is a ton of stuff you have to get straight before you can even print your first "Hello World!" to the screen. I dropped the class and changed the major...and apparently I am not human.
Your poor reading comprehension is perhaps the root of your confusion. I didn't say anything about a tool for all jobs.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
Rapidly switching back and forth between en-US and the keyboard layout for your native language can be uncomfortable as well.
Your poor reading comprehension is perhaps the root of your confusion. I didn't say anything about a tool for all jobs.
I apologize for imperfectly understanding your comment. I'll instead try to explain my miscomprehension one step at a time so you can help me understand where I went wrong. As far as I understand your comments so far, you're suggesting using one tool for entering code and another for entering native language text. Writing a program includes both code in a programming language and comments in the language of the programmer team. And as I understand dunkelfalke's comment, the programming language is optimized for the en-US keyboard language, but the language of the programmer team is not en-US. If one's responsibilities include rapidly switching between writing code in a programming language and documenting it in a human language, what are you trying to say is the appropriate tool for each job?