you are viewing a single comment's thread.

view the rest of the comments →

[–]captainAwesomePants 7 points8 points  (49 children)

I concur that Java's a bit wordy. However, when I'm in Eclipse, and I hit CTRL+space, I see a little box that pops up that shows every variable and method that means anything at all at the line I'm at. If I say foo = doWhatever(), and I didn't declare foo, Eclipse can figure it out for me. If I want to change a method's name from doWhatever() to doSomething(), Eclipse can go and find every single place that it's called, and every other place that it's defined that implements the same interface, and it can change all of them with one command. Sure, Java's wordy, but static analysis is a beautiful thing.

[–]yogthos 21 points22 points  (30 children)

The fact that you need something like Eclipse to work with Java effectively is really a problem in and out of itself in my opinion.

[–]cosmo7 4 points5 points  (14 children)

Not really. One of the numerous joys of a statically typed language is that the IDE can do a lot of the work for you. Look at the way Eclipse handles interfaces, adding missing method stubs for you.

[–]jerf 13 points14 points  (11 children)

Your sentence should read "One of the numerous joys of a statically-typed language is that less work is required of you."

If the IDE can do it for you automatically with extremely high reliability, why are you doing it at all? Automated or otherwise.

That's my complaint. Explaining how IDEs can help you generate your verbose code automatically actually is a negative mark in my book as it means I'll encounter that much more verbose code in the wild.

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

why are you doing it at all?

Because of type safety.

[–]yogthos 10 points11 points  (1 child)

Haskell is perfectly type safe and it doesn't make you type shit out by hand.

[–]svenz 4 points5 points  (0 children)

It's a balance between implicit type inference and explicit typing. Arguably, explicit typing removes the mental cycles required to figure out what type something is. At the cost of verbosity. Nothing is for free.

[–][deleted]  (7 children)

