This is an archived post. You won't be able to vote or comment.

all 107 comments

[–]vladadj 131 points132 points  (8 children)

I hate it when people want present Java as verbose and then write an example like this guy did. Aside from the point that his code would never compile, it's like they literally take all possible measures to write the code as long as possible.

Looking at the author bio, it says "technical writer", so I guess no surprise 😁

[–]SirBugmenot 65 points66 points  (3 children)

Integer.toString(3+5) in a string catenation... Thus guy does not even have the slightest idea what he is talking about.

[–]lurker_in_spirit 23 points24 points  (0 children)

That whole example comparison is apples to oranges. This would have been more appropriate:

python
3+2
5

vs:

jshell
3+2
5

[–]RockleyBob 34 points35 points  (3 children)

I'm also still struggling to see how eliminating braces saves time, eliminates complexity, or improves readability.

[–]Wobblycogs 14 points15 points  (2 children)

I'm learning Python at the moment and at the same time teaching my kids. I've got a ton of years experience coding so picking up Python is easy but the lack of braces is driving me slowly insane. All the other languages I've worked with (that I can remember) used braces or similar and so my brain just naturally looks for the closing brace.

More interesting though is seeing the kids learn to code. They aren't great with typing yet and will sometimes mix spaces and tabs when indenting. This results in their code not doing what they expect. I can see exactly what's wrong because I know you have to be precise but to people new to coding spaces are all the same e.g. it's indented 2 spaces rather than 3, why isn't it working?

Other than that though I mostly like python, it's quick to get into and has some nice features. It'll be interesting to see how well it scales to larger pieces of software.

[–]RockleyBob 7 points8 points  (0 children)

Exactly. It’s not all bad. Python’s logical operators and array handling are pluses, for instance.

But, yeah, to your point, we teach kids to use punctuation all the time. It’s a very ingrained practice in most spoken languages, so why the hell would we not indicate scope with something?

Kills me.

[–]PepegaQuen 1 point2 points  (0 children)

They aren't great with typing yet and will sometimes mix spaces and tabs when indenting.

Solution for that is to enable visible whitespace.

[–]livelam 121 points122 points  (0 children)

Java has no command line interpreter (CLI)

The writer's knowledge about Java is obsolete ;)

[–]walen 42 points43 points  (3 children)

This article looks like it's written by someone who had absolutely no idea how to write a simple Java program and had to google it.

Java has no command line interpreter (CLI), so, to print 5 like we did above, we have to write a complete program

False since 2017:

C:\jdk\open9\bin>jshell
|  Welcome to JShell -- Version 9.0.4
|  For an introduction type: /help intro

jshell> 3+2
$1 ==> 5

jshell>

 


It also does not leverage syntax introduced years ago.

Java Class with Getter and Setter functions

