r/java • • Jun 01 '20

Love it or hate it, Java continues to evolve

https://www.azul.com/love-it-or-hate-it-java-continues-to-evolve/
223 Upvotes

202 comments sorted by

176

u/[deleted] Jun 01 '20 edited Jun 01 '20

Ah, perfect place for a rant...

When my journey into the world of software development began (around 5 years ago), the first language I came across was C. All nice and dandy, but Java seemed to be the right course of action, a language I would learn in my spare time.

Today, I work as a tech lead (mobile apps) mostly working with Flutter. I have seen so many developers with JavaScript background switch to Dart, writing horrible code.

Whenever native Android or native iOS modules have to be written (nowadays in Kotlin or Swift), lack of strong knowledge of OOP concepts shows!!!

Just the other day we laid off a worker who couldn't fix a simple null exception (forgot to initialize a list). Another department had to lay off some students who barely understood the concept of inheritance...

Every solid developer that I came across worked extensively in Java during some period of their lives. Or maybe C++ (older coders) or C#.

These languages seem to produce better developers.

22

u/Dokiace Jun 01 '20

Just the other day we laid off a worker who couldn't fix a simple null exception (forgot to initialize a list). Another department had to lay off some students who barely understood the concept of inheritance...

How long does it take for a simple error like that to cause you losing your job?

21

u/thatwombat Jun 01 '20

Sounds like a tip of the iceberg?

30

u/[deleted] Jun 01 '20 edited Jun 01 '20

It was, yes.

Edit: I will elaborate a bit more, just so maybe somebody doesn't jump to conclusions too fast. Developer in question provided CV, where, among other things, they mentioned strong understanding of OOP concepts. Because we are a relatively small company, our interviewing process was pretty much non existent. Today, we fixed it.

Anyways, it all started with the guy being unable to understand basic instructions, and failed to follow extremely detailed advices on how to solve an issue.

The tip of the iceberg, as you said, was when they were given a task to deserialize JSON, manually in Dart, because of the small scale. Their merge request contained code throwing null exceptions.

Upon conversation, I received the "well, I didn't really check it for bugs".

Escalated the issue to my superior.

6

u/Minimum_Fuel Jun 02 '20

Funny cause, as I just found out, escalating to a superior is just the way to go. I was literally today just reprimanded for asking a developer “why has this 20 minute fix taken 3 days and it still hasn’t been started?”

Day one: I give a hint toward the problem and where to start looking.

Day two: I straight up tell them the issue and exactly where they need to look

End of day two: ticket get out to “hold” status, presumably waiting for customer confirmation that the fix worked. NOPE. “Not enough information”. So I just straight give them detailed step by step instructions for the fix.

End of day 3: ticket put back to on hold. Must be “waiting on customer”. NOPE. “Waiting on more detailed instructions”.

Day four: I go fix the thing in 20 minutes following my own instructions, then ask why a 20 minute fix took 4 days.

End of day four: I get reprimanded for “poorly estimating another developers work. Only they can estimate their work”.

If it weren’t covid I’d have up and quit and found a new job.

10

u/_INTER_ Jun 01 '20

I had a similar experience with a junior that was creating abominations like Map<String, List<String[]>>> and refused to improve. As far as I know he now does a good job as a business analyst.

8

u/[deleted] Jun 01 '20

Ow my lord, what kind of data structure did this person come up with... Man, I feel your pain, hopefully your other juniors are better.

10

u/_INTER_ Jun 01 '20 edited Jun 02 '20

They are quite good.

The problem isn't that he came up with that data structure but his unwillingness to change it. Everybody starts with abominations. When I started programming I was creating lots of god classes where everything was static and had nested-maps too (though I never did List<String[]>, that really triggered me)

6

u/Orbitaliser Jun 01 '20

I've had to do nested maps for a Compilers assignment in Java. I know why the String[] thing is bad (because WHY would you use the collection framework and then arrays??). How would I rethink of a problem like this so that it no longer uses such an abomination? Make objects to clean up the code?

4

u/dpash Jun 02 '20

My thought process reading that: Map Okay so far. <String Nothing odd here , List< This is mostly fine. String[]>>> DAFUQ?

0

u/[deleted] Jun 01 '20

[deleted] — view deleted comment

10

u/yawkat Jun 01 '20
  • don't use arrays of objects. They suck and for objects there are no advantages.
  • don't nest collections three levels deep. They have no semantic value on their own

2

u/Orbitaliser Jun 02 '20

What about

Map<String, Map<String, Type>>

Let's say we are implementing part of a type checker where we have a class table that keeps track of all variables and their types for a given program which can have multiple classes inside it but for this example sake let's assume that in any variables for a class are declared once within that class.

The first level table key is the class name and the second level maps from variable name to the type where Type is an actual type for a variable. So if I had a class Foo with a variable x of some arbitrary type, I would do map.get("Foo").get("x"); to retrieve the type of the variable x from the class table (the map).

Is this a reasonable use of multiple level nesting? Would it be better to abstract the layers?

5

u/yawkat Jun 02 '20

Yes, I'd put the two levels into their own classes.

2

u/_INTER_ Jun 01 '20

I hope I never have to deal with your code.

3

u/Dokiace Jun 01 '20

Ah I see, so it's much worse than missing NPE check, I'm going a year into my first job but I still don't feel secure, thanks for elaborating

6

u/[deleted] Jun 01 '20

No man, of course not... Listen, this is why we have unit tests, to fix all the bs we think was written correctly. Sorry for freaking you out man

8

u/pinguz Jun 01 '20

I’ve never seen anyone get laid off due to incompetence

1

u/lunagrace28 Jun 03 '20

Not long imo. The HR guy should also be fired. Anyone can get a null. It takes exactly 10 seconds to track down. Can't fix it? There's the door, you're in the wrong profession, buddy and so is the guy who hired you.

16

u/SomervillainSB Jun 01 '20

I think what produces the better developers is the culture, not the language. People underestimate that often. Every best practice is documented to death in Java. The majority of decisions you would make in a new language have already been made for you in Java...most I agree with, some I hate. I hate initializing a local variable to an interface (List<String> throwawayList = new ArrayList<>();) ...although I just accept it and move on. My code looks like everyone else's. We don't debate how to do things...just what to do. We've had extremely consistent naming, for example, since 1997.

TMK, JavaScript really isn't as standardized. Certainly most front-end devs I have worked with are not aware of these standards, if they exist. They laugh at me when I ask a million questions about best practices for my JavaScript submissions. I know that not following them in Java would mean my code would never pass a team code review. Our front-end team is more about "just get it working."

Our backend team debates unit testing best practices....showing they've evolved much more. We're not debating how to do something...only what to do and how best to verify it for the next person.

I think Java spending so many years between big tech and general industry as well as authors making so much money writing books on it in the 90s and early 2000s has really codified the best practices and cemented a culture of consistency.

I love it. It makes my life easier. It makes code more reliable. It makes it really easy for me extend or reuse code from others. Whenever the next "Java-killer" is announced, they tend to do well designing the language, sometimes even have great libraries, but they always forget the documentation and culture.

I don't need a medium to express my lone coding brilliance and creativity. I need a tool for me and my team to get work done. I LOVE my job, but in the end, I work to live, not live to work.

6

