View Single Post
Old 7th November 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Quote:
Originally Posted by mdh View Post
As much as I like C, I have to ask in what way you find it to be "small"? C is simple indeed, in that it stays out of my way and lets me do what I want to do (for the most part - being able to cast a function pointer to void * and pass it around would be useful). I don't see the small, though. Compilers are hugely complex, and the amount of code that must be written to perform a given task is usually more than with a lot of other, especially interpreted, languages.
How is C small?

The syntactical rules fit in your head easy, compare to Perl and it is microscopic !!! The hardest thing to remember is how to use an enum[eration] or that in pointer arithmetic, you increment or decrement in multiples of the size of the memory it points to rather then directly modifying the address N. The differences between foo.bar, foo->bar, p, *p, and &p being fairly easy to recall.


There are no built in functions - everything is 'man made', be it your own functions, stuff from the standard library, or abusing compiler 'built ins'. Likewise their are only a few fundamental types (char, short, int, ...).


Standard C is so darn portable, it's practically useless for a lot of fun stuff -> file system manipulations; network communication; the good, the bad, and the ugly of manipulating processes / threads, e.t.c. If you ever dig into it, you would probably be surprised just how little standard C places on the 'popular' demands of popular operating system features being present. That's why we have things like POSIX, SUS, and the DOS/Windows APIs to define whats hopefully available on platform X. For example: dirent.h and the various ^.*dir() functions are fairly portable by convention, but not required to be there.

Of the standard issue functions and feature found in hosted environments, the most complex are probably the string, time, and math procedures.





Now let's look at a few larger languages.... C++, Java, Python, Ruby. We gain much larger standard library features, which will be there in the case of Java, Python, and Ruby at least (as I never read the C++ standard). They generally dictate a number of operating system features be provided, such as those related to threads, processes, file system, and network resources.


We also have to accept the fact that many things are now objects and gain a list of common 'methods' which we must now remember. Strings, Lists, Hashes, blah blah and their manipulations. Although in the case of C++, things like std::string and std::vector are optional, you probably want them!!! By contrast most of the string functions in C are stuff most sane programmers would write themselves if need be, and come in a can of common operations so we don't have to debug them.


Likewise we gain exceptions, reflection, and in the case of Java/Python/Ruby a much more complex form of code reuse (packages / modules, jars / gems / eggs, et. al.) and any associated complexity. Hey, what if some poor schleps destructor throws an exception, causes other objects to be destroyed while unwinding the stack and one of those destructor's throws an exception? Oh shit, if some one just tried to delete 20MB of allocated database queries, that's really bad -- terminate() now! (It's probably not a good idea to throw exceptions from a destructor in any language with a call stack anyway, let along in C++).


Then look at assembly languages, X86 ASM for example... You have to deal with some form of consideration about the several modes the CPU has (real, protected, blah blah) and I'm no even going to mention the # of addressing modes... That's a lot more to stuff in head then C, lol.



C is the kind of language, that is small, beautiful, and elegant; but so mind numbingly so, that you can spend a long time in coming to either appreciate or hate it for what it is, at least that is my opinion of the matter.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

Last edited by TerryP; 7th November 2008 at 08:27 AM.
Reply With Quote