News for hackers. Stuff that matters.
Re:Playing with Go1.1beta2, it's much faster by cmccabe on Tuesday April 09, 2013 @12:52AM (#5516497)
Slower than Java at what?

At program startup time? Java is a joke in this area.

At memory consumption? Java has a high fixed memory cost. It also uses more memory than Go does. There are fundamental reasons for this. Java needs to keep around runtime type information because the code can change at runtime due to new classes being loaded. Go does not. Java also chose to implement a scheme where any object can serve as a mutex or condition variable. The result is a few words of extra memory per object when compared with Go... usually somewhere in the neighborhood of 8 or 16 bytes per object, depending on architecture. Using memory efficiently is HUGE in modern architectures and Go is better at that.

Go also gives you more control over how your program uses memory. This is because Go has both pointers and value types. The result is that things that would have had to be "boxed" (i.e. separate memory allocations) in Java can be unboxed in Go. If you know C, think of it as the difference between doing a malloc for each structure element, and just having a bunch of structs stored by value inside another struct.

Go is faster at interfacing with native code. Have you checked the speed of JNI lately? Speaking as someone who's written a lot of JNI... it's not pretty.

Java still has the edge in one area: HotSpot has a precise garbage collector, something Go doesn't currently have. But I have a feeling that gap is going to be closed.

Note: I am oversimplifying the unboxing discussion a bit. In theory, it might be possible to unbox certain structures in Java, such as non-nullable final fields. However, Go preserves a lot more of the intentions of the programmer in this regard-- and without knowing how the programmer intended to use the memory, most optimizers will struggle.

Re:Playing with Go1.1beta2, it's much faster by coldtea on Tuesday April 09, 2013 @03:52AM (#5516919)
>Slower than Java at what? At program startup time? Java is a joke in this area.

No. In actual performance for most cases of algorithmic code.

http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...

Java is 2-6 times faster and uses more memory for slightly more code. I'm willing to trade.

Yes, "those are not real world programs etc". In general the shootout gives a quite realistic results (not to mention that anybody who thinks he can do better can go code his own solution). Programs are programs. In my own tests with larger programs Go has been 1/2 the time of Python and slower than Java too. If you're not IO bound, those things matter. If you are IO bound, you could as well run Python, since you aren't missing much.

Startup time doesn't matter at all except if you do scripting or old-style CGI. Java (and Go for that matter) target long running network servers and such.

>Go also gives you more control over how your program uses memory.

On the other hand Java gives most control to the JVM, which is smarter than most programmer's fine tuning and knows a whole lot more about the code's runtime behavior.

Re:Playing with Go1.1beta2, it's much faster by enneff on Tuesday April 09, 2013 @04:08AM (#5516961)
> Programs are programs

The programs in the shootout are nothing like the programs people typically run and write. For instance, most of the programs I write do a lot of I/O. The shootout programs do none.

> Startup time doesn't matter at all

It certainly does in cluster environments where you regularly spin up new server instances. It's also important for command-line tools.

Re:Playing with Go1.1beta2, it's much faster by bad_user on Tuesday April 09, 2013 @07:13AM (#5517343)
> It certainly does in cluster environments where you regularly spin up new server instances. It's also important for command-line tools.

This is certainly true, however not because of the startup time per se which is entirely negligible, especially compared to the time it takes to boot the whole freaking OS, but rather because of the warmup time of the JVM ... for high-volume apps, cold JVMs don't provide a good throughput and so you need a smart load-balancer that knows to not route as many requests as it can to cold machines.

To alleviate that, when the auto-scaling feature kicks in to add new machines on Amazon's EC2 (using their load balancer called ELB), it ads 3 machines instead of one.

Then the auto-scaling feature kicks in again when the latency levels are lower than a threshold for 30 mins, removing machines from the cluster and so it stabilizes itself to the optimal number of machines required.

Compared to Go however, I would still go with Java, because you can do a lot more with a Java server. Our app is both CPU bound and I/O bound and is able to process about 4000 requests per second per server in under 30ms per served request on c1.medium instances. And this is for a real world app that needs to do logging and requests to Memcached/DynamoDB and make predictions in real time.

