Encapsulation is just the idea of having function pointers as part of structs. Inheritance is a logical consequence of that. C has scope as well. cout/cin are just objects in the standard library. You can still printf your heart out if you prefer. Templates are something that C badly needs, and technically already has in the form of #defines, but for objects, you need the same idea implemented in a way that #defines don't cover, and virtual functions are simply ways to designate a method that *must* be implemented in a subclass or it won't compile. Java uses interfaces instead. In Python, you have to program the base class to throw an exception for functions that must be overloaded.Monkey wrote:I have to admit that I like the fact C++ classes have methods/functions within them (encapsulation or whatever the buzzword is for this). However, I'm not sure that C is Just C++ with a few additions. From what I remember of C++, there's lots of extras: encapsulation, inheritance, polymorphism, operator overloading, scoping differences, cout/cin/whatever, templates, virtual functions, etc.Lucifer wrote:C++ isn't that complex. It's basically what you get when you allow function pointers to be members of structs, and the logical things that that allows (inheritance and polymorphism). It's called C++ because it really is just C with a few additions to it.
Edit: I forgot that operator overloading is just a mechanism to tell the compiler how to do math with different types. When the compiler doesn't know how to add two data types together, you have to tell it how to do that. That's all that is. It already knows how to add/subtract/multiply/divide/exponentiate ints, floats, words, chars, long ints, etc. But it doesn't know vectors until you write a vector class telling it to. Furthermore, you may want multiplying vectors to find the determinant instead of just multiplying the components, so the compiler can't even try to do it lazily. Operator overloading is easy. C just doesn't need it because it doesn't have user-defined types, only user-defined aliases for types it already understands.
See? It really is just C with a few extra things that logically follow when you allow a struct to contain function pointers.
Nowadays you don't have to compile your linux kernel either.Linux has much more hardware support than any BSD true, but I wouldn't say that Linux does hardware support better than the BSDs. A good example is (or at least was) the differing APIs for different architectures that Linux has (or at least had). OpenBSD uses one API for all architechtures, keeping machine-independent code together and machine-dependent code seperate; it's all nice and tidy. Another example is kernel modules; OpenBSD doesn't have any. The reasoning behind this is that using kernel modules can produce race conditions (i.e. bugs). Also, everyone uses the same kernel (called "GENERIC"). Therefore bugs can be reproduced more easily/consistently. There's no compiling your own kernel (well, you can but it's not encouraged other than for kernel hacking).
However, if you write GPL drivers, the interfaces for those are static and well-supported. The device interfaces that keep changing are Linus Torvalds's way of throwing the middle finger at NVidia for refusing to write GPL drivers.
Also, Linus Torvalds is on record as saying that kernel modules were a bad design decision. He's been trying to move to a more sandboxed approach since 2.6, but I don't know what sort of progress they've made since then.
Heh, that was my joke. Does the HURD kernel do anything other than generate flamewars yet?Yeah, good luck with that. GNU is a recursive acronym, standing for GNU's Not Usable. Harsh but true.Lucifer wrote:Maybe the GNU kernel is the best because it doesn't have to compete with anybody
[/quote]Yes it is. So is vi vs EMACS. It's probably obvious that I'm a vi guy. I used Vim for years until I decided it was too complex and switched to vi. I do miss multiple undos but other than that, I haven't looked backLucifer wrote: Lisp vs C is one of the classic flamewars, after all.
I was a vi guy until they invented GUIs. Nowadays, I'm all nano, but I found a cool syntax-highlighting code editor that works similar to Kate in a terminal. Then I got a new (to me) laptop and didn't need it anymore.