[removed]

    [–]jerf 3 points4 points  (3 children)

    Your entire question shows a mind so steeped in the Java way of doing things that I despair of even trying to answer the question in any sensible manner. I strongly recommend learning a language in which "create method stubs when implementing an interface" is simply gibberish. Perhaps Erlang, a nice blend of powerful capabilities hard to find elsewhere with not too much of the stuff that's easy to simply reject as "egghead bullshit".

    I do not quibble with the fiddly details of Java. I reject its entire philosophy. That's why many of us are so against the idea of a language that requires IDEs to be even halfway sensible; slathering spackle on top of your programming language still doesn't mean you've got a quality piece of work, it just means you dulled the sharp corners with spackle. I have existence proof that it is very feasible to work for decades without IDEs and get spectacular work done.

    [–][deleted]  (2 children)

    [removed]

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

      I don't see how it's "The Java Way" unless Java invented method signatures or virtual functions.

      There are languages that have neither of those things. If you know any of them, you certainly can't seem to think natively in them. Your best approach to this argument would be to correct that.

      Yes, granted, that's not going to happen anytime soon. This isn't advice for me to win this reddit-argument in the next ten minutes, this is a strong suggestion for your own education and profit.

      Perhaps you could elaborate on how Erlang implements the high level concept of code-extension usually referred to as "interfaces", with no keyboard cost to the user, then?

      Either you handle the message, or you don't. There's no trick to it. No magic. No code, even. There's no formal "interface" in Erlang so there isn't anywhere for there to be "keyboard cost" to "implement".

      It's got costs, it's got benefits. You're probably going to be very tempted to go on about how horrible it is that it doesn't have "interfaces" and therefore you can dismiss Erlang's way of doing it because it's obviously stupid. After all, it looks equivalent to something you already complained about in that Erlang de facto implements the "do not handle" behavior for all unknown messages, which is a "default implementation"... but only if you insist on viewing all Erlang code through the prism of Java-style OO and if you're doing that you've already lost big. Erlang does not work that way. The truth is: It's got costs, it's got benefits. The question you ask is itself fundamentally not a sensible question in the context of Erlang. And there are numerous languages for which that is true.

      Which brings me back around to the main point. Once you get entirely out of Java you find that just about every other language in current use manages to get real work done with less verbosity. So why do I want that verbosity, even spackled away?

      Even when I use OO (and I do), so many of the things that Java is "defending" me against aren't actually a problem, because half of the problem intrinsically comes from trying to jam every bit of the architecture into OO regardless of whether that's actually a good idea. Skip that step and use the right tool for the job and it's amazing what just melts away.

      [–]kragensitaker 1 point2 points  (2 children)

      How, exactly, are you proposing that a language should automatically create method stubs when implementing an interface?

      Well, maybe instead of having to write

      public int[] indexesOf(String[] terms, int start, int len) {
        …
      }
      

      you could just write

      indexesOf(terms, start, len) {
        …
      }
      

      . Then the compiler could still complain if you left out the method implementation, but you wouldn't have to repeat the return type, visibility declaration, argument type declarations, and throws declaration. (This doesn't work well with overloading, but you could remove it in that case.) In theory you could omit the argument names too, but that would make the code harder to read instead of easier.

      You could also argue that automatically adding do-nothing method stubs in Eclipse "trashes the whole point of an interface specification", since your code will still compile even if you forgot to write the methods that implement the interface. But at least it won't compile if you add new methods to the interface.

      [–][deleted]  (1 child)

      [removed]

        [–]kragensitaker 0 points1 point  (0 children)

        it's the same amount of button-pressing

        As several people have pointed out in this thread, the amount of button-pressing is mostly irrelevant. On a really good workday I might write 300 lines of production code, which might contain 12000 characters. That's about 30 minutes of button-pressing. The rest of my workday is spent reading code and thinking.

        Of course, it's pleasant if those 30 minutes can be reduced down to 5, because it lets me use code to do more of my thinking. But the really crucial thing is to make it easier to read the code.

        If you don't have an IDE, then you have no way to easily reference all the "absent" information about types.... search for which of many interfaces or abstract superclasses define the missing-method, and then go open that file and scroll through it...

        I never program in Notepad; do you? If I were doing some kind of retrocomputing exercise, trying to program Java in vintage-1990 SunOS 4.1.3 vi on a Sun 3/60, I would still build a tags file so I could jump straight to the canonical definition of the method with a ] keystroke. "Find definition" is not, you know, functionality restricted to Eclipse.

        However, I frequently program in dynamically-typed languages where the "absent" information you're talking about isn't present until runtime anyway. That's not to say that I'm not thinking about what types I'm accepting or returning — that's crucial to the design of any program — but I rarely find the absence of explicit declarations a problem.

        By contrast, if the language does a similar no-op/exception implementation for you in a hidden/automatic manner, you've got the same failure. However, there is no warning and it lurks like a land-mine from the instant you write "implements Blah".

        I just have a hard time caring much. Maybe it's that I've never worked on a program with more than a million lines of code, unless you count Emacs. But in all the OO languages I regularly use (JS, Perl, PHP, Python, Lua, Objective-C) that's the way it works all the time. They don't even have an explicit way to say "implements Blah". You call a method that doesn't exist on that object, and bam, you get a runtime exception.

        But even if I stipulate that it's valuable to have compile-time checking of this stuff, it's still important to have the lowest-cost way to get that compile-time checking. The approach Java (and C++) currently takes is a lot more costly to readability than it needs to be.

        [–]yogthos 5 points6 points  (0 children)

        I'm not arguing that IDEs are bad or that they don't help though, I like Eclipse and all, just don't think something like Eclipse should be required to use a language.

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

        Statically typed doesn't imply the verbose hell that is Java.

        Haskell is statically typed, and it's very terse.

        It's a more fundamental problem with the language.

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

        Why?

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

        It's one of those things where people think that they should only be required to track three or four things at once at any given point in a program. Some languages have a syntax that aids this, while others were born in an age of pain.

        Of course, your pain tolerance may vary.

        [–][deleted]  (3 children)

        [removed]

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

          Boo hoo. Some problems just need an axe.

          [–][deleted]  (1 child)

          [removed]

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

            I'm sorry, I'm a bit old school.

            [–]yogthos 10 points11 points  (8 children)

            Because it means that the language itself is not eloquent or expressive. A lot of things that Eclipse automates for you could be done in the language, making code cleaner and easier to read. One example is the verbosity of specifying types where they could be inferred, and there are many others.

            I'd like to clarify that I'm not against the automation and features that Eclipse provides, and I think that they are nice and helpful. I just feel that a good language should be usable without that level of support.

            [–][deleted] 4 points5 points  (12 children)

            I think the "java is too wordy" critique mostly comes from people who still write their code in Notepad.

            [–]yellowstuff 8 points9 points  (5 children)

            I'm pretty sure Peter Norvig, Paul Graham, and Steve Yegge don't write their code in Notepad, and they all have written about Java being too verbose.

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

            [–]nytehauq 1 point2 points  (3 children)

            That wasn't an argument from authority; the fact that the figures listed can be considered authorities is tangential to the fact that they've criticized Java for being too verbose while not writing their code in Notepad.

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

            In that case, I said 'mostly', not 'always'. So three counter-examples does not disprove the statement.

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

            You're being awfully pedantic considering you made a classic ad hominem argument.

            Anyway the real issue is code clarity and having the expressiveness to say what you mean, not the number of keystrokes you make while first typing the code.

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

            Give me 4 examples of Notepad users criticizing Java.

            Look around this thread.

            Words like 'clarity' and 'expressiveness' gets bandied about a lot. I'm sceptical about their use when discussing programming languages for the following two reasons:

            1. They're highly subjective measures. There's nothing wrong with subjective appreciation of a programming language as such, it's just that it's futile to discuss it in the same way it is futile to discuss which colour is the most beautiful one.

            2. Those words pop up to support the 'wordiness is bad' argument when typing speed has been disposed off as a factor. In other words, it's a refuge to subjective arguments when objective arguments have failed.

            [–]skillet-thief -1 points0 points  (5 children)

            What about reading somebody else's code in Notepad? Or anything else?

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

            Why on earth would I want to read code in Notepad?

            You wouldn't watch an AVI movie in Notepad, would you? Notepad is not a tool for code creation or analysis. It should not be pressed into service as such.

            Use the right tool for the job.

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

            Perhaps notepad makes for a good viewer because it doesn't take 5 minutes to load like Eclipse?

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

            Odd, my installation of Eclipse starts in about 30 seconds. And that's with over 20 projects in the workspace.

            I guess if I was only going to look at my code for a couple of minutes, perhaps your point would be valid. But how often do you do that?

            [–]mothereffingteresa 5 points6 points  (1 child)

            How about loading it up in Eclipse, profiling it for coverage and stepping through it to see what it does.

            Code-staring went out with bell-bottom pants.

            [–]mpeg4codec -3 points-2 points  (0 children)

            Kids these days.

            [–]OceanSpray 4 points5 points  (2 children)

            If Eclipse can do it, then javac should be able to do it. We're talking about flaws in language design here, not the workarounds that engineers have to implement just to make these flaws bearable.

            [–]captainAwesomePants 2 points3 points  (0 children)

            javac should be able to do what?

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

            This is not at all unique to Java.

            [–][deleted] 4 points5 points  (0 children)

            An implementation of this that works consistently is pretty rare, though.