Stream Class Collections and Equivalents between Smalltalk, Perl, Python, and Ruby

I have little experience with languages ​​such as Python, Perl, and Ruby, but I have developed a bit in Smalltalk. There are fairly simple Smalltalk classes that are very popular and implemented using Cross Smalltalk:

FileStream ReadWriteStream Set Dictionary OrderedCollection SortedCollection Bag Interval Array 

What classes will be equivalent or valid semantic replacements in Python, Perl and Ruby? I found several language comparison pages comparing syntax, however it seems that translating the main and base libraries helps a little.

I also wonder if there is a base or core class in Python, Perl or Ruby that is missing in Smalltalk or vice versa?

+7
source share
3 answers

Perl

I am responsible for Perl, as I am fluent in both Perl and Smalltalk.

The Smalltalk Dictionary is pretty close to the Perl hash type. The dictionary uses the equivalence of objects for keys. Perl uses simple strings for keys, so flexibility is somewhat limited.

Smalltalk OrderedCollection is pretty close to the Perl array type.

Smalltalk FileStream is similar to Perl file descriptors in that they represent a stream of data to an external file or device.

And about this, since Perl has only hashes and arrays and file descriptors. :)

+7
source

ruby

 FileStream -> File ReadWriteStream -> IO (or other things that duck type like it) Set -> require 'set', then use the Set class Dictionary -> Hash OrderedCollection -> Array SortedCollection nothing similar Bag nothing similar Interval -> Range Array Ruby has no fixed-length collection class. 
+4
source

Python

 FileStream -> file ReadWriteStream -> file Set -> set Dictionary -> dict OrderedCollection -> list SortedCollection -> no equivalent object (must call sort on a list) Bag -> no equivalent object (must implement using dict) Interval -> no equivalent object (but a range() function exists for making lists) Array -> no equivalent (tuple is read-only, fixed length. list is variable length) 

I should note that there is a collection of .Counter object for Python 2.7, which is equivalent to Bag.

+2
source

All Articles