8 ms·
Learn Go: Hand-crafted Go exercises and examples
- mpoteat 6y agoI can never tell whether these titles are referring to the programming language or the board game.
- minkzilla 6y agoNeither can I but it’s not much of a problem because I’m interested in both!
- sound1 6y agoGood one! BTW, it is 2am here :-)
- dominotw 6y agoI was disappointed to see it was golang. Is there a site like this for the game?
- dpflug 6y agohttp://playgo.to/iwtg/en/ http://playgo.to/iwtg/en/ for basic rules, http://www.goproblems.com/ http://www.goproblems.com/ for building skill, https://openstudyroom.org/ https://openstudyroom.org/ for learning with others
- slimsag 6y agoObservation: I see that you do 26 exercises before doing anything with pointers. I often wonder if one of the reasons Go is more "simple" or approachable to some is because you can, to a large extent, ignore pointers and interfaces and "just write that weird little * or & in some places" and get away with it. Whereas, I believe in other languages, this is much less possible (e.g. in Java or Rust you need to learn about less "just logic" traits of the language earlier on (class inheritance, generics or Options, borrow checking, etc.) I'm not saying the above is a good thing, but I often wonder if there aren't ways to make this more of an incremental learning curve in other languages in a similar way that you can largely ignore pointers in Go for a long time and be productive without understanding them. What would a similar incremental learning curve for generics be?
- littlestymaar 6y agoYour can't really do anything real without pointers in Go though because you won't be able to mutate states out of a function.
- slimsag 6y agoThat's definitely true, but I've often seen beginners just say: type Foo struct { ... } func (f *Foo) Bar() { ... } And go "Aha, that's an object and a method, I get it!" but when asked whether they should be using a pointer there or not, have no idea what that even entails. In other words, it's possible to neglect the details of pointers easily and have things generally work
- edoceo 6y agoRemember ByVal and ByRef from VB? (I hope you don't, it was the dark ages) but those to terms I've found are very useful for getting folk introduced to pointer - and also why.
- slimsag 6y agoThat is really interesting to me! I never used VB, is the only difference here that it is "named" ByVal and ByRef that you think made it easier for people to understand than "pointers"?
- edoceo 6y agoWell, I use those terms (ByVal/Ref) and then say, one is a copy (byVal) and the other is a reference (pointer to you and me) to the thing. So, pass small things ByVal (int, float), it's on the Stack. Pass big things (Object) ByRef cause they're in the Heap. Then I start saying pointer more than ByRef and the link is made. Then on to ByRef/Pointer to how that then manipulate the shared data. Once that basic is done, we refine/clarify around what Pointer really is, and also it's syntax.
- gotoeleven 6y agoSure they're hand crafted but are they artisinal and free range and carbon neutral?
- philosopher1234 6y agoThey were baked in a wood fire oven, with the classic Napoleon style.
- edem 6y agoThis doesn't ask the most important question: why would I learn Go at all?
- valachio 6y agoWhy should one live at all?
- loudlambda 6y agoTo answer the question: what would a language look like if you put it's designers in a time capsule for 20+ years and had them make a language that was uninformed by all the language advances and learnings they'd missed out on.
- d1str0 6y agoThis doesn’t answer the question at all. Also it’s very disingenuous. The designers of Go were very much aware of the the last 20 years of language development. They decided on a subset that catered to software engineering between teams of people spanning a length of time. It purposefully leaves out lots of features and cutting edge design philosophies because many Of those make things difficult when sharing code between multiple developers Spread over a long length of time. Go’s philosophy has always been close to KISS. Don’t provide all these cutting edge tricks and tips because you can accomplish the same thing in a far clearer and maintainable way by doing it simpler.
- loudlambda 6y agoThis is the story I keep being told, but it doesn't seem to match with the reality of a language. Two example off the top of my head: Loop variables are captured by "reference", not by value, so it's very easy to create bugs where you capture accidentally capture the wrong thing and don't have the value you'd expect. Nulls, the billion dollar mistake. Most languages are quickly moving away from nulls (and pointers for that matter), or creating constructs that make them much safer (such as what typescript is doing). Instead go doubles down on both of these. In the last decade of programming in kernel level c, python, ruby, c++, java, typescript, scala I've never worked with code that crashes so much and is as buggy as go. Both of these problems could have been addressed fairly easily without bloating the language. Google has people on the c++ committee; it very much feels like the creators of go had too much hubris to walk down the hall or across the campus and kindly ask a good language designer to shoot holes in their design. Another example is "iota". How does that make code sharing easy at scale? Any time I see iota, I have to start manually counting lines, and remember the rules for if blank lines or comments bump the counter, and it completely circumvents the ability to quickly grep for a value seen in a log message. It is completely antithetical to teams of people and spans of time and whatnot. It seems more like a team of three people who randomly had ideas and ran with them without thinking the consequences through very well, or consulting the wisdom of others.
- ganstyles 6y agoThis looks pretty cool. When I was learning Go a long time ago, I used a site called Gophercises and found it really helped me understand the language better.
- crunchbang123 6y agoIf you're interested in interactive language learning exercises, then try codewars(https://www.codewars.com https://www.codewars.com)
- alexandrerond 6y agoThis is great, but I think it should be written in Rust. It will then run way faster and be completely bug free.
- zealsham 6y agoTheir is nothing like a bug free code as a result of the programming language used . RUST programmers are like the new version of those Haskell programmers that spams every functional programming thread with a message that tldr: "write everything in Haskell or die "
- efiecho 6y agoI have not yet been able to find a simple "Hello World" example of starting a new project with Go modules instead of $GOPATH.
- triztian 6y agoHey there I found modules to be confusing coming from GOPATH too, but they're straight forward, super barebones example: #!/bin/bash cd $HOME # Create project directory mkdir hellogo cd hellogo # Init project modfile go mod init example.com/hellogo # Create the main source file # Uses bash's heredoc cat << EOF > ./main.go package main import "fmt" func main() { fmt.Print("Hello world") } EOF # Build it go build # Run it ./hellogo
- sk0g 6y agoYou can also skip building, and run directly using `go run`!
- hans0l074 6y agoActually, the official Go Blog has a decent "Hello World" example[0] for go modules - I've used this before, had to double check. [0] https://blog.golang.org/using-go-modules https://blog.golang.org/using-go-modules
- JoshuaRLi 6y agogo mod init github.com/your/project Then, go get -v will download your dependencies to GOPATH, and (re)generate go.mod, go.sum. For info on how to update dependencies, read `go help get`. When using modules (presence of a valid go.mod file), GOPATH won't be used for resolving imports. So you don't have to actually work in GOPATH anymore, dependencies are just stored there.
- notokay 6y agoWhy snaps? Is apt-get not good for you already? What's wrong with it?
- gotzmann 6y agoI've compiled a few interesting quizzes about Go's slices: https://medium.com/@gotzmann/so-you-think-you-know-go-c5164b0d0511 https://medium.com/@gotzmann/so-you-think-you-know-go-c5164b...