For Programmers: Free Programming Magazines  


Home > Archive > Smalltalk > March 2005 > binding and generics









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author binding and generics
Smallfernandes

2005-03-16, 8:58 pm

does Smalltalk support generic programing ??
it does early or late binding ???
what about type variance e object dynamic allocation ???
thanks...(I'm starting with smalltalk and I'm looking for the differences
bettwen this and JAVA :) )

Reinout Heeck

2005-03-17, 8:58 am

Smallfernandes wrote:
> does Smalltalk support generic programing ??


Yes

> it does early or late binding ???


Late


> what about type variance


Not sure what you mean, but look up the term 'duck typing', that is what
Smalltalk does.


> e object dynamic allocation ???


Super dynamic :-)


> thanks...(I'm starting with smalltalk and I'm looking for the differences
> bettwen this and JAVA :) )
>


http://wiki.cs.uiuc.edu/VisualWorks...+C%2B
%2B


http://wiki.cs.uiuc.edu/CampSmallta...ava+Programmers

http://wiki.cs.uiuc.edu/VisualWorks/Donald+Raab's+Smalltalk+vs+Java+Comparisons




Enjoy!

Reinout
-------
Smallfernandes

2005-03-17, 8:58 am

Thanks for the answer...
could you tell me the structures used to do generic programing in
Smalltalk?

And the structures to do dynamic allocation (like new in JAVA) ?

can I do early binding in Smalltalk too ??

Syver Enstad

2005-03-17, 8:58 am

"Smallfernandes" <cafernandes@gmail.com> writes:

> Thanks for the answer...
> could you tell me the structures used to do generic programing in
> Smalltalk?


You can *ONLY* do generic programming in Smalltalk. You don't do
anything else. The types are only checked at runtime (late binding).

> And the structures to do dynamic allocation (like new in JAVA) ?


Send the message new to the class or use a custom instance creation
method.

Like this:

variable := MyFavouriteClass new.

Or (if you wrote another instance creation method).

variable := MyFavouriteClass
with: bread
and: onions.

>
> can I do early binding in Smalltalk too ??


No.

You come from a C++ background yes? Smalltalk is like other dynamic
languages such as Javascript, Python in that all programming is
generic. Templates/Generics had to be invented in C++, ADA and Eiffel
to work around the static typesystem, which is not neccesary in
dynamically typed languages such as Smalltalk.

Basically Smalltalk won't stop you from:
1 + '3' "adding a string to an integer"

It generates an exception when you run it though.

So in Smalltalk you have to check the types yourself. I find that in
practice this is much less of a problem than I thought it would be (I
have a C++ background), especially when you have good automated tests
for the project you are working on.
Smallfernandes

2005-03-17, 8:58 pm

Thanks everybody....
All my doubts are OK.

and Syver....yes I started programing with C++ and now i'm programing in
JAVA(J2SE 1.5)that has some "peculiarities", like generics that we didn't
have before.Our study group is making this research to know some
differences bettwen C++, JAVA and Smalltalk(that's new to me).

thank you again.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com