4 ms·
Let me guess.. you are a java senior developer, aren't you? You should learn python, or ruby. They will open your mind to a whole new level of abstraction.
by fisadev 14y ago
Let me guess.. you are a java senior developer, aren't you?
You should learn python, or ruby. They will open your mind to a whole new level of abstraction.
- happycube 14y agoI've only dabbled in Python, Ruby and JS, but when I sat down to actually write node.js code, I felt like I was writing (basic) Python with C syntax. Given that I've more-than-dabbled with C... :)
- lmm 14y agoPlease. Python is my favourite language, and has hardly any of the silliness of js. In python classes are still classes, methods are still methods, constructors do look like methods but are clearly a special method. Calling something from the superclass looks slightly odd, but only slightly. People know better than to monkey with object internals unless they have a good reason, in a way that doesn't seem to happen in javascript - I suspect because many perfectly sensible things in javascript look like monkeying around with object internals (foo.prototype.x = ...). Python is dynamically typed, but it gets away with it because its types are strict; if you think a is an int but it's actually a string, you'll catch it when you try and do a + 5. And even given that, python has added (weak, optional, but still there and standardized) type annotations. Code completion works, I don't know how but it does (maybe this could be done with javascript too). Modules are standard and heavily used. The language has a standard and multiple compatible implementations. Thought: if "prototypal inheritance" really is more powerful/useful/etc., why don't we see efforts to implement it in languages with traditional classes? I've seen dozens of attempts at implementing "traditional" inheritance in javascript, but none goingin the other direction.
- ufo 14y agoI think is because you kind of are able to get many of the benefits of prototypal inheritance via features like metaclasses or doesNotUnderstand. Also, classes are only classes in Python if you want to. You can do some very crazy shit if you start messing around with metaclasses :)
- anonymoushn 14y agoImplementing prototypal inheritance in Python requires 0 LOC. Python's method resolution and inheritance already works the right way.
- tikhonj 14y agoWell, the reason you don't really see efforts to implement prototypal inheritance in classical languages is because it would be much more difficult than the converse. Prototypal inheritance is both simpler and more flexible than classical inheritance, so building the latter on the former is much easier. Another thing: there is nothing fundamentally wrong with coercing types. The only time you have an issue with this is when you combine overloading with coercion. Particularly, JavaScript overloads + and uses it to coerce values, which is just broken. Either overloading on types or coercing types by itself is fine and neither is clearly superior; the problems stem from having both. JavaScript also has a standard and multiple compatible implementations; all the cross-browser issues I know of have to do with the DOM rather than the language itself. On top of this, some of the JavaScript implementations are really fast for a dynamic scripting language. Also, let's not get into Python's many problems and weird semantics. It may not have the "silliness" of JavaScript, but it has plenty of silliness of its own. I say this as somebody who's been forced to use it both at work and in my courses: it's just as confusing as JavaScript was, just in different places.