News for hackers. Stuff that matters.
Re:The libkern C++ Runtime by frabert on Thursday July 12, 2018 @05:58AM (#17513272)
Banning the use of namespaces and templates for embedded programming seems arbitrary at best, since they are both completely compile-time features
Re:The libkern C++ Runtime by bnastic on Thursday July 12, 2018 @09:00AM (#17513937)
IOKit predates anything resembling wide adoption of those C++ features. Exceptions are a particularly thorny subject when mixed with multithreading and (non-existent) memory model. And not to mention RTTI, which was always just a patch job.
Re:The libkern C++ Runtime by frabert on Thursday July 12, 2018 @09:19AM (#17514123)
I think choosing to exclude exceptions is a totally fine decision, and I actually think it's the right thing to do in embedded systems where you _cant't_ afford to let an uncaught exception bubble up
Re:The libkern C++ Runtime by senozhatsky on Thursday July 12, 2018 @08:52AM (#17513893)
My guess would be: banning of namespaces and templates greatly simplifies name resolution and so on. For instance, look at https://en.cppreference.com/w/cpp/language/lookup and then remove namepsaces and templates from the picture.

Or maybe they just wanted developers to be "less creative".

-ss

Re:The libkern C++ Runtime by veli_joza on Thursday July 12, 2018 @06:22AM (#17513337)
I don't know what their reasoning was, but it might have not been technical one.

Embedded development positions are not your typical developer positions, they require more intimate knowledge of system, of possible states and transitions, and of hardware internals. This results in less focus on actual coding skills.

Even if you are highly skilled, you won't be doing your company a favor if you're writing code that only 5% people can understand and contribute to. My understanding is that every team that writes C++ will restrict it to some subset to make the codebase more manageable.

OTOH I think namespaces can only lead to better and more modular architecture, I'm not sure where they should be avoided.

Re:The libkern C++ Runtime by frabert on Thursday July 12, 2018 @06:25AM (#17513343)
That would make sense if it wasn't for the fact that many embedded systems are programmed in assembly language, which is not the most easy to follow for people not acquainted with code.
Re:The libkern C++ Runtime by veli_joza on Thursday July 12, 2018 @07:39AM (#17513598)
I haven't heard of any professional project using assembly in last couple of years. Maybe bits and pieces, like startup code to set up C/C++ environment, things that a single person can write and maintain. It doesn't work at all for large teams.
Re:The libkern C++ Runtime by berti on Thursday July 12, 2018 @07:32AM (#17513562)
If you're a hardware guy, assembly is a lot more intelligible than many of the things you can do in C++...
Re:The libkern C++ Runtime by pilif on Thursday July 12, 2018 @06:38AM (#17513377)
a reason for banning namespaces is that they didn't want to add namespace support to their stripped-down RTTI solution and a reason for banning templates would likely be code-size concerns.

I mean - I'm just guessing here, but I can at least see some technical reasons for these decisions.