On Dec 4, 2014, at 3:01 PM, Peter Corlett <abuse at
cabal.org.uk> wrote:
On Tue, Dec 02, 2014 at 08:09:42PM -0500, Toby Thain wrote:
[...]
You can give it up any time. There are dozens of
far better languages that
have cropped up in the 40 years since C was invented for a particular
environment (that doesn't resemble anything much we do today).
When it comes to what calls "freestanding" environments, options are
*extremely* limited, with C being the lingua franca. C++ is a reasonable
alternative as it can be used to file off some of the rougher edges if used
diligently, but brings problems of its own. Rust has some excellent ideas and
can likely move into this space, but it's not quite ready for prime time.
These are all still essentially procedural stack languages with manual memory
management though, as it's easy to reason about and provides cheap interop with
existing legacy C code.
Are there any other (sane, supported) languages
suitable for bare metal
programming that I ought to be aware of? Right now, C++ seems least-worst.
As you mention, C++ usually has a lot of required run-time support. C has *some*
but it's requirements are the least.
Part of the problem in adopting other languages for these low level tasks is the
runtime that the language drags along with it. C is the default for this because
it's required runtime is small and thus can be ported over easily (or written from
scratch).
Anytime you start putting an exception model or a higher level memory model
(such as auto-allocation and garbage collection) in a language that immediately raises
flags for me since the vast majority of my work is "at the metal". They get in
my
way for trying to implement what I'm trying to do (which is usually the lower levels
of an OS).
TTFN - Guy