LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2013, 03:38 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
Best systems programming language other than C?


C - simple, elegant, low-level, incredibly portable. But, if you had to write a new operating system or O.S. kernel, and you couldn't use C, which language would you pick?
 
Old 05-18-2013, 04:51 PM   #2
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 999

Rep: Reputation: 142Reputation: 142
"...you coudn't use C.." => it's very unlikely, no?
The real reasons for your question lie probably somewhere else?
 
2 members found this post helpful.
Old 05-18-2013, 07:29 PM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by Pearlseattle View Post
"...you coudn't use C.." => it's very unlikely, no?
The real reasons for your question lie probably somewhere else?
Not a trick questions. I am simply wondering what people would consider to be a systems programming language nearly as good, as good, or better than C.

Obviously if I just asked the question "What is the best systems programming language", likely everyone would say "C" because it is tried and commonly accepted, and I would learn nothing from this thread.
 
Old 05-19-2013, 03:10 AM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Maybe ada would be useful. However, I think C would be the best for systems programming.
 
Old 05-19-2013, 11:11 AM   #5
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by hydraMax View Post
Obviously if I just asked the question "What is the best systems programming language", likely everyone would say "C" because it is tried and commonly accepted, and I would learn nothing from this thread.
"C" didn't get that honour by accident. It is very powerful because of the almost unrestricted way you can use pointers (and typecasting).

Other languages (eg Java) try to restrict the ways you can use pointers because of the power that pointers give you in "C" (eg writing viruses). However, these are not intended to be systems programming languages.

Alternatives to "C" might include assembly language or some versions of "Forth" but I don't think many people would consider these seriously.
 
Old 05-19-2013, 11:24 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by hydraMax View Post
Obviously if I just asked the question "What is the best systems programming language", likely everyone would say "C"
I would say C++, not C.

If I were writing an OS or OS kernel, I would certainly select C++, not C.

Quote:
because it is tried and commonly accepted,
I see three aspects of that:

1) Leveraging the experiences of others. C has been used the most for the kind of work you describe, so any weaknesses of the language for such purposes has already been revealed. Some other language that seems good for such purposes may have weaknesses whose consequences are not yet fully appreciated.

2) Leveraging the wisdom of others. So many people have chosen C for such purposes, it must be good. I totally reject that notion. People are stupid and consensus is usually built on factors unrelated to whether the consensus is correct.

3) Popularity of a tool forms its own benefit. Even if everyone who chose C for a purpose was wrong, the fact that they did creates benefits for doing so again.

Quote:
Originally Posted by psionl0 View Post
"C" didn't get that honour by accident. It is very powerful because of the almost unrestricted way you can use pointers (and typecasting).
I think flexible pointers are a powerful tool in almost any interesting project, and more so in the kind of projects (such as OS kernel) where C dominates.

Most other popular languages are too restricted in pointer use. So more than a specific language (as an alternative to C) I would suggest some criteria, one of which is flexible pointer use, and the related feature of flexible composite structures.

In C (and C++) you can make a complicated composite that has parts directly contained and/or has parts pointed to. So far as I understand parts of an interesting composite in a language like Java must be pointed to. When the language has both those ways for a composite to contain parts, it tends to also need the ability for pointers to point into the middle of an object, something most languages lack.

Quote:
Originally Posted by psionl0 View Post
because of the power that pointers give you in "C" (eg writing viruses).
I would hardly list viruses as an example for either the extra power of flexible pointers or the extra danger.
Flexible pointers require extra competence from the programmer to avoid memory leaks and/or using data after it is deleted and/or using data that is the wrong type. I think having all those dangers is inherent in having the flexibility that I think is mandatory.

Quote:
Originally Posted by psionl0 View Post
Alternatives to "C" might include assembly language or some versions of "Forth" but I don't think many people would consider these seriously.
Assembly language is a very different niche than C. I never thought Forth to have a valid niche at all, and such technical merit it might have had has vanished as computers got more powerful.

Long ago, I used Bliss a lot. I found its syntax a little more awkward than C, but in many ways it was a better systems programming language. C is not an inherently great language. But the success of C has tended to kill things like Bliss and suppress the development of better languages that fill the same need as C. Meanwhile languages that fill different and narrower needs (Pascal, Java, Python, etc.) are not good alternatives to C for either big projects or "low level" projects.

Last edited by johnsfine; 05-19-2013 at 11:43 AM.
 
Old 05-19-2013, 11:31 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Even the creators of the g++ compiler chose to write it in C... LOL
 
Old 05-19-2013, 11:49 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by gnashley View Post
Even the creators of the g++ compiler chose to write it in C... LOL
That is a project inertia feedback effect..

The gcc compiler is a massive project grown over a long period of time using a lot of extreme C programming to do things that would make far more sense in C++.

Think about what kind of person would join such a project and be productive in that environment. It pretty much requires a fanatic C programmer.

How would the decision be made to start transitioning it to C++? Most importantly who must make that decision? Obviously the people deciding whether to transition the project to C++ are fanatic C programmers, because they are the people who have already proven their dedication and ability in an extreme C project. So obviously they don't want to transition to C++.
 
Old 05-19-2013, 04:12 PM   #9
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Well, historically, for binary digital computers, the first OS was (obviously) written in binary. A rather difficult language, but it works.

