5 ms·
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 ma
by vorg 12y ago
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.
- wyager 12y ago>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.
- stcredzero 12y agoDepends 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.)
- wyager 12y ago>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.
- stcredzero 12y agoYou 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.
- dragonwriter 12y agoMost 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".
- Peaker 12y agoWriting 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.
- kyrra 12y agoFYI, to create a set in Go you can also use struct{} for the value. map[something]struct{}. The value takes up zero space then.
- Shorel 12y agoDlang has scope(exit) that does the same thing as Golang's defer.