Hacker News new | ask | show | jobs
by jgardner1 3468 days ago
> > Function Pointers -- Missing

> Java 8

Yet again, they admitted an important feature was missing. Again, I am not familiar with Java 8 but I suspect their implementation is horribly wrong.

> > Constructors can't call each other

> Again see the code at the end.

See my response.

> > Methods With the Same Name as Constructors

> Yea that's allowed, I don't see what's wrong with that. It's a real function name so it should be allowed. I've never accidently made this error.

I have. I guess I have just logged more time in Java than others.

> > Run-time Dispatch: Fantasy

> This is a design pattern issue but you're meant to use the highest or lowest version of an abstraction. From there you can ideally handle it in a generic way or if not you can use if (x instanceof Object) to filter out specific cases.

Please tell me how to do it properly. IE, if I have a variable of type Foo that is holding a value of type Bar, how do I invoke the function with Bar instead of Foo in the signature?

> > No Globals means Frameworks

> This is where decorators and static/singleton classes come in handy. You can do some amazing things with decorators, singleton/static classes, and if you need it a bit of reflection.

My point exactly.

Other languages just use globals. Because they are useful and people need them.

Java makes you invent a new programming paradigm to overcome its artificial limitations.

> > import is Useless

> You can just use the fully-qualified name of the other class and it will work fine. I've had maybe one instance where my naming conflicted with another package but that was a rare case.

And what do you do when you blow out the 80-char limit on columns?

Oh let me guess. You like your 1024-char limit on columns because you are using a superior IDE.

> > No List Literals

> Arrays.asList

I don't recall that being an option. I do know that people used to prefer the curly brace format but that turned out to cause memory leaks.

> > Inner classes Don't Work

> I don't know what he means as this works perfectly fine for some design patterns. Inherit state? No way. Provide impelemntations of an abstract/interface for a specific object? Yes way.

> In ArrayList it is perfectly fine to make an ArrayListIterator as they are the same bits of ideas and as such should be in the same file.

> I also prefer state enums to be defined in a class.

The issue with inner classes is that so many thing are contrary to expectations. I started to list them all but it got too long. I'll have to revisit it and try to condense it down.

> > Java is So Hard People Prefer to Write Code in XML, Jython, Scala, and Clojure

> I don't do this only """ENTERPRISE""" Java developers do this. There's a lot of great work being done moving away from this mentality but there is still a lot to be done.

The point is the reason why they do it is because it's easier to write, test and debug these other languages than Java. People know that coding in native Java is slow and cumbersome and time-consuming with no significant benefit.

> > Speaking of the JVM...

> I'd love some numbers on these claims.

What claims need numbers? LLVM and PyPy exist. JS with JIT kicks the pants off of almost everything --- because it is compiled down to native machine code. Go look them up for yourself.

JIT is the new fad, and it's a huge deal.

> > DNS Client Implementation

> Yea this is a problem. It's in here for compatability. There are many libraries implementing this better at the moment.

Name one.

> > Why Use Java at All?

> Why use any language at all? Write binary and opcodes (like I've been doing in my CPU project). It's very fun!

I write code to get the job done so I can get paid, my company's stock price can go up, and I can get money. It's a job. Yes, I love programming, but I prefer to get as much done with as little work as possible.

> In seriousness Java gets concurency right and I've not found another language that lets me write concurrent code like this ever before. Very nice platform to run on and one of the worlds best VMs. Everything is simple and documented well. I don't need to read a novel to get something working. I can think of a class, type that a control-space on my IDE, get a list of classes, find the one in the right package and move on. No google, no searching, just tooling and built in documentation. What's even better is most of the language is implemented in Java! I have the sources downloaded so CNTRL+Click and I can see everything's implementation! I'd love to see a python dev do that (I cant and I've been writing python for years).

Yeah, you strike me as someone who only knows Java. Let me know if I'm wrong.

