3 posts tagged “perl”
I started looking at the language Objective Caml, and I gotta say, i'm losing interest VERY fast. All I really wanted to know is how to get some user input. This sort of thing is not difficult to figure out in most languages (though exceptions do of course exist). So I tried googling something like ""objective caml" input", not much there, so I got a bit more creative:
""objective caml" stdin"
""objective caml" read"
That got me something, a vague reference to a command called "read_line". Cool, it could have been easier to find, but hey, now I have a starting point. So I look that up a bit, and literally all you can find is it's prototype. While this is probably ok for people who know a bit about programming, it certainly doesn't go into any detail about it's more interesting uses. Not to mention if you don't know any languages, you're pretty much up the creek.
Now, I will admit that I was being highly impatient in my searches, but this is pretty crappy. If I have this much trouble trying to learn to take input, I can only fathom the hours I could spend later on trying to figure out how to do something obscure. You look at Perl for instance, and you can find more information on dang well near any routine then you will ever need (or want).
This isn't meant to single out O'Caml as a particularly tough language to pick up either. Anyone ever tried Haskell? Holy cow! I wouldn't consider myself adept at ANY language, but I have working knowledge of several, so generally picking up pieces of a new one isn't too difficult.
Haskell is a whole new experience. I can only guess that if you have the right mindset it is an absoute pleasure to work with, but without it, it would be akin to a small child trying to wrap their mind around quantum physics. Granted I knew it would be worse for me, having programmed mostly Perl. Perl is pretty unique, and is known to fairly well cripple programmers if it is their first language. FYI, never did get anywhere in Haskell, still don't know how to use any of it.
Forth... wow. Quite a new concept as well. There is a good bit of documentation around, but I never did find any I cared much for. In fairness though, I didn't give forth it's due dilligence.
I know that with some languages it can be argued that it simply hasn't been around long enough to have good documentation. I don't buy this too much. NewLisp for instance is developed by a pretty small community, and hasn't been around very long, but has some great documentation.
I'm really looking for a small compiling, very fast, but decently programmer friendly language, and am having a difficult time. ANSI C is kinda my best choice for small compiling/fast (and boy is it ever both of those), but it is certainly not programmer friendly. There is also C++, while it is a fair bit nicer to program in, it adds a great deal of overhead in compiling. I wish there was a good, small, optimizing compiler for Perl code. I pretty much wouldn't use anything else.
Seriously Perl community. Someone should make one. I know that it would be insanely difficult (maybe impossible, I have no idea), but can you imagine it. There really wouldn't be a good reason to use anything else for any common task.
Oh well, the research goes on I suppose.
ADDENDUM :
Oh yeah, one more thing : APL ... yeah... read the article. This is one I can pretty much guess I will never understand.
They are quite possibly the coolest programming tool ever. I am writing a program in Perl right now, and wanted to internally handle directory change commands. So, things like cd.. or cd directory, or even cd ../directory. After a bit of tinkering around with a regex designer, I have this:
^cd ?((\.\.){1}(\\\.\.)*)*([\w\d\s]*(\\[\w\d\s]*)*)$
It seems to work great! Now I have to write the code to handle what those commands do, but at least I can capture them all with one single regex. Wicked.
I recently started learning some Python to add to my vast assortment of pieces of programming language I know. Now, if you look up comparisons between Python and Perl you will find a decently large preference for Python. Having worked in it for a few days (admittedly hardly a chance to know it very well) I can't see why.
For starters, Python is said to be far more maintainable because of it's syntax. For those not in the know, Perl is loaded with brackets {} and every command ends in ";". This contrasts greatly from Python, which has quite literally nothing. All the command termination in Python is done via spacing and end of lines. While this decreases the amount of symbols, all that means to me is that there are no clean cut areas where an end of command/structure is highly visible.
Another point of Python is that the base library is smaller. This is done to keep the base free of clutter. Ideally this would result in faster run times. Of course theory and practice and two quite different beasts... I notice no speed improvement over Perl. (This does not necessarily indicate that there is not one, just that it is not a big difference)
Going hand in hand with the small code base is another gripe though. Lets say you want to execute a script from within your Perl script and catch it's output, you may do something like this
$output = `command`
Simple, easy to use, not that much to remember. You pretty much put your command in backticks.
Same thing in Python on the other hand is
import os
output = os.popen("ls")
Not as simple. And there are actually 4 different popen methods. You do not have to "import os" everytime of course, but it must be imported for the script to work. Python is full of little things like this that just plain take up more space. Take another example. Say you want to check if a given file exists.
In Perl that would be:
if (-e "file)
In Python on the other hand:
if os.path.isfile("file")
Again, it isn't a massive difference, but imagine how much more typing that can be over a couple hundred lines. Worse though is the full on missing functions. Many programmers are familiar with the auto increment/decrement functions. Usually indicated by placing a double plus "++" or double minus "--" in front of a given variable. Though a rather simple function, it saves time. In Python, no such thing. The best method I know of is to add the value of the variable to 1 and return it. So:
In Perl:
++$myvar
In Python
myvar = myvar + 1
Kinda lame.
Then today I was starting work on a script parser, and thought transliteration would be a handy way to do something. Guess what. Again no such thing.
I don't know, there are aspects of Python that I quite like. For instance it appears to have a great socket layer, which is something I have found somewhat lacking in Perl. Overall though, it hasn't managed to knock Perl out of being my favorite language.
If some Python programmer happens to find this, and I am wrong, please let me know. Not only would it be handy to know some better ways, but I will happily correct myself here.
