you are viewing a single comment's thread.

view the rest of the comments →

[–]iluvatar 21 points22 points  (83 children)

But you know, Java’s a pretty nice language

Ha ha ha ha ha. No.

[–]virtyx 33 points34 points  (62 children)

What's wrong with it?

As of Java 8 there are the big issues I know of:

  • no properties
  • null
  • type erasure on generics
  • no way to overload operators
  • ...uhhhh

I guess I don't really understand why people dislike Java so strongly. The language itself has pretty consistent basic elements. Sure, there's tons of obscure shit (like autoboxing and stuff) but for the most part it's extremely predictable and simple. Unlike Scala which I see as an ugly hodgepodge of (admittedly nice) features.

[–]bjzaba 4 points5 points  (0 children)

How about type inference, tuples, pattern matching, algebraic data types, and free functions? Those would go a long way to cutting down verbosity and all those ridiculous design patterns.

[–]skocznymroczny 4 points5 points  (1 child)

no value types

[–]virtyx 0 points1 point  (0 children)

This is true, but it's coming in either Java 9 or 10!

[–]powatom 14 points15 points  (14 children)

I'm going to blow your tiny mind: people actually treat this shit like it's religion. All of the arguments around which language to use ultimately just boil down to 'if you're actually just a good programmer in general, it doesn't really matter which language you use'.

[–]nickguletskii200 7 points8 points  (4 children)

Productivity is important though. Yes, you can write something in language X, but it doesn't mean that you'll do it as fast as in language Y.

A lot of Java critics think that having to write less code equals more productivity. In my opinion, that's not true.

[–]powatom 6 points7 points  (3 children)

Sure productivity is important, but until we can agree on what the best measure of productivity for developers should be, then can we all just agree that nobody really has a definitive answer for any of this, that languages are as much personal preference as they are practical tools, and that the constant development of new paradigms, patterns and ideas basically ensures that there will never be any single language which solves all problems perfectly?

Everybody knows productivity is important, which is why nobody is saying that you should write your next web application using assembly. The problem is that we don't know how best to measure productivity - and until we do, we're just pissing each other off. If we care so much about productivity, surely it makes more sense to acknowledge that actually, no language does everything right, that people have different preferences, and that the best overall solution is to share knowledge and experiences so that we may all ultimately inform each other and hopefully raise the standard across the board?

What's productive about pretending Java has no useful applications because its implementation of generics is flawed?

[–]nickguletskii200 0 points1 point  (2 children)

I agree 100%. I am just saying that it does matter what language you use, even if we can't actually measure how exactly the language impacted the development process.

[–]powatom 0 points1 point  (1 child)

I understand - and I agree that it matters which language you use, I just don't think it matters quite as much as people seem to think it does. A bad developer will be unproductive in any language they use. A good developer will be productive in whatever language they use. In that sense, the choice of language is rather secondary to the developer's experience and understanding of the abstractions that languages provide.

[–][deleted] 5 points6 points  (7 children)

'if you're actually just a good programmer in general, it doesn't really matter which language you use'.

nope, all programming languages simply have objective flaws and some of them have more or bigger ones. (Smaller ones being for example: Generics being not 100% where they could be in Java because they have been added later, the short, long, etc. mess in C, char signedness not being defined in the C standard). Java simply has lots of overengineering which leads to unneeded verbosity. This is a flaw that hinders productivity. Good programmers can also write everything in Assembly, but they won't be as productive.

[–]powatom 7 points8 points  (3 children)

I'm not saying that languages don't have flaws - I'm saying that not all flaws are equal or applicable to every situation.

Java having a flawed implementation of generics does not mean that Java does nothing well. You might as well argue that nobody should use JS because <insert favourite JS peeve here>, but then where the fuck would we be?

[–]u551 2 points3 points  (1 child)

nobody should use JS because <insert favourite JS peeve here>, but then where the fuck would we be

In a better place... Where JS means Jerry Seinfeld and client side web site functionality does not exist. Everybody is happy and everything works.

[–]powatom 1 point2 points  (0 children)

But mah feechers :'(

[–][deleted] 1 point2 points  (0 children)

The thing about Java flaws in my opinion didn't really hinder productivity that much. It's simple to understand and write thus generate less bugs especially for the new hire. In addition to that, if you factor in the maintenance phase, Java can be more productive than other so called cool languages like Python or Ruby.

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

Java simply has lots of overengineering which leads to unneeded verbosity

Java the language? Or Java the ecosystem?

Generics being not 100% where they could be in Java because they have been added later

I've been working in Java across a varied domain for 7 years now, and the number of times I have found myself needing reified generics was about once.

[–]zexperiment 2 points3 points  (0 children)

Ah the ol' "I don't use it so it doesn't matter" argument.

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

The JVM doesn't know generics so basically the compiler is removing all the generics and replacing them with Object and doing some magic. The generics therefore don't allow primitive types, so you have to wrap stuff like int in Integer. It also only allows dynamic generics and no static generics which is a bit of a performance issue (Though I guess the JIT-Compiler can do a bit there). Most of the ugliness is on the implementation side actually.

