Page 1 of 1

Why was VLC written in C and not C++?

Posted: 31 May 2007 11:55
by MetalheadGautham
I have looked all over the website, but got no answer on this one.

I mean, isn't C++ much more feature rich that C?

Posted: 31 May 2007 12:01
by Jean-Baptiste Kempf
Well, yes, but C is faster for many tasks and more supported in many platforms.

Posted: 31 May 2007 12:14
by MetalheadGautham
how? when I learnt C, I noticed that to display my name, all I had to type were around five lines, but for C++ it takes a page, but for large programs isn't C++ supposed to be better? OOP is supposed to reduce size isn't it?


or are you just using C because it is easier to learn, with only 28 keywords?

Posted: 31 May 2007 13:24
by Jean-Baptiste Kempf
Why is Linux kernel in C and not in C++ ?

Posted: 31 May 2007 13:28
by ipkiss
Interesting troll, let's feed it :)
how? when I learnt C, I noticed that to display my name, all I had to type were around five lines, but for C++ it takes a page,
Hum... You probably didn't learn C++ at the same time then, because you really don't need more lines in C++ then in C for such a task :-)
but for large programs isn't C++ supposed to be better? OOP is supposed to reduce size isn't it?
Size does not matter ;-)
In fact, OOP is essentially a different way to structure the code, grouping data with the functions which manipulate this data. The central notion is the one of encapsulation, which in turns often allow reusability and less code, but the size of the source code is not the direct aim of OOP (in fact, it may even be more verbose in some cases).
or are you just using C because it is easier to learn, with only 28 keywords?
C is probably easier to learn (and often constitute a first step before learning C++), but the number of keywords has nothing to do with that.
Well, yes, but C is faster for many tasks and more supported in many platforms.
That's not really true. Well-written C++ is as fast as C, and nowadays C++ is supported on a lot of platforms (all the ones supported by g++ in particular). One can argue that the compilers do not support all the features of the languages, but it only concerns "rare" features, used only in a few very specific programs.
I think that the main reasons why most of VLC is in C are the following:
- the first developers knew C very well, but not C++, so naturally started using C
- at that time, C++ was indeed less spread, and many compilers didn't support properly many features of the language (templates in particular)
- C++ ABI is much less well-defined and stable than C one, so the modules mechanism as it is now in VLC would be more tricky to do in C++ (if even possible)
- VLC core, written in C, has a nice design which "emulates" the notion of encapsulation; so some of the advantages of C++ are there (of course, other advantages like the STL are still missing).
- rewriting everything in C++ now would be a colossal task that nobody is ready to do

Note also that some modules of VLC are written in C++.

Posted: 31 May 2007 13:53
by Jean-Baptiste Kempf
:'( Well, someone at least took your question seriously at least, Metal.

Just for your information, skins and Qt4 are in C++

Posted: 01 Jun 2007 04:43
by MetalheadGautham
:'( Well, someone at least took your question seriously at least, Metal.

Just for your information, skins and Qt4 are in C++
well it was not one of my useless questions I can assure you that. I asked this because of curiosity and intrest to relearn C and/or C++ which I learnt way back just after elementary schooling, but forgot due to lack of use and lack of presence of a comp in my house at that time...

and I think this makes a good thing to add to the FAQ.

Posted: 01 Jun 2007 10:20
by Jean-Baptiste Kempf
and I think this makes a good thing to add to the FAQ.
Add it :D

Posted: 01 Jun 2007 11:45
by DJ
Oh! Oh!

Now you know, as long as he keeps sitting in that Electric Chair he is frying more BRAIN CELLS and forgetting more than he will ever remember, thinking about how wonderful it is! :roll: Drugs do that too.

Posted: 01 Jun 2007 18:42
by CloudStalker
:) Wow. Who would've thought a Moderator could be so cruel; there's hope for CloudStalker yet. :P

Posted: 01 Jun 2007 20:10
by DJ
:twisted: Yup! That's ME! The guy who never got the meaning of the word "empathy". :P

Hmm! Must need vitamins or something. :idea: More Jamba Juice!

Posted: 02 Jun 2007 12:12
by MetalheadGautham
:twisted: Yup! That's ME! The guy who never got the meaning of the word "empathy". :P

Hmm! Must need vitamins or something. :idea: More Jamba Juice!
hey all! I realised that DJ is for Drunk Junkie :twisted:

Re:

Posted: 14 Jul 2007 11:07
by Trollslayer
Why is Linux kernel in C and not in C++ ?
Legacy, pure and simple.

Re:

Posted: 14 Jul 2007 11:08
by Trollslayer
Well, yes, but C is faster for many tasks and more supported in many platforms.
Which platforms have C compilers but not C++ then?

Re: Why was VLC written in C and not C++?

Posted: 17 Jul 2007 15:58
by dionoea
Lots of handheld devices... although that doesn't count for VLC.