Search code examples
pythonrubyperlprogramming-languagessmalltalk

Collections and Stream classes equivalences between Smalltalk, Perl, Python and Ruby


I have few experience with languages like Python, Perl and Ruby, but I have developed in Smalltalk from some time. There are some pretty basic Smalltalk classes which are very popular and cross-Smalltalk implementation:

FileStream
ReadWriteStream
Set
Dictionary
OrderedCollection
SortedCollection
Bag
Interval
Array

Which classes would be the equivalent or valid semantic replacements in Python, Perl and Ruby? I've found several language comparison pages comparing syntax, however it seems there is little help when comes to the translation of core and base libraries.

I also wonder if there is a base or core class in Python, Perl or Ruby which is not present in Smalltalk or viceversa?


Solution

  • Perl

    I'll answer for Perl, since I'm fluent in both Perl and Smalltalk.

    Smalltalk's Dictionary is fairly close to Perl's hash type. A Dictionary uses object equivalence for the keys. Perl uses simple strings for keys, so the flexibility is somewhat limited.

    Smalltalk's OrderedCollection is fairly close to Perl's array type.

    Smalltalk's FileStream is somewhat like Perl's filehandles, in the sense that they represent a stream of data to an external file or device.

    And that's about it, since Perl has only hashes and arrays and filehandles. :)