Live data from Hacker News

Why I Program in Go

tech.t9i.in

21–30 of 171 posts

Re: Why I Program in Go

#21
post #18

Earlier quoted context omitted.

My day job involves working with Java and C++ on 10+ year old systems. All of my hobby or side projects are in Go these days with occasional diversions into haskell, ML or various Lisps. So I'll try to impart some understanding of why I would switch to Go from Java or C++. First lets get some things out of the way. Go is fast enough and getting faster very quickly and it definitely has a smaller memory footprint. So…

How did you write a go script faster than a python script? That sounds intriguing.

edit script in vim.

use :!go run %

It will compile and run the script so fast you will swear it was an interpreted language except it runs way faster than an interpreted language.

Re: Why I Program in Go

#22

Those are many of the same reasons I program in Go. To add another: * Go's build tools and the language's overall approach to building projects are fantastic. For the vast majority of projects you don't need an external build manager like make. One of my least favorite bits of programming in C and C++, even when I was doing that on a daily basis years ago, was the huge morass of make/autoconf hell that would grow up…

Actually, the "get" command implies "build" and "install", so it's just (a real example):

  go get github.com/nf/todo
and you get a todo binary in your workspace's bin directory.

Re: Why I Program in Go

#23
post #19

Earlier quoted context omitted.

Yeah- that is great as long as you don't care about using 30x times more memory.... The awesome bloat cough I mean power of the JVM in action. Go vs Scala: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t... It will be interesting to re-visit this when Go 1.1 is out as well. Go being even younger than Scala has a lot of low hanging optimization fruit. :) P.S. If Go didn't exist I would still be using Java…

The memory consumption is probably mostly due to the JVM's GC implementation that can be very finely tuned (although large RAM footprint surely is a feature of the JVM). Some of the bloat is, true, baggage that's been accumulated through the years, but that's being taken care of in Java 9. And the rest of the "bloat" is there for a reason. Let me put it this way: if you have a program that absolutely requires JVM per…

I agree about the great tools, I have used them.

But for being so simple Go gives you a lot of tools as well: http://golang.org/pkg/runtime/pprof/ http://golang.org/pkg/net/http/pprof/ http://blog.golang.org/2011/06/profiling-go-programs.html Go also has gdb support I used from my IDE (http://golang.org/doc/gdb)

Re: Why I Program in Go

#24
post #17

Earlier quoted context omitted.