In my experience, the only way we could have better bang for the buck would be to build the app in C/C++.

Re:Playing with Go1.1beta2, it's much faster by coldtea on Tuesday April 09, 2013 @06:40AM (#5517241)
>The programs in the shootout are nothing like the programs people typically run and write. For instance, most of the programs I write do a lot of I/O. The shootout programs do none.

Which is as well, because you only want to benchmark for CPU bound parts of the program.

IO is the same speed for all languages, so it cancels out.

>It certainly does in cluster environments where you regularly spin up new server instances.

Not really a common use case.

>It's also important for command-line tools.

I don't think command-line-tools are Go's or Java's niche.

Re:Playing with Go1.1beta2, it's much faster by enneff on Tuesday April 09, 2013 @07:04AM (#5517312)
> IO is the same speed for all languages, so it cancels out.

That's not true, particularly in concurrent systems. Recent improvements to Go's scheduler (that make it more aware of various I/O concerns) have made it 2x faster under some workloads. You don't just optimize the compiler to produce the tightest code, you must also finesse its integration with the rest of the world.

> Not really a common use case.

If you say so.

> I don't think command-line-tools are Go's or Java's niche.

There are a lot of Go command-line tools out there. I think Go is a superb language for this area.

Re:Playing with Go1.1beta2, it's much faster by coldtea on Tuesday April 09, 2013 @07:39AM (#5517434)
>>Not really a common use case. >If you say so

Why the irony? How many cluster deployments you know where you "spin up instances all the time"???

Compared to general server / network application programming done in both Java and Go it's LESS than a drop in the bucket.

If you work somewhere that this does not hold, you could also be an outlier.

Re:Playing with Go1.1beta2, it's much faster by redbad on Tuesday April 09, 2013 @08:44AM (#5517659)

    > Why the irony? How many cluster deployments you know 
    > where you "spin up instances all the time"???
Any cluster environment whose applications abide 12-Factor semantics stands to benefit greatly from low startup times. This describes both SOA environments like Amazon and Netflix, and PaaS environments like Heroku and [what is enabled by] Docker.

http://12factor.net

Re:Playing with Go1.1beta2, it's much faster by igouy on Tuesday April 09, 2013 @10:10AM (#5518103)
> the programs people typically run and write

How do you know what programs people typically run and write?

Assumption? Guess? Data?

Re:Playing with Go1.1beta2, it's much faster by enneff on Tuesday April 09, 2013 @05:09PM (#5521396)
A large part of my job is meeting programmers around the world and talking to them about what they do.

But you can draw the same conclusion by browsing GitHub.

Re:Playing with Go1.1beta2, it's much faster by igouy on Wednesday April 10, 2013 @12:09PM (#5526001)
Thank you for understanding that it's ordinary to be asked for clarification about something we've said.

1) I think the way in which the benchmarks game programs are most unlike a lot of other programs is that these are tiny tiny toy programs.

"Toy programs" as-in -- http://books.google.com/books?id=gQ-fSqbLfFoC&lpg=PP1...

And that's intentional.

2) Why do you say "...I/O. The shootout programs do none."?

regex-dna, k-nucleotide, and reverse-complement do read data in FASTA format before processing.

(fasta and reverse-complement also write data in FASTA format -- but redirected to /dev/null)

Not TBs of I/O but not none.

Re:Playing with Go1.1beta2, it's much faster by Roboprog on Tuesday April 09, 2013 @09:31AM (#5517903)
It seems odd to me that the language shootout is so "algorithmic", and that there doesn't seem to be a test that works through a lot of string manipulation. Most web apps seem to simply generate a bunch of useless beans and womp through strings in prepared statements and page templates. Benchmark that???
Re:Playing with Go1.1beta2, it's much faster by igouy on Tuesday April 09, 2013 @12:29PM (#5519197)
?

    regex-dna

    reverse-complement 

    k-nucleotide
