Better HN
topnewbestaskshowjobs
Log inSign up

throwawayEmb

6 karma · joined Jan 7, 2024 (2y ago) · 5 submissions

Submissions

comment 2y ago · link · parent

I was replying to this

> Genuine question. With Rust and C++, even for embedded systems, what is the use case for starting a new project that does binary encoding and network with such an unsafe language like C?

And I gave a genuine answer :)

If you want to restrict the context to libwebsockets, I suggest you edit your question to clarify that.

Network code != libwebsockets.

I have written Ethernet-connected firmware without OS/RTOS on 8-32 bit MCUs that definitely would not be able to run libwebsocket.

There is a big world in embedded between PLCs and e.g. RasPi. That is often where you use C (in my experience).

comment 2y ago · link · parent

Perhaps I read your statement too literally. If we are only talking about targets able to run libwebsockets unmodified, STM8 is of course irrelevant.

That assumption was not clear to me though.

Many embedded code bases do not have a 100% standard-conforming libc and e.g. miss I/O functions like fopen and friends (because there is no file system).

And at that level, you will sometimes only get compilers for C (or older C++ dialects).

comment 2y ago · link · parent

Anything POSIX should do, no?

Anyway, I still think the point stands: many lower level targets do not have C++ or Rust compilers, but do have okay-ish C compilers.

You replied to

> I can think of several embedded platforms where Rust or C++ is not even an option.

… asking “Go on, name a few”. I understood this as “name a few targets for which C++ and/or Rust is unavailable”.

These targets do exist and are perhaps more common than you assume. In my own experience, it is mostly seen with small micros though.

But perhaps I misunderstood you?

comment 2y ago · link · parent

Not sure what you mean by “with standard library”, but STM8 has no C++ or Rust compiler that I know of.

For other MCUs where you do get C++ support, you often only get C++98.

Replied to your other comment about this as well.

comment 2y ago · link · parent

The STM8 processor for instance has no C++ or Rust compiler to my knowledge, even though it was produced in huge volumes [1].

It is still quite common to see proprietary compiler-suites in the embedded world.

Most only support C. Some do not even support C99 :)

Sure for many ARM targets (e.g. Cortex series), you can use GCC or LLVM etc. and get access to C++.

Many embedded shops targetting the lower end (8-32 bit CPUs <100MHz + 8-32kb RAM) prefer C for the simplicity.

1: STMicro announced back in 2016 that they’d sold more than 2 billion of these chips, so it’s not some obscure little niche processor.