> I'll be emailing the author at this email: jgardner @ XXX .net and giving him this comment. I hope he can rebute some of these points.

My email is jgardner@jonathangardner.net. It's been around for decades so feel free to send me as much email as you like. I'll see the good stuff and the spam folder will eat the rest.

Let me change your example:

   class Test {
   	private final int i;
   	public Test(int i) {
   		this.i = i;
   	}
   	public Test() {
                this.test(7);
   		this(10);
   	}
   
   	private void test(long number) {}
   }
Tell me how that works out for you.
3 comments

>JS with JIT kicks the pants off of almost everything --- because it is compiled down to native machine code. Go look them up for yourself.

>JIT is the new fad, and it's a huge deal.

The term "Just-in-time compilation" was borrowed from the manufacturing term "Just in time" and popularized by Java, with James Gosling using the term from 1993.[16] Currently JITing is used by most implementations of the Java Virtual Machine, as HotSpot builds on, and extensively uses, this research base.

https://en.wikipedia.org/wiki/Just-in-time_compilation

Java definitely has room for improvement but claiming that JS is better or faster is hilarious and makes me wonder what you are trying to sell.

JS seems fast if you only compare it to Python and PHP.

https://benchmarksgame.alioth.debian.org/u64q/javascript.htm...

Works just fine if you change:

    this.test(7);
    test(10);
to

    test(10);
    this.test(7);
Of course, since this is a made-up example to highlight one of your pet problems I don't know if that ordering is important to you. However there is a reason for the insistence on calls to the constructor being first, and it's not specific to Java. You run into this problem any time you have code that might mutate a data structure before if has been initialized. There are other ways to write this kind of code that avoids this, but it is by no means unusual in imperative code.
> Yet again, they admitted an important feature was missing. Again, I am not familiar with Java 8 but I suspect their implementation is horribly wrong.

Admitting something is broken does not mean it sucks. See this comment: https://news.ycombinator.com/item?id=13216187

Also, please read this before you wave it off: http://stackoverflow.com/a/1073427

> I have. I guess I have just logged more time in Java than others.

Java is probably my most used language and that's saying something as I work as a TA for a Python class, use python for most personal projects, and also use many other languages. Java consumes the most time because it has the most polished toolings and standards for developers. Now they may not always be ovserved but if you stay in your own walled garden everything is all honky-dory.

You will never make these mistakes if you follow basic practices in Java's naming conventions. All lower case classpaths, all uppercase class names, lower then cammel function names, etc. You'll never be able to mistake Test() for Test.test() as they are instinctivly different names.

> Please tell me how to do it properly. IE, if I have a variable of type Foo that is holding a value of type Bar, how do I invoke the function with Bar instead of Foo in the signature?

    void something(Foo f) {
        if (f instanceof Bar) {
            (Bar-Specific commands)
        }
        (generic commands)
    }
Or better yet use your magic want: Abstraction. Wave it around and use your super powers to move that functionality into Foo and in anything that needs a specific handling of that function, override that.

> My point exactly. Other languages just use globals. Because they are useful and people need them. Java makes you invent a new programming paradigm to overcome its artificial limitations.

Well if you want to resort to global constants you can. Use a static import. LWJGL makes heavy use of this anthough I dislike it. I'd rather have an abstract interface into the library rather then have a global constant.

> And what do you do when you blow out the 80-char limit on columns? Oh let me guess. You like your 1024-char limit on columns because you are using a superior IDE.

Yes very much so. Please see this: https://www.youtube.com/watch?v=wf-BqAjZb8M

Line length != good code. Now granted, that doesn't mean run wild but I do have some code written that is perfectly good code, I've just ended up using some long variable names. This happens in Python as well. And no, you don't need an IDE for this, I write most of my prototype Python in nano before moving it into an IDE as Python IDEs are extremely sub-par.

> I don't recall that being an option. I do know that people used to prefer the curly brace format but that turned out to cause memory leaks.

