[sdiy] Programming Language Recommendation
sleepy_dog at gmx.de
sleepy_dog at gmx.de
Wed Dec 9 21:25:43 CET 2020
Spiros Makris:
> I have settled with C++ on my embedded projects and didn't have any
> problems so far.
That point I am most interested in.
There have been so many comments about "C++ big, clunky, all those
libraries make stuff huge, no good for embedded".
It looks to me like saying "C is too slow, because it has a library,
which has sqrt(), and some of my team members really like sqrt()".
Just that nobody forces you to call sqrt() in an ISR, or at all.
(I am sorry for having to use such a gruesome example more suited to
Halloween than Christmas)
If someone has a toolbox with a hammer in it that's really nicely
shaped, beautifully colored, and is enticed to use the hammer when a
small screwdriver is called for...
well, it is hardly the toolbox that's at fault!
It's about knowing your tools as well as your workpiece.
Using e.g. newlib nano; disabling exceptions, RTTI; not using std
container types that need dynamic allocation; being thoughtful with
template usage, not going crazy with inheritance (generally a good
idea), esp. not using calls to stuff with vtables in ISRs and such,
... are all things you can decide to do.
std:: containers were still being avoided in many studios in game
development in the mid 2000's, for performance / predictability reasons.
See, they could choose. C library has no such things to begin with -
that's hardly something that makes C faster.
As for size - as long as you're not on a target where you really can't
spare a single digit number of KB for the extra stuff getting linked in,
I don't see the problem.
Stuff you don't use is thrown out by the linker.
Someone mentioned cryptic error messages.
Sure. C++ easily takes the cake there, with any compiler I have seen.
You'll get an idea of what they usually mean after fighting through it
for a while, though.
As for Python:
It is funny you don't like it coming from C++, I also can't get myself
to really get into Python.
I do get its merits, one not small of them being that it's already
installed frickin everywhere and if you'd like to do something on a
small Linux system without installing anything else, and actually get a
Turing complete, and not cryptic, awkward (no pun intended) syntax
language... well, Python will be there.
I've tried, a couple times... but I just don't like it. (and am not too
fond of a type system-ish as an afterthought)
But I'm particular, or was it peculiar, probably both - I hate Java's
guts but really like C#, considered very similar by many - but in a
bunch of important ways, they're not.
> I don't want to use assembly ever again, but the experience of
> learning it was indeed valuable and wholly recommended for anyone
> trying to get into this field on a professional or academic level.
It can sometimes still be useful for some snippets in embedded projects
(just a bit of inline assembly)
It can also help being able to read that when you step on instruction
level through optimized code when debugging.
(that said, my ARM asm chops are basic at best)
- Steve
More information about the Synth-diy
mailing list