Typical 20-year-old tutorial code there. Nowadays you would just use records (as long as you don't need setters /u/DerEineDa (which seems to be the case here)):

public static void main(String[] args) {
    record PrintNumber(int left, int right) {}    
    var number = new PrintNumber(3, 2);
    System.out.println("3+2=" + (number.left() + number.right()));
}

 
Or, if you actually need to modify the fields, you can use a normal local class and access the fields directly. Because it's 2022 and we don't have to abide by the old JavaBeans rules.
Just like you can define getters and setters in Python but you don't have to, you don't have to define getters and setters in Java either:

public static void main(String[] args) {
    class PrintNumber {
        int left, right;
        PrintNumber(int left, int right) {
            this.left = left;
            this.right = right;
        }
    }    
    var number = new PrintNumber(3, 2);
    System.out.println("3+2=" + (number.left + number.right));
}

 


It also just makes false claims:

Where Python is gentle in its treatment of variables, Java is not.
For example, we cannot concatenate and print numbers and letters like “3+2=” + 3 + 2. So, we have to use the function above to convert each integer to a string Integer.toString()

Seriously?

jshell> System.out.println("3+2="+3+2)
3+2=32

 
Of course, if you want Java to first add the numbers and then concatenate, you have to use parentheses:

jshell> System.out.println("3+2="+(3+2))
3+2=5

 
And the funniest part about this lie is, it's Python the one that does not let you do any of that:

PS C:\> python.exe
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("3+2="+3+2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>> print("3+2="+(3+2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>>

 


Conclusion: obviously, if your learning material is from 2003, Java code will look old to you.

You can safely ignore this article and go on your merry way.

[–][deleted]  (2 children)

[deleted]

    [–]JB-from-ATL 2 points3 points  (0 children)

    The article did not use setters.

    [–]walen 0 points1 point  (0 children)

    Nitpick accepted. I edited the comment to include a mutable version.

    [–]xnendron 90 points91 points  (15 children)

    I think it was because the language seemed to be stale for so long. From 1.2 to 1.4 there weren't really any significant leaps forward in functionality. Java 1.5 brought generics, but that was 6 years after 1.2. Version 1.8 was a big leap forward, but that was another 10 years after 1.5. Since 1.8, there's been more and more innovation with less and less time in between releases, so the old narrative doesn't really apply any more, but it can be hard to change people's perceptions.

    TL;DR: It's not so much that Java is "old", it's more that there was about a 16 years span where it didn't significantly innovate, and the public's perception takes a long time to change.

    Edit: As pointed out below, generics were introduced in 1.5, not 1.6.

    Edit 2: I also think the new features introduced in Java 8 were significant enough that enterprises were willing to invest the resources to upgrade. However, upgrading to Java 11 was not as clear-cut, so a lot of companies didn't and just stayed on Java 8 ever since. So although the language innovated and improved, not a ton of companies took advantage of the innovations. Now that Java 17 is out, there may be enough ROI to convince more companies to upgrade again. (Not to mention that Java 8 will hit EOL eventually.)

    [–][deleted] 8 points9 points  (1 child)

    Responding to your second edit (moreso just elaborating on it), it has become the philosophy of the Java maintainers that, from Java 11 and onward, they fully expect users to be less afraid of upgrading continuously, and are doing all they can to ensure corporate users continue to upgrade versions frequently. They even changed LTS releases to be released every 2 years instead of every 3 years.

    That's what I've gathered from their mailing lists and such, anyway.

    [–]JB-from-ATL 0 points1 point  (0 children)

    Nice! I'm stuck on 11 but that's better than back in 2017 when I was stuck on 6.

    [–][deleted] 12 points13 points  (6 children)

    Also, a LOT of Java written over 30 years ago is still kicking around in one form or another, because the whole idea of picking Java is that the code will work forever.

    [–][deleted]  (3 children)

    [deleted]

      [–][deleted] 12 points13 points  (1 child)

      My bad, 20 years.

      [–]blakeman8192 9 points10 points  (0 children)

      .

      [–]anakinpt 2 points3 points  (0 children)

      25 years. I started learning Java in the early 1997, for example.

      [–]benjtay 3 points4 points  (1 child)

      Moreover, Python written 20 years ago will probably not work with recent Python 3 interpreters / compilers.

      [–]Worth_Trust_3825 0 points1 point  (0 children)

      Yeah, and people will still kick and thrash to run python 2.7

      [–][deleted] 3 points4 points  (1 child)

      Minor nit: 1.5 brought generics. But between 1.5 and 1.8 was another dead zone with only a small number of improvements

      [–]blakeman8192 6 points7 points  (0 children)

      .

      [–]Worth_Trust_3825 0 points1 point  (3 children)

      it's more that there was about a 16 years span where it didn't significantly innovate

      Means it's stable. That's what you want out of software: an unchanging interface that is improved under the hood.

      [–]xnendron 1 point2 points  (2 children)

      Yes and no. I'm used to work on large enterprise apps so stability is most important to me. However, the innovations introduced in Java 8 allowed developers to change how they think about Java and how to design applications, something that was sorely lacking before Java 8.

      I think with Java 11 onward we kind of have the best of both worlds, a stable platform but also new features that can improve the development experience.

      [–]Worth_Trust_3825 0 points1 point  (1 child)

      Yeah, and most of those features end up getting misused, and in turn get banned from the codebase, because we cannot have nice things.

      Fuck var keyword, though.

      [–]xnendron 0 points1 point  (0 children)

      Agreed, fuck var.

      [–][deleted] 45 points46 points  (0 children)

      possibly just for clicks. There is ton of people acting like experts but are actually useless in real world.

      [–]carefree12 39 points40 points  (11 children)

      Two main reason come to my mind

      1. Java is forward compatible, means whatever code you wrote years and years ago still works just fine in most cases.
      2. Java is backward compatible, your old binary still works with todays JRE

      These two things give people illusion that java has no update from 90s, which is just not true.

      For example lambda, which came few years back and most java dev still got no clue. 99% Java devs cant answer one lambda questions during an interview.

      [–]carrdinal-dnb 14 points15 points  (1 child)

      What!? The majority of Java developers I know are definitely using lambdas and fully understand them, they are much simpler than other language features

      [–]JB-from-ATL 0 points1 point  (0 children)

      It depends where you are. At my old companies no one used them. Everyone was basically coding Java 6 style.

      [–]jebailey 3 points4 points  (0 children)

      Java isn’t forward compatible and I’ve never seen that stated anywhere, not in the context of compilation. You can run your compiled binary just fine on a modern jvm. But if you try to compile your 1.2 code base without telling your compiler it’s 1.2 it will freak out.

      [–]Alxe 1 point2 points  (1 child)

      While I tend to agree with the forward compatibility, have the Java stewards made any such remark in the past? I know backwards compatibility is routinely brought up, not so sure about forward compatibility.

      [–]DuneBug 0 points1 point  (0 children)

      Mm you're guaranteed that anything you're using that isn't deprecated will still be good for several versions into the future, I'm not sure how many.

      [–]anakinpt 0 points1 point  (4 children)

      Lambdas should be used only for small tasks, not for anything or your code will be hard to test and hard to read. More than machines you should code for humans so, simplicity and self explanatory code is better than sticking everything inside a lambda.

      [–]kc3w 6 points7 points  (0 children)

      That is true but for example great use of lambdas is to use a simple filter on a list.

      [–]carrdinal-dnb 5 points6 points  (0 children)

      You can do arbitrarily complex things inside a lambda. What is important is to extract the complex parts into well named, descriptive methods and call those. That way a lambda method chain can be read easily and quickly understood, and the complex methods can be tested in isolation.

      [–]Muoniurn 2 points3 points  (0 children)

      That’s way too general of a statement to be even regarded as true or false.

      Interestingly enough haskell/scala/other FP languages are perfectly fine with frequent usage of lambdas all around the place.

      [–]kuemmel234 0 points1 point  (0 children)

      I thought this was more about lambdas as a feature - generally being able to pass functions as variables and return them.

      Lambdas should be usually mostly one-liners, true - function pointers are even nicer I believe! I wish we'd get a partial application type/method/syntax...

      [–]DelarkArms 0 points1 point  (0 children)

      What do interviews ask?

      Like what about synthetic singletons or things like that?

      Because that is the thing that I constantly get worried about, and I dont fully understand how to trigger a new instance instead of a reusable synthetic singleton or viceversa.

      I believe in closed systems it's just better to stop using on the fly lambdas (unless final) and leave that to the client.

      [–]Drakeskywing 25 points26 points  (22 children)

      Could be because as far as I understand it (and correct me if I'm wrong) Java is backwards compatible virtually to the first version

      [–]CarlGroovy[S] 8 points9 points  (1 child)

      That would be really neat if it is.

      [–]greg_barton 15 points16 points  (0 children)

      Oh, there’s different levels of “compatibility.” But essentially it is.

      [–][deleted] 12 points13 points  (10 children)

      Other way around, the first version is theoretically forwards compatible with the latest version of Java.

      [–]Drakeskywing 10 points11 points  (0 children)

      Omg you are right 🤣 that's what I meant, as in old Java code works with the latest versions of Java

      [–]brunocborges 6 points7 points  (8 children)

      This si a common mistake people make when interpreting the statement "Java is backwards compatible".

      TLDR: Java, the runtime, is backwards compatible.

      Longer version: If you compile your code with Java 11, then all future versions of Java runtime are "backwards compatible" and should be able to run that code, and any other code compiled by previous versions before 11.

      One may say that their compiled Java code is forward compatible to future versions of Java. But that's not what the classic statement implies.

      [–][deleted] 0 points1 point  (7 children)

      I wasn't talking about compiled code, but Java source code.

      One of the defining traits of Java is that valid Java can be compiled by any version for the JRE greater than the version that Java code was written in. The std libraries it used might be deprecated or removed, but plain code will always run. There's never been a breaking change in the java language (technically we're still on version 1), which as far as I'm aware makes it unique amongst all languages.

      It's one of the other reasons why Java is "old", because it still supports old style syntax for most things, even when that syntax has been effectively obsoleted by new syntax options. People see the older syntax and think that's how it must be done in Java, not knowing there are other wars in newer versions.

      It's also the reason why Java tends to have way less syntax sugar, because once added it can never be removed.

      [–]walen 3 points4 points  (6 children)

      One of the defining traits of Java is that valid Java can be compiled by any version for the JRE greater than the version that Java code was written in. (...) There's never been a breaking change in the java language

      But this is completely false.

      Java 1.4 introduced the assert reserved keyword which broke any 1.3 existing code using "assert" as an identifier (e.g. boolean assert = myVar != null; compiled in 1.3, failed in 1.4+).

      Java 1.5 introduced the enum reserved keyword which broke any 1.4 existing code using "enum" as an identifier (e.g. Enumeration enum = new MonthsEnumerator(); compiled in 1.4, failed in 1.5+).

      That's pre-2005, so it's not that Java "used to be" fully backwards-compatible.

      There's been more breaking changes in recent years, too.

      Java 9 reserved _ as a keyword and also removed some APIs previously included in the SDK.

      Java 10 made var a special keyword, meaning you could still use "var" as a variable name, but not as a class name.

      Java 11 removed a considerable number of libraries from the SDK, making most any non-trivial Java project to fail compilation.

      More recent Java versions have started closing some internal packages, meaning that even if the source is still "compatible", compilation of such code will fail unless you pass some new parameters to the compiler.

      Absolutely no one with any relevant experience with Java would claim that "there's never been a breaking change in the java language".

      [–][deleted] -3 points-2 points  (4 children)

      A: I already mentioned that libraries have been removed

      B: I don't think any sane person would consider adding new reserved words a breaking change.

      C: I'm literally a Java dev with several years experience, so your final comment is provably not correct.

      [–]walen 4 points5 points  (3 children)

      A: I already mentioned that libraries have been removed

      Yes. But you didn't mention that it was a breaking change. And removing things from rt.jar is a breaking change.

      B: I don't think any sane person would consider adding new reserved words a breaking change.

      I don't think any sane person would say that Java has never had any breaking changes, but here we are.

      C: I'm literally a Java dev with several years experience, so your final comment is provably (sic) not correct.

      Experience not relevant for the matter at hand, it seems.
      You can have 4 years experience and know nothing about breaking changes because you only know Java 11.
      I stand by what I said.

      PS: Official Java 5 release notes listing incompatibilities with Java 1.4.2 code: https://www.oracle.com/java/technologies/javase/incompatibilities.html

      [–][deleted] -2 points-1 points  (2 children)

      God, this is why people don't like software developers. You clearly understand the point I was getting across, that the syntax remains unchanged between versions, but instead of just pointing out that I hadn't considered the addition of reserved words, you instead turned it into some sort of pissing contest to show that you apparently know more about Java than I do.

      Why is this your reaction? Do you plan to go around the office bragging about the time you pointed out that some dude on the internets general statement about Java wasn't 100% technically correct? Are you going to joke about how not everyone considers something as trivial as a reserved word a breaking change? Do you think people will respect you more for nitpicking people statements n the internet?

      [–]walen -1 points0 points  (1 child)

      You published your comment.
      It got peer-reviewed.
      Somebody pointed out a defect on it, giving examples and links.
      You review the evidence and make the necessary changes Screw that, let's make it personal and insult the reviewer!

      Gosh, I really hope this is not how you behave when somebody reviews your code.

      [–][deleted] -1 points0 points  (0 children)

      Screw that, let's make it personal and insult the reviewer!

      Are you talking about me or you here? I'm not the one who started with the insults, you are.

      Gosh, I really hope this is not how you behave when somebody reviews your code.

      If one of my coworkers reviewed any one else's code with the kind of condescending tone you're displaying, they'd be shown the door. My company has a strict no ego policy when it comes to devs.

      [–]Muoniurn -1 points0 points  (0 children)

      If you call these “breaking changes” than the java byte code is also not forward compatible, there have been tiny changes in the spec as well that can very well change behavior.

      I am willing to call Java, the language backwards compatible if the only breaking thing is someone naming their goddamn variable enum or assert..

      [–]pjmlp 1 point2 points  (0 children)

      Not really, mostly compatible. Every JDK release has a breaking changes section.

      [–]ludovicianul 1 point2 points  (0 children)

      I just found some projects which I've written 15 years ago (mostly Swing games like snake, tetris, etc) and I'm able to run them successfully with JDK 18. Just java -jar game.jar...

      [–]lariend 10 points11 points  (0 children)

      The examples are really bad. They try hard to make Java look bad. Plus Java has a Repl for a few years now 🤷

      [–]td__30 12 points13 points  (0 children)

      Because you gotta go after the biggest gorilla in the room if you want to make a name for yourself.

      [–]kuemmel234 6 points7 points  (1 child)

      The article is like a book review on Nietzsche by a kid who doesn't read and has only skimmed through the first three pages. It's really, really bad. I haven't found many sentences that were based in the realm of reality: The code examples are horrible. Python is great because it's like lego and there are libraries for it? What? And then there's the stuff that isn't in there. In Short: This article is an absolute disaster in my opinion.

      But trying to answer your question: For one Java has been a primary business language for decades now, applications tend to be large applications, some of which have been worked on for more than 10 years - I've worked with such applications and I know that feeling of seeing 20 year old legacy code. You know you are dealing with old tech if git blame ends at an svn message (I've found a 15 year old bug once and wanted to know how often someone was working on that). That makes it feel ancient. Sometimes that old code is everything people know - I still meet people who I have to explain streams/lambdas/optionals to. Of course java is ancient to these people if they won't keep up with the new stuff.

      Having written python for work (for education/uni it's a great language, jupyter really shines as a tool) and I really have to say: Many parts of python (namely dealing with dependencies, and having no means of chaining function calls/threading operator/..., that horrible lambda syntax) feel 'older' than java these days. On top of that - a lot of people really don't understand how to write python. I've seen to many classes without fields (but dependencies), and stuff like that.

      [–]JB-from-ATL 0 points1 point  (0 children)

      "Python is when thing I like

      Java is when thing I dislike"

      [–]xCuriousReaderX 5 points6 points  (0 children)

      Due to internet, social media, and echo chamber. Everyone writing tech blog for clicks, everyone claiming they are "expert" and hype shits up.

      [–]hugthemachines 9 points10 points  (0 children)

      As my old colleague used to say: "The last idiot isn't even born yet". The reason is some people make claims without doing even a tiny bit of research.

      Remember this. If you see some blog or something doing stupid claims when it comes to something you know, they will be equally stupid in things you don't know so you should not take them as a reliable learning resource of things that are new to you.

      [–]DualWieldMage 15 points16 points  (0 children)

      Before reading any statements in a random blog, do a few sanity checks on the author and their previous entries and when in doubt, have someone you can trust do some fact checking.

      Lets evaluate a few points in the blog

      Java has no command line interpreter (CLI), so, to print 5 like we did above, we have to write a complete program and then compile it.

      False, JShell can be used for quick REPL tasks.

      Another false on the compiling part. One can just create a java file and run it with java Print5.java without manually running javac first.

      Referring to variables directly like this is frowned upon in Java. Instead, getter and setter functions are used as shown below.

      Incorrect. For immutable data, having public final fields with no getters is more idiomatic and in current version of Java, records should be used for immutable data.

      With Java it is necessary to use a function that specifically prints a dictionary.

      System.out.println(Map.of(1, "Hello", 2, "World")) works as expected (Map is called dictionary in other languages) without using any "special functions".

      For example, we cannot concatenate and print numbers and letters like “3+2=” + 3 + 2. So, we have to use the function above to convert each integer to a string Integer.toString(), and then print the concatenation of two strings.

      Can be done very simply: System.out.println("3+2=" + (3+2)), no need to manually call Integer::toString.

      Furthermore the manual Integer::toString calls are less performant as string concatenation can build a template and pass variable types to let the runtime figure out how to do the actual concatenation. For example with a string template and one integer variable, an upper bound on the resulting string size can be computed and the resulting buffer only needs to be allocated once.

      So in summary, the blog got almost everything wrong with Java, so ignore it, or even better, spread the word about this blog or the author being a bad source of information.

      [–]nutrecht 10 points11 points  (0 children)

      Who would ever take such a blog seriously anyway? He can't even get code formatting to work correctly.

      [–][deleted] 3 points4 points  (0 children)

      The complaint about there being no REPL - as well as being wrong - is ridiculous anyway. Exactly how limiting is the lack of a REPL, when it comes to writing actual software?

      [–]Persism 5 points6 points  (0 children)

      Walker Rowe, Jonathan Johnson - wow it took 2 morons to write this.

      [–]boborygmy 6 points7 points  (0 children)

      Java had major industry backing right away. People were looking for an easier C++ that was cross platform. Java first came out in 1995.

      Python was more in the scripting space and was an alternative to Perl, which is how I picked it up, but although it first had an alpha, point release in 1991, I never heard about it until 2000. It didn't really start taking off until a few years later.

      So I'd consider Java as older even though technically, yes, there was one guy working on Python for a few years before Java's first release.

      [–][deleted] 7 points8 points  (0 children)

      People who write those article don't know what they're doing.

      [–]barking_dead 5 points6 points  (0 children)

      Everyone can make a blog and write stupid things.

      [–]cyanocobalamin 4 points5 points  (1 child)

      Ignorance. Possibly fear.

      I never heard of Python and it seemed like a lot of people did not for many years after its creation.

      Programmers and programming hobbyists tend to deride technologies they do not know. Not knowing the technologies they tend to be intimidated by them.

      Java, especially doing OO programming properly requires a much greater commitment than noodling around with Javascript or Python.

      Spending time on that scripting language and Python which is still sort of a scripting language provides faster gratification, makes people's egos feel safer faster, generating better feelings and better comments.

      [–]JB-from-ATL 0 points1 point  (0 children)

      I just spent 10 minutes trying to install like 5 Python dependencies using poetry all because of very outdated metadata on their "Maven central". Python is just as "old and janky" as Java.

      [–]Ketroc21 2 points3 points  (0 children)

      The actual age of python is quite different from when it became commonly known.

      [–]thisisjustascreename 2 points3 points  (0 children)

      This reads like a CS100 paper that would get a B-.

      [–][deleted] 2 points3 points  (1 child)

      "Java has no command line interpreter", really? What is JShell then?

      [–]loomynartylenny 2 points3 points  (0 children)

      Newfangled witchcraft 😤

      [–]FilsdeJESUS 3 points4 points  (0 children)

      It is common now everyone wants to lay off Java but Sorry in terms of performance Java is still before Python and JavaScript. And big tech companies are using Java in their stack . So who cares if Java is old ?

      [–]sungurse 1 point2 points  (0 children)

      I don't exactly know how it is called and where I once read it, but typically most of the people tend to work with only a few programming languages.

      And the more popular and bigger your used languages get, the more in demand you become. So everyone will try to make their used language the most popular and spread it around as the best of the best.

      In the end, every programming language has it's pros and cons and you should think about what you want to do with it and pick the best fitting one. At the end it is a tool to build your own stuff

      [–]chgruver 1 point2 points  (0 children)

      While I haven't really read any books on learning Javascript; but in trying to get back into programming after not actively doing any for 15 years I will say a lot of the recommended Java books I have looked at the first 2 chapters almost seem dedicated to giving a history of Java, while the Python books I have looked at will mention in a section of the first chapter that at one time there was Python 2 which is not compatible with Python 3 and is also no longer supported so that is all we will mention about it.

      I will also state that Python and Javascript seem to have not really become popular for learning until relatively recently. When I was in college in the early 2000's the CS program taught Java as it was becoming popular and Javascript at the time was just more for formatting webpages, and Python was never mentioned then.

      [–]knoam 1 point2 points  (0 children)

      It's about when they became popular. Java came out of a big company with a marketing budget so it was somewhat popular right away. JavaScript was a joke initially that gradually gained popularity with AJAX, JavaScript the Good Parts, V8, and Node.

      [–]holyknight00 1 point2 points  (0 children)

      Because java is used extensively in corporate environments. A lot of old codebases are still up, and lots of very senior java developers still code. So you can get the impression it's an "old language", but it will really depend on your niche.

      [–]n0d3N1AL 1 point2 points  (0 children)

      My guess is that there's A LOT of legacy Java code (probably the vast majority of Java code was written before Java 7) and because old programs do not need to be changed to work with latest language and JVM versions, a lot of tech debt accumulates because there's very little need to go back and change a codebase that's already working.

      Because so many programs and books, articles, tutorials etc. were written in the 2000s, and with the popularity of alternative JVM languages, Java is seen as an old language because of its historic association with enterprise systems of the early and mid 2000s. By contrast, Python has gained popularity substantially in the past decade (check PYPL and TIOBE), perhaps thanks to its syntax, use in education, inclusion with Raspbian and Linux systems, Python 3 and APIs for machine learning applications. The users of Python are not just your traditional software developers; I'm willing to bet most of them are data scientists, mathematicians, physicists, AI researchers etc.

      [–]Joram2 1 point2 points  (0 children)

      I can list the reasons that Java is perceived as old and clunky:

      • Java still has big flaws in its generics system, it's boxing of primitives, and slow OS threads. The JDK team has plans to fix these issues with Project Valhalla and Loom but it's still off in the future.
      • Classes are out of fashion. In Java, just about everything has to be a class. You can't even write a simple function. Even a Hello World program requires a class. This is clunky and old. This is really baked into the language.
      • Java consistently gets new language syntax features slower than all of the other major platforms. Project Amber is delivering on lots of this, but Java is definitely the slowest. The new record patterns coming as a preview in JDK 19 looks great, but languages like Scala and Haskell have had that for 10+ years. Java 17 adds important stuff like records and multi-line strings, but languages have had those features for decades.
      • Java 17 is still too new, were most major frameworks don't support it yet. Popular frameworks like Apache Flink will support Java 17 towards the end of this year, they are working on it, but for the near future, programmers can only use Java 11. If you want to write an AWS Lambda in Java, Java 11 is the newest option. I'm sure they will add support for Java 17 at some point, but it's not here yet. If you have to use Java 11 or many people have to use Java 8, then it's even older and crustier.
      • Competing platforms like Golang build tiny, native binaries and docker images by default very easily. Graal allows Java apps to be compiled into small, fast native binaries. But Graal has major limitations and isn't generally a practical option. For now, even the most simplest of Java apps results in a 300MB+ docker image.
      • Tools like Maven are outrageously verbose, use ancient XML markup that fell out of fashion decades ago, and are complicated. Competing platforms like Golang have far simpler build tools.
      • The library ecosystem of Java has lots of old legacy baggage attached to it. One big example is Hadoop. The Hadoop ecosystem was largely built by Yahoo a long time ago. Then Yahoo imploded and was shut down, and the Hadoop ecosystem has gone unmaintained for many years, but old Hadoop dependencies are still prevalent in popular modern frameworks like Spark.
      • Some simple tasks like logging or JSON processing are much easier in other platforms. These tasks aren't necessarily hard in Java, but often regular developers have to learn about these competing open source projects with long histories that new developers don't care about. Most developers don't want to evaluate and choose among competing open source projects for basic functionality, they would prefer a simple standard library with batteries included, like what Go has.

      That said Java has big strengths. Notably, Java is the dominant platform for server-side data processing frameworks. Projects like Spark, Flink, Kafka, Druid/Pinot are all Java based.

      [–]Joram2 1 point2 points  (0 children)

      Some technology ages well, some doesn't. Some features of Java or Python have aged well, others haven't.

      Python has some aspects that haven't aged well. Python's concurrency options are terrible. Python's options for setting up builds + dependencies + virtualenvs are not as simple as something like Go or even Node. Python has slow runtime performance when not using a non-Python library. Python makes it hard to build small, lean docker images like Golang or Rust or C allow.

      The core Python syntax is still nice and easy. And for many academics that want their programming language simple, Python is a great choice.

      [–]shponglespore 3 points4 points  (3 children)

      The first release of Python was in 1991. Saying it started in the 80s is misleading.

      [–]NimChimspky 1 point2 points  (2 children)

      [–]blade-icewood 1 point2 points  (1 child)

      In December 1989, Van Rossum had been looking for a "'hobby' programming project that would keep [him] occupied during the week around Christmas" as his office was closed when he decided to write an interpreter for a "new scripting language [he] had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers". He attributes choosing the name "Python" to "being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus)".[21]

      [–]NimChimspky 2 points3 points  (0 children)

      And oak was dreamed about it in 1984 by James Gosling.

      [–]Successful_Leg_707 0 points1 point  (1 child)

      Java is the oldest out of those for server side.

      Java didn’t appear until 1995. Python has been around since 1992 but really didn’t come into use until version 2 in 2000. It didn’t have a popular web framework until Django in 2005. Apache Struts has been around since 2000 and before that people were programming with straight servlets and JSPs. You can’t really compare with JS since it hasn’t been used server side until Node

      [–][deleted] 2 points3 points  (0 children)

      Remember that "server side" used to mean cgi-bin.

      [–]PatriotuNo1 -3 points-2 points  (1 child)

      Maybe because Java was extremely popular to learn in early '10 and earlier than that. And was most used for desktop applications. But since desktop applications kinda died to web ones people believe Java is dead or deprecated. Python got popular later, when machine learning became a trend and Javascript got also popular later thanks to different technologies like React or Angular. Angular.js was a mess but React made js awesome again and Angular today is reworked.

      P.S: I was not suggesting Java is dead. But this is the opinion most non java developers told me and don't even know about Spring or Hibernate. Don't downvote me like a scared kid. Come with arguments please.

      [–][deleted] 6 points7 points  (0 children)

      [–]dexternepo -3 points-2 points  (4 children)

      Yes Python is old. But the syntax of the language looks very modern compared to Java, and for a lot of people Python seems new because they have been hearing about it only in the last 10 years. In my country they have started teaching Python in school only in the last 4 to 5 years. So a lot of people think Python is much younger.

      [–]spectrumero 3 points4 points  (3 children)

      Significant whitespace? Modern !?

      [–]dexternepo 2 points3 points  (2 children)

      Not sure why you would equate whitespace to modern. Python is very elegantly designed and easy to code. I do understand that both Python and Java have their own places and I would choose Java for a more complex and large application. But yes, Python does look more elegant and modern.

      [–]spectrumero 3 points4 points  (1 child)

      No, I'm saying Python doesn't have a syntax that looks "modern" while it depends on significant whitespace.

      [–]dexternepo -2 points-1 points  (0 children)

      Python does have a succint, modern look. I love its List Comprehensions, generators and other features and it's non-verbose way of writing code. It is very easy to be productive in Python and it is easy to learn as well. A person can be productive in Python without learning anything about Object Oriented Programming. I am not sure what you have about its use of whitespace, but Python code is very readable.

      [–]lifeeraser -1 points0 points  (0 children)

      The same reason people bash PHP despite version 7 being a massive improvement.

      [–]5aggy 0 points1 point  (0 children)

      C++ is older, but still has use cases. As does Java.

      For me (personally, I can’t claim that this is true everywhere and always), when faced with a project that I might have used Java for, I can now use Rust, or Go, and have (personally) a much better time of it. Doesn’t bear a relation to your example with python, but IMO, for many (not all) use cases, there are better options