Live data from Hacker News

Build Pong in Your Terminal with Go for Some Reason

earthly.dev

1–10 of 44 posts

Re: Build Pong in Your Terminal with Go for Some Reason

#4
post #2

I've been trying to learn go by building Pong in my terminal. Here is part One where I create a bouncing ball.

I remember a pretty similar program that was included in the Vic-20 users guide circa 40 years ago. I miss the simplicity of learning by coding something that finally ends up like a game!

Re: Build Pong in Your Terminal with Go for Some Reason

#5
I also have been using Go with Tcell recently. Making small games is how I have always learned new programming languages.

I am coming off of a couple of years of playing with C to understand languages better, and free myself from the complex stacks that I use at work. I've been chatting with a highly-educated PL friend of mine about my language likes/dislikes, and he would always remark on really pragmatic choices Go had made.

I had always dismissed Go, and that has really let me see a reddit/HN hivemind I'm susceptible to. It was so easy to think "GC? Google? No thanks". After a while I saw a pattern of people disparaging Go in favor of Rust, but then using Python/JS for their own actual code. It made me feel that maybe the hivemind had overlooked the actual use-cases.

I understand that the language had its problems, from sub-par GC performance to poor Windows support, to the "no generics" meme. But for someone just getting into it now, it has been SEAMLESS. VSCode is a first-class dev environment after being configured by the single official Go plugin. Modules are awesome, and coming from C its so nice to just "go build" and have that just work.

I really expect Go to pick up a lot of steam with hobby developers soon. For simple games, Go is capable of producing cross-compiled static Windows binaries with SDL2 from Linux. That kind of dev experience could really win over a lot of C++ holdouts from the itch.io and HandMade communities that would prefer if C++ was just C with classes and types. The GC is so fast that it doesn't even cut into a 60fps time budget, and all the preallocation tricks from C still work fine... it has pointers and arrays like we are used to.

I was shocked to find how much I'd enjoyed Go. If you are interested in C/Zig/Odin, I think it is certainly worth checking out Go as a tool to play with arrays and structs, a paradigm many programmers enjoy. Having high quality libraries in the stdlib like JSON (de)serializers and even animated GIF authoring means that a lot of the simple code you might write for your own amusement won't be subject to the fast bitrot of other ecosystems.

Re: Build Pong in Your Terminal with Go for Some Reason

#6
This is a great idea for learning Go! I’ve been trying to pick it up recently and tried to do a CLI for indexing and searching through files. Reading PDFs is such a long hill to climb while trying to learn a new language. A game or something with a TUI sounds like a much more enjoyable goal.

Re: Build Pong in Your Terminal with Go for Some Reason

#8
I learned some basics of Go in much the same way a few years ago. An implementation of Andy Sloane's (famous?) donut in a terminal: https://github.com/onnos/donut

And playing with funky patterns using braille characters: https://github.com/onnos/rotaterm

It's not great quality code but it got me started! It's nice to have some immediate output you can play with - tcell is lovely.

Re: Build Pong in Your Terminal with Go for Some Reason

#9

I also have been using Go with Tcell recently. Making small games is how I have always learned new programming languages. I am coming off of a couple of years of playing with C to understand languages better, and free myself from the complex stacks that I use at work. I've been chatting with a highly-educated PL friend of mine about my language likes/dislikes, and he would always remark on really pragmatic choices Go…

I don't really buy into go (it's not my type of language), but I wanted to ask a genuine question: are there many semi-mainstream languages that don't have modules that _just work_, or an official plugin for VSCode that just works? I've never found that to be a "plus", as much as it is the bare minimum. and nowadays I don't see that many up and coming languages that miss out on it. Admittedly though the cross compilation is nice (not enough to win me over, at all, but still very nice. The very few times I've needed cross compilation in other languages I reached for nix, and that wasn't very pleasant)
Post reply on HN