4 ms·
Turner obviously understands his tools, and exercised a lot of discipline with them to write pong within a resource budget. The systems that I have encountered
by jstewartmobile 8y ago
Turner obviously understands his tools, and exercised a lot of discipline with them to write pong within a resource budget.
The systems that I have encountered professionally have been uniformly more complicated, and written with less discipline, than Jason Turner's pong.
And that is not to say that the people who wrote the original programs were bad programmers. In business, you're trying to beat the other companies to the finish line, so a lot of siegeworks engineering happens out of necessity. Turner had the luxury of taking his time.
- gumby 8y agoThe point of a language like C++ is to build the abstractions that make it possible to quickly deploy something efficient and robust. Yes, that takes some time up front, but so does designing a board!
- jstewartmobile 8y agoThe abstractions are not free. The cost is negligible when working with megabytes. The cost is immense when working with kilobytes. If you're doing something more complicated than toggling LEDs with one of these low-energy chips, C++ is a false economy--rapid progress in the beginning, and a slog of memory budgeting in the end.
- gumby 8y agoBelieve me I am used to programming machines with a KB of RAM, or even less, and small amounts of bank-switched program memory. I've been a compiler and RTOS developer, and have worked on telecom, avionics, automotive control, power generation, and instrumentation. Certainly the abstractions can be free (at runtime -- may require the compiler to do hard work, but that's what it's for). A struct that allocates some of its instance variables into memory-mapped IO space and the other ones in regular ram can reduce errors that appear from splitting representations and/or doing explicit pointer arithmetic. Can people write shitty code? Of course they can. Can you use your tools to reduce the chance that that will happen? Sure, sometimes. Let's be realistic: while some of the very best programmers I've worked on have developed high-performance embedded systems, those are very few and far between. Most people writing embedded code have low status (this is the case in Japan and China in particular) so are often not the best developers, or are hardware engineers who figure writing some code isn't all that hard (isn't necessarily, but often leads to spaghetti) or are non-embedded programmers who figure "how hard can this be?" Another commenter's reference to hearing, "well it works when the optimizer is on" is a symptom of this. Sure, people who fling around the STL on a small resource machine will rapidly suffer. But those people will fail regardless. I have built code that takes up less space with a C++ compiler than the C version.
- jstewartmobile 8y agoYes, yes. Since you are so experienced, and everyone else is "low status," riddle me this: If C++ is so great, why does every joint turning out even halfway decent C++ have to subset the bejesus out of it? Even in game dev, where resources are plenty, they still subset it. Could it be that maybe, maybe, someone discovered that even competent devs do better work when a few pieces of duct tape are stuck over the sharper, rustier edges of C++. On low RAM devices, I'd subset it all the way down to plain C. Fellow low status developer Linus Torvalds would do that at the outset for any device.
- pjmlp 8y agoBecause many embedded developers are religiously against anything that isn't Assembly or a C89 dialect that only works in a specific CPU range, C99 and C11 are foreign words. Language subsets is not unique to C++.
- jstewartmobile 8y agoI would like a passport to that country with its strange and beautiful religion. Where I'm at, C++ is the sugar sex magic that rights all wrongs and triumphs over evil. edit: P.S., if I have a whole megabyte like Bjarne did in his AT&T days, I like C++ just fine.
- pjmlp 8y agoYou can ask Dan Saks about it. CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++” https://www.youtube.com/watch?v=D7Sd8A6_fYU https://www.youtube.com/watch?v=D7Sd8A6_fYU Embedded Development with Dan Saks https://cppcon.org/leveraging-modern-cpp-for-embedded-systems/ https://cppcon.org/leveraging-modern-cpp-for-embedded-system... When I started coding in C++ (Turbo C++), 640 KB were just fine, I could even make use of a full TUI framework (Turbo Vision). Hence my point of view about PIC class processors with single digit KB, being eventually the only target not possible to use with C++, unless one wants to suffer a bit with linker scripts.
- 8y ago
- tcbawo 8y agoIt sounds like you have more of a problem with poorly written code than C++. The motto of C++ is to not pay for what you don't use. The rub is using abstractions doesn't absolve you of efficiency and design constraints.