Does this mean Python and JS meet the same definition and are as "clean and comfortable"?
Does this mean Python and JS meet the same definition and are as "clean and comfortable"?
Although I like Python, and I don’t know JS well, I really enjoyed learning Smalltalk, even though I will likely never use it professionally.
Imagine that you could do something like this in JavaScript:
(name === "Mike").ifTrue(() => console.log("Hi Mike");
The implementation of this is done through a Boolean class, which has two subclasses, True and False.
True implements the ifTrue(fn) by invoking "fn", False simply returns.
The main advantage is that everything is predictable and inspectable.
Everything being an object may do the trick for you or not. I don't mind a marketing page (even for a programming language) being opinionated, as long as not borderline delusional.
Many sibling comments, IMHO, miss the point of the parent and focus on the claim about python and js.
Python and js could perhaps have been completely object based. It still wouldn't make them comfortable for many.
Python 3.9.5 (default, May 27 2021, 19:45:35)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1
>>> type(x)
<class 'int'>
>>> dir(x)
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod
__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribut
e__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__
invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__
', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__',
'__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__'
, '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__',
'__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_length', 'conjugate',
'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
>>>
>>> y = [2]
>>> type(y)
<class 'list'>
>>> dir(y)
['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__
doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd
__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '_
_ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '
__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', '
index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>>
>>> def sum(a, b): return a + b
...
>>> sum
<function sum at 0x7f673429d1f0>
>>> dir(sum)
['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__
dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals
__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__modul
e__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setat
tr__', '__sizeof__', '__str__', '__subclasshook__']
Apparently everyone keeps forgetting that after the new class type declarations were introduced and the primitive types made subclasses of them, everything in Python is an object as well.Its not uncommon in dynamic OOP (or even object-first multiparadigm languages); it’s true in Python, Ruby, JS, and others.
Maybe the closest "real world" examples would be Lua, and scheme?
Are things like message sends or activation records accessible and manipulable as objects in Python and JS?