Then a small assembler language interpreter was written (in binary, of course) which made things somewhat easier. (That assembler was - sometimes - called "A".)

Then a more compact, untyped, language ("B" or "Bcpl") was written in "A."

That was followed by a typed language, "C," which (along with "A") is still in use.

Those were followed by a large number of additional languages. But they all have one thin in common: no matter which "language" you use, the end result is binary code.

As to code with which to develop an OS, many different languages have been used. (I recall at least one hardware vendor - I've forgotten the name - wrote their OS in FORTRAN II.) Which one is "best" depends on your target. Currently the "hot" languages for OSs are C, JAVA (and Google's derivative variant) and "A" for special devices (usually hidden in "device driver microcode").

Note that "OS" is a vague term. Even here, in a Linux forum, many people refer to a distribution as though that was an OS; others call the combination of the GNU tools and the Linux kernel an OS; and others call the kernel itself the OS.

So, for your question, what do you mean when you say "OS?" And, if you intend to build your whole tool chain, at which level will you start? (And, given the current legal climate, where the US -- and some other jurisdictions -- allow patents on software, be cautious even starting your tool chain from the "binary" level. If you use a patented concept -- weird, but it has happened -- you might be liable for large infringement fees.)

Last edited by PTrenholme; 05-19-2013 at 04:14 PM.
 
Old 05-19-2013, 07:49 PM   #10
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by PTrenholme View Post
So, for your question, what do you mean when you say "OS?"
In this context, I'm thinking mainly of a kernel, some kind of standard library, and device drivers. You would probably want to do the low level utilities in the same language as well (ls, cd, pwd, etc.) if it was a highly portable language.

Somebody earlier seemed to suggest that one could write an OS in any language. Is that correct? I was under the impression that you have to have the "flexible pointers" component, in order to work with the hardware I/O memory locations. (At least, if you want an O.S. that will run outside of a virtual machine.) Or am I mistaken about that?

BTW, I know that the HOUSE project attempted to make an OS with a modded version of Haskell. I haven't looked into it, but I think one of the key features was some kind of memory manipulation system which was supposed to be both type-safe and flexible enough for systems programming.
 
Old 05-19-2013, 09:11 PM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by gnashley View Post
Even the creators of the g++ compiler chose to write it in C... LOL
'gcc' suit developers have the last laugh: ATM: http://gcc.gnu.org/ :


Quote:
GCC now uses C++ as its implementation language [2012-08-14]
The cxx-conversion branch has been merged into trunk. This switches GCC's implementation language from C to C++. Additionally, some data structures have been re-implemented in C++ (more details in the merge announcement). This work was contributed by Lawrence Crowl and Diego Novillo of Google.
.

I am no fan of C++, but as a system programming language it's better than "C" because of better type strictness. C++ is almost exactly a superset of "C".
 
Old 05-19-2013, 10:50 PM   #12
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Well, my current favorite language is pure, which compiles to LLVM "portable" code. With that approach, you could do your development on an existing system, and, when you decided on your target hardware, all you'd need was a LLVM interpreter for that hardware and you'd be "good-to-go." I suspect that it could be done, but I'm 73 years old now and I don't think I'd be interested in trying to do it in the time I've got left to play with such things.

If you're interested, pure is a pure functional language, using (preferentially) "curried" functions. (Both haskell and curry are named to commemorate Haskell Curry. pure could, with some lack of precision, be thought of as a "mild" curry.)

<edit>
A pure example:
Code:
$ pure

 __ \  |   |  __| _ \    Pure 0.57 (x86_64-redhat-linux-gnu)
 |   | |   | |    __/    Copyright (c) 2008-2013 by Albert Graef
 .__/ \__,_|_|  \___|    (Type 'help' for help, 'help copying'
_|                       for license information.)

Loaded prelude from /usr/lib64/pure/prelude.pure.
> fact n = 1 if n==1; fact n =  n * fact (n - 1) if n>1;
> map fact (1..10);
[1,2,6,24,120,720,5040,40320,362880,3628800]
> fact 100L;
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L
</edit>

Last edited by PTrenholme; 05-19-2013 at 11:12 PM.
 
Old 05-19-2013, 11:22 PM   #13
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
@PTrenholme: Thanks! I'm installing it now from source.

Question: Can you explain a little bit about what kind of type system it has, or how it works? I am not quite clear on this: the intro page on its site stated that it is an "essentially typeless" language, but the wikipedia page said that it is a "dynamically typed" language. (I'm coming from a Haskell/GHC background, if that helps with the explanation.)
 
Old 05-20-2013, 02:44 AM   #14
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
In case you are into lisp:
http://en.wikipedia.org/wiki/Lisp_machine
 
Old 05-20-2013, 07:40 AM   #15
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Everything about that question depends on exactly what you mean by "systems" programming.

If it means "being able to issue specific sequences of processor-specific instructions that run in privileged mode," the C language is ideally suited for that because it is, in essence, an "über-glorified assembler." Although Ada is used extensively in US (military) applications, in the civilian sector at least, "C" remains the workhorse of that, rather rarefied realm.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Google Unleashes Go: A Brand New Systems Programming Language LXer Syndicated Linux News 0 11-12-2009 12:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration