Hi, Sven,
so here is my favourite
http://esolangs.org/wiki/Ook!
Proper way to learn c ?
Moderators: hgm, Rebel, chrisw
-
- Posts: 1334
- Joined: Sun Jul 17, 2011 11:14 am
Re: Proper way to learn c ?
And you haven't noticed SQRT???
I *do* wonder who created that.
Matthew:out
Some believe in the almighty dollar.
I believe in the almighty printf statement.
I believe in the almighty printf statement.
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Proper way to learn c ?
According to this source, it was not a redesign, but just an effort to get it to compile with g++ (presumably to allow certain C++ features to be used):Sven Schüle wrote:I see two reasons why that "C++ rewrite" of the Linux kernel failed:mar wrote:Huh. C++ is a superset of C. So I really don't see why Torvalds wanted to rewrite the kernel in C++,
that's completely stupid as it would break existing C programs.
1) You cannot simply "rewrite" something as complex as an OS kernel in C++ unless you also redesign it. A procedural-style software of that magnitude will remain procedural even if you introduce some classes, inheritance, something here and something there. I don't say that Linus made no attempt of a redesign but at least "rewriting in C++" does not suggest to me he did so.
In the dark old days, in the time that most of you hadn't even heard of the word "Linux", the kernel was once modified to be compiled under g++. That lasted for a few revisions. People complained about the performance drop. It turned out that compiling a piece of C code with g++ would give you worse code. It shouldn't have made a difference, but it did. Been there, done that.
I don't see why a kernel written in C++ could not run existing C programs.mar wrote:Huh. C++ is a superset of C. So I really don't see why Torvalds wanted to rewrite the kernel in C++,
that's completely stupid as it would break existing C programs.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Proper way to learn c ?
Name mangling being reason #1 (overloading). There's more, much moresyzygy wrote: I don't see why a kernel written in C++ could not run existing C programs.
EDIT: Absolutely agree with Sven and Daniel.
Last edited by mar on Wed Jul 11, 2012 1:30 am, edited 1 time in total.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Proper way to learn c ?
Reminds me of brainfuck
EDIT: uh ok, got it
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Proper way to learn c ?
Do you realise that Linux executables are not linked against kernel object code?mar wrote:Name mangling being reason #1 (overloading). There's more, much moresyzygy wrote:I don't see why a kernel written in C++ could not run existing C programs.
Name mangling is not an issue here at all.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Proper way to learn c ?
No I don't Against CRT then? So all you have to do is use extern "C"syzygy wrote: Do you realise that Linux executables are not linked against kernel object code?
Name mangling is not an issue here at all.
Cool. Very C++ish
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Proper way to learn c ?
Huh? Do you know what the Linux kernel is? It is not the C library....mar wrote:No I don't Against CRT then? So all you have to do is use extern "C"syzygy wrote: Do you realise that Linux executables are not linked against kernel object code?
Name mangling is not an issue here at all.
Cool. Very C++ish
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Proper way to learn c ?
You tell me. You don't link against kernel directly. You don't link against CRT. That sounds like magicsyzygy wrote:Huh? Do you know what the Linux kernel is? It is not the C library....
EDIT: how do you open a file then? You leave an email to Linus?
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Proper way to learn c ?
No, the normal way is to link against glibc, which will then invoke the kernel using a system call. Making a system call can only be implemented in assembly and you will not notice any difference between C and C++ there.mar wrote:You tell me. You don't link against kernel directly. You don't link against CRT. That sounds like magicsyzygy wrote:Huh? Do you know what the Linux kernel is? It is not the C library....
EDIT: how do you open a file then? You leave an email to Linus?