7 ms·
Ah, sorry. Despite having used Perl for years, I'd forgotten how much emphasis it puts on concepts that invoke a high cognitive load.
by kstrauser 11y ago
Ah, sorry. Despite having used Perl for years, I'd forgotten how much emphasis it puts on concepts that invoke a high cognitive load.
- Dylan16807 11y agoThere is nothing "high cognitive load" about having different operators for addition and concatenation. I think it's simpler.
- ionforce 11y agoWho "adds two strings"? You're 1) converting the strings to ints 2) adding the ints. The possibility of confusion is the part that is already complex.
- nikatwork 11y ago> Who "adds two strings"? $timeText = $systemHours . ':' . $systemMinutes; vs $durationTimer = $userInputHours + 1; There ya go.
- kbenson 11y agoOn the contrary, I think there is a higher cognitive load in having to reason about the behavior that results from using the + operator between two types when their types may differ. e.g., the Wat talk[1]. To be clear, there is a cognitive load to both. One is based on keeping correct type of the variables you are using with the + operator, the other is knowing that numeric addition and string concatenation are not the same thing, and have different operators. Since string concatenation and numeric addition really aren't the same thing, and don't share the same properties, I prefer the different operators. 1: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- btilly 11y agoOn the contrary, I think there is a higher cognitive load in having to reason about the behavior that results from using the + operator between two types when their types may differ. e.g., the Wat talk[1]. The simple fact that you run out of operators limits how many types can usefully exist. In Python you use + quite reasonably for integers, floats, strings, and arrays. By contrast raw Perl has equivalents only for numbers and strings, and is unable to distinguish between integers and floats. That is why Perl doesn't do exact arithmetic with large integers. But, you say, Perl allows you to use bigint? Well, yes. And that is internally implemented with the magic of overload. Using that you can have any number of types which overload + to do what they want, and you have all of the same issues as arose in the Wat talk. It took a long time for me to be convinced, but I am now convinced that typed variables and untyped operators (like Ruby and Python do) is strictly better in practice than untyped variables and typed operators (like Perl does by default). And as for the complexity, it is just something you have to live with. Want evidence? https://mitpress.mit.edu/sicp/full-text/sicp/book/node48.html https://mitpress.mit.edu/sicp/full-text/sicp/book/node48.htm... discussed this exact problem some 30 years ago. I do not believe that the intrinsic problem is being solved any better today than then.
- jrumbut 11y agoPHP and other languages have a . vs + distinction. I would say that the one area where you're right, and you are so very right, is context. Have %/@/$ cause such chaotic (and not terribly consistent, at least outside the core libraries) behavior changes was not worth the improved error messages or cool tricks you can do with it. This is coming from someone who really likes Perl (5) both in practice and philosophically.