4 ms·
Effective Go
- krakensden 14y agoIs there some reason documentation on the Golang website has 57 upvotes?
- melling 14y agoIf I had to guess, it's because people are quite excited about the language and they're interested in giving it some visibility. There's always lots of new technologies, but very few gain wide adoption.
- pasbesoin 14y agoThere is a collection programming books titled "Effective X", for language X. From multiple publishers, IIRC, though I think it may have started with Addison Wesley. The majority of those books with which I'm familiar have pretty good if not excellent reputations. I would suggest that this documentation's title may be acknowledging this, and perhaps -- deliberately or not -- leveraging it. EDIT: No, maybe it was indeed O'Reilly. E.g. Effective C and Effective C++.
- zoul 14y agoI enjoy the pragmatic reasoning behind the documented choices. It's an interesting input even if I don't work in Go.
- usea 14y agoIt's more of a "best practices" than it is documentation. In the vein of Effective C++ by Scott Meyers. It's well-written, informative and interesting. Definitely one of the best resources on Go I've come across.
- sp332 14y agoA page of examples of the Zen of Python got almost 200 upvotes. https://news.ycombinator.com/item?id=2203101 https://news.ycombinator.com/item?id=2203101 and https://news.ycombinator.com/item?id=3697378 https://news.ycombinator.com/item?id=3697378
- oofabz 14y agoI have been tinkering with Go for a couple months and I've been so impressed with it I'm about to start a real production server using it. It has all the low-level functionality of C with some very useful features added, like garbage collection, string manipulation, new data types like slices and channels, and of course threading. The main downside is that there are not a lot of libraries available. If you want to use the language you will find yourself using 3rd party wrappers off github of unknown quality, and you will probably have to wrap some C libraries yourself, because no one else has. Also, both the garbage collection and the goroutine scheduler could use some work. Like most other garbage-collected languages, Go's GC has to stop all threads in the program while it does its work, causing milliseconds of lag. This makes the language unsuitable for realtime work like a fast-paced video game. The goroutine scheduler works using a fixed-size thread pool. You have to tell it how many threads to use - by default programs are single-threaded. It has no ability to lower the thread count when the system is under heavy load, or to raise the thread count when most threads are unproductively waiting on network IO. Despite these minor problems it is amazingly full-featured for a compiled language, and amazingly fast for a full-featured language. They are actively working on improving the garbage collection and they plan to improve the thread scheduler.
- luriel 14y agoI will just note that improvements to the GC and scheduler and other compiler optimizations are already implemented and will be part of Go 1.1 Also, the Go stdlib is very rich and covers lots of stuff, I have rarely found need for bindings to C libs unless it is OpenGL. Which brings me to the point of games, there are already a couple of games using Go, the GC pauses are not as big of an issue because the GC is good enough (it is parallel) and in Go is easy to avoid generating garbage.
- thebigshane 14y agoQuestions for those more versed in Go's GC than I: 1) Let's say you want to do everything you can to avoid generating garbage. What would some those techniques be? 2) There is no delete function is there (for memory deallocation, not hashmap key removal)? 3) Is it possible to eliminate all garbage, and if so could you prevent the GC from starting up at all? Possible existing answers that are a bit above my understanding (C# and Python spoil me): http://news.ycombinator.com/item?id=4231048 http://news.ycombinator.com/item?id=4231048 http://blog.golang.org/2011/06/profiling-go-programs.html http://blog.golang.org/2011/06/profiling-go-programs.html https://groups.google.com/forum/?hl=fr&fromgroups#!topic/golang-nuts/Ir7ZrKLddTU https://groups.google.com/forum/?hl=fr&fromgroups#!topic...
- uvtc 14y agoThe Go language seems to have some substantial documentation, which is great. Though, throughout, the code snippets would look better with some syntax highlighting.
- rogerbinns 14y agoAny idea why Go uses tabs for formatting? (A google search didn't provide the answer but did suggest I may want to find out why God does!) About the only good pro-tab stance I have seen is that it allows the viewer to choose a level they prefer, but I would expect consistency would be far better.
- oofabz 14y agoGo doesn't require tabs. Tabs and spaces work just like C, they separate tokens but are not otherwise relevant. It's not like Python where they indicate indentation level. The only whitespace character that works differently than C is the newline. In Go, newlines (usually) separate statements, like a semicolon does in C.
- rogerbinns 14y agoFrom the topmost section: We use tabs for indentation and gofmt emits them by default. Use spaces only if you must
- georgemcbay 14y agoCode formatting conformity is pretty big in the Go culture. Go the language doesn't care if you use tabs or spaces, Go the community would prefer you to use tabs so when your Go code is loaded in whatever random editor any member of the community uses there are no surprises.
- foodoo 14y agoI only care that it was formatted with gofmt.
- james4k 14y agoThat was actually one of the questions asked during the "Meet the Go team" talk at Google I/O. They joke around for a bit, but they end up giving some solid arguments. http://www.youtube.com/watch?v=sln-gJaURzk&feature=player_detailpage#t=1735s http://www.youtube.com/watch?v=sln-gJaURzk&feature=playe... Edit: If you're curious/interested in Go, it's worth watching the whole talk.
- nodrama 14y agodid you read this? "One caveat. You should never put the opening brace of a control structure (if, for, switch, or select) on the next line. If you do, a semicolon will be inserted before the brace, which could cause unwanted effects. Write them like this " For me that means that the compiler will insert some characters and then complain about them, or, even worse, not complain about them. How about just compiling what I write?