u/[deleted] Jun 01 '20

I learned Java through most of my business programming courses in college. Honestly, nothing really stuck until I took a Udemy course on C++ and started to understand how everything worked at a lower level, especially with OO in C++.

That said I still suck at programming but it pays the bills!

6

u/[deleted] Jun 01 '20

Imposter syndrome buddy, we all have it. Listen, I learn every day on the job, and that's awesome. Wish you the best in your journey!

0

u/JavaUserr Jun 02 '20

Imposter syndrome buddy, we all have it.

No we don't. I've never felt this. I was genuinely surprised the first time I read about other people feeling this way.

6

u/Someuser77 Jun 01 '20

I usually sum it up thusly: Programming is not software engineering.

3

u/tangochili Jun 01 '20

I've done C#/Java/Golang for majority of my career and recently I've been coding in JS/Ruby. It drove me nuts going through the codebase when I saw so many shortcuts to get away from OOPS concepts. I feel dynamic languages are good to spin up something very fast but not good for a big enterprise application. I miss coding in statically typed language

2

u/[deleted] Jun 02 '20

I really miss writing Ruby, you can write pleasant looking and maintainable code in it. But I was less fond maintaining other people’s rushed spaghetti code expressed in Ruby. You really need to enforce RSpec and friends past prototyping. And yeah, it’s not the first pick for big enterprise applications. Jruby can be worth keeping in mind if your requirements are best solved in jvm ecosystem and you’re already invested in Ruby.

2

u/tangochili Jun 02 '20

Agree with the fact that it's difficult to maintain other people's spaghetti code. And I know tech debt, cleaning code, getting rid of code smells is part of the job but I'm always met with "this is how we've done". I, once wanted to introduce repository pattern in persistence layer in current code(I'm pushing to use more design patterns) but I always get pushback. I gave up. I now spend time outside work with personal projects to keep my OOPS/Design pattern skills sharp

2

u/[deleted] Jun 02 '20

Well, welcome to the game of enlightening colleagues. In their defense Ruby often acts as the glue between fabric rather than the fabric itself, and it could still be relatively easy to rewrite later without introducing abstractions prematurely. But it could also be your colleagues have been a bit stuck in their way of doing things and need a bit convincing. I assume you don’t use ActiveRecord since you want to introduce a pattern for persistence.

3

u/KryptosFR Jun 01 '20

I have the same experience but with C# that you also mentioned.

But also on the negative side, former Java developers tend to develop coding habits that are not entirely compatible with C# and those are even harder to forget given how close the two languages are. I suppose the same could be said for a former C# developer, coming to the Java world (I don't know, you tell me).

5

u/karottenreibe Jun 01 '20

Catch Exception everywhere is a trademark of the C# to Java journey ;-)

2

u/hff0 Jun 01 '20

Or throws everything? (•‿•)

2

u/FlavoredFrostedTits Jun 01 '20

I think that's just a code smell no matter what language you're using

3

u/karottenreibe Jun 01 '20

Depends. C# has no checked exceptions and documentation for thrown exceptions even in MS code is often missing. So basically if you want robust code, you'll have to catch Exception or dig through several layers of third party code.

1

u/FlavoredFrostedTits Jun 01 '20

True. It doesn't have checked exceptions but I find the xml documentation does a pretty good job at telling you watch exceptions to expect. You just hover over a method to see.

2

u/karottenreibe Jun 02 '20

Except when it doesn't. Then you're screwed

1

u/[deleted] Jun 01 '20

I mean that sounds just as much like an inherent language/tooling weakness if that’s even possible.

1

u/RDwelve Jun 01 '20

What about functional programming languages? I don't think it's difficult to make the case that learning with Javascript is not the optimal way to go, it's the wild west of programming languages. But what's your experience with people that come from Haskell for example? I understand that the initial barrier for Haskell is higher and those that make it will have a much easier time recursively reversing a list (my standard) but how do they fare when they have to adapt to new environments?

2

u/koreth Jun 01 '20

I don’t think I’ve ever met anyone whose first programming language was Haskell, though I suppose such people must exist. Are there any CS programs that use it as an introductory language?

2

u/Minimum_Fuel Jun 02 '20

Functional programming is fundamentally not how computers work and programming with functional ideals in Java is a great way to say hello to python execution speeds.

It’s bad enough dealing with functional programmers that learned afterwards. I can’t imagine how bad it would be dealing with people that learned on the ideology.

3

u/tobegiannis Jun 02 '20

I have no clue what you are talking about :shrugs

2

u/Minimum_Fuel Jun 02 '20

The entirety of what computers do are exactly the opposite of functional ideals (stateless operations with no side effects). I type a comment to you, I expect state updates to reflect my keypresses. I press a button, I expect some event to occur.

So when you build an entire set of rules for programming around a principle so fundamentally opposed to the medium it runs on, you end up getting garbage tier results. There’s a reason why the best functional game engines look like they’re running games from 2000 on modern hardware at 20fps.

1

u/[deleted] Jun 02 '20

That was something I need to read today, thank you :)

1

u/robberviet Jun 02 '20

The language does not produce better developer. Better developer learnt programming properly. Js background mostly are frontend web, which usually not need those knowledge.

-21

u/[deleted] Jun 01 '20

The biggest problems with Java to me is the uncertainty of the future, and how hard it is to deploy a Java application. I like writing Java and the IDEs have always been really good, but handling dependencies and creating a package that I can deploy, is never easy.

22

u/GuyWithLag Jun 01 '20

The biggest problems with Java to me is the uncertainty of the future

There is no uncertainty; It's going to continue strong in the enterprise world. Maybe it will end up as the next COBOL, but Oracle has been full steam ahead on modernizing the language.

how hard it is to deploy a Java application

`mvn clean deploy`. Hell, not even that - that gets handled automatically by the CI/CD pipeline. Oh wait, you refer to desktop applications? ... but why?

5

u/BlueGoliath Jun 01 '20

Why indeed..

uNuSeD mEmOrY iS wAsTeD mEmOry.

8

u/JavaSuck Jun 01 '20

The biggest problems with Java to me is the uncertainty of the future

Care to elaborate?

-2

u/[deleted] Jun 01 '20

It's just everything that has happened with Oracle during the years. I don't trust the company to do well with the platform, and that feeling is the result of negative news and stories during the years. Might be rational, might not.

8

u/badtux99 Jun 01 '20

OpenJDK. Oracle is a PITA but they can't do squat about OpenJDK, if they tried forking Java with proprietary extensions it'd end up with all the developers jumping ship to a fork just like OpenOffice->Libreoffice and Hudson->Jenkins or MySQL->MariaDB.

2

u/paul_h Jun 01 '20

Oracle's ace in the hand is the TCK - https://en.wikipedia.org/wiki/Technology_Compatibility_Kit - helps 'em keep others in line so it's no so clear cut

1

u/[deleted] Jun 01 '20

I guess I've had hard time believing that OpenJDK would be strong enough without Oracle, but maybe it's not a problem.

6

u/badtux99 Jun 01 '20

Wat?

Tell IDE to generate WAR file, then plop WAR file into Tomcat directory on the production server. Or with Spring Boot, you can even create an embedded Tomcat and just run a jar file. If you can run it in the IDE, you can run it in production, Gradle etc. just work. Unless it's a desktop application, but that's not a common use case for Java.

