The other day I found out that Python 3000 uses b"..." for byte literals and "..." for Unicode (default) literals. Good idea. Reminds me of Objective-C's @"" (for NSString) and C's L"" (for widechar strings.)
And what does Perl have? The backticks to execute (`ls` runs the command); the quotes and double quotes that decide on interpolation (" interpolates, ' does not) and //, the regular expression creator.
I would argue (against perl) that attaching behaviour such as executing stuff to backtick is a much worse idea than using backticks to differentiate between Unicode and non-Unicode strings. An operation like "execute" belons in a verb, like system() or execute(). Not only it looks bad, but also forces things like security to be swept under the carpet, and into "system-land." What I mean is that something like `ls` has a lot of configuration that is implied and only accessible (if at all) through some other system/language dependent constructs. Contrast that with something like: env.system('ls'); -- which, although more verbose, is absolutely obvious -- and you know that env is probably something that can tell you what OS you are running on*.
But hey, Perl has to keep all the UNIXisms... otherwise UNIX hackers might cry, wake up and realise they are not in the 70s anymore. UNIXisms might be nice for sysadmins, but they should have only minor places in modern programming languages. All the unix utilities are quite cool, and each does its own thing very well, but let's face it, there are better ways of expressing the exact same computations using modern ideas. Let's pick up what's useful and plays well with other ideas, and toss the rest.
The one thing we should take from perl, the thing that perl has had major, indisputable success with is regular expressions. Which is a little bit sad if you really think about it. Regular expressions are the bread and butter of any text processing you are going to do, and any programming language that doesn't have them is a bit of a toy. It's for that reason that a good programming language should include a syntax to facilitate writing regular expressions. If it doesn't, and we are forced to use straight strings instead, we end up in Java-land (aka "The Land of the Quoted Regex", aka "\\\s" aka "one backslash to quote the backslash, then another quoted backslash before the first one to send a quote to the regular expression engine")
So, what would a better programming language look like? Let's just say that removing most (if not all) UNIXisms from perl would be a step in the right direction. How about something like X"" ?
---
* I am aware that perl has system(), but that's beside the point, and, if anything, another UNIXism.
Wednesday, September 1, 2010
Programming language ramblings I
Posted by
Andres N. Kievsky
at
5:19 AM
Labels: perl, programming, programming language design, python
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment