Re: [vox] Why C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox] Why C?
On Sat, 2002-02-23 at 22:03, Matthew Johnson wrote:
> Trying to get back into programming...Because its so much fun :).
> Caught between C, C++ or perhaps Perl or Python?
> I have experience in C and C++ (although wish I had university
> experience though...).
> Any ideas? Just the facts, want to avoid flame fest from Hell. Warm
> enough right now thank you
> Personally found C++ easier to deal with than C. Although knowing Perl
> would be cool too.
Will, first off, let me emphasize:
> PS Yes I probably will want to know them all...
You really ought to learn them all. All of them are very invaluable.
Okay, now for my opinions (which, with a question of this sort, is all
you should expect ;) )
C is my very very favorite language in the world. It sucks. But it
sucks way less than anything else in existence. C is the only language
which really lets me do exactly what I want to. Some things are much
harder to accomplish with it from scratch than in other languages, but
that's what libraries are for. C is still a lot more portable than C++
(still a lot of non-standard-conforming compilers to stay portable with
in C++), and particularly in UNIX, it just plain makes sense.
C is also very dangerous for people who aren't willing to invest
brain-power into being careful about everything they do. Poor C
programming is to blame for the vast majority of the world's
buffer-overrun security problems. But, if you learn from a variety of
sources (so that hopefully some of them would be good) and develop good
development skills, you can overcome these.
C++. Hm. This language I have a love/hate relationship with. I love
object-oriented programming, generic programming facilities such as
templates, resource-protection (e.g., the auto_ptr class), and the STL
(particularly the algorithms library). However, there are a lot of
truly horrific language constructs which I consider brain-damaged (won't
get specific today), that are probably only a part of the language
because of the nice, high-level constructs they tried to force onto the
otherwise very C-like language.
My biggest complaint against the C++ language is that almost as many of
its idioms and concepts get in my way as facilitate. Also, for some
reasons completely unknown to me, there is no kosher way to examine an
object's bytes by casting a pointer to it to an unsigned char * - the
only way to do that is to use a reinterpret_cast or equivalent C-style
cast, which has completely implementation-defined behavior. And, as I
discovered only recently, there is no portable way to read standard
input as a binary stream instead of as a text stream - which caused some
strange problems on a Sun machine, believe it or not. C has always had
the reopen() function, but C++'s OO streams have no similar facility.
I fell in love with Perl when I got into System Administration and Web
Development. Perl is a fun language - it never gets in your way, and
lets you do what you want, how you want it. Perl was in a very large
way my introduction to the world of UNIX (I learned it on Windows, but
there's so much of UNIX in it, you learn a lot from it).
My biggest complaint, though, is that Perl doesn't have nearly enough
ways to help you constrain yourself, which is a very important part of
software engineering. As a human, I make mistakes - I like to use
languages that will let me know about as many mistakes as possible.
Perl does not make this particularly easy - even when I use strict.
Perl 6 will make gigantic strides in this area.
With Perl 6 coming in the near future, it's worth keeping in mind that
if you learn Perl now, you'll have to almost completely relearn it when
Perl 6 comes out, as it looks to be a very substantially different
language than the current incarnation. But it's still much more widely
used than Python or Ruby, and could make an excellent tool for your belt
for that reason alone.
Plus it's just so darn fun!
Python. I like that Python tends to produce such very readable code,
and has object-oriented support which isn't "hacked on" like Perl's.
Another thing I like about it is that all strings are also lists of
characters, so you can iterate over them - this is surprisingly
unstraightforward in Perl, and requires a little maneuvering.
There are a few things I don't like about Python, but I've forgotten
almost all of them (I don't use the language much). I do remember that
I dislike the lexical scoping rules, and the other things I didn't like
were as minor as that.
Python doesn't really have the "fun factor" that Perl has, I think -
just because Perl offers so much freedom, and so many ingenious ways of
doing things. But Perl relies a little too heavily on "magic", which
also hampers the general readability of Perl code.
I favor Perl for heavy text processing, because honestly its tools for
that sort of work are more numerous and flexible. But Python makes a
great language for many other tasks - such as admin stuff, or for
knocking up quick programs, etc. It also makes a really good "glue"
language, or as a front-end scripting language for things like games
Well, that's all I have to say about that for now, I think ;)
I can get pretty verbose when it's a favorite topic of mine....
vox mailing list