3 ms·
I tried to find a succinct question to respond to for your first section, and couldn't. My answer is the same as before: no one has bothered to write a Go runti
by striking 8y ago
I tried to find a succinct question to respond to for your first section, and couldn't. My answer is the same as before: no one has bothered to write a Go runtime that can run on microcontrollers. This is because Go does not do anything fundamentally different from C at that level, except things that are less suitable for low-memory and low-CPU environments; and because it takes a lot of work to write a compiler and runtime for these devices. Note that there are very few compilers for each individual microcontroller. They generally only have one or two.
>I see it as clearly superior.
You are not looking hard enough. Go has flaws, as does any language or tool. It is almost a rule of thumb that not understanding the flaws of a tool is a sign of inexperience with it or alternatives to it. I think if you actually tried to learn and use C and C++, you might better understand the difference.
>I don't see why Go can't replace C and C++ applications
My answer is the same as before: it can, except that C/C++ apps already have that territory, and Go doesn't provide a fundamentally different experience except in lacking libraries for most GUI applications. There are still places it shines, though. For example, it is doing a fine job of replacing C/C++ for cloud orchestration tools; static linking is important to those users, and Go provides it easily.
>Basically I am wondering why Go in 2018 isn't where C and C++ were by 1998, for example.
This is a mathematical error. The C programming language was developed in 1972, and C++ piggy-backed off of C's ecosystem very effectively.
>Go as a syntax is better than C or C++ as a syntax
I don't think I can come up with a better example of a "skin-deep" comparison, nor do I think anyone has actually argued for C/C++'s syntax being actually good.
>stable language features
Didn't Go 1.11 break all of the community's tools? Isn't that why the story we're posting on the comments on exists?
>To me, a microcontroller program running with next to no memory just has to not leak memory or crash,
Some microcontroller programs need to have very low latencies, or the physical things they are connected to will break (the GC defeats this). Some microcontroller programs are only allowed a couple of KB of RAM (Go can't handle that). Most microcontroller programs are compiled without a standard library (and Go would have to provide its own impls of basic Go stuff in order to function). Some microcontroller programs never allocate memory, cannot allocate memory, or must allocate all memory up front. And so on. You can solve these things by having more expensive and fault-tolerant gear, or buying more RAM, or paying people to write more Go compilers/runtimes, etc., but these things get expensive fast; that is often incompatible with the design goals of what microcontrollers are used for. You're welcome to write Go and slap it on a Raspberry Pi, though.
>In a way you could say I don't really get what's preventing this.
Try writing a microcontroller program and GUI app, both in C or C++ and in Go. I very strongly doubt you will succeed faster in Go than in C/C++, in either kind of project, because of multiple factors: ecosystem, communities, example code, language features, existing toolchains and compilers... But if you don't believe me, try it out for yourself.
- logicallee 8y agoI read this several times hours apart. Lots of information, thanks. I don't have many questions except this: "Some microcontroller programs are only allowed a couple of KB of RAM (Go can't handle that)." What in here... https://golang.org/ref/spec https://golang.org/ref/spec ...can't you possibly implement in only a couple of KB of RAM? (For what required feature or features can we say for sure that a couple of KB of RAM is insufficient to implement as specified?)
- striking 8y agoAs it turns out, the only mention of the feature is in that link's introduction. The garbage collector (https://github.com/golang/go/blob/master/src/runtime/mgc.go https://github.com/golang/go/blob/master/src/runtime/mgc.go) makes many references to 4KB pages and 1MB arenas. This (the code and the user of the technique) would need some serious reconsideration for small devices.
- logicallee 8y agoIsn't the specification the actual language, and Google's compiler just one implementation? (That's true for C/C++.) Is the specification underspecified or something? We're not talking about a syntactically huge language...