[wellylug] Non-standard languages on Linux
Phillip Hutchings
sitharus at gmail.com
Thu May 12 09:12:49 NZST 2005
> Pascal and C aren't OO -- you can write OO code in them if you really
> want to, but you have to do many things explicitly that are built into
> OO languages. OO is wonderful; judicious use of it will solve world
> hunger.
Though you do get OO extensions, such as Objective-C, which aren't too
bad. And Obj-C also implements dynamic typing and (if you're using the
GNU Obj-C runtime and not Apple's) garbage collection. Apple give you
a manually reference counted solution, so y ou still don't need to
explicitly destroy objects when you're done with them.
> Neither Pascal, C nor C++ provide garbage collection, aka Automatic
> Memory Management. This means that when you allocate memory from the
> heap, you don't have to give it back manually, which is *really
> convenient*. The wonders of garbage collection will bring about world
> peace.
Except when it doesn't like circular references (eg Java). I believe
Python detects when two objects have a circular reference, but not
three. There is a weak referencing module for this though. So there
still are some tricky aspects to garbage collection.
> Dynamic typing is another feature missing from Pascal, C and C++. It
> means that you don't have to specify the types of objects; just send
> messages to them. If no method with the correct signature is found,
> runtime errors will occur. But if the object is capable of handling
> the message sent to it, the message will be sent, regardless of the
> type of the object. This lack of discrimination will bring an end to
> racism.
Yes! This is really useful! In OO programming you should never care
what object you've got, so long as it responds to the things you ask
it to do. Interfaces are really useful for that. Of course, if you
can't catch the method not found exception, then you have a small
problem..
> So there you have it: ending world hunger and racism; creating world
> peace. These are obvious reasons for switching to a more modern
> language :-)
You forgot exception handling. C, Pascal, etc don't have exceptions.
Exceptions are really useful, you can send error messages out-of-band
back to whatever function really cares about them. Eg, in a web client
the transport layers shouldn't care if the server can't be contacted,
but the user interface needs to present an error. An exception allows
this to propogate from the lowest level to where it's needed without
having to make all the functions in the call stack aware of it, so if
a new exception is added you don't need to add a ton of tests. This
would make it impossible for George W. Bush to be elected.
--
Phillip Hutchings
http://www.sitharus.com/
sitharus at gmail.com / sitharus at sitharus.com
More information about the wellylug
mailing list