137 points · by AlexeyBrin · 7y ago · 71 comments
The programmer just copies and pastes from the demos, makes small modifications, and it just works.
(No offense intended towards your framework, I've used gtk, qt, and swing and have never understood them like I understand nuklear and dearimgui)
It teaches you fundamentals, especially on an embedded system such as R-Pi.
The first language I learned was C on an ARM processor. Learning about registers, bit manipulation, seeing how compiler optimizes the code based on GCC flags, understanding pointers, memory management, the whole thing is difficult for a beginner but to me, it was immensely helpful. I also love Python/Julia/Java/JavaScript but man it makes you appreciate neat things higher languages offer.
One day I want to build my own 8-bit computer from discrete gates. I’m sure it won’t be a waste of time.
This is definitely not a waste of time. But though building a physical ALU from TTL is feasible, constructing a reasonable amount of memory would be a waste of time and money.
Once you have written the nand2tetris HDL for the hardware, you could translate it to Verilog and burn an FPGA quite easily.
For learning C and starting to poke at low-level embedded stuff I would recommend starting with Arduino (and then into plain AVR) - and not go anywhere near a GUI toolkit.
There is a reason we don't actually throw kids into the deep end when teaching them to swim. Most of them would just drown...
But a new GTK2 book sounds like teaching Python 2 for beginners.
GTK 2 and GTK 3
One thing worth mentioning at this point is that there are two versions of GTK in use. The current version is GTK 3, and this is still under active development – it changes quite a bit between releases.
For this reason, many people prefer to use the older version, GTK 2. This offers most of the same functionality, but it is stable code which doesn’t change very much any more. Some say that it is always better to use the latest and greatest version of anything, but more cautious old engineers (like your author…) tend to prefer the older version that has had a lot more testing and with which people have stopped fiddling about! In terms of the examples we are looking at here, there aren’t that many significant differences between the two, but just to be clear, the examples in this book will use GTK 2.
Also, in this universe Win32 API was released in 90s, not 80s.
But I never found a decent beginner friendly resources.
Anyone reading this comment, please chime in with your suggestions.
https://github.com/bztsrc/raspi3-tutorial
It's also fairly popular for emulators, since it's types are orthogonal and it's low level design is well suited to designing a pseudo-machine. It's definitely being displaced in that realm by C++/Rust/Nim/etc though.
I.e. why is it that C and assembler is “fundamental”, but electronics is not?
(I have written about this before: https://news.ycombinator.com/item?id=19106922#19113359 )
For fast, efficient software there will always be low level languages such as C, C++, etc. and I would always urge more people to learn them, even if just to learn to appreciate how much is managed by their high level language and understand the trade-offs they're making with those languages.
It's called "economics". C and C++ are simply too cumbersome for most applications; most applications don't benefit from that speed (either because the deadlines aren't that critical or because the bottleneck is I/O) and their project deadlines can't afford the velocity tax they impose. Especially when many of those languages allow you to opt out of "slow" features (or FFI into C/C++/etc) for your hot path. Lastly, higher-level languages are improving: Go is probably the easiest language out there and it's almost as fast as C (in the same ballpark, but still slower) and Rust is far, far friendlier than C or C++ but it performs on par.
Don't pessimistically de-optimize either. It's harder to remove bottlenecks from mature applications than it is to plan ahead for the target platform and common use cases.
By all means, prototype in Python but if your target platform is, at minimum, a R-Pi 2 and you want the experience to be snappy even when their is high IO or CPU work being done... then don't release on Python; use the prototype to drive the implementation in C.
Maybe consider even compiling from a higher-level language into a C library to minimize the boiler-plate.
Planning goes a long way, even if you don't plan everything up front.
> For fast, efficient software there will always be low level languages such as C, C++, etc.
this sounds like every "low level developer" ever, in that the opinions are completely removed from reality. it isn't 19<whatever>. if by inefficient, you mean slow, then java isn't anywhere near comparable to javascript or python. beyond being a completely different type of language, java is fast. so is c# and f#. so is chez scheme and sml. so are plenty of much higher-level languages than c and safer languages than c++ that are just as fast (if not faster in some cases dependent upon development time and application and developer) than c and c++.
also, c++ is low-level? it is an insanely complex high-level language.
Who cares what year it is. Fact is, with low level languages, you can write software which consumes less resources. This won't ever change.
> if by inefficient, you mean slow, then java isn't anywhere near comparable to javascript or python.
Sure, I (and presumably the poster you responded to) agree. Java is plenty fast for most things. But its memory usage is horrendous. Like seriously bad. It seems Intellij takes a solid 1.5gb to simply exist. I'd like to use Java (well, JVM based languages really) more, but basically all JVMs are memory hogs that take too long to start up. Graal might help here, we shall see.
C#, F#, Chez, et al. follow a similar suit. (Chez is probably the best of that lot, though. Would be my choice).
I've never dealt with Raspberry Pi world, but I can see the value of stripping the software world on one to the bare minimum. I wonder if someone has put together a FreeRTOS tool chain for it.
His reasoning is that GTK2 is stable and GTK3 changes with each iteration.
These toolkits are inevitably on their way out. The future is the browser stack, loathe though I am to accept it.
As a tangent, it wouldn't be horrible if something like a browser was used as a window manager and UI runtime a la ChromeOS except with apps running in containers (and no bastardized Linux kernel and the restrictions that come with). This would have lots of benefits--the whole frontend benefits from all of the investment going into the web (including wasm) and the whole backend benefits from the investment in containers. Notably, packaging / dependency management, process management, log management, etc would all be much simpler/easier.
[0] https://www.pcjs.org/pubs/pc/reference/microsoft/mspl13/c/c4...
There's an almost symbiotic relationship going on where the foundation doesn't exactly ignore the hobbyist or industrial communities - far from it - but they are still holding to their core mission, and these notable, but ultimately ancillary communities provide the budget for it.