Live data from Hacker News

Ask HN: Why not Java?

news.ycombinator.com

101–110 of 112 posts

Re: Ask HN: Why not Java?

#101
post #30
post #22

Earlier quoted context omitted.

Rigth tool for the right job is key here. I personally like to add Groovy to the devops list.

I think groovy is sensless language. You lost all Java benefits like checked exceptions, robust code... what is about debugging? And you is not faster developing with groovy. You developing faster if you ensure quality and not inline filters or other crap. If you like groovy, look at Python.

I've used it _alot_ especially for scripting. Really powerful support for quickly write dynamic code to run transformations, connect to db's, connect to mq's etc. It's easier to read than python (for me) and you can just drop a lib in groovy_home for support to whatever dbdriver (like oracle). Seriously give it a go, before you call it senseless. But you know, use what you know and what you can be effective with to solve a given problem.

Re: Ask HN: Why not Java?

#102
post #53

Earlier quoted context omitted.

The two areas that most frequently annoy me are processing collections and (lack of) first-class functions. Java: List firstNames = new ArrayList (); for(Person p : people) { firstNames.add(p.getFirstName()); } addCallback(new Runnable() { public void run() { doSomething(); } }); Python: first_names = [p.first_name for p in people] add_callback(do_something) Scala: val firstNames = people.map((p) => p.firstName); add…

This is, because you can't Java. How you will find out, where you use first_names = [p.first_name for p in people] ? More verbose, but right way in Java is like (you can do this better with enums and/or guava, it's just example): class PersonTransformer implements Transformer { public Object transform(Object o) { return ((Person)o).getFirstName(); } } and then: Collection firstNames = CollectionUtils.collect(people,…

Are you really arguing that the 'java' way in your example is superior to Scala's

Re: Ask HN: Why not Java?

#103
post #21

> Why is it so horrible as a systems language above C? * First class functions (interfaces with one method) plus garbage collector eventually encourage a functional programming style, with lots of little objects created on the heap. Alas, the per-object memory overhead of popular Java implementations is horrendous. * Strong emphasis on using threads for concurrency. Alas, in practice, threads are incredibly large mem…

* If you are using the JVM's generational + concurrent garbage collectors, generally the hoards of little objects disappear without hiccups or leaving much of a footprint.

* My beef with threads for concurrency revolves not around memory footprint (can you substantiate threads as "memory hogs"?), but instead around the necessity to be mindful of resource sharing. Yes, the JDK gives you lots of useful tools in this quest, but it's still not all that difficult to end up with a deadlocked app.

Re: Ask HN: Why not Java?

#104
post #83

Earlier quoted context omitted.

Python has threads. In Python classes are first class objects, and you can easily do anything you could do with Java anonymous classes on the fly. Furthermore Java anonymous classes are usually used as a verbose replacement for a lack of closures. But in Python you can create closures and pass them around. (You do have to do some juggling to mutate variables, but 1 element arrays are only a slight pain to work with.)

Yes, but again, there is no Python syntax for anonymous classes. That you can "easily do" something a different way is not proof that two things are the same, it's proof that they are in fact different. Which again, is my point. That Python has other, different features that can be used for other different effects just makes it that much more different. Python has green threads, but if you want concurrency, you have…

I'm not saying you should do this, but you can have an anonymous class like this:

  type('', (dict,), {'__init__': lambda self, *args, **kwargs: not super(self.__class__,self).__init__(*args, **kwargs) and setattr(self,'__dict__',self)})
Python easily allows multiple threads to exist at once. The only reason they don't run at the same time is an implementation detail of the most common Python implementation. Python running on the CLR, the JVM, and extensions for both CPython and PyPy show that you can run multiple threads concurrently if you really want to.

Re: Ask HN: Why not Java?

#105
post #23

Earlier quoted context omitted.

You can ditch the xml almost entirely in spring 3, which I've been using for 2 years now. All you need is 50-100 boilerplate lines and the rest is annotations. I agree that 2.x was xml hell, but it is worlds better now.

> All you need is 50-100 boilerplate lines That answers "Why not Java?" perfectly ;)

Java is a verbose language, but it's still awesome for a large category of projects. Are you a rails guy? how about those 50-500 lines of boilerplate code in the config files? Same thing as the Spring config files. Does that lead me to say "Why not Rails?" No it doesn't!

Saying it politely as possible: don't be a hater.

Re: Ask HN: Why not Java?

#106
post #67
post #16

Earlier quoted context omitted.

Well, for starters the whole idea of programming in XML. That and gems such as http://static.springsource.org/spring/docs/2.5.x/api/org/spr... or http://static.springsource.org/spring/docs/2.5.x/api/org/spr... Of course I can't a priori prove that Spring is garbage, much like I can't a priori prove that it's better to be healthy and rich than to be poor and sick. It is a judgement call, but a judgement call that I be…

The word "SimpleBeanFactoryAwareAspectInstanceFactory" reflects everything I hate about Java and it's intended approach to OOP.

Cool, you must hate Objective-C too. I've done initWithParamAAndParamBWithASideOfAnObsurdlyLongMethodName but that doesn't mean I hate Objective-C.

Re: Ask HN: Why not Java?

#107
post #30
post #22

Earlier quoted context omitted.

Rigth tool for the right job is key here. I personally like to add Groovy to the devops list.

I think groovy is sensless language. You lost all Java benefits like checked exceptions, robust code... what is about debugging? And you is not faster developing with groovy. You developing faster if you ensure quality and not inline filters or other crap. If you like groovy, look at Python.

You ensure quality by writing automated tests, not by the language you pick to write software in.

And for the record Groovy is awesome. I used to develop in it alot, but now do more Rails and JavaScript, and I miss it's power and simplicity.

Re: Ask HN: Why not Java?

#108
Java reputation suffers because of the association of such language with corporate drones.

We may say that with the current crop of languages running on the JVM, Java is a low-level language. It is to the JVM what C is to hardware. You avoid coding in both when you have higher-level languages available which will make you more productive.

But when you want to optimize performance on the JVM for specific chunks of your application - without resorting to JVM bytecode of course - Java is the right choice.

Re: Ask HN: Why not Java?

#109

Earlier quoted context omitted.

From what I see, knowledge comes from experience and study. An IDE doesn't magically separates you from the need to know how stuff works. What you describe is a unexperienced programmer, but those exist in any area, using or not a IDE. From what I understood you, your see a problem with code generated by a wizard or by an automated process and if that's your point I agree, but that's not how eclipse is used. Besides…

I agree that an IDE does not separate from the need to know how stuff works. But I certainly know a few programmers who do not dare to think beyond what their IDE allows them to do. They use built-in wizards and refactorings, but they do not seek solutions that are not easily expressible with those. Hence, their code is factored just the way the IDE would, even if there are better alternatives available. This is the…

Refactoring can't create functionality. What you are saying is not compatible with the theory if entropy. Eclipse is a high level language running on the JVM, and not a bad one.

Re: Ask HN: Why not Java?

#110
post #21

> Why is it so horrible as a systems language above C? * First class functions (interfaces with one method) plus garbage collector eventually encourage a functional programming style, with lots of little objects created on the heap. Alas, the per-object memory overhead of popular Java implementations is horrendous. * Strong emphasis on using threads for concurrency. Alas, in practice, threads are incredibly large mem…

Java's heavy syntax for anonymous classes and immutables actually discourages functional programming even when that's a strongly desired approach by the programmer.
Post reply on HN