News for hackers. Stuff that matters.
Re:Why Go Is Not Good by vorg on Sunday June 29, 2014 @06:22PM (#7962714)
I've recently tryed out Go for its Unicode integration. What I liked at first sight...

* the indexing makes a map[something]boolean act like a set. Sets and maps are so similar it always felt wrong for them to be two separate constructs.

* making exported functions/vars/etc begin with a capital letter. When naming important stuff, it's a relief not worrying about naming conflicts with keywords. When naming locals, just use i,j,p,q,p2 anyway.

* using defer and recover instead of catch and finally. The catch clause is really two functionalities rolled into one and using defer and recover decomplects them.

Other languages should copy those.

What I'm concerned about...

* printf and regex notation are used so much they're really part of the language, but have an entirely separate syntax embedded within strings which must be learnt. But unlike the rest of Go's syntax, they're unintuitive, especially regexes for Unicode. Unicode is meant to be one of Go's strengths. I understand quick parsing is one of Go's primary reason's for existing, but the regex and printf notations could have been cleaner. When you think about it, why are the arithmetic and bitwise operators generally part of a language's primary syntax, but string matching and formatting delegated to sub-languages?

* statements, like if/else and ++/--, don't return values in Go which is hard to get used to. I understand making statements generally be shorter so the code looks good after running through gofmt could have motivated this.

Overall, I think Go's a systems language intended for quick parsing and eliminating C++'s complexity, and the author's comparing it to languages with far higher level constructs. The correct solution is for people to implement languages like Haskell and Clojure in Go, making them execute as fast as possible.

Re:Why Go Is Not Good by wyager on Sunday June 29, 2014 @06:36PM (#7962754)
>The correct solution is for people to implement languages like Haskell and Clojure in Go, making them execute as fast as possible.

Uh, what? Haskell already compiles to native code, and is faster than Go in many cases.

Also, if you were implementing a programming language, there are much better languages to do it in than Go.

Re:Why Go Is Not Good by stcredzero on Sunday June 29, 2014 @08:00PM (#7963002)
Depends on your particular value of "better." If you're optimizing for programmer time, writing a language in Go is not a bad tactic. You get out of having to write your own GC, you can incorporate a few nice concurrency features with little effort, and you still get pretty good performance. (Admittedly, far from the best performance, though.)
Re:Why Go Is Not Good by Peaker on Monday June 30, 2014 @12:47AM (#7963738)
Writing a language in Go, which doesn't have sum types won't be fun.

Also, if you want to implement a compiler, and not an interpreter, the host language having GC is not very useful to get GC.

Haskell is going to make working with ASTs much easier and safer. It also has a superset of the concurrency features of Go.

Re:Why Go Is Not Good by zik on Monday June 30, 2014 @07:59AM (#7964593)
I'm writing a language in Go. It is fun. Sum types (and ASTs) are implemented with interfaces which provide a pretty clean and type safe way of doing this.
Re:Why Go Is Not Good by Peaker on Monday June 30, 2014 @10:14AM (#7965119)
Can you show some small example encoding of an AST in Go?
Re:Why Go Is Not Good by stcredzero on Tuesday July 01, 2014 @04:57PM (#7973463)
The code for Twik has a simple AST in it. Of course, it's Lisp, so it's perhaps too simple.

http://blog.labix.org/2013/07/16/twik-a-tiny-language-for-go

Re:Why Go Is Not Good by Peaker on Wednesday July 02, 2014 @01:53AM (#7975454)
The duplication there in each AST node kinda hurts the eyes :)

Also, the type-switch on interface {} is ugly.

Consider how an AST looks like in Haskell:

  data AST
    = LiteralInt Int
    | LiteralFloat Float
    | List [AST]
    ...
And then an eval looks like:

  case ast of
    LiteralInt int -> ...
    LiteralFloat float -> ...
    List nodes -> ...
and it is safe, rather than interface{}, you get the AST type and you get exhaustiveness checking that you covered all cases.

Also, if you add an annotation to each AST element (e.g: inferred types), you can very easily and safely map over them, etc.

Re:Why Go Is Not Good by rogpeppe1 on Tuesday July 01, 2014 @10:04AM (#7970701)
http://golang.org/pkg/go/ast/

Well, not that small, i guess :-)

Re:Why Go Is Not Good by wyager on Sunday June 29, 2014 @08:05PM (#7963013)
>You get out of having to write your own GC

You also don't have the ability to write a GC-less language, because there is no practical way to write non-GCed Go code.

>you can incorporate a few nice concurrency features with little effort

You also can't implement any custom OS-level concurrency features.

Re:Why Go Is Not Good by stcredzero on Sunday June 29, 2014 @11:15PM (#7963517)
You also don't have the ability to write a GC-less language, because there is no practical way to write non-GCed Go code.

True, so you probably don't want to do that.

You also can't implement any custom OS-level concurrency features.

True. But for "journeyman" level language implementation, the toolset is quite good.

Re:Why Go Is Not Good by dragonwriter on Sunday June 29, 2014 @11:29PM (#7963554)
Most of those seem to be things that could arguably be "implementing a language that compiles to Go and then leverages the Go compiler & runtime", which is pretty much orthogonal to "implementing a language in Go".
Re:Why Go Is Not Good by coldtea on Monday June 30, 2014 @03:12AM (#7964071)
>You get out of having to write your own GC

No, you really don't. The built-in GC is nothing like the GC needed for lots of other languages.

Re:Why Go Is Not Good by stcredzero on Monday June 30, 2014 @10:01PM (#7968815)
The built-in GC is nothing like the GC needed for lots of other languages.

Don't write those languages in Go.

Re:Why Go Is Not Good by coldtea on Tuesday July 01, 2014 @05:13AM (#7969741)
That kind of defeats the whole idea that it's a good language for writing other languages in.

Not to mention that to use the GC, you'd have to carry the whole baggage of Go's runtime with you in the new language. And that's Go's GC is not that good in the first place.

Re:Why Go Is Not Good by stcredzero on Wednesday July 02, 2014 @12:33PM (#7977939)
There are different levels of language implementation. Doing it in Go is more of a "Journeyman" level. If something like the Go runtime is going to enable more people to have written an interpreter, then this is a good thing. Most people's implementation of GC will probably be no better or worse than Go's.
Re:Why Go Is Not Good by kyrra on Sunday June 29, 2014 @10:58PM (#7963481)
FYI, to create a set in Go you can also use struct{} for the value. map[something]struct{}. The value takes up zero space then.
Re:Why Go Is Not Good by Shorel on Tuesday July 01, 2014 @03:54PM (#7973110)
Dlang has scope(exit) that does the same thing as Golang's defer.