Earlier quoted context omitted.
Yes Java is as quick as anything else once it is up and running ; the point GP was making was getting to this warmed up state is what makes people perceive java as slow.
A situation that only occurs if one doesn't make use of JVM that cache JIT code like IBM J9, or willing to pay for an optimizing AOT compiler like Excelsior JET. Also another example is those that perceive the JVM as slow due to using it with Clojure, when the slowness in this case is caused by the Clojure implementation itself.
Why is this Go faster than the equivalent Java?
81–90 of 105 posts
Re: Why is this Go faster than the equivalent Java?
#82Earlier quoted context omitted.
Java is not slow in practice. Many top trading systems have been written in it, including the excellent and widely licensed nasdaq architecture (omx, singapore, asx, swx, etc) and the independently designed Lmax Disruptor. You do not have to use any library you don't want to. there is nothing stopping you from building everything in preallocated byte arrays, and never triggering gc. Nio2 is fast. Jvm is a leading fou…
Yes Java is as quick as anything else once it is up and running ; the point GP was making was getting to this warmed up state is what makes people perceive java as slow.
But on perceptions: naive perceptions don't justify a false statement. So why draw focus to them, why excuse them? Facts trump perceptions.
Re: Why is this Go faster than the equivalent Java?
#83Earlier quoted context omitted.
Given a specific machine with a set amount of cpu, ram, and io bandwidth, I find I can easily do more on that machine with go than java. Also, try running multiple java processes on a machine as opposed to multiple go programs.
So could I. I imagine a Java aficionado would say the opposite. Like I said, different ways to think about the problem.
Re: Why is this Go faster than the equivalent Java?
#84Earlier quoted context omitted.
So could I. I imagine a Java aficionado would say the opposite. Like I said, different ways to think about the problem.
To the posters point about running multiple Java aaps on a single machine, I think ram is the real issue. Java makes in my experience far less frugal use of it. I've seen Java applications eat hundreds of mbs of ram rewritten in Go using 1-2 mb.
Re: Why is this Go faster than the equivalent Java?
#85Earlier quoted context omitted.
Hmm... I was asking because I am about to graduate in CS. But I think I like Sysadmin stuff more.
If you can program well, and like some aspects of sysadmin-ing, then becoming a Site Reliability Engineer (at eg Google) might be for you. There are always looking for people. (I used to work as an SRE, before I made my way back into functional programming and finance recently.)
Re: Why is this Go faster than the equivalent Java?
#86Earlier quoted context omitted.
Continue with your CS degree. In my experience, all good sysadmins have significant development experience. This is especially useful when working at small companies/startups.
I'd like to counter (but not disagree) with: in my experience, all good developers have significant sysadmin experience, whether professionally or self-taught. As a tech lead of a team that is largely junior, I keep running into places where a lack of sysadmin-type knowledge seriously harms the ability of a CS degree holder (anywhere from BSc to PhD) to do real-world software engineering work unless they have either…
However, if you haven't had networking experience in college, you went to a terrible program. I had exposure to networking (at Cal) in 3-4 classes.
Re: Why is this Go faster than the equivalent Java?
#87I'm surprised the warmup problem in Java hasn't been invoked here yet. Java has bootstrap and warm-up overhead which for comparisons like this one may have a decisive impact on the perceived results. What will happen is (after the JVM starts), there will be (by default) 10000 interpreted iterations, then shortly after that a stop-the-world pause to replace slow interpreted code with its native counterpart JITed by a…
In Java 8 tiered compilation became the default. After a first threshold is reached, a method or loop will be compiled as a first approximation with further record keeping. At the second threshold, a more aggressively optimized version without record keeping will be put in place. This is kind of like the merging of the old C1 and C2 compilers into one to help get up to speed quicker.
When you want to measure this stuff you use JMH, Java Microbenchmarking Harness, an amazing piece of work that will warmup the JVM before executing performance tests. Be very careful writing your own Java timing code, and for the most part rely on JMH.
Re: Why is this Go faster than the equivalent Java?
#88The moment I saw the problem I started coding :-) https://gist.github.com/depp/3a6f0377284fbb9b33984063856051b... Rather than brute forcing all possible permutations, we start from all possible final states and BFS backwards towards starting states. There are probably tons of opportunities for further optimization, but this takes ~800 ms on my desktop, and it only uses one core. We don't need to track the number of t…
Edit: Is it because each solution must take into account every possible permutation of gameplay?
Re: Why is this Go faster than the equivalent Java?
#89That problem is that type of problem that is well suited for a prolog system with a constraint library.
The problem that I see with Prolog in this case is that a simple solution is simple because it is turning the search over to Prolog's built in constraint solver that knows nothing of the problem. This often leads to unacceptable performance with Prolog; performance problems can sometimes be addressed in practice by the appropriate placement of the cut operator within the logical specification of the constraints. This, at least in my experience, makes understanding what the program is doing very difficult.
Generally, I view Prolog (along with languages like Smalltalk) as a language appropriate for some problem domains that have come to the end of their lifetime because mainline, more generally useful, languages have adopted their features or incorporated them in libraries.
Re: Why is this Go faster than the equivalent Java?
#90Not as fast as dietrichepp's solution, but not terrible either, and probably the winner in terms of memory use. Since there's no state to keep track of, adding parallelism with OpenMP was trivial, too.