3 ms·
Perl would be my bet.
by vgy7ujm 10y ago
Perl would be my bet.
- sametmax 10y agoPerl fail on big code base, particularly because the cognitive load of reading it is high.
- vgy7ujm 10y agoI'm not really buying into that argument. I have seen Python code that is unreadable, actually a lot worse than 90s PHP/Perl. Take a look at modern Perl please.
- sametmax 10y agoPerl 6 is better, but it still offloads a lot of the logic parsing to the human brain. Create an array or string, take the last element and display it: <A B C>[* - 1].say; The same in Python: print(['A', 'B', 'C'][-1]) The same in Ruby: print ['A', 'B', 'C'][-1] The first version is a good example of what perl is good at : it's short to write. The Python version is more verbose. But, your brain has to do the following: - Scan the element to realise A, B and B are strings. Perl can have strings with "A", but in this here you can write it without it. So when you read, you need context to know what's going on. The Python version make it clear it's a string. - Then figure out the that the separation is on the spaces. Python put comas, so you don't have to parse negative space in your head. - the you have the "*" you need to integrate to get context of what element you use. Then you get the ";" which is just noise. Small elements like those add up very, very quickly in a code base. Every time your brain has to gather context before understanding what it reads, you add cognitive load. You can't scan the code. PHP, Perl and JS by nature have a higher cost that Ruby or Python. The laters have been design with readability in mind. You have less tricks, they are more boring. And easier to read. Of course you have many other small issues with perl, like figuring out why you use .say but .WHAT in uppercase. Why the shell by default on some linux setup have a broken history. Why you can leave out the .say most of the case in the shell, but sometime if you don't use it nothing is displayed. That you have to install the rakuto package on Ubuntu but run the perl6 command to start the shell, etc. All in all, Perl is a neat technical achievement, but has not been very ergonomy oriented.
- vgy7ujm 10y agoIs Russian the hardest language to read for someone that doesn't know Russian? C type brackets and semicolons are second nature to a lot of people. Perl has a lot of built-in stuff that makes a lot of sense when you have learned it. Your example in Perl 5: print qw/A B C/[-1]; I instantly know that qw has to do with a list of words, and the qw// can be replaced with qw(), qw[], qw##, etc to make the code the most readable to you. Can be written like this if you like the commas and quotation marks: print qw/'A', 'B', 'C'/[-1]; #Will warn print(('A', 'B', 'C')[-1]); 'say' instead of 'print' adds a newline: say qw/A B C/[-1]; Print the three first elements: print qw/A B C D/[0..2]; Assign elements to variables: my ($a, $b, $c) = qw/A B C/; Print the number of elements and assign it to a variable at the same time: print my $num =()= qw/A B C/; You CAN very easily write "boring" readable Perl if you want to. But the power is there when needed. One letter variables, insane uncommented regexes, removing all whitespace etc is generally not how modern Perl programmers code. Take a look at some code in Python that is done by someone less disciplined (or intentionally obfuscated). It is as unreadable (or worse) as the obfuscated C and Perl from the late 90s.
- sametmax 10y agoOf course you can get used to anything. But even if you get use to run, walking is always easier. Using so much context to convey meaning implying a lot of processing even if you are train for it, so you have an additional load. Using so many symbols to convey meaning as well. By design, Perl is harder to read if you write it the way it's intended to be used. Just like Russian is harder to read than english because the language has some concept like letter effecting other letters than implies you brain need to backtrack. Eventually, if you become a master at it, you won't feel it. But you can only master so many things in life. Most of the stuff, at best, we become very good at it. But very good means you still use your brain CPU. There is no way around it. That's why language design is important, and to me, Perl failed this big time. It's not just about habit either. Take Erlang for example. It is a very different language. It's hard to reason about. But it's not very hard to parse in your head because it's quite consistent and regular in the way it unfolds. Erlang has other issues of course and I wouldn't recommand it over Perl for non highly // related tasks. But yes, Perl has been written to be clever. This is not a quality in language design. Handy yes. Intelligent yes. Clever, not so much.