Re:Playing with Go1.1beta2, it's much faster by igouy on Tuesday April 09, 2013 @10:02AM (#5518066)
To be fair, the benchmarks game pages most people look at still show Go 1.0.3, and won't be updated until Go 1.1 final.
Re:Playing with Go1.1beta2, it's much faster by trailfox on Tuesday April 09, 2013 @02:46AM (#5516776)
For most applications the startup time is irrelevant. The startup time of a server app which runs for months is not an interesting data point. The throughput in requests per second is far more important and this is where the JVM has been very strong (3x faster than Go 1):

http://www.techempower.com/blog/2013/03/28/framework-benchma...

Memory consumption is often not a major concern on modern systems, saving 50 MB or even 500 MB is seldom as important as the ability to process more requests per second.

I'm busy learning Go, and am very impressed by the performance gains in 1.1 (and GC improvements). My main concern at the moment is how much less expressive the language is relative to Python, Scala and Ruby. Go is fast, but so is Scala, and Scala is also very expressive compared to Go.

Go has a definite edge in environments where memory footprint is important and simple interfacing with native libraries is critital. Scala and the JVM are still more appealing to me in most other areas.

Re:Playing with Go1.1beta2, it's much faster by agentS on Tuesday April 09, 2013 @03:18AM (#5516856)
To be fair, I would rather write this: https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...

rather than this: https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...

(not to mention the 2 other Java files to setup the server).

Re:Playing with Go1.1beta2, it's much faster by icebraining on Tuesday April 09, 2013 @06:25AM (#5517209)
Well, that's using a particular framework (netty). Play seems much simpler.
Re:Playing with Go1.1beta2, it's much faster by coldtea on Tuesday April 09, 2013 @07:43AM (#5517444)
Not to mention this gives you a lot of flexibility and quite a battle tested backend, whereas the Go equivalents are still mostly in progress and less flexible.

Oh, and in the recent shootout, netty gets to 30,000 rpm, whereas Go peaks around 10,000.

Re:Playing with Go1.1beta2, it's much faster by voidlogic on Tuesday April 09, 2013 @09:40AM (#5517953)
First off, is was 14k vs 38k. Just wait until next benchmark update when they have switched to Go 1.1

Based on these results Go and Netty should be much closer: https://gist.github.com/errnoh/5320784

Re:Playing with Go1.1beta2, it's much faster by errnoh on Tuesday April 09, 2013 @06:38AM (#5517237)
I'll skip most of the Java vs Go discussion but as you're probably aware that was Go 1.0.3 running on that benchmark.

Here's Go 1.1 vs 1.0.3 on a bit beefier machine: https://gist.github.com/errnoh/5320784

Next benchmark will have Go 1.1 running, can't promise that it'll scale as well as on this server but it'll be significant change anyways.

And most of all, main part of the language is that it's intuitive to write and comes with a clear and readable spec and standard library.

edit: updated gist with Netty using the same configuration

Re:Playing with Go1.1beta2, it's much faster by ansible on Tuesday April 09, 2013 @07:24AM (#5517380)
Memory consumption is often not a major concern on modern systems, saving 50 MB or even 500 MB is seldom as important as the ability to process more requests per second.

The difference between 50 MB and 500 MB is that the former is more likely to fit in L3 cache than the latter. Ignore that difference at your peril.

Re:Playing with Go1.1beta2, it's much faster by voidlogic on Tuesday April 09, 2013 @09:45AM (#5517980)
>>Memory consumption is often not a major concern on modern systems, saving 50 MB or even 500 MB

Tell that to the folks that have to pay for cloud or VPS servers... Also, less memory usage means higher CPU cache hit rates and fewer page faults.

Re:Playing with Go1.1beta2, it's much faster by Ziomislaw on Tuesday April 09, 2013 @11:58AM (#5518978)
what do you mean by expressive?

are you _really_ sure it is not just your bias that is preventing you from "expressing" what you want? ie. you want to write python/java in Go?

Re:Playing with Go1.1beta2, it's much faster by trailfox on Tuesday April 09, 2013 @04:20PM (#5521028)
Go typically requires 2-4 times less code to do the same thing:

http://benchmarksgame.alioth.debian.org/u32/benchmark.php?te...

