And Objective C ?
Announcement
Collapse
No announcement yet.
The Future of Compiz In Question
Collapse
X
-
Originally posted by curaga View PostEww. Please tell what is good in OO. Having to type 10x longer function names just to get anything done clearly affects production rates.
That said, Obj-C is probably not the best bet for a low-level component like the X server. It's a relatively dynamic language and incurs a lot of overhead on method calls compared to something like C or C++. (C++ has no additional overhead compared to C for non-virtual method calls, and its implementation of virtual methods is essentially identical to any C code that uses a shared struct of function pointers -- and you can implement any other style of virtual methods in C++ but do it with a shorter and easier calling convention than C would require.)
Here I was thinking this was 2009 and that irrational fear of anything non-C was long dead.
Comment
-
Originally posted by curaga View PostUhhh... Lets compare.
C: puts("Hi")
Java: system.output.println("Hi")
C++: std:uts("Hi")
C is leading with 4 chars. The same function in Java is measly 22 chars, and in C++ it's 9 characters. And you were saying about shorter functions?
btw that's a trivial example and can easily come up with other trivial examples where c++ wins , just look at operator overloading... matrix3 = 2DMatrixPlus(matrix1,matrix2); versus matrix3=matrix1+matrix2;
There are something that c++ buys you like templates , much better type safety and streams and it's only getting better with c++0x which adds some nice features.
Then we've got the fact that the speed arguments for c++ are bullshit.
A lot of folks use function pointers and structs to emulate objects , then we've got the whole mess with frameworks like GObject.
The fact is that object oriented code in c++ is more readable than object oriented code in c.
Yes you can write hard to read c++ but you can also write hard to read c.
IMHO most arguments against c++ are generally basing their opinion on past compiler support , it's much better now (although the error messages in some cases could be significantly improved).
Comment
-
Originally posted by Ze.. View PostIMHO most arguments against c++ are generally basing their opinion on past compiler support , it's much better now (although the error messages in some cases could be significantly improved).
The other half of the C++ hatred is just ignorance and obstinence, really. Linus has his famous mailing list post that people keep quoting as reasons to avoid C++ at all costs, despite the fact that his whole argument comes down to "stupid people write stupid code in C++, so C++ must suck!" By his own logic and by his own complaints against much of the contributed kernel code, C must be an even more horrific language than C++.
C++ isn't the best language for most use-cases, but honestly, here in 2009, I can't think of any reasons to _ever_ prefer C over C++ if you have the choice. And no, language binding modules are not a good reason. Absolutely nothing stops people from writing C modules for Python/Perl/Ruby/whatever in C++. Extern "C" exists for precisely those use cases.
You don't even need to write your code as OO in C++. C++ is NOT an OOP language, it's a multi-paradigm language. If you just want to use some of C++'s features to make your procedural code easier to read and maintain, go for it!
Comment
-
C++ versus C? I though i was in a thread about Compiz... but as long I'm here
IMHO I don't think C, C++ (or whatever other language) is better or more efficient than the other. We all can give 1000+ examples where the one or the other is more compact or better... the thing is it are just tools and we devs just choose the best tool for the job.
That said, I prefer C++... just fits my way of thinking betterLast edited by tmpdir; 13 January 2009, 04:12 PM.
Comment
-
Originally posted by energyman View Postdon't forget that Linus talking from a kernel point of view - and C++ isn't that good for kernel work.
Anybody who says c++ isn't good for kernel level work is a fool who doesn't understand the language. If c++ is bad for kernel level work then so is c.
The linux kernel has a huge mess where they try to do object oriented c but it's a horrible kludge. They could make their lives easier by using c++. You can still do the low level bit manipulation with c++, but you can also do higher level things with more checking instead of hacky macros and sacrificing some compile time checking.
Originally posted by elanthis View PostThe other half of the C++ hatred is just ignorance and obstinence, really. Linus has his famous mailing list post that people keep quoting as reasons to avoid C++ at all costs, despite the fact that his whole argument comes down to "stupid people write stupid code in C++, so C++ must suck!" By his own logic and by his own complaints against much of the contributed kernel code, C must be an even more horrific language than C++.
Originally posted by elanthis View PostC++ isn't the best language for most use-cases, but honestly, here in 2009, I can't think of any reasons to _ever_ prefer C over C++ if you have the choice. And no, language binding modules are not a good reason. Absolutely nothing stops people from writing C modules for Python/Perl/Ruby/whatever in C++. Extern "C" exists for precisely those use cases.
Originally posted by elanthis View PostYou don't even need to write your code as OO in C++. C++ is NOT an OOP language, it's a multi-paradigm language. If you just want to use some of C++'s features to make your procedural code easier to read and maintain, go for it!
Comment
Comment