How would you make a language that does system programming better than C?

Chat about just about anything else
Post Reply
0x2620
Level 2
Level 2
Posts: 79
Joined: Mon Jan 09, 2017 3:17 pm

How would you make a language that does system programming better than C?

Post by 0x2620 » Tue Mar 06, 2018 6:58 pm

I recently read this paper (PDF warning) which is a response to this paper (again, PDF warning) and various criticisms of C.

After reading both of them, I found myself with a lot of questions.
1. What would a language that does C's job better than C look like?
2. How can you make a language more communicative than C?
3. In what ways can the tools and systems used when writing and debugging a systems programming language be improved?
4. How can a systems programming language be made more configurable and modular than C, and as safe or as unsafe as you want (or easier to be safe if you want to)?
5. How could a high level programming language be made that is nonetheless closer to assembly language than C? How can it access all hardware features that don't necessarily align with the abstractions which C assumes exist; and how can it allow you to be as platform specific as you want?
6. How can the compiler-linker-loader toolchain be improved?
7. What things are possible in assembly language which are impossible or not easily done in C?
8. How can an operating system be designed to ease and facilitate debugging?

In short: what if you went in the opposite direction from languages that were intended to replace C with something that is more managed and through that safer?

edit

Here's a quote from a book I'm reading on Java I/O.
The underlying flaw in most people's analysis of Java I/O is that they've confused input and output with the formatting and interpreting of data. Java is the first major language to cleanly separate the classes that read and write bytes (primarily, various kinds of input streams and output streams) from the classes that interpret this data. You often need to format strings without necessarily writing them on the console.

You may also need to write large chunks of data without worrying about what they represent. Traditional languages that connect formatting and interpretation to I/O and hard-wire a few specific formats are extremely difficult to extend to other formats. In essence, you have to give up and start from scratch every time you want to process a new format.

Furthermore, C's printf(), fprintf(), and sprintf() family only really works well on Unix (where, not coincidentally, C was invented). On other platforms, the underlying assumption that every target may be treated as a file fails, and these standard library functions must be replaced by other functions from the host API.
Should a language make assumptions about data or operating system?
Is it worthwhile to abstract things like String formatting and text I/O apart, or is it better to reflect what actually goes on under the hood?
Should a language should deal with hardware as it actually is?
How can a language be made to better reflect what is going on in the machine?
How can a language/systems designer make it as easy as possible to design small, fast, and efficient programs?

rene
Level 8
Level 8
Posts: 2075
Joined: Sun Mar 27, 2016 6:58 pm

Re: How would you make a language that does system programming better than C?

Post by rene » Tue Mar 06, 2018 8:20 pm

Haven't read the papers you link to at this point but the question that is the topic I am inclined to answer with "perhaps not unlike https://www.rust-lang.org/en-US/". Certainly I feel that that a newer systems programming language needs newer and more ingrained parallelism support as perhaps the most important progression from C.

User avatar
jimallyn
Level 18
Level 18
Posts: 8419
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: How would you make a language that does system programming better than C?

Post by jimallyn » Tue Mar 06, 2018 9:56 pm

Not sure that I know enough about system programming to make any meaningful contributions here, but I am interested enough that I will watch this thread. One thing you can say about C is that it is one of the few languages in which one could write the operating system, the applications that run under that operating system, and the firmware running on the 8 bit microcontroller in the keyboard attached to the system, right down to the interrupt routines. (I remember years ago in one of the electronics magazines I was subscribed to, somebody ran an ad that included something about writing interrupt routines in Cobol for 8051. April Fools Day, of course.)
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
Fred Barclay
Level 12
Level 12
Posts: 4147
Joined: Sat Sep 13, 2014 11:12 am
Location: Bumping around in the bush

Re: How would you make a language that does system programming better than C?

Post by Fred Barclay » Tue Mar 06, 2018 10:19 pm

+1 for Rust. I just started learning it yesterday.

That being said, if you're willing to give up low-level stuff then you can't really beat python, in my opinion. I use it everyday, and it's been fun to watch the Matlab folks in my department slowly, one-by-one convert to python and/or R. :mrgreen:
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein

User avatar
catweazel
Level 16
Level 16
Posts: 6983
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How would you make a language that does system programming better than C?

Post by catweazel » Wed Mar 07, 2018 3:42 am

0x2620 wrote:
Tue Mar 06, 2018 6:58 pm
1. What would a language that does C's job better than C look like?
C++
Caution: Dancing Wu Li Master and Official curmudgeon-in-chief

