←back to thread

Show HN: Go Plan9 Memo

(pehringer.info)
302 points pehringer | 1 comments | | HN request time: 0s | source

A quick dive into the Plan9 assembly I picked up while developing my SIMD package for Go, and how it led to a 450% performance boost in calculations.
Show context
saclark11 ◴[] No.41880371[source]
> Overall, pretty weird stuff. I am not sure why the Go team went down this route. Maybe it simplifies the compiler by having this bespoke assembly format?

Rob Pike spoke on the design of Go's assembler at a talk in 2016 [1][2]. I think it basically came down to the observation that most assembly language is roughly the same, so why not build a common assembly language that "lets you talk to the machine at the lowest level and yet not have to learn a new syntax." It also enables them to automatically generate a working assembler given an instruction manual PDF for a new architecture as input.

[1]: https://www.youtube.com/watch?v=KINIAgRpkDA [2]: https://go.dev/talks/2016/asm.slide#1

replies(4): >>41880468 #>>41881654 #>>41884035 #>>41886094 #
alphazard ◴[] No.41880468[source]
And it worked. Go established cross-compilation as table-stakes for new programming languages, at a time when very few were doing it well, if at all.
replies(5): >>41880634 #>>41880798 #>>41883225 #>>41883804 #>>41884968 #
cloudfudge ◴[] No.41880798[source]
Yes, this is a great leap forward in my opinion. I had to do a project at a previous job where I wrote an agent that ran on x86, MIPS and ARM, and doing it in Go was a no-brainer. The other teams who had a bunch of C code that was a nightmare to cross-compile were so jealous they eventually moved a lot of things to Go.

I've been doing this for 35 years and cross compiling anything nontrivial was always a toolchain nightmare. Discovering a world where all I had to do was set GOARCH=mips64 (and possibly GOOS=darwin if I wanted mac binaries) before invoking the compiler is so magical I was extremely skeptical when I first read about it.

replies(4): >>41881898 #>>41882917 #>>41883141 #>>41886387 #
somat ◴[] No.41882917[source]
A fair enough assessment, it be that way, however I will note that a large reason that C exists in the first place was to have a machine independent language to write programs in.
replies(2): >>41883238 #>>41884135 #
kloop ◴[] No.41884135{3}[source]
> however I will note that a large reason that C exists in the first place was to have a machine independent language to write programs in.

That's fair, but what we call a monstrosity by modern standards is much simpler than porting the assembly

There were cross plaform languages before C, but they never really took off for system development the wat C did (OSs, for example were commonly written in pure assembly)

replies(1): >>41902490 #
1. pjmlp ◴[] No.41902490{4}[source]
A side effect of C not having a price tag associated with it, anyone with UNIX source tapes got a C compiler for free, until commercial UNIX became a thing, and splitted into user/developer SKUs, and thus GCC largely ignored until then became a thing worth supporting.