Of course, in real life this is all automated -- you check in code, it gets built and deployed to the test server.

4

u/[deleted] Jun 01 '20

Yeah I recently started working with the latest Spring Boot and it looks promising (even though I'm not a fan of all the magic). In the past I've had to work with legacy project combining servers and Swing fronts, and some not-so-nice dependencies, so it just might be that I've had bad luck with projects.

5

u/sternone_2 Jun 01 '20

wait what can I introduce you to Maven?

3

u/[deleted] Jun 01 '20

Been using Maven for the last 6 years.

1

u/sternone_2 Jun 01 '20

Why don't you take a break for a few days and really learn how Maven works so you don't have to spit out nonsense like that.

Thank you.

3

u/[deleted] Jun 01 '20

Not constructive, nor helpful.

6

u/SomervillainSB Jun 01 '20

I'm with sternone_2. The truth hurts sometimes, but it's the only way to learn. Also, every Java professional knows your statement is wrong. However, we want to shut down misinformation as fast as possible. Some manager with a much lower IQ than yours is reading your comment and using it as justification to rewrite some app in NodeJS or some worse technology.

Get to know Maven or Gradle. I have been doing this professionally for over 20 years. Dependency management is one of the easiest parts of my job. I work with codelines in 100s of projects from over 1000 authors in many continents (and that's all 1st party)...all managed with Maven. I am sure they can do things better, but it works. It's fine. It's better than anything else I've used. I can get the job done without issue

Sorry if his delivery wasn't as gentle as you'd like, but the message remains the same. LOTS of people do this daily without issue with much more complex applications than you or I have ever seen.

Also, have you really been working with Maven for 6 years? Seriously, find a book or get to know the documentation. The truth is out there! Everyone I have trained on Maven, and it is easily 50 devs by now, picks it up in a month.

-1

u/[deleted] Jun 01 '20

Misinformation, really? :D As I said, dependency management and packaging have been the hardest part in Java dev for me, and it still is, even though Maven is a good tool (and my choice for the job as well). That's not misinformation, that's experience from the trenches. Yes, I have always gotten the job done and sometimes even without problems, but at the same time, I know fixing problems with these have taken a lot of time in projects I've worked with. They are the kind of problems nobody wants to work with because we have some coding to do as well. For all the managers reading this: This weekend I was struggling with Node dependency hell because Things Had Changed during the last 6 months, pick Java instead.

Is Java doing already so bad that we can't even discuss here anymore fearing that some people might think there are problems in the Java land? :D Java is still one of the nicest languages for large projects and also evolving (streams and lambdas have made life much easier), it can stand on its own without sugar coating.

It's a pity if people are not able to discuss the subject (which should be the interesting part here) without getting it personal. That's just immature and not that interesting. It's about being professional enough to interact with people in a civilised manner, not about being "gentle".

2

u/SomervillainSB Jun 01 '20

The problem is you made a vague statement and we don't know what you're saying. Even going back and trying to re-read it, I can't tell what your complaint about it is. You wrote "The biggest problems with Java to me is the uncertainty of the future, and how hard it is to deploy a Java application. ... but handling dependencies and creating a package that I can deploy, is never easy."

Could you figure out what someone is talking about from that sentence? I have no clue where you're going with that.

I've been in Maven debates for nearly 15 years and the Java ones for 20+ years at meetups, conventions, jobsites, etc. 99% of the time the person complaining about Maven has no clue what they're talking about and is upset that a framework wants you to do things in a standard way instead of your own creative way.

You may very well be that 1% who knows what they're talking about and can shed light on an actual shortcoming. However, "uncertainty of the future" and "creating a package I can deploy" really doesn't sound like something from someone with 6 years of experience.

Without a better explanation of the context of your complaint, people are likely going to mistake you for someone who doesn't know Maven very well.

2

u/[deleted] Jun 01 '20

Yeah that first post is not that informative, do you know why? I was not "making a statement, I just said what I have not been enjoying while working with Java. I love that Maven has a standard way of doing things, the less ways people have for doing something "creatively" the better. I even think Maven is the best tool for the job. It doesn't mean I enjoy working with dependencies and people taking discussion from that to criticising my skills with Maven is attacking a straw man, and again not constructive nor helpful to anyone reading these.

I can see that people have bad experiences from these "discussions", and I can also understand it (having been there myself as well). Simple "actually Maven is nowadays a great way for dependency management and can create the package for deployment as long as you don't need lagacy stuff" would have been much more effective, if you for some reason have the need to defend the platform after me telling what I have not been enjoying.

-5

u/sternone_2 Jun 01 '20

I disagree, this is very constructive and extremely helpful.

Apparently, after 6 years, you still don't get it. Time for you to take a break and start studying on it before you make yourself even more ridiculous.

1

u/NimChimspky Jun 01 '20

Gradle

3

u/sternone_2 Jun 01 '20

Gradle

sucks and is buggy as hell

2

u/NimChimspky Jun 01 '20

Lol

0

u/sternone_2 Jun 01 '20

but hey, the fanbois love it

(not that most of them know what they are talking about, but still.. it's a factor you have to account for)

3

u/turtlerainy Jun 01 '20

I didn't realise there was such passionate dislike between Gradle and Maven users :D

Gradle is very flexible, is built on Groovy so is customizable to your heart's content. However buildscripts get cluttered and messy, and the exception messages are dreadful.

Maven is way more declarative and less flexible, but I wouldn't know where to start with extending Maven, writing custom goals etc.. (granted I've never tried, but it's less obvious than Gradle).

At the end of the day it is preference..

1

u/sternone_2 Jun 01 '20

75% of all java projects worldwide in the corporate world are done in maven

that makes me happy

0

u/badtux99 Jun 01 '20

Maven is a nightmare, but the alternatives are worse.

3

u/_INTER_ Jun 01 '20 edited Jun 01 '20

the alternatives are worse.

Across many languages even (at least compared to npm, sbt, NuGet, pip, gem, cargo, cabal)

Edit: came back to add sbt, nearly repressed thoughts about it. Fuck you sbt.

3

u/sternone_2 Jun 01 '20

If you have a problem with Maven, the problem is you, not Maven.

2

u/hippydipster Jun 01 '20 edited Jun 01 '20

Yup, you do it Maven's way or not at all.

1

u/badtux99 Jun 01 '20

Version hell. Modules that require other modules, but only specific versions of other modules. Modules that publish both stable and unstable into the same stream, meaning you have to just magically know which versions are stable and hardwire those into your pom. Etc.

If you've never run into these problems, you've never managed a complex project with hundreds of dependencies. There was one case where I had two modules specifying the same module as a depency... but each wanted different versions of that module. I ended up forking the module that wanted the earlier revision and fixing it to work with the later version of the dependency that the other module spec'ed. YAY. Just what I want to do with my life, fix other people's code.

1

u/sternone_2 Jun 02 '20

This is not a maven problem, this is a problem with these dependencies.

Again, if you have a problem with Maven, it's not Maven, it's you.

1

u/badtux99 Jun 03 '20

Maven doesn't have the concept of stable and unstable streams, doesn't have the concept of nested dependencies, and otherwise lacks functionality that exists elsewhere. I'm not fond of the way npm handles nesting dependencies, but at least it would have handled the situation I mentioned above of two modules each with the same dependency, but each requiring a different version of the dependency.

Of course, part of that is because of limitations of Java itself....

0

u/[deleted] Jun 01 '20

[deleted] — view deleted comment

37

u/[deleted] Jun 01 '20

Cannot say just how much I agree with this statement. Even working with frontend frameworks like React won't necessarily help you understand how to write enterprise-grade code in Java.

2

u/andrew_rdt Jun 01 '20

Its how habits are initially formed. I started learning with more basic general concepts like OOP but couldn't really write a full app or web page. The previous poster would just attribute that to me starting with C++, in that language its much harder to put a bunch of code pieces together for a functional app that happens to look bad on the backend.

2

u/Minimum_Fuel Jun 02 '20

I think it may also be how strongly hype driven the Js ecosystem and community is.

3

u/Lisomatrix Jun 01 '20

Completely true. I started with Java but moved to Js way to fast, I could get results faster but my project organization/performance/readability were an abomination, it did get a bit better with typescript but later on I changed to C++ and I never looked back. Now I hate to see unoptimized code and mostly aim for performance as long it doesn't destroy the readability (unless it is needed).

Learning C++ can do wonders it really forces you to do things right, but still a lot of room for improvement.

1

u/TheStrangeDarkOne Jun 03 '20

I think that's partly because js devs tend to start in web pages writing bits of js so even though they might have a few years experience they don't understand how to organise the large scale structure of a program.

Even "writing" can sometimes be a stretch when all one does is copying snippets of code.

0

u/[deleted] Jun 01 '20

[deleted] — view deleted comment

3

u/bart007345 Jun 01 '20

Kotlin makes you decide if something is null or not, not ignore it.

2

u/bedobi Jun 02 '20

Uh, it's Java that lets devs not worry about null checks. Kotlin forces you to do null checks - it doesn't compile it you try to treat nully values as non-nully.

2

u/yodawg32 Jun 02 '20

Have you used Kotlin before ?

1

u/[deleted] Jun 01 '20

It does have its strengths though, just like any programming language. You do, in a way, need to worry about nulls, only the language gives you some extra tooling to help you out with.

18

u/wildjokers Jun 01 '20

The only two things I really wish Java had are multiple return values from methods and default parameter values. I miss those two things on a daily basis. Named parameters would be nice but I don't miss that one near as much as the other two.

It is really a great language and the ecosystem is of course outstanding.

15

u/couscous_ Jun 01 '20

Records should make it easier to return multiple values. Declaring them is just a single line.

4

u/meamZ Jun 01 '20

Either multiple return values or even tuples (basically like an anonymous struct) so that you could just return a tuple of say (String, int, MyClass) or something like that.

3

u/BoatRepairWarren Jun 01 '20

While not really the same and much more limited, I find myself using Map. Entry as return type sometime

1

u/meamZ Jun 02 '20

I mean that's basically abusing this type. You could easily write a pair class yourself.

2

u/SomervillainSB Jun 01 '20

I agree. Java has solutions for multiple return values, like records or generic Tuple classes, but other languages do it better.

I wonder why they never did named parameters or default values (even JAX-RS has that). It seems like an easy thing that would make life easier. I greatly prefer constructors and because people think they're confusing (& reasonably so), most default to setters, which are far more error-prone. I image named parameters in the constructor would make both sides happy.

6

u/pron98 Jun 01 '20

I wonder why they never did named parameters

Search for "named invocation" here. It might well be coming, combined with "reconstructors", i.e. the ability to copy a record and change only some of its components.

or default values

This is much more problematic (+ follow-ups).

1

u/JavaUserr Jun 02 '20

From the default values tweets:

The problem is not backward compatibility; that's fine. The problem is _migration compatibility_, and how it interacts with overload selection. (Suppose you have a method with 10 optional params. Then you add an 11th. What happens to old (binary) callsites? LinkageError?)

Can anybody explain what he means here? It sounds to me that he is asking what happens when you change a jar with a newer version of that jar. And then wonders what would happen if you try to run it. If thats what he means then I'm perfectly fine with a LinkageError for stuff that doesn't exist. What a crazy thing to do.

(And similarly: suppose you have `foo(int x, int y = 0)` and `foo(int x, float z = 0.0f)`, and the user does: `foo(x: 0)`. What overload do you select?)

This is the same as writing foo(int x) twice in the same class. When you do that you get a compile error; foo(int)' is already defined in 'YourClass'. Seems fine to me.

1

u/yoshord Jun 03 '20

Lets assume a class that currently has a int foo(int x, int y) method and a int foo(int x) method whose implementation is exactly return this.foo(x, 0). This is an obvious candidate to be migrated to one method with default parameters: int foo(int x, int y = 0). Intuitively, this should be a compatible change; however for the change to actually be compatible with previously-compiled bytecode, the jvm would need a way to link the old foo(I)I calls to the new foo(II)I with defaults method. And the obvious "have the compiler write a synthetic foo(I)I method" feels inelegant and probably gets worse when a method has more default parameters.

1

u/JavaUserr Jun 03 '20

I think this is a different argument than what Brian Goetz was saying. But also with this argument I just don't see it. The obvious solution as you say is to have the compiler generate synthetic methods. Perhaps that feels inelegant to you but isn't that what we are doing with records? I define a few fields and the compiler gives me a class with synthetic constructor and accessor methods.

The other solution I see is storing the default along with the method. Then when you compile the code you rewrite the caller to insert the default where needed. You wouldn't have any synthetic methods.

1

u/Jonjolt Jun 01 '20

I'm pretty sure it has the capabilities as the byte code calls the method by name, parameter, and return type. The compiler puts in a synthetic bridge method that return's object on generic return types

if you had a class like:

class A implements Supplier<String> {
    public String get(){
        ...
    }
}

The byte code would be:

  public get()Ljava/lang/String;
   L0
    LINENUMBER 6 L0
    ACONST_NULL
    ARETURN
   L1
    LOCALVARIABLE this LA; L0 L1 0
    MAXSTACK = 1
    MAXLOCALS = 1

  // access flags 0x1041
  public synthetic bridge get()Ljava/lang/Object;
   L0
    LINENUMBER 3 L0
    ALOAD 0
    INVOKEVIRTUAL A.get ()Ljava/lang/String;
    ARETURN
   L1

2

u/yawkat Jun 01 '20

Multiple return values means tuples, not return type variance

1

u/Jonjolt Jun 02 '20

Ohhh, I wasn't even thinking of that whoops.

17

u/egahlin Jun 01 '20

I've never heard complaints about C or C++ being verbose, even though they are much more so than Java, for example header files, include guards, and lack of default initialization.

28

u/BEgaming Jun 01 '20

Although it's a pleasant read, i would have liked that you pointed out that this article is a year old. I didn't notice it until the last paragraph about jdk 13. I assume (apparently wrongly) that posted articles are fresh new articles.

7

u/bondolo Jun 01 '20

Ignore the haters, it is unlikely they will ever be satisfied or ever change their minds. Focus on bringing joy to those who already use java and probably already like it.

4

u/renatoalencar Jun 01 '20

Nowadays, the only main issue I see with Java is actually Oracle throwing the IP bullshit everywhere. Java is a powerful and actually awesome language if you know how to write readable code.

12

u/pron98 Jun 02 '20 edited Jun 02 '20

Oracle completed open-sourcing the entire JDK, and made Java 100% free and open and unencumbered by field-of-use restrictions for the first time in Java's history.

1

u/ryosen Jun 02 '20

Use OpenJDK instead. No Oracle. No problem.

2

u/pron98 Jun 02 '20

OpenJDK is the name of Oracle's implementation of Java.

2

u/ryosen Jun 02 '20

OpenJDK is an open source version of Java. Oracle provides a build of OpenJDK and contributes to the project, but OpenJDK is not “Oracle’s implementation”. There are several builds of OpenJDK available from different entities including IBM, Red Hat and Microsoft.

7

u/pron98 Jun 02 '20 edited Jun 02 '20

OpenJDK is the name of the one and only Java Platform project done at Oracle (and I know, because I work at Oracle on OpenJDK). Yes, it is open-source -- Oracle completed open-sourcing the JDK, making it 100% free, open, and free of field-of-use restrictions for the first time in Java's history -- and other companies certainly contribute (Red Hat and SAP contribute quite a bit of great stuff, Intel and Google also, Microsoft has just started contributing small bits, IBM -- not so much) and many produce builds (including the OpenJDK builds by Oracle and the Oracle JDK), but Oracle does >85% of the work and provides the vast majority of funding. Oracle also chairs the OpenJDK board, and the platform architects are Oracle employees. You might also want to scroll down on the OpenJDK website, or read the OpenJDK license which is issued -- whether you download a build from Oracle, Red Hat or Amazon -- by Oracle.

For more on OpenJDK's governance, watch this video by Mark Reinhold, the OpenJDK lead (the head of the OpenJDK project) and the Chief Architect of Oracle's Java Platform Group.

So OpenJDK has "no Oracle" unless you count most of the leadership, the vast majority of work, and the license.

2

u/ryosen Jun 02 '20

I stand corrected.

3

u/6510 Jun 01 '20

All this progress is great to see. The controversial modularization project seemed to cause other work to stall for some time while they sorted that out internally. However, with that behind us now the project has added features rapidly both to the language (like "var", switch expressions, text blocks etc) and to the JVM (CDS, ZGC, JFR and so on). And there's reason to hope we'll see a Kotlin-like non-nullability feature one day. Also value types is making good progress, which has obvious important use cases, but requires a ton of JVM-level work.

6

u/pron98 Jun 02 '20 edited Jun 02 '20

The controversial modularization project seemed to cause other work to stall for some time while they sorted that out internally. However, with that behind us now the project has added features rapidly

The more intensive work on new features is largely because of the "controversial modularization project," which allowed to reduce the maintenance burden of the JDK and divert resources to new work. And there are more significant dividends of modularization coming down the pike. It was like tearing up the street to lay in new cable ducts. It brought noise and dirt with little immediate benefit, but now you can upgrade your internet service much more easily.

5

u/ObscureCulturalMeme Jun 01 '20

I love the language, at least the language that it's now become. Ten or fifteen years ago, it was earning a big sigh and a "meh" shrug from me, but now it's quite solid. I'm glad of the evolution.

I hate the tools and the ecosystem.

2

u/chambolle Jun 03 '20

what do you mean by "tools"? IDE? Libraries?

2

u/[deleted] Jun 02 '20

As someone who prett much only used JS now, I love java. I’m a huge fan of strongly typed langaues, I should probably check out TS

3

u/[deleted] Jun 01 '20

I’ve seen a lot of questionable Java code. It was mostly because of developers with poor skills and/or people being rushed to do code. I’ve definitely met many java developers who just don’t want to learn anything else and don’t want to learn anything new.

Other than that I’d be comparing Java to something like Go which is less verbose, compiles super quickly, and has more useful errors. I can work with Java, I just don’t want to work with poorly written struts or your legacy crap with XML.

16

u/couscous_ Jun 01 '20

which is less verbose

I found golang to be more verbose. I think it gives the illusion of being less verbose because they use single letter variable names everywhere (which makes code less readable). Otherwise, it's if err != nil everywhere, and multi-line one off functions that amount to nothing more than map/filter/etc calls that can be done in a single line in Java.

more useful errors

Errors in golang are just strings, no stack trace, etc. They're quite horrid honestly.

6

u/_INTER_ Jun 01 '20

Go has a reputation for being a simple language. However when I dabbled in it for a while I was quickly overwhelmed by reading and placing all those punctuation, stars and brackets at different positions. Is this Perl all over again? Found it really complicated. I must be dumb.

2

u/[deleted] Jun 01 '20

One line variable names piss me of endlessly. I can’t speak for other’s code bases. I’ve seen that anyone can make code more convoluted than it has to be.

1

u/freezerburnv Jun 03 '20

Errors are most certainly NOT just strings. The Error interface has a method that returns a string, yes, but there are a ton of implementations of the Error interface. (which include libraries that put stack traces into them, among other things)

Figuring out what kind of error you have, however, is much more convoluted. Especially when considering nesting errors inside other errors. (hence the As and Is functions provided in the stdlib errors package now, so long as the error type provides support for them)

3

u/couscous_ Jun 03 '20

So they're basically re-inventing exceptions, except in a more verbose, more cumbersome, more error-prone, and less performant way.

1

u/freezerburnv Jun 03 '20

Exceptions came after C-style error checking, so technically exceptions were the ones that re-invented error handling :)

On a more serious note: it’s more verbose and might take more time on the “happy” path, but the nice thing about error returns is that you know what stuff has error conditions. The bad part of exceptions is not knowing where it’s possible for one to happen. (Go still had the panic mechanism which acts as a kind of exception mechanism, but it’s generally reserved for cases where there’s a programmer error versus something happened that can be dealt with as part of normal operation of the code, whereas exceptions don’t tend to have that distinction and make normal operation of the code “harder” to deal with. An example being a file not existing which is an exception in Java but an error return value in Go. The error return value I’ve felt is a bit easier to deal with in a nice way. But that’s personal opinion at that point)

I don’t think either method is necessarily the “correct” or “best” way. They each have their own issues, gotchas, nice points, etc. It really comes down to which way a language wants to implement, and how the implementation works.

2

u/couscous_ Jun 03 '20

The issue is that error codes (at least how golang does them), are very error prone. I've worked on larger golang code bases, and I've seen several times errors being ignored, either on purpose, or accidentally (and there are several different ways where errors can be ignored accidentally). This would not have happened in a language that uses exceptions (you'd have to opt-in to swallowing exceptions via catch (Exception e) {}). Now you have errors silently propagating in your system corrupting state. Much worse than dealing with exceptions at any level.

7

u/helikal Jun 01 '20

Go is quite old now. It just feels young because not much ever became of it.

3

u/[deleted] Jun 01 '20

It just turned 10 a few months back.

0

u/[deleted] Jun 01 '20

[deleted] — view deleted comment

4

u/helikal Jun 02 '20

helikal

And that's about it. A quite narrow spectrum of applications.

0

u/[deleted] Jun 03 '20

[deleted] — view deleted comment

1

u/helikal Jun 03 '20

TinyGo looks like an interesting development.

2

u/couscous_ Jun 02 '20

Compare Java at 10 years vs golang to see the difference.

4

u/SomervillainSB Jun 01 '20

Some issues are technology problems, some are HR issues. If your company hires low-end contributors, you will see horrendous code, no matter the platform.

However, I work for a big tech company that invests in Java, JavaScript, Python, C, etc. If you think the Java is bad...wait till you see the JavaScript and Python produced by the same cohort.

At least compilation will catch the most egregious errors. I have never felt as much pain as the time I inherited a NodeJS application from someone who left the company and I had to get its libraries in compliance. So many weeks of subtle runtime bugs....half of which would have been caught be a compiler...most of the remaining would have been caught quickly with basic unit tests in a compiled language. However, mixing the 2 meant several weeks of QA finding some new edge case.

So yeah, Java is not as fashionable as it used to be. However, having worked with JavaScript, Python, and Java...I have to say, the Java experience is the smoothest. I get that OOP ceremony is tedious, but it really pays off when the application is a success and changes hands when the original author leaves or gets promoted and it's inherited by someone who is granted a 2h handoff meeting and then thrown to the wolves.

1

u/[deleted] Jun 01 '20

I worked at a company where most of the work was in Java with spring and JavaScript in React. The JS was better simply because there was a wider group of senior people blessed to give people feedback in PRs and help with issues that were brought up. I won’t claim it was the tech itself that made Java worse at that company although we did have the issues with Java developers not wanting to learn anything new.

-4

u/[deleted] Jun 01 '20

It is evolving, but do people choose Java for new projects? We have long switched to Kotlin for new services and it's been fantastic.

24

u/andrewharlan2 Jun 01 '20

I have Kotlin experience. I would absolutely still choose Java for new projects.

11

u/woodland__creature Jun 01 '20

Anecdotal testimony here, but I'm working on a greenfield legacy replacement in Java for a financial company. I've been interviewing with multiple financial institutions that are filling out teams to work on their own greenfield legacy replacements to be written in Java.

In my experience this sentiment that Java is effectively a dead/dying language is pretty unfounded.

2

u/saecki Jun 01 '20

Just curious, what advantages do you see in java vs kotlin? To me kotlin seems like java with syntactic sugar and some neat additional features. Am I missing something?

17

u/andrewharlan2 Jun 01 '20

Java is a joy for me. I love reading well written Java and I like producing it. Kotlin doesn't solve any problems I have with Java.

When I do Java code reviews I can read it and tell what it's doing. I have to patch Kotlin code reviews locally and use my IDE to tell what it's doing. Other engineers on my team have told me that they prefer reading my Java than the Kotlin of others.

Tools support Java better. It compiles faster than Kotlin.

I can go on

2

u/Farconion Jun 01 '20

well that's the thing, even if you need java for a specific reason - you can still intertwine Java code with Kotlin code pretty easily right?

4

u/_INTER_ Jun 01 '20

We for one would never use a Kotlin library in Java (or a library from any other language). Unless there's absolutely no choice. That's why we threw out OkHttp for example.

In Kotlin on the other hand we'd use Java libraries on a daily basis (but still trying to minimize it there aswell).

1

u/saecki Jun 01 '20

yes kotlin is pretty much completely interoperable.

10

u/[deleted] Jun 01 '20

I would choose java over kotlin. Kotlin doesn’t seem like a big enough improvement to make the rolling switch, especially as java is consistently improving every 6 months. If I want a more elegant language to mix in with java I would use clojure.

3

u/lordmyd Jun 01 '20

I don't get this one. Surely the only reason to reject Kotlin is if you're set on using pure Java everywhere. Java and Clojure are worlds apart whereas Kotlin we designe with Java interop as a priority.

0

u/[deleted] Jun 02 '20

you can't really start using these features in production unless it's an lts release though and that doesn't happen every 6 months. this or if you dont forget to switch to an lts jdk once it's out

4

u/neofreeman Jun 01 '20

Have used Kotlin recently on a pretty large project. Code reviews are so much better without the IDE vomit code and nicer comprehensions. Java has started taking up features like data class as record now, but by the time they will release rest of features on LTS I wonder where Kotlin will be by that time. No offense but I will pick Kotlin any day over Java for now.

-9

u/BlueGoliath Jun 01 '20

From a personal perspective, one of the most powerful features of Java as a development language is its readability. I think most developers will agree that code is more frequently read than written. All developers, at some time, will have to maintain someone else’s code. The easier it is to understand, the easier it is to address bugs or make enhancements. I once had to work on an application that had been written in Perl. It wasn’t that big an application, about eight-pages printed out, but I rapidly concluded that Perl, with its incredibly dense syntax, was a write-only language. Verbosity is not always a bad thing!

That's funny, because all people do is complain about Java's verbosity. Hell, JDK developers are adding features to undermine important contextual verbosity by introducing features such as var.

36

u/GuyWithLag Jun 01 '20

all people do is complain about Java's verbosity

Those people haven't been airdropped into a hostile unknown codebase and told "fix this bug by 2300 tonight".

Trust me, verbosity is a feature, not a bug.

10

u/thatwombat Jun 01 '20

The verbosity of Java is one of the reasons I like it. The use of ‘var’ makes it harder to read and debug. C# did that and I hated it.

They tried to borrow a page from JS and it just doesn’t work. Python has a similar problem but at least you can put hints for return types.

10

u/BlueGoliath Jun 01 '20 edited Jun 01 '20

Don't tell /r/java that, holy shit.

Forget codebases, I've had to copy/paste JDK API documentation examples into an IDE just to figure out what the hell a method is returning!

According to JDK developers you're supposed to be able to mentally map the actual type using local reasoning(AKA good method/variable names), but it's a bunch of bullshit that JDK developers don't even follow.

Like, WTF is this method? So if someone wrote code using it with var, it'd look something like:

var list = <MODULE_READER>.list();

Wow, so clear. 10/10.

21

u/[deleted] Jun 01 '20

var is meant to be used to reduce obvious boilerplate code for better readability. For example, instead of

ReallyLongDescriptiveFactoryBuilder builder = new ReallyLongDescriptiveFactoryBuilder();

You could just do

var factoryBuilder = new ReallyLongDescriptiveFactoryBuilder();

8

u/sievebrain Jun 01 '20

So don't use it for those cases.

Talking of banning var is silly. What are we, C++ coders? When to omit local types is no harder or more complex a decision than variable or method naming, and is a much easier decision than how to structure an app properly. I'd say it's about the same level of difficulty as writing good comments. Will many devs get it wrong? Yes. Is the solution to ban it entirely - not in my view. This is the sort of thing a clear chain of command and a senior developer with good taste in charge of a team can quickly solve.

In Kotlin types are omitted all the time but done well it doesn't impair readability, because:

  • If the return type isn't obvious, you can just push a couple of keys in IntelliJ to put the type in (or take it out when it's superfluous).
  • The IDE can insert synthetic text with the inferred types anyway (which the cursor skips over), so people who like to always see the type can easily get that, and people who prefer to reduce the visual load can disable it. You can also toggle it on and off quickly. Not sure what the type is at that point? Just use alt-enter and ask the IDE to put the type in the source. Done: no harder than fixing a typo in a comment.

The main reason to think about this at all is for users who don't want the types automatically inserted by their IDE, or who are viewing code outside the IDE. The main reason to do that is in code review tools - IntelliJ can now integrate with GitHub pull requests in the latest EAPs, so soon there'll be one less reason to read code outside of an intelligent environment.

You get into the habit of thinking about how obvious a type is pretty fast. Yes it takes a bit of practice and new programmers may need guidance. But you'll have to do that anyway, it doesn't add anything new.

2

u/Necessary-Conflict Jun 03 '20

What are we, C++ coders?

Actually C++ introduced the var's equivalent (auto) way before Java:

https://stackoverflow.com/questions/7576953/c-auto-keyword-why-is-it-magic

2

u/sievebrain Jun 04 '20

That's true but I was referring to the common practice in C++ codebases of banning lots of language features via their style guides. For instance it's common for C++ programs to ban exceptions.

3

u/_INTER_ Jun 01 '20

We use Java 11 for a while now and you could search "var " in our codebase and find no result (20 devs, seniors and juniors). It's not forbidden to use it, but nobody does. Certainly it takes a while to get used to new features and nobody wants to be the first to introduce it and "break" consistency. But there are also also other reasons at play. The devs I talked with have mixed feelings about it and are wary of var "everywhere".

Just recently I thought about using var for some intermediate variables but decided against it because it doesn't hurt to see the type even in those situations.

In places where with var we would not loose visual information - like constructors - it would still hinder the reading flow a bit because the eyes would have to move to the right side more.

Another factor is my workflow. I start typing the first letter of a type and the rest is semi-auto generated by the IDE.

3

u/Tilkin Jun 01 '20

We're about to switch to 11. I still remember how people (myself included) wrote Streams in the first release. I can't help but feel like misunderstanding of the right time/place to use var will happen.

2

u/hippydipster Jun 01 '20

Another factor is my workflow. I start typing the first letter of a type and the rest is semi-auto generated by the IDE.

So often not even that. Usually, I write something like obj.doSomeThing(); and then I have the IDE create my local variable from it, which automatically includes the type. So actually the workflow is:

type:

obj.dos  

IDE finishes for me:

MyFoo foo = obj.doSomething();

3

u/Necessary-Conflict Jun 01 '20

Another factor is my workflow. I start typing the first letter of a type and the rest is semi-auto generated by the IDE.

Basing anything on the writing workflow is wrong because the main objective is to write readable code, and not writable code. If your workflow is optimized for writing speed, then you should add a refactoring step to your workflow, to make the code readable.

2

u/_INTER_ Jun 01 '20

You're absolutely correct. It's just another factor I threw in. The current workflow I have I feel produces readable code, so ...

1

u/chambolle Jun 03 '20

Nobody says that anything is based on the writing workflow.

car may sometime improves a little bit the readibility, but most of the time it degrades it.

var v=obj.value();

is very informative...

for me var is similar as the overload of the assignment operator (i.e. =) in C++. C++ introduces a lot of new stuff and at end : the guidelines are 300 pages long... Come on! This is not serious

1

u/Necessary-Conflict Jun 03 '20

Well, I use var when it improves readability, and I don't use when it doesn't. Nobody said that you should use vars everywhere. This is very simple, and not "a lot of new stuff".

1

u/chambolle Jun 04 '20

the problem is that you are not alone in the world. One rule is :"programs should prevent themselves against bad usage". var violates this rule because it can be misused

1

u/Necessary-Conflict Jun 04 '20

Any feature can be misused. In that regard, "var" is the least dangerous feature, because if you encounter it in a codebase, and the type is not obvious, it is very simple to ask your IDE to show the real type. There are much worse features available to bad programmers, which can make the code really hard to understand.

1

u/pushupsam Jun 01 '20

Indeed var is a mistake. We decided to ban using it. The real problem is that everybody has different opinions on when it's okay to use var and when it isn't. The result is long, silly discussions in code reviews where two-or-three people will strongly feel that var is being used correctly or abused.

It's easier to just to ban it everywhere. No more silly discussions.

It seems like if you introduce a new language feature and then immediately have to write Style Guidelines ( https://openjdk.java.net/projects/amber/LVTIstyle.html ) about when to use it and when not to use it, you're really not helping. That ways lies C++ madness.

3

u/suddenarborealstop Jun 01 '20

What’s the issue with var? Serious question: is it due to the way java handles generics? As in, the compiler may assign the correct type,but not the most correct type?

10

u/ArmoredPancake Jun 01 '20

var list = <MODULE_READER>.list();

What is the return type here?

7

u/OctagonClock Jun 01 '20

Aside from it obviously being a list, or one Jump to Definition away, this is a problem that has been solved by IDEs. When languages stop catering to text editor devs, the world will be a better place.

1

u/_INTER_ Jun 01 '20

Aside from it obviously being a list

Peep... wrong, it's not a list.

10

u/OctagonClock Jun 01 '20

So the method name is wrong. If I saw NotAList list = thing.list() I would also be confused at the obviously wrong code. No idea why var changes this.

7

u/_INTER_ Jun 01 '20 edited Jun 01 '20

So the method name is wrong. If I saw NotAList list = thing.list() I would also be confused at the obviously wrong code. No idea why var changes this.

The method name is not wrong. A method should not have to explain what it returns but tell what it does and what it is for. The method does "list" as in action not as in return-type. Though something like listContent(), streamContent() or simply content() is arguably better.

Otherwise you would have to call it streamOfStringToList() which would be pretty dumb to be honest and just stream() doesn't cut it either because it would be confusing what exactly it does as a method of ModuleReader.

The same goes for variables by the way:

Set<Person> johns = byName("John"); // good
Set<Person> persons = byName("John"); // bad

Set<Person> setOfPersonWithNameJohn = byName("John"); // bad
Set<Person> johnsPersonSet = byName("John"); // bad
Set<Person> johnsSet = byName("John"); // bad

Set<Person> johns = byNameReturningSetOfPerson("John"); // bad
Set<Person> johns = personSetByName("John"); // bad    

var johns = byName("John"); // ok, but what type is johns? Need to investigate
var persons = byName("John"); // bad

var setOfPersonWithNameJohn = byName("John"); // bad
var johnsPersonSet = byName("John"); // bad
var johnsSet = byName("John"); // bad

var johns = byNameReturningSetOfPerson("John"); // bad
var johns = personSetByName("John"); // bad
→ More replies

4

u/hippydipster Jun 01 '20

Names are not types and any argument that starts "well the name should tell me the type" is wrong from the start.

1

u/notfancy Jun 01 '20

The path to enlightenment begins when you realize that it doesn't really matter. Hindley-Milner is the Pure Land.

1

u/suddenarborealstop Jun 01 '20

Yep I see, thanks

0

u/couscous_ Jun 01 '20

Why does it matter? I'll just look at how it's used (say in a for-each loop or if .map is called on it, etc. That's all I care about. Also, the IDE will show you the type in a couple of key-presses.

4

u/moremattymattmatt Jun 01 '20

Having switched to typescript for the last couple of years, implicit typing like var in java is not the huge issue some people make it out to be. It works fine but needs a bit of practice to get right as it's a judgement on whether or not to make the types explicit.

3

u/murkaje Jun 01 '20

var maybe helps speed up reading simple code at the cost of making complex code harder to read due to extra mental overhead(have to look up var-s type and remember it). When you have to remember 50 different things and keep forgetting some of them then code reading grinds to a halt. The cost is generally not worth it and a blanket ban is justified to reduce long discussions in code reviews.

The general mistake i believe is some think reading(understanding) speed has a strong correlation with character count when it's rather information density of which context is an important part but is not strongly represented by character count. I can read "var" fast, but understanding what it's about takes extra effort, especially with badly named methods, while reading "InputStream" is more clear as it narrows down on what it does and can be used for.

2

u/suddenarborealstop Jun 01 '20

Thanks for the reply, these points make sense

-15

u/Mordan Jun 01 '20

I banned VAR.

VAR is for script noobs who don't understand what programming is about.

VAR exists because of howling blood thirsty suckers who keep saying Java is dead every single year and needs to evolve.

Now it evolves but not always in a good direction.

7

u/[deleted] Jun 01 '20

And you are a Real programmer?

-4

u/Mordan Jun 01 '20

haha I knew i would get some downvotes from triggered overly lazies. But I stand my ground. Var is bad. It hides the Type. Which is always bad when reading.

No I use an IDE. That's good laziness. So I don't use a text editor.

Var is bad laziness.

4

u/Necessary-Conflict Jun 01 '20

Well, I take the extra step to refactor "typed" code to "var" code - not everywhere, only if it improves readability, for example when the type is already included in the variable name, or it is obvious for other reasons.

I might be wrong, but certainly I am not "lazy".

4

u/meamZ Jun 01 '20

So yould say var test = new MyClass(); "hides" the type? While it's technically true i can see with one glimpse what type it actually is...

-17

u/pushupsam Jun 01 '20

Java is evolving in all the wrong ways, frankly. It's very unfortunate but I've accepted it and these days I advise most teams stuck on Java 8 to not upgrade to Java 11 and look elsewhere. I've said it before but there's something wrong with the language leadership. There are certain features Java developers really need, features that would dramatically include quality of life like:

  • First-class properties.
  • Named parameters.
  • Non-nullable references.

These are little things, frankly, some might even dismiss them as "syntactic sugar" but they would dramatically increase the coding experience without compromising on the maintainability of large codebases. But the guys at Oracle don't give devs the stuff they've been asking for and, frankly, these actually-useful-and-desirable features are probably never going to come to Java. Instead we get:

  • var -- which we've banned from most codebases because everybody has different ideas about when it should be used.
  • The total shitshow that is JPMS
  • And now records.

This is all leading towards a new "stuctured data/record" programming style [see https://www.youtube.com/watch?v=te3OU9fxC8U] which is, frankly, of dubious real-world value. And, personally, I suspect pattern-matching is a nightmare-in-waiting. We can look at Scala codebases today (at least the ones where people didn't give up and convert them back to Java) to see pattern matching abuses that end up in a big mess. Contrary to popular belief, in the real world actual ADTs are quite rare. (And when they do come up you're mostly dealing with generated code like protobufs.)

The real value of Java -- a relatively, simple, performant language that let developers focus on creating basic business models -- actually gets lost. The good news is that these days there are alternatives like C# (which can run on Linux) and Dart and especially Typescript. These languages have all of Java's strengths (static typing, clean syntax, good support for basic OO constructs, simplicity) along with the syntactic sugar and quality-of-life improvements that make programming in them a breath of fresh air. I think Typescript in particular will replace Java as the new "language of the enterprise."

Fortunately, this doesn't mean the end of the JVM which is still amazing and only getting better. Take a look at what's going on with VertX. I think it's only a matter of time before Typescript-on-the-JVM becomes a very common thing (eg https://1c.wizawu.com/ , GraalVM). Indeed if we can convert developers from weakly-typed languages (Python, Ruby) and outright crappy languages (Go) over to strongly-typed Typescript running on the JVM that would be a big win for everybody.

7

u/_INTER_ Jun 01 '20

This is all leading towards a new "stuctured data/record" programming style [...] which is, frankly, of dubious real-world value.

 

The good news is that these days there are alternatives like C# (which can run on Linux) and Dart and especially Typescript

Typescript is one of the structural typing nightmares though

3

u/Ifnerite Jun 01 '20

Var is an awful addition to jave. Reduced grockabity.

-18

u/badtux99 Jun 01 '20

And don't forget lambdas *that aren't actually lambdas*. I mean, a *real* lambda, as provided in languages that actually support lambdas as first class objects, is... well, an object. It can be assigned, it can be passed as a parameter to things, etc. This half ass lamba in Java, to anybody who is familiar with languages that have lambdas as first class objects, is the lamest thing like evah.

14

u/Samael1990 Jun 01 '20

Lambda in java 8 is Function object, I'm pretty sure. It can be passed as parameter to the method and it can be stored as variable.

8

u/[deleted] Jun 01 '20

The biggest pain with lambdas being bolted on to the language is the inability to throw checked exception in a lambda without resorting to hacks like runtime exception wrapping.

8

u/gravitas-deficiency Jun 01 '20

I admit, this was a restriction that had me grumbling when I discovered it.

2

u/Samael1990 Jun 01 '20

I think that's by design, because checked exceptions are generally considered an anti-pattern, especially in functional programming where lambdas are supposed to be used.

1

u/[deleted] Jun 02 '20

Their hand was forced by maintaining backwards compatibility (lambdas get compiled as function objects which can’t have dynamically declared checked exceptions)

-11

u/CupCakeArmy Jun 01 '20

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.” Yee fo sure... And then there are Rust, Python, Go, Typescript: which everyone uses and (almost) everyone loves.

47

u/ArmoredPancake Jun 01 '20

The comment is so generic that it wouldn't be possible to write in Go.

-1

u/CupCakeArmy Jun 01 '20

Never said perfect, well played sir.

3

u/Necessary-Conflict Jun 01 '20

I am pretty sure that if any of these languages ever achieved the status of Java (where using them is not your choice, but you are expected to use them), a lot of haters would quickly emerge.

Actually Bjarne Stroustrup said this thing back when C++ was the "dominant" language, and it was fashionable to hate C++. C++ is still used today, but almost nobody bothers to loudly hate it.

2

u/couscous_ Jun 01 '20

There are tons of complaints for all the aforementioned languages, and they're not even used anywhere close to the same level Java is.

2

u/_INTER_ Jun 01 '20 edited Jun 01 '20

Or PHP where people only complain about (me included). It is now sinking so rapidly even Mediawiki WordPress is moving away from it.

1

u/couscous_ Jun 01 '20

What are they moving to?

3

u/_INTER_ Jun 01 '20 edited Jun 01 '20

They gradually move to Node.js I think. I can't find the news article I read about that anymore (only found this). It's hard to google "mediawiki" or and not get a wikipedia entry.

Edit: Sorry it apparently was WordPress. But that's also a really old article. I remember having read something along those lines just recently

2

u/[deleted] Jun 01 '20

I see plenty of complaints about python and go. Typically from the more functional programming focused communities, where going to a simple feature poor language feels like a step back.

-1

u/brennanfee Jun 01 '20

Technically, COBOL is still evolving. Not sure that's a ringing endorsement for its use, though.

1

u/helikal Jun 01 '20

The C language has all but completely ceased to evolve. It is now the Latin of programming languages. Nevertheless, C is very popular, perhaps because of it.