I don't remember `new int[] {};` causing memory leaks but yes you can even do a static import to do the following: `asList(1, 2, 3, 4)`.

> The issue with inner classes is that so many thing are contrary to expectations. I started to list them all but it got too long. I'll have to revisit it and try to condense it down.

I'd love to hear it, and I'd love to define a set of "sane" sub-features of sub-classing in Java. I've working with libraries that where HORRIBLY written that have used sub-classes and I've also worked with amazing ones.

> The point is the reason why they do it is because it's easier to write, test and debug these other languages than Java. People know that coding in native Java is slow and cumbersome and time-consuming with no significant benefit.

I don't think this is the case. Enterprise Java came about because design patterns, like viruses, spread through code bases. You should look at this: https://www.youtube.com/watch?v=JxAXlJEmNMg

David goes through the history of development and I find it enlightening. He mentions it VERY breifly but many government contractors and researchers ended up using XML a lot. It came from another standard that they developed. As such, it was easier for them to write XML templating.

Then again this isn't a bad thing for two reasons:

    1. Someone else being bad at writing Java doesn't mean Java is bad.
    2. Sometimes XML is the correct way to do things. Do you write ALL of your web pages in Javascript adding elements in with document.createNode....()? No you use an XML notation. 
Java has gotten out of hand with XML because monkey-see-money-do but that doesn't mean the language is bad. I blanket refuse to use XML-requiring libraries. I just right my own implementation if it's required. I've done it for a game I'm working on. I've tossed all UI libraries as they all need XML and I think it's a waste of my time. I can write the library, and then use the library faster then I can read all the documentation about writing their stupid XML format.

> What claims need numbers? LLVM and PyPy exist. JS with JIT kicks the pants off of almost everything --- because it is compiled down to native machine code. Go look them up for yourself. JIT is the new fad, and it's a huge deal.

I've worked a lot with NodeJS, I've worked a lot with LLVM, and I'm about to do a lot of work with libdill (you'd like it if you've not seen it). I love lazy evaluated, JITed, and optimized languages. Runtime or no. That's why I love Java.

Java, especially after Jigsaw, will have major opprotunities to blow other languages out of the water. Java is great in runtime performance but horrible in startup performance. For server applications you can't get much better.

> Name one.

http://www.dnsjava.org/

I think Commons has one but I like this better as it's not-Commons. In my book that's a feature.

> I write code to get the job done so I can get paid, my company's stock price can go up, and I can get money. It's a job. Yes, I love programming, but I prefer to get as much done with as little work as possible. > Yeah, you strike me as someone who only knows Java. Let me know if I'm wrong.

My resume includes Python, JavaScript, C++ (now), C, Java, PHP, X86/ARM Assembly, LISP-Like languages and a few other things that I'm not remembering off the top of my head. I've got one project coming up in Go as well. This is in order of most-recent-project. Today I wrote something that will search craigslist and ebay for a x220t with an I7 and email me all of the results under $200. I'm looking for one and I'm in college so I'll just wait it out for the price to be right. Anyway, that was a Python project.

I also TA for a Python class at my university which I've successfully shot down trick questions from that one way-too-smart student that we all were once a time (He tried to tell the prof to use xrange instead of range for a performance boost and I had to bud in and say "xrange was removed" since he was stuck in the land of Python 2). I've also ported over Python code bases from 2 to 3. I mention Python so much because it seems as if you're a fan.

I hope that well establishes my programmer-cred.

>Let me change your example:

   class Test {
   	private final int i;
   	public Test(int i) {
   		this.i = i;
   	}
   	public Test() {
                this.test(7);
   		this(10);
   	}
   
   	private void test(long number) {}
   }
This is the best behavior to have. If you haven't initialized the state of a class you shouldn't acess it's methods. I'd rather have this rather then have an uncertianty about the contents of uninitialized state.