News for hackers. Stuff that matters.
Re:Program your next server in Go by pvelagal on Tuesday June 07, 2016 @03:04PM (#11856889)
Slide 13 (https://talks.golang.org/2016/applicative.slide#13) is interesting. I was expecting Go to be very close to C/C++ on the X axis (fast/efficient) as it doesn't use VM, but it is more close to Java ?
Re:Program your next server in Go by _ph_ on Tuesday June 07, 2016 @06:33PM (#11858532)
Ideally, Go should be pretty close to C, but currently there are reasons for it lagging behind (though there are also Go programs which perform better than their C counterparts):

- The Go compiler certainly isn't as sophisticated as the better C compilers. It looks that the code produces by Go 1.7 is quite improves vs. 1.6 with the SSA compiler and I would expect further gains in future releases.

- The Go compiler does not offer optimization levels and overall is optimized for compilation speed to, so these tradeoffs could be limiting.

- While the Go GC is very good and improving, so that the pauses are very low, it does use CPU, also while running in parallel to the program. How much exactly very much depends on the allocation behavior of the program, but should be accounted for.

Re:Program your next server in Go by eudoxus on Tuesday June 07, 2016 @03:30PM (#11857092)
It's true that Go compiles down to an executable and doesn't run on a VM like Java, but it does have it own runtime compiled into it, which manages the GC and goroutine scheduler to name two, so there is definitely some more overhead to Go then just straight C/C++
Re:Program your next server in Go by pcwalton on Tuesday June 07, 2016 @03:33PM (#11857116)
In addition, the language isn't designed for zero-cost abstractions like C++ is. You see this in the design of things like defer, which requires allocating records on the heap in certain cases, as compared to exceptions in C++ which can be implemented in a zero-cost manner.
Re:Program your next server in Go by weberc2 on Tuesday June 07, 2016 @04:16PM (#11857439)
I think interfaces are a better example, personally.
Re:Program your next server in Go by mahyarm on Tuesday June 07, 2016 @11:23PM (#11859776)
In my experience programming speed goes like this:

- 1x benchmark - C / static C++

- 2x slower - pure virtual C++ / objective-c

- 3x slower - statically typed GC languages (java,go)

- +6x slower - dynamically typed GC languages (js, python, etc)

After a well optimized implementation, speed comes down to manual vs GC memory management, static vs virtual function dispatch, dynamic vs static typing and heap vs stack allocation.

Compile speed is usually slowed down by any sort of type inference or templating/generics, which is probably one reason why go resists implementing generics or subclassing

Re:Program your next server in Go by snovv_crash on Wednesday June 08, 2016 @01:45AM (#11860271)
That 6x is for when you have a JIT. Without one (I'm looking at you, CPython) it is 20-30x, with perhaps the exception of Lua.
Re:Program your next server in Go by shpx on Wednesday June 08, 2016 @09:29AM (#11862119)
Re:Program your next server in Go by tyingq on Wednesday June 08, 2016 @08:59AM (#11861922)
Two considerations...

Your rules of thumb are probably mostly related to CPU bound tasks. If database i/o is the bottleneck, then the differences across language probably don't matter much.

And, runtime performance isn't always the most important thing. In many cases, "time to market" or "cost of development" might be a higher order priority. In those cases, a higher level language might be more attractive.

Re:Program your next server in Go by slmyers on Wednesday June 08, 2016 @03:02AM (#11860532)
Sorry, but I feel like I'm a little confused by your post. How can it be 6 times slower to program in JS or Python than C? Isn't this very much contrary to the conventional wisdom?
Re:Program your next server in Go by pmontra on Wednesday June 08, 2016 @05:41AM (#11861074)
I think OP wrote programming speed but meant running speed.
Re:Program your next server in Go by mahyarm on Wednesday June 08, 2016 @01:39PM (#11864012)
Yup. "Speed of the programming language"