Live data from Hacker News

"Should I still learn Java?" Answered: Yes.

beginwithjava.blogspot.com

91–100 of 108 posts

Re: "Should I still learn Java?" Answered: Yes.

#91
post #89
post #87

Earlier quoted context omitted.

jdk textmate / jedit / nano ant What else do you need? :/

Is it common for java developers to use a "dumb" editor like textmate / jedit / nano? I've heard that a good IDE is a requirement for writing significant amounts of Java. To be fair, I've mostly been interested in Scala; but it seems like you have to know Java to get the most out of Scala.

It's a myth. People who don't like Java moan on that it's so verbose and the only way to get anything done is by using an IDE.

Do people use IDE's to write assembly language? I'd say majority do not. You just learn to organize your code well and to be concise and tidy. A good skill to learn.

My current project (Mibbit), is about 25k loc, in around 200 files. I've never had any issue working with it.

I think the difference lies in if you write 'Enterprise' java, use XML for everything, use patterns, tons of threads etc or if you just write tight, tidy, concise speedy java.

Re: "Should I still learn Java?" Answered: Yes.

#92
post #75
post #20

Earlier quoted context omitted.

As someone who programs Java a fair bit, what bad habits do you believe it teaches?

- Strong push towards threading. Before NIO, there wasn't a way to avoid threads if you wanted to talk to multiple sockets. NIO has solved that for networks, but the whole java framework/idioms push you towards threads where it shouldn't. - No way to tell how things are implemented. I had written a heapsort in Java. It run x40 slower than the equivalent C. I was trying to figure out why -- e.g. was it inlining the th…

> Strong push towards threading. Before NIO, there wasn't a way to avoid threads if you wanted to talk to multiple sockets. NIO has solved that for networks, but the whole java framework/idioms push you towards threads where it shouldn't.

Where? I'm starting to think people dislike Java for the community / way it's used in enterprise rather than anything to do with the language.

There's no push toward threading in the language :/ And NIO has been around for years.

- No way to tell how things are implemented.

What?? Look at the source code. Decompile the class file into byte code :/

Re: "Should I still learn Java?" Answered: Yes.

#93
post #26
post #20

Earlier quoted context omitted.

As someone who programs Java a fair bit, what bad habits do you believe it teaches?

Most of my work these days is Java too, fwiw. But only because I need Lucene and Hadoop ;-) The main bad habit is a gross overuse of patterns to compensate for language stupidity (see: http://norvig.com/design-patterns/ ). A few particular examples include: - Too much global state. You call it a Singleton. I call it a global variable with a fancy name and a lot more code. - You lose the ability to think functionally…

> It's bad enough that passing a small fn (1 line of code in a decent language), requires a separate class and 20 lines of code in Java.

No need to exaggerate, it's only a few extra lines

    functionTakingCallback(new Callback() {
        public void fn() {
            ...
        }});
I agree it's verbose enough to be annoying, but hardly a deal-breaker imho.

EDIT: Just occurred to me that you might be looking at it from the other side, where you would have to define the callback class. Still, defining a static nested with a single function is only 3 lines of code.

Re: "Should I still learn Java?" Answered: Yes.

#94
post #83

Earlier quoted context omitted.

First, even in Java you don't know the return type / invariants ... int n = func_that_returns_positive_even_number() What you need is to document the thing: def func_that_returns_positive_even_number(): """Returns positive even number.""" This comment will be available when typing "help(func_that_returns_positive_even_number)" in the Python console btw. Or if you're paranoid and that function can totally break your c…

First, even in Java you don't know the return type / invariants ... This is a classic type system straw man. The language doesn't support encoding integer ranges in the type system, ergo, the type system is not ever a significant advantage and all invariants must be documented. You fool! What you need is to document the thing: Some invariants require further documentation. The more you can express concisely in code v…

"""The more you can express concisely in code via the type system, the more time you and your API clients save in both development and maintenance"""

That's not necessarily true ... the more complex the type-system, the more time you lose feeding it.

"""It's still up to you to track them down (at runtime) and figure out where you went wrong"""

A language with runtime-dispatching and/or where NULL is allowed will have the same problems. I mean, personally I had more null-pointer-exceptions than all the other kinds of errors combined and multiplied by a dozen.

We are talking about Python versus Java here ... Haskell's type system is smarter and can detect lots of errors for you, but then again we were also talking about beginner-friendliness.

Re: "Should I still learn Java?" Answered: Yes.

#95
post #90

Earlier quoted context omitted.

Why do you need to enforce rules, other than documenting the classes/methods defined? What happens if the superclass method isn't called Shit doesn't work or it breaks, then the person who sub-classed needs to fix it. Sometimes it also means your class is leaking encapsulation. This also happens with plain aggregation/composition btw. It also happens with data-immutability (which has nothing to do with inheritance, a…

Why do you need to enforce rules, other than documenting the classes/methods defined? The less repetitive work we delegate to human fallibility and instead delegate to a machine, the more time we have for human ingenuity. Shit doesn't work or it breaks, then the person who sub-classed needs to fix it. It's not that simple. The more difficult it is to understand the rules of behavior before changing the code, the more…

     this method must be called in the context of a 
     READ-COMMITTED transaction
I get what you're saying, but I like conventions and clear APIs with proper encapsulation.

Here's a sample from Python/Django ...

      @transaction.commit_on_success
      def do_stuff_with_the_db():
           db.execute("insert into tmp values (1)")
           raise Exception
Or if you need to supply the DB queries yourself, you can implement your own context-manager than use it with a with block ...

     with stuff.inside_transaction() as obj:
          obj.execute("query")
No need to extend a class that represents a transaction or some other shit like that.

       having the language assist in simply not breaking it at all
You know that's an utopian goal. What I dislike most about languages that try to detect too much shit for me is that it gives me a false sense of security. And the worst offender is Java: not only is its type-system too weak, because it is manifest-typed you get the false impression that it guarantees stuff for you, when it doesn't.

Re: "Should I still learn Java?" Answered: Yes.

#96
post #86

Earlier quoted context omitted.

Inheritance instead of composition. Too much worry about security theater public/protected/default/private instead of actually reusing code. The inability to fake stuff for tests without designing ability to fake things into every class. Basically, you write the code, and that's what you have. If anything changes, it's basically a rewrite, even with Eclipse's "refactoring" features. Type erasure. When all you have is…

I know I'm not an average Java programmer (I hate IDE's, hate patterns for example), but I've never seen anything as an AbstractHammerFactoryInterface. Seems like you're confusing Java the language, with how some people choose to use Java.

If you are going to use Java contrary to 90% of Java programmers, what's the point? You can't use any libraries and they won't understand your code. So you might as well use a good language instead.

Re: "Should I still learn Java?" Answered: Yes.

#97
post #49

Earlier quoted context omitted.

Inheritance instead of composition. Too much worry about security theater public/protected/default/private instead of actually reusing code. The inability to fake stuff for tests without designing ability to fake things into every class. Basically, you write the code, and that's what you have. If anything changes, it's basically a rewrite, even with Eclipse's "refactoring" features. Type erasure. When all you have is…

Yes! It's amazingly hard to do inheritance right. As a rule of thumb, if you can't prove that the inheritance doesn't violate the Liskov substitution principle, you shouldn't be allowed to do it. (It amazes me how many java 'programmers' have never heard of lsp or a refinement proof).

Ironically, Liskov is the exact opposite of how people do OOP. Most people subclass to add restrictions, where Liskov suggests that subtypes should relax restrictions.

This means your programs work better, but you have to plan ahead.

Re: "Should I still learn Java?" Answered: Yes.

#98
post #86

Earlier quoted context omitted.

I know I'm not an average Java programmer (I hate IDE's, hate patterns for example), but I've never seen anything as an AbstractHammerFactoryInterface. Seems like you're confusing Java the language, with how some people choose to use Java.