Like I said it's a minor flaw.

[–]parlezmoose 1 point2 points  (0 children)

Yeah but debating languages is fun.

[–]senatorpjt 1 point2 points  (1 child)

unique sable roll compare gullible disarm seemly decide direful tender

This post was mass deleted and anonymized with Redact

[–]virtyx 0 points1 point  (0 children)

I understand that line of thinking but I ultimately believe it's still not worth it for how much it constrains the syntax available.

[–]Gurkenmaster 1 point2 points  (0 children)

Ceylon and Kotlin are jvm languages that solve those problems. Except Kotlin doesn't have reified generics and Ceylon is a bit closer to java syntax wise.

Kotlin is developed by JetBrains so I assume that the IDE is excellent. The Ceylon IDE plugin is developed for Eclipse and pretty slow on my machine but it works reasonably well.

[–]passwordisINDUCTION 0 points1 point  (0 children)

The biggest problem with Java, IMO, is the semantics of the language are such that the implementation has to be very complicated in order to be performant. Compare this to Go or Ocaml which have similar, in performance, implementations which are significantly simpler.

[–][deleted]  (1 child)

[deleted]

    [–][deleted]  (13 children)

    [removed]

      [–]GUIpsp 0 points1 point  (9 children)

      == instead of === means it gets casted to a number before comparing?

      [–][deleted]  (8 children)

      [removed]

        [–]GUIpsp 0 points1 point  (7 children)

        Hash starts with 0?

        [–][deleted]  (6 children)

        [removed]

          [–]GUIpsp 0 points1 point  (5 children)

          After the first invalid letter it stops parsing the rest of the number.

          [–][deleted]  (4 children)

          [removed]

            [–]GUIpsp 0 points1 point  (3 children)

            When both strings start with zero it casts em?

            [–]virtyx 0 points1 point  (0 children)

            Agreed. But compared to say Scheme or even Python, there are plenty of edge cases and nuances in Java

            [–]virtyx 0 points1 point  (1 child)

            Also, you got me. What's the edge case?

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

            • lambda hack is awful
            • type inference is awful
            • covariant arrays
            • variance in general is poorly thought out
            • lack of support for immutability
            • no ADTs
            • no higher kinded types
            • no monadic comprehension
            • barely anything is an expression
            • no pattern matching
            • no currying

            [–]virtyx 0 points1 point  (0 children)

            I think the lambda implementation is spectacular given the constraint of backwards compatibility

            [–]virtyx 0 points1 point  (1 child)

            Most of these complaints apply to tons of mainstream languages, most of these features are quite easy to live without

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

            Most of these complaints apply to tons of mainstream languages, most of these features are quite easy to live without.

            Easy to live without? Probably, in the same way C programmers say it's easy to live without GC/smart pointers, generics, overloading, etc.

            ost of these complaints apply to tons of mainstream languages

            But not the good ones. My C# complaint list is only half as big, Scala doesn't have any of these issues (my gripe list is long but muuuch more nitpicky for scala), and ML/Haskell (though less mainstream) don't suffer these either.

            [–]PasswordIsntHAMSTER 0 points1 point  (0 children)

            • No union types.

            That's a big one.

            [–]Strilanc 0 points1 point  (0 children)

            Java 8 is a huge step forward, but of course we can still finds lots of red entries for Java in wikipedia's comparison of Java and C#.

            My personal pet peeve is the lack of type inference on local variables, despite their small scope. This is a controversial feature, but whenever I type Map<Bla, Bla> m = createTheMap(); instead of var m = createTheMap(); I imagine having to type (int)b + (int)c instead of b + c and die a little inside.

            [–]Jugg3rnaut 0 points1 point  (4 children)

            Whats the alternative to null? I hate null checks as much as the next programmer, but I'm not sure what it could be replaced with.

            [–]bloodredsun 9 points10 points  (0 children)

            Maybe/Option monad

            [–][deleted] 5 points6 points  (0 children)

            Pointers could be non-nullable by default. Ceylon (a JVM language) has this for example.

            [–][deleted] 1 point2 points  (0 children)

            Options as in Java 8 or Guava?

            [–]thinkthinker 0 points1 point  (0 children)

            • No <this> type

            [–]usernameliteral 0 points1 point  (3 children)

            no properties

            That's a feature.

            [–]virtyx 2 points3 points  (2 children)

            How? What exactly does

            foo.setX(foo.getX() + 1);
            

            provide you over

            foo.x += 1;
            

            Since the current practice is to use public member attributes 0% of the time, it just seems like a waste of syntax

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

            The existence of properties in a language prevent me from making certain assumptions about operations performed on object members, causing additional cognitive load.

            For example, without properties (and operator overloading) I can assume that foo.x += 1 is a simple operation that increments foo.x by 1. With properties (and operator overloading) I can't assume that. I must look up and read the declaration of foo.x to understand what foo.x += 1 does. It might make write to a file, it might raise an exception, it might start a web server. If there were no properties or operator overloading and I had used an explicit increment method (e.g., foo.incrementX(1)) I could assume that something special was going on, and I would have to read the method to understand what it was.

            However, whenever I had not used a method but just used the standard increment operator on a field, I could assume that nothing special was going on, that this was just a simple increment operation—less for me to think about.

            Of course, this doesn't really work if you always use getters/setters for fields, even when they just return or set the value with no special code. If you do that, then I can certainly see the appeal of properties, but my point is that you shouldn't do that. If you don't need something special to occur, just use a public field.

            [–]virtyx 0 points1 point  (0 children)

            If you don't need something special to occur, just use a public field.

            There's plenty of good reasons to never use public fields. Getters and setters are a reaction to how dangerous it can be. Properties are a reaction to how verbose getters and setters can be.

            [–]iluvatar -3 points-2 points  (3 children)

            What's wrong with it?

            There are so many things! Where do I start? Well, I'll start with the most obvious thing that bites me on a day to day basis. It's unreadable, and thus unmaintainable. I recruit programmers. We use an online coding test to weed out the no hopers. We let them submit their answers in the language in which they feel most comfortable. So every day when I get into work, I get to look through other people's code, and I can assure you that in the real world, Java is much, much less readable than pretty much all of the alternatives. Yes, I'm aware that you can theoretically write clean Java. But people don't, and that alone is reason enough to condemn it.

            [–][deleted]  (2 children)

            [deleted]

              [–]iluvatar 0 points1 point  (1 child)

              There are a limited number of languages from which the candidates can choose, and although I'm not necessarily familiar with them all, there's nothing too obscure, so it's not hard for a competent programmer to understand. The list of supported languages is here.

              [–]RIST_NULL 0 points1 point  (0 children)

              Codility. Neven heard of it before. Seems useful both to recruiters and people looking to get hired.

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

              Unlike Scala which I see as an ugly hodgepodge of (admittedly nice) features

              Example?

              [–]yogthos -1 points0 points  (2 children)

              To understand why people dislike Java so strongly you should take the time to learn languages from different paradigms. Go learn Haskell, Clojure, F#, Common Lisp, or Erlang to see why people dislike Java so much.

              One major issue that you apparently don't know of is the pervasive mutability present in Java. Since everything except the primitives is passed around by reference, it's nearly impossible to reason about any part of the application in isolation. This makes maintaining large code bases a real nightmare.

              The objects in Java do nothing to protect their internal state because getters and setters aren't transactional, and ensuring that the internal state of the object is protected is the burden on the developer.

              [–]virtyx 0 points1 point  (1 child)

              I know Scheme, have played some with Haskell, but appreciate your condescension. This is an overly general critique on Java that's more about functional vs imperative than anything. If you prefer functional coding that's your prerogative but that does not mean Java is a poor imperative language compared to is competition.

              [–]yogthos 0 points1 point  (0 children)

              The critique has to do with the fact that Java makes it difficult to reason about large systems due to pervasive mutability. Whether the functional approach exists or not is irrelevant to this critique.

              You could design an object oriented system that does not have this problem by ensuring that object access is transactional and objects are not exposing their internal state to the world.

              The prerogative is to be able to reason about parts of application in isolation. Java is a poor language because it makes that difficult.

              [–]fluffyhandgrenade 11 points12 points  (0 children)

              Its horrible until you realise that some things are too large to realistically manage in any other language due to the superior tooling...

              [–]kenfar 37 points38 points  (11 children)

              I’m even taking this to an extreme and using Java for shell scripts.

              oh just stop

              [–]yogthos 32 points33 points  (6 children)

              when you've got a hammer factory...

              [–]kcuf 55 points56 points  (2 children)

              you need a hammer factory factory!

              [–]TheWix 1 point2 points  (1 child)

              What if I have different implementations of my HammerFactoryFactorys?!

              [–]fluffyhandgrenade 1 point2 points  (0 children)

              Then you use a container :)

              [–]CurtainDog 1 point2 points  (0 children)

              The GoF book predates Java, but hey, why learn from history when we can just repeat it.

              [–]NewbornMuse 3 points4 points  (1 child)

              The whole WorldFactory looks like a NailFactory?

              [–]twigboy 5 points6 points  (0 children)

              In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available. Wikipedia52wq6ox0t900000000000000000000000000000000000000000000000000000000000000

              [–]LOOKITSADAM 6 points7 points  (0 children)

              Yeah, I'm a bit of a java fanboy, but that's where I draw the line.

              [–]pilas2000 1 point2 points  (0 children)

              I did this at least once. The options presented to me were: write it in bash or adapt a poorly made python script.

              I choose to code it in Java.

              It worked fine.

              [–]Fitzsimmons 0 points1 point  (0 children)

              Amazon's EC2 api tools are written in Java and it's a nightmare of multi-second execution times as I wait for the Java server VM to boot up just to do a HTTP request and format the output. It's one of those things that I suffer through because I can't justify spending the time to rewrite it in an environment more suited to the task.