Yeah, I agree with this. Fixing circular dependencies in C++ is pure hell. C++ never should have used C’s build & link process - that was a relic of the past that ought to have died.
You know, most of these things brought up in this thread are pretty unimportant IMO. I would imagine most of us have used languages with or without operator overloading, lambdas, various kinds of generics, properties vs getters/setters and none of this makes a squat of difference to whether you can produce good code in language X.
The number of people I’ve seen swear black and blue that you can’t use Java because it doesn’t have syntactic sugar Y. It’s rubbish. For me, the best reason to use Java is that mistakes fail early and verbosely. When I fuck up, it tells me where and why rather than failing silently like Javascript or crashing the machine like C++. As a whole, I like the language features in java but I doubt anyone would leave if some of these decisions were one way rather than another. I don’t like operator overloading - I have worked with C++ in large dev teams and as Cas alluded to, that can get painful - but if it were added to the language I’d embrace it the same way I now use generics although I never thought the language needed them, either.
The slow introduction of new things is a great boon to Java, I think.
Cas
What I don’t like are annotations.
At first they were just visual sugar but I knew that wouldn’t last. Now your code won’t work if you’re missing or have the wrong annotations.
As far as I’m concerned annotations are the equivalent of C macros. Programmers can do anything inside them and the potential for misuse outweighs the advantages.
What code breaks without annotations?
Cas
Any code using the latest buzzword-compliant J2EE web application framework du jour, I’ll guess.
Personally I’m not against annotations having actual semantic meaning (rather than just compiler/documentation guides), but there’s some horrific over use out there. But then you can write horrible code if you (ab)use any language feature.
JUnit gets annotation usage about right in my book.
Two things: i can cope with Java cause it allows a team of differently skilled people to work with each other. It has so little syntactic sugar that almost anyone can read and given a little time understand most of the code. There aren’t to many ways to severly shoot yourself in the foot either. I could not imagine working on anything > 2k LOC in JS with a team spanning novices coming straight from univ. to seniors.
Also, all the things mentioned here are available in C#. Why aren’t we using C# again?
All good points. Often the introduction of new features hinders the ability to create good code and decreases the quality of existing code. Any form of pointers, for example, would instantly eliminate the readability, simplicity, interoperability, stability, security, reliability, portability, and predictability of code - and degrade the usefulness of static analysis and debugging - and nullify the possibility of certain compiler optimizations. Talk about porting a feature from an entirely different language to Java always makes me cringe. Sometimes it is a sign of inexperience. I’ve seen a lot of people insist on coding in C++ “because it’s faster” that do things like use new
with every constructor. And on the other hand, some people say things about Java that suggest they know nothing about heap allocation, stack allocation, or garbage collection. Aside: It amuses me to see people C++ programmers casually talk about (quick) sorting strings being significantly slower than sorting other types.
There’s a huge difference between languages like C and C++, languages like Java and C#, and languages like Javascript and PHP. C++'s special operators, copy constructors, and heavy use of value type variable assignments makes ordinary coding and working with data structures radically different from Java programming practices. You can’t easily integrate every feature from or use the same part of your programming brain in both languages. Users of that final class of languages seem not to notice how strange it is to use regular expressions and built in array functions instead of working with appropriate data types and algorithms.
I don’t really agree with the sentiment that things like Generics and properties are purely unnecessary syntax sugar. You can live without them, but Generics is a huge help to write good code faster without sacrificing code quality. Properties are debatable, but very similar to Generics in that respect. It also speeds up coding as a user of third party libraries. I absolutely agree with you on your best reason to use Java. My best reason to use Java is that it makes mistakes easier to find and, more importantly, makes it so much easier to avoid mistakes entirely. There are annoyances in the Java language (enough so that it might be a good idea to reinvent it or invent a new language based on it), but they all can be worked around without sacrificing much and the time it takes is usually tiny compared to the time you save when using Java in large projects or anything involving more than one person’s code. It scares me when I hear serious talk about new features from other languages, especially scripting languages.
Once your language is turing-complete, everything is syntax sugar. What I want to see more of in languages is “semantic sugar”. When you notice that JDK8 lambdas do local type inference, that definitely fits into the semantic sugar category, and the effects of it will ripple beyond merely more concise code, and toward fundamentally better libraries and/or idioms that use it. When you can express map concisely, it’s a quick step to fmap, and just like that, you can wave bye-bye to null. That’s the power of semantic sugar.
Yeah, er, it’s just that the conceptual leap from lambda to waving goodbye to null is a hard one for us ordinary programmers to grasp after so many years without anything like it. Slowly does it! It’ll take a long time to get Java programmers to make the leap from purely imperative programming to functional programming. I know this because of the number of Java programmers I’ve met who simply cannot write SQL.
Cas
But it can make a huge difference in the amount of time you spend creating it…or led to choosing to use language Y instead of X.
The features in Java that are as they are tend to lead it towards being bashed by individuals with an agenda, balanced by increasing praise as the number of programmers in a group* increases.
Cas
- what is the collective noun of programmers? A mess? A business? A bag? An arraylist? (ho ho)
Redundant Array of Inexpensive Developers
Given that Java started at Sun…
It would be nice to simply be able to lot of things in more of a shorthand way. Writing getters and setters is a bit of a pain, and it’s nice in languages like Objective-C where you simply define a variable as a “property” and then you’ve got your getter/setter created and it can be treated with dot syntax as if it were a public variable. Long sentence. But it is a pain sometimes how much I need to explicitly write out.
I really despise using Javascript, but I have to say it’s pretty amazing to just say myObj.whateverTheHell = whateverTheHellElse. Whenever I want. Anywhere. So easy, so fast. But obviously extremely error prone.
And I can’t even count the number of ways that Java is better than C++. Seriously. So. Much. Better. Working in C++ makes me feel like I’m going to have to program on a punch card next and feed it into the DVD drive. It’s just so old and backwards.
Java’s biggest problems are also in many cases its biggest strength - extreme verbosity in variable and method names means a lot of typing but also means self-documenting code; extreme restrictiveness on what you can do means being forced to code a certain way but also means being forced to code a certain way… etc.
Stuff like operator overloading is great, but is so often abused I tend to avoid it. I know exactly what list.add() means, but list + x is not immediately clear. And if you’ve ever used Unreal Engine, you’ll know why operator overloading can go so very wrong. Although I think they have improved this since.
My favourite feature of Javascript is array literals, object literals and JSON. Being able to make an ad-hoc tuple is very handy - and Java could easily implement that with a hashmap (but again, it’s the syntactic sugar that makes it work as others have mentioned).
Hehe. A Chaos of programmers? An Anarchy of coders?
Yes, obviously I can’t claim that all syntactic sugar makes no difference otherwise I’d have to be advocating direct machine or byte code programming by reducto ad adsurdum. And I’m NOT claiming that!! I’m just saying that people seem to pick on one feature and say “that’s one’s non-negotiable!”. When you see people say they can’t use Java because of Operator Overloading and others say that they couldn’t use Java if it DID have operator overloading, you know really that this is just hyperbole: one of these view points might get frustrated but they could both produce code in Java just fine.
I really don’t like the C# handles properties with the get/set thing in one place but that hasn’t stopped me using it productively on occasion. That’s really my point - yes the body of features is important but people overstate the importance of individual features. That’s all.
You know, most of these things brought up in this thread are pretty unimportant IMO. I would imagine most of us have used languages with or without operator overloading, lambdas, various kinds of generics, properties vs getters/setters and none of this makes a squat of difference to whether you can produce good code in language X.
For me, the best reason to use Java is that mistakes fail early and verbosely. When I f**k up, it tells me where and why rather than failing silently like Javascript or crashing the machine like C++.
I’m not sure that you’re being entirely consistent. Generics introduce a whole new class of mistakes which fail early and verbosely rather than by throwing an exception at runtime. AFAIC that makes it easier to produce good code.
Disagree?
I have my idea what could be done to improve Java, but what I disagree with in the Java language?
After thinking about something to whine about, I thought of this:
What I find most ridiculous is that you have Integer, Float, Double, Long, Double, Char, Byte, and even String objects for their respective primitive types. Couldn’t they make up their mind? Then they added the auto-boxing feature… great, yet another hidden overhead to their laziness.
Then those objects are “special”, you can’t pass them around into methods as regular objects, because they are treated as primitives.
And then I see lots of guys using the object primitives instead of the primitives themselves in their code. It’s horror seeing people jump from using primitives and object primitives in the same class. Maybe they don’t have a choice because there’s some library they’re using that relies on everything being objects. Well… it’s crazy language design that creates this mess.
They should kill off the objects, turn them into non-instanciable classes with static helper methods. We’ll all be better off. And why can’t I do:
myIntObj.add(anotherIntObj) ???
Stupid.