Live data from Hacker News

Why I Program in Go

tech.t9i.in

71–80 of 171 posts

Re: Why I Program in Go

#71
post #52

> Now, you might want to ... acquaint yourself with [dataflow variables and declarative concurrency] because [they are] the centre-piece of Go's language features. Not so. Go has native support for neither dataflow variables nor declarative concurrency. Go does have native support for message-passing concurrency--but that's different.

You're right about that. However, I find it easier to understand Go's concurrency model by starting with dataflow and then adding one more requisite (channels), than starting with classic fork-and-join and then making a bigger jump to message passing concurrency.

Re: Why I Program in Go

#72

His second point is, to me, the most important for would-be language designers: Standardized formatting: A standard tool to enforce formatting rules that is not subject to change based on the team members' or leader's opinions is a welcome feature for lowering the "not my code" mental barrier. This is a godsend. The best thing to have happened to our industry since a very long time. But his first point is oversimplif…

If the biggest gain for the language is a formatting utility then that language is not worth learning.

Re: Why I Program in Go

#74
post #38

Earlier quoted context omitted.

It's not about commanding the GC. It's about avoiding unnecessary allocations.

OK, can you be specific how this is done? What is the technical reason here?

For instance, in Go everything is passed by value. If you want to pass a reference, you must pass a reference type (like a pointer). This means that you can pass around structs without having to put them on the heap. In JVM-land, nearly everything is passed by reference, and the data must go on the heap.

Relatedly, in Go if you allocate an array of n values of type T, the size of that array in memory is n * sizeof(T), and the items are laid out sequentially in memory. There are no other bookkeeping data structures and no indirection.

Here's a story about one project's struggle with data structures and Java: http://marc.info/?l=git&m=124111702609723

Relevant quote:

    JGit struggles with not having an efficient way to represent a SHA-1.
    C can just say "unsigned char[20]" and have it inline into the
    container's memory allocation.  A byte[20] in Java will cost an
    *additional* 16 bytes of memory, and be slower to access because
    the bytes themselves are in a different area of memory from the
    container object.  We try to work around it by converting from a
    byte[20] to 5 ints, but that costs us machine instructions.
In Go, you would just write [20]byte. If you wanted a struct with a field of [20]byte you can do so, and all it costs is the 20 bytes.

Re: Why I Program in Go

#75
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…

You need to be commended for defending Go. I don't think the Go developers hide the fact that they mean go as a Systems level programming language. It has higher level features, but the developers don't really mind the fact that Go isn't going to be delivering a whole lot of high level features. Maybe if they come in the form of libraries... Funny thing about Go is that as a compiled language, folks often need to sen…

> Funny thing about Go is that as a compiled language, folks often need to send the source-code to the deployment servers to compile on them too.

Not in my experience. Nearly everyone I know who deploys Go code does it by shipping a binary. One of the benefits of static linking.

Re: Why I Program in Go

#76

His second point is, to me, the most important for would-be language designers: Standardized formatting: A standard tool to enforce formatting rules that is not subject to change based on the team members' or leader's opinions is a welcome feature for lowering the "not my code" mental barrier. This is a godsend. The best thing to have happened to our industry since a very long time. But his first point is oversimplif…

If the biggest gain for the language is a formatting utility then that language is not worth learning.

What is the "biggest" gain a language can have is a matter of taste. Someone who considers the handling of formatting and style to be the "biggest" is likely to be one who values those things highly.

That you do not value those things as highly is not particularly profound. It doesn't mean that he is wrong to be excited about that, nor that he is excited about the wrong language, nor even that there is no reason for you to be excited about that language. It only means that there is no reason for you to be excited about that language for that particular reason.

Re: Why I Program in Go

#77
post #63
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…

I have a hard time believing anything can beat or even match the garbage collection performance of the JVM. Not that there is something special about the JVM, just that there have been _so_ many smart people working on the problem for so long now. And for good performance doing server tasks (ie, not computational tasks) exceptional GC is a must. Can a GO program handle a workload that creates tens/hundreds of thousan…

I have to raise the eyebrow to that. I have had more GC problems with Java than any other language. Geniuses fuck up too, and when they do it's pronounced "OutOfMemoryError: PermGen space."

Re: Why I Program in Go

#78

His second point is, to me, the most important for would-be language designers: Standardized formatting: A standard tool to enforce formatting rules that is not subject to change based on the team members' or leader's opinions is a welcome feature for lowering the "not my code" mental barrier. This is a godsend. The best thing to have happened to our industry since a very long time. But his first point is oversimplif…

If the biggest gain for the language is a formatting utility then that language is not worth learning.

The formatting utility is really just a side effect of the decisions to Go team made regarding syntax and semantics in the language. There's also a tool to automatically update your code if the language changes (this was important during the days of rapid churn, where your programs would break every week).

They made some very opinionated choices and have largely stuck by them. You can't have an unused variable, it just won't compile. What a pain, right? Well, if there's one thing I've learned from compiling open source code, it's that you CANNOT trust programmers to clean up their code before releasing it--just play "count the unused variable warnings" next time you compile pretty much any Linux program.

Re: Why I Program in Go

#79

Go nails code readability and documentation better than any other language I'm aware of. For example, look at the package documentation for Go's list data structure at http://golang.org/pkg/container/list/ . 5 seconds of reading this you immediately get what the package does and how to use it. Now let's say you want to know how the list is implemented. No problemo. Click the package files link list.go, http://golang.…

> Go nails code [cut] documentation better than any other language I'm aware of.

That's because you haven't seen PHP's documentation.

Look at your Go's list example.

It doesn't even show how to create a list and fill it with items.

It doesn't have users' comments.

It doesn't explain much about the data structure. Can it be a circular doubly link list, for instance?

Is there a method to empty the list, or quickly insert more than one element?

Instead it has strangely named sections (like "type Element") that aren't obvious to somebody new to the language.

Sorry, but this documentation is shit.

Post reply on HN