Tuesday, April 05, 2005

Programming in C

My Operating Systems class this quarter is going get down and dirty with the Linux Kernel. The Kernel is the most basic part of the operating system. *nix uses a microkernel, that is the kernel is as small as it can be. Everything else is just a user program. That's why there are so many shells for Linux, for example. It's easy to just write another if you don't have to dig into the kernel. All the programs to move, delete files, change directories, etc, all of these are just small little programs. But I digress. Since we're messing with the kernel, we have to know and use C. Now, I always thought that C was just a subset of C++ (which it is, C++ is an add-on to C). So if you knew C++, C was about the same thing, just a few less wrappers. Boy was I wrong. C is a functional (or procedural) language. That means there are no objects. The early '90s had a revolution in programming design - object-oriented programming. Basically, everything in the system became an object, or a subtype of another object in the system. Objects interacted by calling methods (verbs) on the object, or directly manipulating it's attributes. This made conceptualizing and designing large systems a lot easier. There are even automated tools to develop code-structure from natural-language descriptions. This object-oriented method led to the development of C++ as an extension to C. C/C++ are very powerful languages. C is really just a high-level assembly language: it's low enough you can do cool tricks, but high enough, when you fuck up you don't know why. C++ is easier to design and code large systems in, but it has a larger footprint (higher overhead cost). This is one of the reasons why optimized systems, like the Linux Kernel are written in C. Object-oriented systems are still possible in functional languages like C - after all, C++ is oo, and it just built on / extended C. However, it's more difficult, and doesn't feel as clean. Perhaps it's just taking me a bit to get used to it. We had to design queue and hash table data structures for our last homework assignment. It wasn't as clean as it would have been in C++. It's definately harder to understand, what with typedefs all over the place. (typedefs are pretty much "replace ThisGuy with ThisOne", causing a lot of looking around the files to see what you're really dealing with.) I still feel odd writting from an oo perspective while in a functional language. I've gained a greater appreciation for C++ from this. I'm also liking C more - lots of cool tricks I didn't know/think about before. F*ck you Java! <still like my C# though>

"Technological advance is an inherently iterative process. One does not simply take sand from the beach and produce a Dataprobe. We use crude tools to fashion better tools, and then our better tools to fashion more precise tools, and so on. Each minor refinement is a step in the process, and all of the steps must be taken." - Chairman Sheng-ji Yang, "Looking God in the Eye"

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]