If you are going to use Java contrary to 90% of Java programmers, what's the point? You can't use any libraries and they won't understand your code. So you might as well use a good language instead.

Right. And this gets to the heart of the matter.

I do not use languages just based on what other people use it for.

I completely agree, most people abuse Java using it in stupid ways, writing absolutely ridiculously verbose and complex needless code, using XML for everything etc etc. But that's not Java's fault. It's simply the fact that it looked attractive to Enterprise and they threw their crapstorm at it.

If suddenly looked attractive to corporate world, it'd get thrown a ton of crap as well and suddenly fall out of fashion with the people who choose languages based on fashion.

If you pick languages based on community / how most people use it, I think you're missing the point of languages.

Re: "Should I still learn Java?" Answered: Yes.

#99
post #26
post #20

Earlier quoted context omitted.

As someone who programs Java a fair bit, what bad habits do you believe it teaches?

Most of my work these days is Java too, fwiw. But only because I need Lucene and Hadoop ;-) The main bad habit is a gross overuse of patterns to compensate for language stupidity (see: http://norvig.com/design-patterns/ ). A few particular examples include: - Too much global state. You call it a Singleton. I call it a global variable with a fancy name and a lot more code. - You lose the ability to think functionally…

Saying that you can't think functionaly in Java is not a "bad habit" - that's a style choice. Likewise, being verbose is not a bad habit - it's an issue of style.

As for global state - using singletons is a design decision. If you don't like them, don't use them!

So many people on HN hate on Java just because they've made the switch to functional programming. All power to you, but none of what's good about FP makes Java bad - it's just different.

I'd agree that there are some inherent design issues with Java - I've never liked primitives and I don't like how generics were implemented but other that that, it's a really excellent tool for a number of tasks. Just because it doesn't look like what you like, doesn't make it bad (this reminds me of when Java came out in the first place and all the C++ programmers were saying that it was useless because it didn't have operator overloading. not bad, just different!)

Re: "Should I still learn Java?" Answered: Yes.

#100
post #98

Earlier quoted context omitted.

If you are going to use Java contrary to 90% of Java programmers, what's the point? You can't use any libraries and they won't understand your code. So you might as well use a good language instead.

Right. And this gets to the heart of the matter. I do not use languages just based on what other people use it for. I completely agree, most people abuse Java using it in stupid ways, writing absolutely ridiculously verbose and complex needless code, using XML for everything etc etc. But that's not Java's fault. It's simply the fact that it looked attractive to Enterprise and they threw their crapstorm at it. If sudd…

The reason why you want popularity is because they write libraries for you. That means you can worry about something more interesting than an HTTP parser. Or, it means that if you want to write an HTTP parser, lots of people will help you.

If you are the only person in the world and refuse to collaborate with anyone, then it doesn't really matter what language you use. Except, of course, the compiler and runtime are libraries, and you had better be prepared to maintain those, too.

Post reply on HN