Live data from Hacker News

Go Rocks - How Can We Avoid Something This Bad In The Future?

acooke.org

51–60 of 68 posts

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#51
post #26
post #22

Earlier quoted context omitted.

I guess it is something like the Valley of The Uncanny for languages. Yes, it looks deceivingly similar to C++, C & Java, but is not any of those. When your eyes see the syntax, your brain expects the functionality to be the same. However Go does introduce fairly radical new paradigms (goroutines, type inference...) that really upsets that initial feeling of familiarity. I (unlike the majority) like Erlang's complete…

I agree except for the whole ";" "," "." line endings issue. When I can't copy and paste to move lines around without "fiddling" with the line endings, I get angry.

I think the solution is to treat those as line beginnings rather than endings: http://news.ycombinator.com/item?id=2389715

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#52

I work on Rust, which is in a similar space to Go. IMHO this article is oversimplifying. (1) Recursive anonymous functions: This is the first time I've heard this criticism. MLs usually don't have this functionality either. It's not too much trouble to give the function a name. (2) Tail call optimization: TCO isn't free. It requires all callees to pop their arguments, which slightly penalizes every call in the progra…

(1) MLs allow to nest named functions. Go only allows named global functions, and lacks a feature that Pascal had.

(2) Someone has to do cleanup anyhow. Either the caller or callee. (I am no expert in calling conventions) Anyhow, isn't this practically free, because the stack is in the L1 cache?

(3) To implement lightweight threads (ala. Erlang, Go, Stackless) you already can't allocate your activation records on the C-stack. So the main cost for call/cc is already paid for. Besides, Go lacks any form of non-local jumps, so escape continuations alone (setjmp/longjmp) would already be an improvement.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#53
post #49

I work on Rust, which is in a similar space to Go. IMHO this article is oversimplifying. (1) Recursive anonymous functions: This is the first time I've heard this criticism. MLs usually don't have this functionality either. It's not too much trouble to give the function a name. (2) Tail call optimization: TCO isn't free. It requires all callees to pop their arguments, which slightly penalizes every call in the progra…

Can you elaborate on how popping arguments penalizes every call? It seems like, for non-variadic calls at least, it should take the same amount of time to add a constant to %esp whether you're doing it in the RET instruction or in the caller; but factoring that code into the callee should improve code density and therefore icache hit rates. What am I missing?

Callers have to readjust the stack after each call when TCO is enabled, but without TCO a function can allocate outgoing argument space for every function invocation up front and reuse that space for every call.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#54
post #21
post #4

I wrote a bunch of go code this morning. It's definitely got a few really neat ideas in it. I tend to write erlang or c++ mostly for my day job. I do really wish the designers had a bit more erlang experience. Just a touch. Just enough so that I had a way to propagate the death of a goroutine through a bunch of other goroutines without building all of that manually. For example, code I wrote today: http://pastebin.co…

> I do really wish the designers had a bit more erlang experience. I feel the same way. I had this hope that this would be what I would learn instead of Erlang. You know it has goroutines and channels -- kind of like processes and casts. Well except that it is not the same. Erlang's processes that have explicit pids and messages are cast to those processes by referring to their pid, make a lot more sense to me than a…

I think Rob Pike discusses some of the differences between the Go and Erlang CSP-like models:

http://confreaks.net/videos/115-elcamp2010-go

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#55
post #28

I really wanted to learn something from this post, but it's mostly just hyperbole and whining. "It turns out that, in Go, you can't write a self-recursive anonymous function - there's no way to make it refer to itself. Well, you can do a dirty hack that's the "official work-around" (I'll let you google for the bug report)." To summarize this argument: 1. It is impossible to have a self-recursive anonymous function in…

This is what they want:

    func outer(a int) {
        func inner_helper(b int) {
            ...
        }
    }
Pascal allowed nested functions 40 years ago...

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#56
post #33
post #19

Earlier quoted context omitted.

Wow, that's not intuitive. :) Throwing in a "defer close(ch)" and that range thing did exactly the right thing. I'm not sure my API is right, but I know how to get it right now. Thanks a lot.

I'm surprised you say it's not intuitive. What is it just that you didn't know you could close channels?

The idea of using "range" across what should generally be an infinite channel is not something I would've guessed existed.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#57

No syntactically lightweight way of writing anonymous recursive functions? I can't make myself care about that; I just spent 30 seconds trying, and failed. That's just not a use case worth optimizing for in a practical systems language. Also, it's true that the Go spec doesn't guarantee tail calls are optimized. If Go were designed to be a functional language, that'd be problematic. However, guaranteeing TCO isn't fr…

> Go isn't a very good language in theory, but it's a great language in practice, and practice is all I care about, so I like it quite a bit.

just like C was meant to be a practical language for writing Unix tools. thanks for your comment.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#58

I don't think Go's creators are as ignorant of academic ideas as you say. I've seen Rob Pike refer to OCaml a lot for instance. They just don't seem to like many of those ideas.

I cannot recall him ever saying the word "OCaml".

It's possible that I am mistaking Pike for someone else on the Go team.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#59
post #46
post #23

Earlier quoted context omitted.

I'm a full time OCaml dev these days and I run into OCaml's 'lack of lightweight anonymous recursive functions' maybe three times a year. It costs 3 lines of code to declare the function (called loop() or whatever) and then call it. I've never realized I was supposed to want to switch languages because of it. Otherwise, this comment makes me more interested in Go than I have been before. OCaml has a bazillion feature…

what about pattern matching? that is imo one of the saddest omissions from go - it's not a "huge" feature like continuations, but i find it makes a language significantly more pleasant to work with.

Channels + select are a pretty good replacement for what one usually uses pattern matching in Erlang.

There are pros and cons for both models, but they are roughly equivalent and I never missed pattern matching in Go.

Re: Go Rocks - How Can We Avoid Something This Bad In The Future?

#60
post #59
post #46

Earlier quoted context omitted.

what about pattern matching? that is imo one of the saddest omissions from go - it's not a "huge" feature like continuations, but i find it makes a language significantly more pleasant to work with.

Channels + select are a pretty good replacement for what one usually uses pattern matching in Erlang. There are pros and cons for both models, but they are roughly equivalent and I never missed pattern matching in Go.

Pattern matching isn't just a feature to aid concurrent programming; it's extremely helpful for all sorts of code. However, since Go doesn't have unions (either tagged or unsafe), pattern matching in Go wouldn't be particularly powerful anyway.
Post reply on HN