
Why Systems Programmers Still Use C (2006) - willvarfar
http://bitc-lang.org/docs/papers/PLOS2006-shap.html
======
andrewflnr
We are starting to get alternatives, though. Besides Rust and D, there are
Clay (<http://claylabs.com/clay/>), ATS (<http://www.ats-lang.org/>), and Deca
(<http://code.google.com/p/decac/>). I'm sure there are more. I unfortunately
haven't had time to play with them, and they're in various stages of
development. But at least people are thinking about improving systems
programming.

------
ijt
I was surprised that the author thinks the syntax of Haskell is no better than
that of C++. Let's look at a typical example. In Haskell, the signature for
sort is

sort :: Ord a => [a] -> [a]

which just says that it takes a list of comparable things and returns another
list of the same type. Here's the type signature for sort in C++:

template <class RandomAccessIterator, class Compare> void sort (
RandomAccessIterator first, RandomAccessIterator last, Compare comp );

The difference in terseness and clarity is a big reason why I use Haskell when
I have a choice.

~~~
ajross
Please. The difference in terseness and clarity is made up almost entirely of
the lenths of the symbol names:

template<class I, class C> void sort(I a, I b, C cmp);

Now, the concepts aren't 1:1; Haskell for obvious reasons doesn't represent
the idea of operating on storage directly, so you can't have an iterator and
need to return a "new" list. C++ makes you write out the types you are
parametrizing instead of getting it implicitly. And there are no doubt some
really good arguments why Haskell is terser and clearer than C++.

But this isn't one of them. Come on.

~~~
ijt
The difference is not only due to identifier length. Haskell's sort is a
function in the mathematical sense. By looking at its type, I can see the
input and output at a glance and understand how to use it. It's not
immediately obvious from the signature of the C++ sort procedure that the
"first" and "last" arguments are being used for both input and output. When
you abbreviate the identifiers for STL sort it's even less obvious what's
going on.

~~~
ajross
There's nothing "immediately obvious" to that Haskell signature at all. You
need to understand the [] syntax for list typing. You need to understand that
the language defintion has a built-in notion of "list". You need to understand
the idea of functions having types themselves (a huge hurdle if you're new to
functional languages). And you need to understand that weird "Ord" decorator
gadget and that it means the types can be compared. Basically, you can't
understand that line noise at all unless you know Haskell. Duh.

Likewise, if you're truly confused about C++ STL iterators you're just waving
your own ignorance around. They're a simple concept pervasively applied in the
library. No experienced programmer is going to be confused by that function
declaration.

Look, very good cases can be made for functional languages. But this is just
surface-level stuff that frankly isn't going to help anyone. Expressing a sort
simply isn't a complicated thing in C++ _or_ Haskell and trying to claim
otherwise is just dumb.

------
edwinnathaniel
These days Java seems to become one of the choices to do system programming in
a different area/level:

HBase, Hadoop, Cassandra, GWT tools, MQ, App Servers (Jetty, Tomcat,
GlassFish, etc), EhCache.

Unless if people categorized the above software as non-system-programming.

~~~
ajross
It's mostly a semantics thing, but no: most "systems programmers" would not
categorize those applications as "systems tasks". They're just apps. By
convention, "systems programming" means dealing with the bottom of the
abstraction stack. Java code can't make syscalls. Calling conventions for Java
methods aren't specified at the level of CPU registers or instructions.

So writing a JVM is systems programming. Writing a Java-based data store is
not, even though other stuff then sits on top of the store.

~~~
pjmlp
It is possible to do syscalls in Java.

Following your example there are also JVMs coded in Java.

~~~
ajross
It is certainly _not_ possible to do syscalls in "Java". A system call is a
special CPU instruction (e.g. INT, SYSENTER) not accessible to or defined in
the Java VM specification.

What you do to effect a syscall is to call a JNI function to do the work. JNI
is a C (!) API, defined in terms of the C (!) ABI for the platform.

And sure: you can generate native machine code in Java, just as you can in
python or bash or even BASIC. But you can't call it.

~~~
pjmlp
Depends what you consider Java, as there are VM extensions coupled with
compiler magic that allow it.

One such example is the Jikes VM:

[http://jikesrvm.sourceforge.net/apidocs/latest/org/vmmagic/p...](http://jikesrvm.sourceforge.net/apidocs/latest/org/vmmagic/pragma/SysCallNative.html)

Or the Sun's research in writing drivers in Java
<http://labs.oracle.com/techrep/2006/abstract-156.html>

------
alpad
Interesting article, but he misses the right answer: if it isn't broken, don't
fix it.

C may not be the easiest language to learn, but you wouldn't want newbies
messing with systems programming anyway.

Higher level languages give you a more abstract view, but when you are doing
systems programming that's not what you want, you need to be in full control.
Only C gives you precise control of what the machine is doing all the time.
You don't want a garbage collector to kick in unexpectedly, you don't want
data structures to be allocated in mysterious ways.

~~~
moonchrome
>You don't want a garbage collector to kick in unexpectedly, you don't want
data structures to be allocated in mysterious ways.

All of that (and everything else C is attributed with) can be accomplished
without using an arcane preprocessor/include system and you can have niceties
such as a saner type system, generics/macros, namespaces, etc.

C is a language stuck with the design decisions that reflected the programming
environments in the 60's and 70's but make absolutely no sense in modern
context and now we are just stuck with it because of inertia.

~~~
CJefferson
Anyone who tries building a better C (for example Go) seems to end up going
"too far", and as well as fixing the things you mention, ends up adding
garbage collection, and various other things which are not suitable for very
low level systems programming.

I teach C, and I would love a "cleaner C" mode, which just got rid of lots of
the bizareeness of C, several of which you mention. The fact that many
compilers will warn with '-Wall' about code which is clearly incorrect, but
due to the rules of C they cannot simply reject, is irritating.

~~~
pjmlp
Fact is there are many examples of operating systems implemented with GC
enabled systems languages.

Spin, Oberon, Singularity, Home are just a few of them.

The main problem is that for a systems programing language to be used a such,
there much exist a successful operating system that uses it as its main
language.

In Windows 8, the main systems language is C++/CX (C++ with reference counting
extensions), so the time will come.

------
signa11
why fix something that is not broken ? with systems programming you wouldn't
want anyone/everyone to mess around with it anyways. i don't _need_ bound-
checked-arrays, or or garbage-collection (oh the humanity!) at random
unpredictable times. c gives an unprecedented level of control over what the
machine is doing, for more abstract level interface to the machine, use
whatever suits your fancy...

------
halayli
Things I can think about:

\- low level memory management

\- faster execution (in most cases)

\- cache line optimization

\- avoiding language implementation magic

------
webreac
I have stopped when I read "The concrete syntax of Standard ML [16] and
Haskell [17] are every bit as bad as C++".

The author definetely has no understanding of PL issues or has a huge bias
toward C++ insane syntax.

------
SkyMarshal
bitc appears to be abandonned, but I cloned it from their hg repo and put it
up on Github anyway. Here it is, for posterity:

<https://github.com/bitc-repos/bitc>

Projects like this make me wonder if they would have gotten further had they
put it on a more social oss hub, be it Sourceforge in its day, or Github now.

------
javascriptlol
The problem with systems design is that it's all so complex. Multitasking has
become an excuse to run everything as some absurd daemon. Badly designed
hardware has to be papered over with undocumented binary drivers. Everything
is optimised for throughput benchmarks, so we get warm ups and unpredictable
pauses visible to the user. And it's all full of security holes.

The plain truth of the matter is that none of these things are due to a lack
of special language support. It's that the whole system is too complex, and
the complexity isn't even quarantined in such a way as to be harmless. We need
to be able to start over (something the author acknowledges). We can't do this
if we build yet another complex system in the belief that we'll get it all
right this time round.

~~~
ehsanu1
The problem with that is "Worse is Better". And there's just so much momentum
behind current technologies, that switching seems almost unimaginable to most.
Can you imagine not having Unix-like systems, and not being able to use C and
all the languages built around that ecosystem?

But if you're looking for a replacement for the entire software stack we use
today, one that tries to shun complexity (20k LOC for _everything_ from kernel
to common GUI apps), here you go:
<http://www.vpri.org/pdf/tr2011004_steps11.pdf>

More info (see previous STEPS reports): <http://vpri.org/html/writings.php>

~~~
javascriptlol
Thanks for the link. I will check this out later.

>Can you imagine not having Unix-like systems, and not being able to use C and
all the languages built around that ecosystem?

Yes! Charles Moore has been essentially living this since the 1970's. No many
have his level of courage though.

~~~
andrewflnr
You mean this one? <http://en.wikipedia.org/wiki/Charles_H._Moore>

Can you give some more detail? What does he use?

~~~
stonemetal
Towards the bottom of that page it mentions color forth. That is what he uses.
It is a forth like language that removed punctuation and replaces it with
colors.

~~~
andrewflnr
Ah, upon further reading, colorForth has its own operating system, so he
probably uses that too. I had seen the forth bits, but the GP implied he was
using some non-Unix OS, and I was still curious about that.

~~~
RodgerTheGreat
Forth is conventionally a compiler, REPL, editor and OS all in one package. If
I recall correctly, the reference implementation of ColorForth happens to run
as a Windows application, but it pretty much lives in its own memory image and
could probably be made bootable.

------
javascriptlol
Also, this paper suggests that the answer to multi-tasking problems is to move
the complexity out into the language. It's funny how PL researchers will
always spin the situation so that it demands more PL research. If we're really
moving into a many cores future as people suggest, then we should have
architectures that give each application a dedicated core. No context
switching. Of course, you'd need a simple system and not a billion daemons
running in the background waiting to be exploited by criminals.

~~~
lusr
Jonathan Shapiro is not a traditional PL researcher. He is the architect and
lead developer of EROS (www.eros-os.org) and CapROS (<http://www.capros.org>),
and the author of a vast number of papers on secure and high-performance
reliable real-time operating systems. The confinement mechanism in EROS was
provably secure (i.e. provably impossible for applications to leak
permissions) by Shapiro, and AFAIK is still the only _meaningful_ and
_practical_ security mechanism demonstrated to do so, which is a pretty
significant contribution in the field of computer science.

(Although having been a voyeur of his work for over a decade now, I'm sure he
would be quick to point out that much of EROS was based on formalising ideas
from GNOSIS and KeyKOS, and the work of Hardy, Franz, Landau et al. over 20-30
years earlier.)

BitC evolved out of a need to prove that the _implementation_ of the
confinement mechanism (prototyped in EROS) matched the model (proven in his
PhD thesis), and so the CapROS system (built in BitC) was born (well that plus
some architectural changes based on lessons learned from EROS). From that
perspective it's much more than just another systems programming language - it
has a definitive purpose to advance the state of the art in practical and
theoretical computer science. (FWIW, they never did accomplish this goal
[<http://www.bitc-lang.org/docs/bitc/bitc-origins.html]>).

~~~
javascriptlol
A better idea would be to just build a small system whose security was
obvious. Computer scientists are right to mimic mathematics. They're just
mimicking it too directly. Mathematics is based on construction from simple
axioms and cross-checking of different theories. Computer systems should be
reduced to small parts with redundant checks against human error. If you prove
a kernel "correct" that just means it will be that much harder to rewrite it
if it turns out not to be what you wanted.

~~~
javascriptlol
Why downvote? HN has really gone down the tubes. Why do peopel who downvote
harmless comments without a response get downvote privileges?

~~~
willvarfar
I just downvoted you because you are saying something dismissive about someone
who has clearly spent a long time studying the alternatives and making a
balanced informed decision.

Now it may be that you have some great insight but your post doesn't seem to
give me any epiphanies.

~~~
javascriptlol
Well feel free to let software rot into pure shit under these continued
rationalisations. What a great service you're doing to the users.

