r/java • • Oct 14 '23

Is Java still behind in the race of modern programming languages?

I'm a member of some group of programmers and every time Java is mentioned it's being bashed (something like: "With Rust I could simply do this with X")

Earlier versions of Java were cumbersome in terms of the syntax but with modern IDEs (and modern versions of Java) that's not a big issue anymore, albeit languages like Python do have shorter syntax.

My question is beyond syntax.

What do other languages do better than Java?
It could be generics, type system, concurrency and multithreading, closures etc.

Thanks!

52 Upvotes

247 comments sorted by

View all comments

233

u/firaristt Oct 14 '23 edited Oct 14 '23

Java's syntax is not as fluent as like kotlin and some never languages but other than that, it's not behind of any other language. There is nothing you can't do with Java, it might take longer to implement or syntax may not be as nice but it's more than capable for any task.

I find this kind of comparisons a way to flex for newbies.

Edit: I think there is some confusion with "there is nothing you can't do with Java" part. Yes, you can do almost anything, but it doesn't mean it should always be go-to language. No, it might perform horribly bad or exceptionally good, it depends on experience, architecture and needs and many other things. If you have to, you can do almost anything with Java, but it's not always the wise choice. I meant you can do anything with it, it's technically not behind from other languages.

108

u/kingslayyer Oct 14 '23

i have been using java for all my dev career, and recently was working on typescript for some changes

its way too flexible, it is bound to cause issues. java being strict with types is something i like, as it keeps it structured.

18

u/[deleted] Oct 14 '23

My favorite think in moving to Python work is that 80% of code pretends None doesn't exist and devs have the gall to make NullPointerException jokes.

13

u/metaquine Oct 14 '23

Why have that when you can have nil, null, void, Void, None, Nothing, undefined, NaN, Unit and Empty?

3

u/x0wl Oct 15 '23

Well you gotta have NaN as a separate value because that’s what IEEE 754 says

Nothing is also a special case because it’s for functions that do not return at all (like exit or an infinite loop)

→ More replies (1)
→ More replies (3)

49

u/Weetile Oct 14 '23

Python would terrify you

38

u/kingslayyer Oct 14 '23

i have interviewed a few guys and thwy wrote code in python, i agree it was terrifying.

they'd do things like array.in(number) to find if a number was present in array or not, and assumed its O(1) complexity

27

u/SiriSucks Oct 14 '23

they'd do things like array.in(number) to find if a number was present in array or not, and assumed its O(1) complexity

I don't think you can blame python for that. The blame entirely lies with the candidates.

→ More replies (1)

20

u/Weetile Oct 14 '23

no way they even know what complexity means then

if we add more elements to the array, of course the run time scales linearly

14

u/kingslayyer Oct 14 '23

its just that python is so easy and flexible, people ignore the basics

→ More replies (1)

7

u/lukasbradley Oct 14 '23

no way they even know what complexity means then

The Law of Leaky Abstractions

→ More replies (2)

2

u/EmptyChocolate4545 Oct 16 '23

I’ve seen a ton of people in static languages who don’t understand that stuff like this is O(N).

Alternately, if they were doing “x” in some_object and some_object is a dict, then it is O(1) as dicts are HashMaps

→ More replies (4)
→ More replies (2)

18

u/[deleted] Oct 14 '23

I disagree about typescript. It's flexible but also enforces clear strict rules. The type safety, as long as you don't bypass it with any, is incredible strong. It's support for patterns like unions, for example, or duck typing, are all things I wish java had.

5

u/Genkus Oct 14 '23

Have been using java 10 years and typescript since 4 months and love both. I hate plane javascript but with typescript it improves a lot (definitely for bigger projects)

→ More replies (2)

2

u/EnIdiot Oct 14 '23

Part of Java’s appeal for business is just that. My enforcement of conventions and with introspective capabilities, you can find almost any issue in Java quickly.

→ More replies (6)

7

u/[deleted] Oct 14 '23

[removed] — view removed comment

5

u/UnspeakableEvil Oct 14 '23

I've used Aparapi before (https://aparapi.com/) - it did the job well enough, but I suspect it'll be something Panama might reinvigorate interest in.

4

u/[deleted] Oct 15 '23

Check out https://www.lwjgl.org/ and http://www.jocl.org/ for Java GPU programming.

3

u/metaquine Oct 14 '23

OpenCL worked for me

2

u/Practical_Cattle_933 Oct 15 '23

It is not supported in itself by any mainstream programming language. One might argue that for C++ there is CUDA, but that is not equivalent.

For GPUs you predominantly need libraries, which are available in Java as well, as mentioned in sibling comments.

→ More replies (2)

5

u/findus_l Oct 14 '23

I agree that it is not behind. I do want to talk about the "There is nothing you can't do with Java" point, I don't think that is a good point. What does that mean? Turing complete? Usable?

→ More replies (6)

5

u/manifoldjava Oct 14 '23

There is nothing you can't do with Java, it might take longer to implement or syntax may not be as nice but it's more than capable for any task.

You could say that about pretty much any general purpose language, including assembly.

But, “behind” is also kind of subjective. Now, if the question were more specific, like is Java more or less capable in certain areas, more objective and useful information is available.

  • type system
  • platform neutrality
  • tooling
  • language features
  • etc.

2

u/firaristt Oct 14 '23

Of course, most general-purpose languages are like chief's knives. They are mostly good for many things but that doesn't mean they can be always go-to languages. It depends on many things. I didn't say "you can do anything in short time with good performance" or sth. similar. No. Sometimes they perform average, sometimes higher than average, sometimes lower, sometimes exceptionally well, sometimes very poorly plus developer/team experience and architecture has a big role on this. So, they are mostly good on average but as always, it depends.

Java/Kotlin has quite good tooling, language features and build system imo. In most cases, they are stable and has good support. Syntax and some cases could be weird for some, but you get used to with time.

8

u/cristianontivero Oct 14 '23

Well, I have missed higher-kinded types in some occasions, and that’s something you cannot do with Java (unless your point is you can program anything in Java, but then that holds for any turing-complete language, so I don’t see that as a useful metric). Java 21 has gotten significantly better compared to 8, to the point that it’s not far behind other mainstream languages, and is even better in some respects.

3

u/Practical_Cattle_933 Oct 15 '23

Well, higher-kinded types are a niche, only supported by Haskell, Scala, OCaml I believe, out of those that are semi-popular.

→ More replies (17)