preview

Differences Between Smalltalk And Python

Decent Essays

Type systems
Both Smalltalk and Python are dynamically typed languages. These languages will leave the type check until run-time, in contrast with statically typed languages that enforce types at compile-time. The method lookup also happens at run-time allowing more flexibility in manipulating objects. The two languages have dynamically dispatched, which is message is evaluated depending on the receiver object at runtime (section 3 Code lists).

Smalltalk uses untyped variables and they must be declared before using. The reason why variables should be declared is that we can inform the compiler to leave some memory space for variables. Python also in the same case that it has untyped variables but those do not need to be explicitly declared. Whenever assignment happens for variables, the declaration also occurs. Since no type checks happen at compile time, the responsibility is of programmers to ensure that variables will receive the correct kind of values. The two languages provide type conversions that will return the new objects represent converted values.
Another small difference between Python and Smalltalk is that the former provides multimethods, functions with same name and different types of argument. This is saying that Python …show more content…

Python provides some built-in functions for doing introspection such as type(), isinstance(), callable(), and getattr(). The dir() function is one of the most important function when doing introspection since it gives a list of attributes and methods in the inspected object. However, Python also allows programmers to modify the inner structure of objects at runtime. The inner structure of an object can be changed due to the fact that in its dictionary the pointers to a field can be reassigned at runtime. For example (section 5 Code lists), we can add new function intro() to ref, can modify the method message(), and delete an attribute at

Get Access