0x2620
Level 2
Level 2
Posts: 79
Joined: Mon Jan 09, 2017 3:17 pm

Re: How would you make a language that does system programming better than C?

Post by 0x2620 » Wed Mar 07, 2018 5:28 pm

rene wrote:
Tue Mar 06, 2018 8:20 pm
Haven't read the papers you link to at this point but the question that is the topic I am inclined to answer with "perhaps not unlike https://www.rust-lang.org/en-US/". Certainly I feel that that a newer systems programming language needs newer and more ingrained parallelism support as perhaps the most important progression from C.
You really should read these papers and at least skim the mailing lists in which the authors discuss them. They address Rust and Go.

Is "support for parallelism" the same as "accurately represents what is really going on in a multi-processor environment"? How do the abstractions which C relies on (maybe "assumes" is a better word) fail when it comes to things like FPGAs, massively parallel GPUs, and other more esoteric environments?

jimallyn wrote:
Tue Mar 06, 2018 9:56 pm
Not sure that I know enough about system programming to make any meaningful contributions here, but I am interested enough that I will watch this thread. One thing you can say about C is that it is one of the few languages in which one could write the operating system, the applications that run under that operating system, and the firmware running on the 8 bit microcontroller in the keyboard attached to the system, right down to the interrupt routines. (I remember years ago in one of the electronics magazines I was subscribed to, somebody ran an ad that included something about writing interrupt routines in Cobol for 8051. April Fools Day, of course.)
Here's the abstract for Stephen Kell's paper.
Abstract
The C language leads a double life: as an application programming language of yesteryear, perpetuated by circumstance, and as a systems programming language which remains a weapon of choice decades after its creation. This essay is a C programmer’s reaction to the call to abandon ship. It questions several properties commonly held to define the experience of using C; these include unsafety, undefined behaviour, and the motivation of performance. It argues all these are in fact inessential; rather, it traces C’s ultimate strength to a communicative design which does not fit easily within the usual conception of “a programming language”, but can be seen as a counterpoint to so-called “managed languages”. This communicativity is what facilitates the essential aspect of system-building: creating parts which interact with other, remote parts—being “alongside” not “within”.
The tl;dr is it treats memory as a first class data structure of sorts, which allows it to interface with almost anything, including other languages. The fault of other languages is that they don't do the same (even in a relatively safe manner) and that they try to create walled gardens in which you don't need any other language. He believes that C and the systems which live alongside it make it a easier to do these things and as such it's a more polite language - it works with other systems and languages, not against them.

Fred Barclay wrote:
Tue Mar 06, 2018 10:19 pm
+1 for Rust. I just started learning it yesterday.

That being said, if you're willing to give up low-level stuff then you can't really beat python, in my opinion. I use it everyday, and it's been fun to watch the Matlab folks in my department slowly, one-by-one convert to python and/or R. :mrgreen:
Is it possible to do low level stuff better than C? How does C fall short in that respect?

catweazel wrote:
Wed Mar 07, 2018 3:42 am
C++
I once heard C and C++ described thusly: C give you enough rope to hang yourself, C++ gives you enough rope to rig a fleet of sailing ships and hang every member of the crew.

User avatar
Fred Barclay
Level 12
Level 12
Posts: 4147
Joined: Sat Sep 13, 2014 11:12 am
Location: Bumping around in the bush

Re: How would you make a language that does system programming better than C?

Post by Fred Barclay » Wed Mar 07, 2018 10:40 pm

0x2620 wrote:
Wed Mar 07, 2018 5:28 pm
Fred Barclay wrote:
Tue Mar 06, 2018 10:19 pm
+1 for Rust. I just started learning it yesterday.

That being said, if you're willing to give up low-level stuff then you can't really beat python, in my opinion. I use it everyday, and it's been fun to watch the Matlab folks in my department slowly, one-by-one convert to python and/or R. :mrgreen:
Is it possible to do low level stuff better than C? How does C fall short in that respect?
I'm not entirely sure I understand the question, but C (IMHO) is still the best way to do really low-level stuff, short of you actually writing assembly. I don't expect this will change in a long time.
Python is much higher level than C.
(Interesting anecdote: I have a book about C that describes it as a "high-level" language - which it was at the time. Today I read articles that call python high-level and C low-level.)

Funny quote about C and C++ but I'd actually put it the other way 'round! :D
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein

Post Reply

Return to “Open chat”