Phlip wrote:
That is "weak typing". Perl does that. Don't get me started.
C++ is weakly, statically typed. (The weakness comes from issues like void*
or bool, not from automagic string conversion.)
Ruby, like Smalltalk, Pascal, or Python, is strongly typed. Unlike Pascal,
and like the others, it is dynamically typed.
In C++, static typing means this:
void Foo(Bar &);
That function Foo() will only accept objects whose type is known at compile
time to inherit from Bar. Foo() can only call methods known to exist in Bar
or higher, but not lower. Methods bind at runtime, but types bind at compile
time.
ISO C++ has run-time type identification and it provides virtual methods, but the latest
is not for built-in types. But it provides templates for generic programming. I am not
comparing languages, since such a comparison would be unfair for Ruby in terms for
paradigm support and run-time/space efficiency, but Ruby is OK for non-demanding
applications I suppose.
In a dynamic typing system, all objects inherit from a magic thing called
Object. So, in Ruby...
def Foo(aBar)
aBar.baz()
end
OK, however this method for generic programming is a bit outdated. This is what .NET does
so far. Upcoming .NET 2 maintains this, however it introduces *run-time* generics for
generic programming (which are very limited BTW in comparison to compile-time templates,
but are still better than inheriting all objects from Object - .NET inherits everything
from Object too).
http://msdn.microsoft.com/library/de...classtopic.asp
I think a good suggestion to Matz would be to proceed in this way too. It is cleaner.
At compile time, all the compiler did was hash 'baz'. At runtime, aBar.baz()
uses Object's magic methods to fetch the target method, by hash.
OK, .NET doesn't use hashing for this as far as I know, but virtual methods.
This magic
trades just a little execution overhead for a lot of cognitive freedom. We
can control exactly how typed Foo() is. We can assert that it only take Bar
objects, or we can leave it free to take anything that has a baz().
Further, in Ruby everything is an object, including classes. So you can pass
a class, by name, into a method. This is what C++ tries to give us with
templates. But C++ refuses to change C's type system beyond our simple
vtable, so C++ cannot truly treat classes as objects, and each instance of a
template is a different entity.
I am not sure treating classes as objects having any real benefits. Yes in C++ one can use
templates to pass various types (actually to create function instances for the type),
which I think is sufficient (and vtables are not used in this template approach).
I suppose that Ruby provides types as objects and stuff, because it has not the
run-time/space efficiency concerns that C++ has. Which is not bad for application
programming in nowadays PCs, they just have different design ideals, and thus it is not
fair to compare them on such things, but we can compare them on terms of paradigm coverage
(in OO for example whether everything provided in UML can be modelled in each language).
Under this view, in OO paradigm Ruby looks like not supporting many things, complete
multiple inheritance, comes to mind first.
Also from generic programming it supports the Object base approach and I suppose it uses
some type of reflection as .NET 1.x does, to determine which exact type an object belongs
to. This is a somewhat improved approach to the void * generic programming that C uses.
(in C if you want to write a generic function you write one that accepts a void * and an
additional parameter that helps you determine the exact type).
I am not trying to enforce C++ for everything, however I am demanding and pass any
language under scrutiny (for my chosen language ideals of course). :-) So far two other
languages have gained my interest.
Objective-C and Ada. However both of them do not support my platform so far (Ada has a
..NET implementation, however no one could tell me how to set it up and run). So my
considerations are primarily my platform and second provide the ability for compilation.
An interesting message about another language that I sent in another thread.
[The name of the creator of Python was corrected to Guido van Rossum in a subsequent
mailing of the newsletter]
From WinInfo Daily Update:
Python Expands To IronPython
You might have heard of Python, a popular and powerful cross-
platform open-source programming language. Python, which is the
creation of Jim Hugunin, is described as "an interpreted, interactive,
object-oriented programming language ... often compared to Java, Perl,
Scheme, or Tcl." The basic description says a lot (for more information
about Python, see the URL below). Even behemoths such as Google rely
heavily on Python to develop their solutions. Microsoft has also
recently gotten into the act.
http://list.windowsitpro.com/t?ctl=6431:275FF
Last year, Hugunin decide to expand on Python by creating IronPython
(see the first URL below), a new implementation that works within the
Microsoft .NET Framework and the cross-platform Mono environment, which
Novell sponsors (see the second URL below). Version 0.6 was released to
the public in July, when Hugunin also announced that he was joining
Microsoft to continue working on IronPython's evolution. Last week
(some 8 months after Hugunin joined the company), Microsoft released
IronPython pre-alpha version 0.7 to the public. Incidentally, Microsoft
stresses on its download page that IronPython is a codename, so
undoubtedly the company plans to come up with another name for the
final release.
http://list.windowsitpro.com/t?ctl=6430:275FF http://list.windowsitpro.com/t?ctl=642F:275FF
IronPython is faster than the original Python and lets programmers
handle diverse sets of styles, interfaces, and subsystems. You can also
use the language to communicate with hardware and to develop the same
functionality as programs written in other languages--but with far
fewer lines of code. With IronPython, you can also produce static
runtime executables (.exe files) and DLLs.
The main thrust of IronPython seems to be that it supports
Microsoft's Common Language Runtime (CLR) environment (see the first
URL below), which allows seamless integration of code written in
numerous languages, such as C++, C#, Java, and Visual Basic (VB). If
you want a flexible cross-platform language, be sure to check out
Python, and if you're developing for .NET Framework, you should
certainly check out IronPython 0.7 (see the second URL below).
IronPython also has a message board, documentation, and a bug-tracking
facility (see the third URL below) and a mailing list you can join (see
the fourth URL below), although Hugunin implied in a message to the
list that it might eventually be closed in favor of the message board.
http://list.windowsitpro.com/t?ctl=642A:275FF http://list.windowsitpro.com/t?ctl=6423:275FF http://list.windowsitpro.com/t?ctl=6426:275FF http://list.windowsitpro.com/t?ctl=6427:275FF
--
Ioannis Vranos
http://www23.brinkster.com/noicys