Re:Playing with Go1.1beta2, it's much faster by igouy on Tuesday April 09, 2013 @06:52PM (#5521988)
Not 2-4 times less than those Python programs (less would be shown as a fraction), but 2-4x more.
Re:Playing with Go1.1beta2, it's much faster by cmccabe on Tuesday April 09, 2013 @03:03PM (#5520357)
Memory consumption is often not a major concern on modern systems, saving 50 MB or even 500 MB is seldom as important as the ability to process more requests per second.

That's what the original designers of Java thought too. It turns out that this thinking is wrong, though. Main memory may be big, but CPU caches are still small. For example, the laptop I am typing this on has 64 kilobytes of L1 cache, 256 kilobytes of L2 cache, and 3072 kilobytes of L3 cache. That is not a lot. Turns out, when you're spending all your time waiting for main memory, you are not "processing more requests per second." Main memory is at least two orders of magnitude slower than CPU cache.

Re:Playing with Go1.1beta2, it's much faster by batgaijin on Tuesday April 09, 2013 @02:51AM (#5516785)
Re:Playing with Go1.1beta2, it's much faster by pjmlp on Tuesday April 09, 2013 @03:54AM (#5516925)
> At program startup time? Java is a joke in this area.

It is always a matter if you are using a JVM (from which vendor) or compiling to native code.

Language != Implementation

Re:Playing with Go1.1beta2, it's much faster by enneff on Tuesday April 09, 2013 @04:11AM (#5516964)
> Language != Implementation

Ideally, yes. But in practice a language and its implementation (whichever one you choose) is a tool. If you're comparing tools, you've got to compare a language with its implementation.

Re:Playing with Go1.1beta2, it's much faster by pjmlp on Tuesday April 09, 2013 @04:43AM (#5517027)
So what you compare when a language happens to have multiple implementations?

Which from 6g, gogcc, go express you pick for Go?

Which from OpenJDK, Oracle JVM, IBM J9, gcj, RoboVM, Aonix Perc ... you pick for Java?

Which from Sun Forte, IBM xlc, hpcc, gcc, clang, CINT, Visual C++, ... you pick for C or C++?

Which from CPython, IronPython, PyPy, JPython, ... you pick for Python?

Re:Playing with Go1.1beta2, it's much faster by coldtea on Tuesday April 09, 2013 @11:20AM (#5518684)
That's easy. Except for C++, which is a multi-vendor language.

For all others there is a definitive, used in the overwhelming majority of cases, implementation:

Go: 6g Java: Oracle JVM Python: CPython Ruby: Matz's Haskell: GHC ...

Re:Playing with Go1.1beta2, it's much faster by pjmlp on Tuesday April 09, 2013 @12:04PM (#5519028)
Except that in many cases, e.g. Python, the canonical implementation is not the fastest one.

So of course, the presenter will carefully select the best implementation to prove his arguments, even if there are others available that contradict him/her.

Re:Playing with Go1.1beta2, it's much faster by enneff on Tuesday April 09, 2013 @05:15AM (#5517086)
It depends what you're trying to compare.
Re:Playing with Go1.1beta2, it's much faster by pjmlp on Tuesday April 09, 2013 @06:50AM (#5517269)
It is always up to the present to use the evidence that better fulfills its goals in the eyes of others.
Re:Playing with Go1.1beta2, it's much faster by cmccabe on Tuesday April 09, 2013 @03:11PM (#5520416)
There are fundamental language reasons why Java has a slow startup time. jar files do not contain native bytecode. Instead, they contain standardized, platform-independent bytecode for the Java Virtual machine. What this means in practice is that when you start up, you have to convert all this Java bytecode to native bytecode. This is a CPU and IO-intensive operation. It would be a little like if the first thing your C++ program did was compile itself every time it was run!

There are advantages to the way Java does things. You can distribute a single binary for multiple architectures, for example. However, it does have costs, and one of those is slow startup time.

Re:Playing with Go1.1beta2, it's much faster by pjmlp on Thursday April 11, 2013 @10:33AM (#5532171)
If you distribute jar files yes, there are however Java compilers that generate native code, if you are willing to pay for them.

Even Sun, nowadays Oracle, sells them as part of the Java SDK for embedded platforms.

That the JVM from Oracle, that most people think as the only way to run Java, does not offer that option out of the box, does not mean other vendors don't do it.