3 ms·
The trouble is, many people appear to believe that your argument that there are things which one generally shouldn't do with dynamic languages has the corollary
by ionfish 17y ago
The trouble is, many people appear to believe that your argument that there are things which one generally shouldn't do with dynamic languages has the corollary that one should not be able to do them, i.e., that these features should not be available in the first place. The nuance of "Most of the time you shouldn't do this, but sometimes it's necessary or even the correct approach" tends to get lost; only the first clause gets parsed, and we have yet another round of stupid arguments in which one side says "Dynamic languages are bad because you can change the way core objects function", and the other says "Dynamic languages are good because you can change the way core objects function".
There is a possible explanation for this: language fundamentalism is an easy position to hold, while subtlety is demanding. Dogma merely requires one to follow its commands, rather than using one's judgement to negotiate between conflicting demands. I hope that this isn't, in fact, the reason that these arguments perpetuate, but I fear that it is.
- jerf 17y agoI totally agree; thank you for highlighting that.
- waldrews 17y agoThere's something to be said for language enforced limitations supporting encapsulation when creating an ecosystem of reusable components - something Java/C# has been great at. An analogy is enforced immutability. Unlike Ruby, Python has immutable strings and tuples, and requires the use of immutable objects for hashmaps - a great choice for library writers, though a minor inconvenience for application programmers who want to say "trust me, i won't change this object later."
- jmillikin 17y agoSmall nitpick -- Python doesn't require immutable objects for dictionary keys, it just won't work correctly in some cases with mutable keys.
- ubernostrum 17y agoWell, technically the requirement is to implement both __hash__() and one of __eq__()/__cmp__(). But Python fudges this a bit in how it handles user-defined types.
- carbon8 17y agoThe recommended and near-universally used Ruby hash keys are immutable. Symbols are used most frequently, but even if you pass a string as a hash key it gets automatically copied and frozen. freeze is also a method on Object and can be used anywhere to make an object immutable.