Live data from Hacker News

Ask HN: Why not Java?

news.ycombinator.com

81–90 of 112 posts

Re: Ask HN: Why not Java?

#81
post #65
post #53

Earlier quoted context omitted.

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,…

Why would you want to reuse a construction so trivial? Why would you want to search for it? A couple days back I commented Java, by making some things harder than needed, induces programmers to over-engineer and build things for needs they don't have and to think that's perfectly normal. Think about what you just wrote.

Because it's DRY-Principle. It's doesn't matter trivial or not. If you distribute you 'trivial' constructions over whole application, you doesn't have any chance to have consistent, robust processing. If you collect/group things logically, you can easy find out where you (re)use constructions and what you can break, if you change it.

It's not over-engineering, it's just how to deal with >300 People and >6 years projects and not to have "design dead software".

Re: Ask HN: Why not Java?

#82
post #53

Earlier quoted context omitted.

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,…

orangecat example is type safe, your example trades a "compile time" error for a runtime error.

Python isn't type safe (but Scala). Especially for you I wrote "you can do this better with ... guava, it's just example" :)

Re: Ask HN: Why not Java?

#83
post #78

Earlier quoted context omitted.

I never claimed that the two were the same language. My claim was that you can take anything written in Java and pretty much directly translate it to Python. The fact that there are things Java will flag as errors that a Python translation does not, does not change this fact.

As I said, you seem to be claiming that Python is a superset of Java, not equivalent to it, and that claim is manifestly false. Errors that are detected in one place and not in another are a manifest difference. Also, Java threads and anonymous classes do not translate directly to Python.

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.)

Re: Ask HN: Why not Java?

#84
post #83

Earlier quoted context omitted.

As I said, you seem to be claiming that Python is a superset of Java, not equivalent to it, and that claim is manifestly false. Errors that are detected in one place and not in another are a manifest difference. Also, Java threads and anonymous classes do not translate directly to Python.

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 to resort to the process module. This is not a limitation Java's threading shares.

I'm not arguing that Python is bad or inadequate, just that it is a fundamentally different thing and should not be viewed as a superset of Java.

Re: Ask HN: Why not Java?

#85
post #81
post #65

Earlier quoted context omitted.

Why would you want to reuse a construction so trivial? Why would you want to search for it? A couple days back I commented Java, by making some things harder than needed, induces programmers to over-engineer and build things for needs they don't have and to think that's perfectly normal. Think about what you just wrote.

Because it's DRY-Principle. It's doesn't matter trivial or not. If you distribute you 'trivial' constructions over whole application, you doesn't have any chance to have consistent, robust processing. If you collect/group things logically, you can easy find out where you (re)use constructions and what you can break, if you change it. It's not over-engineering, it's just how to deal with >300 People and >6 years proje…

It's just a list comprehension. Do you imply I should use a function instead? Why not use a very nice syntax feature every Python developer can understand?

Because if you do, I'd advise you not to add integers with the "+" operator, but, instead, build a class with various add methods for different types of arguments or, better yet, build add methods into every class you define so that you can better search for them. This approach would allow you to add things that aren't integers or even not the same type on both sides of the operator.

Re: Ask HN: Why not Java?

#86

In my experience many Java programmers don't really "program" Java. They are more like "expert Eclipse users" and Eclipse happens to output Java. This style of development makes heavy use of wizards and those Eclipse refactoring tools. This probably is a consequence of the verbosity of Java-the-language, which made heavy tooling support a necessity. And then Eclipse, which provides one of the tightest language integr…

The verbosity of java allows an IDE like eclipse to exist. I agree that's very hard to program java without a powerful IDE, but there are a lot of things that you can do only with a static typed language and a IDE like eclipse. It's a fair trade. Could you ellaborate on the link between IDE dependency and the spawn a whole caste of very mediocre programmers? (english is not my first language, so sorry if anything I w…

Sure, I can elaborate.

The idea is that as a programmer, you have to have an intimate understanding of what is going on in order to make the machine do your bidding quickly and correctly.

But that mediocre Eclipse user I caricaturized does not have that understanding. He certainly knows how to get the job done for a certain set of tasks, but he does not know the details of how this is happening. Thus, he creates programs that follow "best practices", "conventions", "design patterns" and lots of automatically created wizard-boilerplate.

That might not be "bad code" mind you, but it almost certainly is not "great code", either. Thus, mediocre. And then these people create libraries that are mediocre and try to use only libraries that they can understand and that are hence mediocre. A culture emerges that is very consistent, but also very mediocre.

Re: Ask HN: Why not Java?

#87
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…

My claim is that it is fairly easy to translate any Java program into an equivalent Python one. That some things need different constructs is not evidence against this claim.

Re: Ask HN: Why not Java?

#88
post #27

The best reason to use Java is the enormous ecosystem of libraries and resources. The best reason to AVOID using Java is the huge demand for Java programmers and the low supply. At my job we can barely find applicants with Java so we end up hiring .NET people and converting them.

Just curious, where do you live?

I live in Phoenix, Arizona, and i've heard my old market (Raleigh, NC) is experiencing similar issues.

Re: Ask HN: Why not Java?

#89
post #87

Earlier quoted context omitted.

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…

My claim is that it is fairly easy to translate any Java program into an equivalent Python one. That some things need different constructs is not evidence against this claim.

Your claim is untrue, and that different constructs are needed is evidence. It is often easy, but that isn't guaranteed.

Re: Ask HN: Why not Java?

#90

Earlier quoted context omitted.

The verbosity of java allows an IDE like eclipse to exist. I agree that's very hard to program java without a powerful IDE, but there are a lot of things that you can do only with a static typed language and a IDE like eclipse. It's a fair trade. Could you ellaborate on the link between IDE dependency and the spawn a whole caste of very mediocre programmers? (english is not my first language, so sorry if anything I w…

Sure, I can elaborate. The idea is that as a programmer, you have to have an intimate understanding of what is going on in order to make the machine do your bidding quickly and correctly. But that mediocre Eclipse user I caricaturized does not have that understanding. He certainly knows how to get the job done for a certain set of tasks, but he does not know the details of how this is happening. Thus, he creates prog…

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 that, I don't think there is a link between bad code and IDE. You can't look at a bad code and say..hmm this code probably was written in eclipse, or at a good code and say that it was written with vi, because this connection does not exist.
Post reply on HN