4 ms·
Smalltalk is not a statically typed, nominally typed language, Smalltalk is dynamic and in Smalltalk classes are objects themselves, so any comparison to Java,
by bad_user 9y ago
Smalltalk is not a statically typed, nominally typed language, Smalltalk is dynamic and in Smalltalk classes are objects themselves, so any comparison to Java, C# or F# does not apply. This is relevant in the context of OOP because in OOP when you talk of methods, you talk of single-dispatching, polymorphism and the Liskov substitution principle.
Static methods are just plain functions tied to classes from an era when people thought having classes everywhere is actually a good idea, in C# and F# also tied to weird, magical compiler rules around operators.
Speaking of Smalltalk and OOP, operators like "+" in languages like Smalltalk are object methods and can be used in generic functions doing polymorphic calls. In OCaml they are plain functions with no overloading. In Haskell they are functions requiring type classes to work, sort of like what F# is doing, but non-broken.
Btw, if you're wondering from where the convention of using static methods for operators comes from, that's another relic of C++, a language not known for elegance, finesse or for being a good OOP language.
- pjmlp 9y ago> This is relevant in the context of OOP because in OOP when you talk of methods, you talk of single-dispatching, polymorphism and the Liskov substitution principle. Which also apply to Smalltalk. > Static methods are just plain functions tied to classes from an era when people thought having classes everywhere is actually a good idea, Using GNU Smalltalk serialization syntax, Object subclass: #MyClass. MyClass class extend [ myClassMethod [ ^ 'Hello from class method' ] ] Transcript show: MyClass myClassMethod. Using Java as example, I see no difference from class MyClass { public static string myClassMethod () { return "Hello from class method"; } } System.out.println(MyClass.myClassMethod()); > Btw, if you're wondering from where the convention of using static methods for operators comes from, that's another relic of C++, a language not known for elegance, finesse or for being a good OOP language. Better know C++, before bashing it. In C++ operators can be defined as member functions and participate in inheritance resolution except for operator=. I guess you are mixing C++ with C#.