>Here, too, the author says that he didn't like Java's IDEs (really? does Go have better tooling? You should really write a GO code to understand what the author means. Writing GO code has no frills. And I have seen nothing cooler than: http://gofmt.com/ .

Even if that's the case, Go just brings too little to the table. And if you think gofmt is cool, take a look at Project Jackpot [1], or its use in the NetBeans IDE [2]. [1] https://bitbucket.org/jlahoda/jackpot30/wiki/Home [2] http://netbeans.org/kb/docs/java/editor-inspect-transform.ht...

Those aren't in the stdlib. gofmt is. So is gofix, go vet, godoc and a host of other things. Batteries included means a lot.

Re: Why I Program in Go

#25
post #10

For the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the argu…

Go programs don't just use less memory, the language makes it possible to control memory allocations.

With the JVM-based languages I'm familiar with, it is difficult to control the memory allocation characteristics of you program, and typically the further the language deviates from the JVM's model (eg, Clojure and Scala) the more garbage must be generated (usually in doing= things like runtime type reflection).

All these allocations put pressure on the garbage collector and, fortunately, the JVM provides a few sophisticated garbage collectors. But even so, I am aware of some high profile companies whose JVM-based servers spend upwards of 80% of their CPU time in the garbage collector. It's just crazy.

On the other hand, the Go language and - critically - its libraries were designed to give the programmer control over the allocation patterns of the program. This creates less work for the GC, and leads to leaner services with predictable performance characteristics.

Go has other advantages over the JVM as a platform, but this is the critical one IMO.

Re: Why I Program in Go

#26
post #25
post #10

For the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the argu…

Go programs don't just use less memory, the language makes it possible to control memory allocations. With the JVM-based languages I'm familiar with, it is difficult to control the memory allocation characteristics of you program, and typically the further the language deviates from the JVM's model (eg, Clojure and Scala) the more garbage must be generated (usually in doing= things like runtime type reflection). All…

I don't see anything special in Go for commanding the GC, can you point me to these APIs?

Re: Why I Program in Go

#27
post #18
post #10

For the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the argu…

My day job involves working with Java and C++ on 10+ year old systems. All of my hobby or side projects are in Go these days with occasional diversions into haskell, ML or various Lisps. So I'll try to impart some understanding of why I would switch to Go from Java or C++. First lets get some things out of the way. Go is fast enough and getting faster very quickly and it definitely has a smaller memory footprint. So…

Oh, I don't doubt many things can be done much better in other languages than Java, only why stop at Go? Clojure pretty much hits every single one of your requirements, it's more modern and expressive than Go, gets concurrency better, and it's about as slower than Go as Go is slower than Java -- and getting faster. Also, you don't have to give up the monitoring and instrumentation the JVM gives you, as well as the vast Java ecosystem.

I'm not saying Go isn't better than Java -- I'm sure it is. My main point is this: if I want to relax, there are more relaxing languages than Go; if I really need JVM-like performance, I'd rather go with Java and not relax as much; and if I need both -- there's Clojure, Scala, Kotlin (soon).

This leaves one point: RAM footprint, which I'll concede. But stacking that against the JVM's monitoring and large ecosystem, I'll take the JVM any day. So, Go is nice. Really nice. But not nearly nice enough to even consider abandoning the JVM (unless you're memory-constrained, in which case the JVM was never an option).

Also:

> Go makes concurrency easy to get right. I haven't seen any other language get this so right since Erlang.

I'm not so sure about that. If I'm not mistaken, most Go objects are mutable and can still be passed as messages.

> Go comes with all the tools you need to programmatically understand Go code... Java doesn't have this.

It does since Java 6: http://docs.oracle.com/javase/6/docs/jdk/api/javac/tree/inde...

Re: Why I Program in Go

#28
post #25
post #10

For the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the argu…

Go programs don't just use less memory, the language makes it possible to control memory allocations. With the JVM-based languages I'm familiar with, it is difficult to control the memory allocation characteristics of you program, and typically the further the language deviates from the JVM's model (eg, Clojure and Scala) the more garbage must be generated (usually in doing= things like runtime type reflection). All…

The only reason you hear less "crazy" Go GC stories is because Go has never been tested as much as the JVM under different application requirements. And if high-profile companies have servers that spend 80% of the time in GC -- well, they must have really neglected their code. That's a result of poor software maintenance, and I doubt any language could help them.

Re: Why I Program in Go

#29
post #25
post #10

For the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the argu…

Go programs don't just use less memory, the language makes it possible to control memory allocations. With the JVM-based languages I'm familiar with, it is difficult to control the memory allocation characteristics of you program, and typically the further the language deviates from the JVM's model (eg, Clojure and Scala) the more garbage must be generated (usually in doing= things like runtime type reflection). All…

If they are spending that kind of time in GC, they are doing something insane. They should send email to hotspot-gc-use and get it solved.

http://mail.openjdk.java.net/pipermail/hotspot-gc-use/

Re: Why I Program in Go

#30
post #22

Those are many of the same reasons I program in Go. To add another: * Go's build tools and the language's overall approach to building projects are fantastic. For the vast majority of projects you don't need an external build manager like make. One of my least favorite bits of programming in C and C++, even when I was doing that on a daily basis years ago, was the huge morass of make/autoconf hell that would grow up…

Actually, the "get" command implies "build" and "install", so it's just (a real example): go get github.com/nf/todo and you get a todo binary in your workspace's bin directory.

TIL.

Thanks, that's good to know. Another (related) wonderful thing about Go is how fast everything compiles, so fast that it never occurred to me that go get was building as part of the install.

Post reply on HN