Slashdot Mirror


Searching for the Best Scripting Language

prostoalex writes "Folks at the Scriptometer conducted a practical survey of which scripting language is the best. While question like that is bound to generate flamewars between the usual Perl vs PHP, Python vs Perl, VBScript vs everything crowds, the Scriptometer survey is practical: if I have to write a script, I have to write it fast, it has to be small (less typing), it should allow me to either debug itself via a debugger or just verbose output mode. sh, Perl and Ruby won the competition, and with the difference of 1-2 points they were essentially tied for first place. Smalltalk, tcc, C# and Java are the last ones, with Java being completely unusable in scripting environment (part of that could be the fact that neither Java nor C# are scripting languages). See the 'Hello world' examples and the smallest code examples. Interesting that ICFP contests lately pronounced OCaml as the winner for rapid development."

159 of 673 comments (clear)

  1. Slashdot Code Auto Answer by Anonymous Coward · · Score: 5, Funny

    Hello, I am the Slashdot Source Code. The answer is Perl. This question is now answered.

    Thank you for visiting Slashdot.

  2. The eternal quest... by Anonymous Coward · · Score: 5, Insightful

    ... for a difinitive answer to a subjective question.

    1. Re:The eternal quest... by LBArrettAnderson · · Score: 4, Insightful

      What they should have done was make a survey where they ask what peoples needs and wants are. I use perl because I think it's the best solution for my website and it does everything that I need it to do. Other people use PHP because it's easier in certain ways. Someone make a points survey which asks questions about the persons' intelligence, personality, and needs, and that MIGHT tell them what language they should be writing in.

    2. Re:The eternal quest... by TastyWords · · Score: 3, Funny

      Hmmm.
      Good Point.
      We'll incorporate it into our next build.

    3. Re:The eternal quest... by DavidNWelton · · Score: 5, Informative

      My friend Salvatore and I did a similar site, although we haven't added so many languages and tests, and are more focused on benchmarking. It's available at: scutigena.sf.net

    4. Re:The eternal quest... by mtsv01 · · Score: 4, Informative
      Another interesting comparison of programming languages is "An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl"
      The interesting conclusions are:
      • Designing and writing the program in Perl, Python, Rexx, or Tcl takes no more than half as much time as writing it in C, C++, or Java and the resulting program is only half as long.
      • No unambiguous differences in program reliability between the language groups were observed.
      • The typical memory consumption of a script program is about twice that of a C or C++ program. For Java it is another factor of two higher.
      • For the initialization phase of the phonecode program (reading the 1 MB dictionary file and creating the 70k- entry internal data structure), the C and C++ programs have a strong run time advantage of about factor 3 to 4 compared to Java and about 5 to 10 compared to the script languages.
      • For the main phase of the phonecode program (search through the internal data structure), the advantage in run time of C or C++ versus Java is only about factor 2 and the script programs even tend to be faster than the Java programs.
      • Within the script languages, Python and in particular Perl are faster than Tcl for both phases.
      • For all program aspects investigated, the performance variability due to different programmers (as described by the bad/good ratios) is on average about as large or even larger than the variability due to different languages.
    5. Re:The eternal quest... by dasmegabyte · · Score: 2, Interesting

      True, true. Over the past five years or so I've used about a dozen scripting languages, and none of them has really stood out and said, "pick me, I'm the best." For starters, some of the fastest languages to write in are also the most esoteric. And some of the most forgiving languages are among the slowest. Here's a brief breakdown of when *I* use which language.

      Oh, and I do not use PERL online, as PERL is WAY too powerful a scripting langauge to allow web visitors to access. Sure, you can tie it down pretty heavily, but why worry about the hassle? JSP has a great security model and I'm used to it, and PHP, being DESIGNED for the web rather than ADAPTED to it, is a nice compromise. These are personal biases and preferences based on my own experiences, please don't flame me because your biases, preferences and experiences WILL be different.

      On the web server, when I want to give it to other people: JSP / JScript (under ASP).
      On the web server, when I just want to get it done: PHP
      On the web server, when money isn't an option and I want to give it to a web designer and never worry about it again: ColdFusion

      On a UN*X machine, when I want to give it to other people: Python
      On a UN*X machine, when I just want to get it done: Perl
      On a UN*X machine, when I just might have to contact a Java object: Python

      On a Windows machine, when I don't care about accessing COM objects: Perl under WSH
      On a Windows machine, when I need good drag and drop support, pretty menus, use COM objects, use Windows networking resources, etc: JScript under WSH (I am more comfortable ending likes with semicolons);
      On a Windows machine, when I might give the code to somebody else who's mind is hopelessly stuck in ASP/VB land: VBScript

      Oh, and don't overlook the usefulness of combining these guys! Marshalling output between scripting languages with UNIX shell scripts or WSH containers is not a black art...if you don't have the time, and you know how to do function XX in Perl and function YY in Python, why NOT pipe XX to YY? I have scripts on my webserver that use three or four different scripting languages, merely because adapting pre-existing code was quicker than porting it.

      --
      Hey freaks: now you're ju
  3. flamewar volley 1 by nocomment · · Score: 4, Funny

    where's php?
    print "hello world";

    --
    /* oops I accidentally made a comment, sorry */
    /* http://allyourbasearebelongto.us */
    1. Re:flamewar volley 1 by kfg · · Score: 4, Insightful

      Scriptometer survey is practical

      Well, for my money, I'm more inclined to start a flamewar over just how they go about defining "practical."

      KFG

    2. Re:flamewar volley 1 by TheRealMindChild · · Score: 3, Interesting

      VBScript is mentioned, but I dont see it anywhere on that page

      MsgBox "Hello World"

      --

      "When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
    3. Re:flamewar volley 1 by prockcore · · Score: 4, Insightful

      Actually, php has the smallest hello world. Anything not wrapped in php tags is passed right through, so "Hello World" in php is literally the length of the string.

      Plus PHP supports everything they checked for.. so why wasn't it included?

    4. Re:flamewar volley 1 by JWSmythe · · Score: 4, Informative

      But they probably would want it at least in the language, so it would be:

      <? print "Hello World" ?>

      or

      <? echo "Hello World" ?>

      They probably should have included it, but that would add quite a few other "web" scripting languages, as long as they have a way to run them locally. Off the top of my head, I'm thinking ColdFusion, I'm sure there are more.

      I think a fun game would be to find the longest way to print "Hello World", without unnecessary filler functions or comments. My first attempt would be to have the Base64 encoded string as a variable, then decode it, then print it, and have all that in an encoded eval.

      I found a script someone had that did their "protection" that way. Without the registration key, you couldn't run it, and they had this beautiful set of encoded strings in evals that did the checking. Took me a good 20 minutes to figure the whole thing out. Then I rewrote that part, so I could try the software without a working key. :)

      The software was otherwise crap, except for all the work they had put into requiring the key. I tried it, and proceeded to delete it. It would have been nice if they had a shareware version to try first. I'm really glad I didn't spend the $200 they wanted for it.

      --
      Serious? Seriousness is well above my pay grade.
    5. Re:flamewar volley 1 by JWSmythe · · Score: 2, Funny


      I'm playing with a script now, to see the most obnoxious way to do it. :) Hmmm, converting it to binary may end up really obnoxious.. Right now, it's just convering characters to their ASCII numbers, binary numbers would make it huge.

      Thanks for the idea!

      --
      Serious? Seriousness is well above my pay grade.
    6. Re:flamewar volley 1 by dieScheisse · · Score: 2, Informative

      True, except the latest versions of php 4.x have a 'CLI', non-web version.

      As a matter of fact, the older versions had a CGI version which could be run from the console as well.

      So, yes, it should have been included.

  4. Biased by javabsp · · Score: 4, Insightful

    I think the author is pretty biased away from Java, at least when compared to C#. If you look at the sample code, the class name for C# is always one letter, but for Java it's always spelled out.

    1. Re:Biased by jelle · · Score: 5, Informative

      One-letter class names? Is he nuts? That guy never had to maintain code I guess...

      --
      --- Hindsight is 20/20, but walking backwards is not the answer.
    2. Re:Biased by p2sam · · Score: 2, Insightful

      for sure! Notice he put in the "public" keyword when declaring the class. That keyword was TOTALLY unnecessary in an allegged quick and dirty script that he claims he was testing.

    3. Re:Biased by p2sam · · Score: 2, Funny

      psam@einstein ~ $ java qwer
      public keyword is not needed for execution
      psam@einstein ~ $ cat qwer.java
      class qwer {
      public static void main( String[] args ) {
      System.out.println( "public keyword is not needed for execution" );
      }
      }

    4. Re:Biased by notsoclever · · Score: 5, Insightful
      There's lots of other subtle biases. For example, in the "grep" example, the sh code simply called grep. If he wanted to be pure about the scripting he'd not have had any way of doing a RE in sh (since it doesn't have true RE handling builtin, it only has globs through 'case') and if he was going to use external calls then why didn't he just do 'exec grep "$@"' or otherwise afford the use of external command execution to the other languages too?

      Also, in a lot of the Tcl scripts he added in a bunch of "good practice" verbosity which he didn't afford to, say, Perl (similar to the C# vs Java disparities you noticed). For example, in tclsh you don't have to explicitly call 'exec' to call an external function since tclsh provides that as an unknown function handler, and he also used the longhand form of checking for a successful execution (namely 'catch') rather than just doing an if on its result.

      Personally, I just use the right tool for the job. I mostly use sh, PHP, and Tcl, depending on which sorts of things I'm scripting, though sometimes I'll also use perl and awk as appropriate (of course, I do often use awk as an external tool from sh).

      --
      There are 10 kinds of people: ones who understand ternary, ones who don't, and ones who think this joke is about binary
    5. Re:Biased by Martin+Blank · · Score: 4, Funny

      No, no... He values maintaining a job. With one-character class names, he's the only one that can really trace the workings. Ergo, he's the only one who can maintain it, and thus unfireable.

      --
      You can never go home again... but I guess you can shop there.
    6. Re:Biased by Anonymous Coward · · Score: 2, Funny

      As the old saying goes:

      "Do you have job security?"

      "Yes? Do you have code to prove it?"

    7. Re:Biased by The_Dougster · · Score: 4, Insightful

      That job security through code obscurity thing really doesn't work because the ones who do the hiring and firing probably have no idea what it is you do other than "some computer stuff" and they probably don't have any clue that the whole system is going to crash a couple months after you're gone.

      --
      Clickety Click ...
    8. Re:Biased by the+gnat · · Score: 4, Interesting

      Also, in a lot of the Tcl scripts he added in a bunch of "good practice" verbosity which he didn't afford to, say, Perl

      Interesting - I hadn't noticed this. Personally, I ALWAYS code Perl with 'use strict', because I've had so many bad experiences with larger scripts that were undecipherable and/or had nasty bugs due to variable mispellings. I avoid using shortcuts whenever possible.

      I think these comparisons are largely bullshit anyway. Many of these programming languages have their own tics or methodologies that appeal to subsets of people. Quite a few people I've talked to (and quite a few posters here, from past experience) are annoyed by Python's syntactical indentation. Since I think everyone should be indenting their code perfectly and consistently anyway, even C or Perl, I love this feature. On the other hand, Python is too slow for some of the simple tasks I need done.

      I don't think you can apply these comparisons broadly either; the code I write in scripting languages includes everything from cleaning up files and batch scripts, to text parsing, sequence alignment, and protein structure calculations. Since at least half of the code I write will never be seen or used by anyone else, I use whatever I think will get the job done fastest AND be the most fun to code in. And if I ever make someone maintain my AWK code, I'll fully expect to be thrown off the roof.

    9. Re:Biased by notsoclever · · Score: 4, Interesting
      On the subject of syntactic indentation, there is one very specific place where Python's syntactic indentation can easily burn you, and that place is Slashdot. Or any web-based forum which makes formatting a simple chunk of text difficult, for that matter.

      One time a few years ago on some webboard I was debating with someone about the merits about syntactic formatting and so on, and he whipped out the usual strawman about "well, which is more understandable, this or this?" and of course, the (whatever the other language was) version would still run just fine (and the formatting could be easily recovered by anyone who cared to), while the Python version was totally worthless specifically because even a human couldn't recover the control structures without the formatting!

      Decent code editors like Emacs and XCode and so on make the indentation easy to maintain, and easy to recover on most languages. But there is no way in hell that you can automatically recover the formatting on a language where the formatting itself is *part* of the language.

      Anyway, yeah, 'use strict' (or its equivalent) is a must. Tcl enforces that by default (is it obvious that I have a thing for Tcl yet?), and it's easy enough to do in PHP as well (with ErrorReporting(E_ALL) or whatever). I have no idea why any programmer in their right mind would deploy a web application which makes assumptions about the default values of variables; many times I've been working on other peoples' PHP scripts which played fast and loose with global variables and automatic registration and so on and they were so full of security holes and REALLY difficult to debug. Like, it's happened way too often that I've been unable to figure out why a variable wasn't getting set only to discover that it was misspelled in its assignment or something.

      --
      There are 10 kinds of people: ones who understand ternary, ones who don't, and ones who think this joke is about binary
    10. Re:Biased by Mad+Marlin · · Score: 2, Funny
      That job security through code obscurity thing really doesn't work because the ones who do the hiring and firing probably have no idea what it is you do other than "some computer stuff" and they probably don't have any clue that the whole system is going to crash a couple months after you're gone.

      Which is when they realize how good of a programmer you are, and hire you back for twice your previous salary.

    11. Re:Biased by djeca · · Score: 2, Informative

      sh doesn't have true RE handling builtin, it only has globs through 'case'

      Note that this isn't true in bash - bash scripting has extended globs feature equivalent to POSIX REs except for lacking backreferences. And you don't have to use case, you can use the [[ builtin.

    12. Re:Biased by RovingSlug · · Score: 2, Insightful
      There's lots of other subtle biases. For example, in the "grep" example, the sh code simply called grep. If he wanted to be pure about the scripting he'd not have had any way of doing a RE in sh ...

      "Pure"? What the ... does that mean? The comparison is "how do you solve a problem in a given scripting environment". The comparison is not "what are the precise language features of each scripting language".

      In shell, to find a substring in a file, you use grep, not some jackass case statements.

      If you must, consider it as comparing the standard libraries between languages. In shell, the standard library is the canonical unix toolset.

    13. Re:Biased by rollingcalf · · Score: 2, Interesting

      Agree 100%. Having consistent indentation is good. But that indentation is much better achieved with a code reformatting utility than by forcing the programmer to constantly indent while typing.

      It becomes especially annoying when refactoring piece of a large method out into a smaller method, which forces you to manually readjust the indentation. With other languages I could just cut-and-paste the segment of code, reformat the code, and everything is indented nicely again.

      I am looking for a tool that will enable me to use curly braces when typing a Python program, then when you're done it would indent the code accordingly and strip out the curly braces to produce a program that the Python interpreter would accept. If I can't find one I may just write one.

      --
      ---------
      There is inferior bacteria on the interior of your posterior.
    14. Re:Biased by DissidentHere · · Score: 3, Insightful

      This is certainly true, and not just with obscure code. In a previous job I wrote a number of reporting and work flow applications that saved the company hundreds of thousands of dollars a month. I was the only one in the company who could code (which was not my primary role), so when I got sick of thier shitty treatment I found another job. The COO didn't want to put together a support contract, or even have me come in once in a while for changes and enhancements - he wanted me to maintain the applications for free! Naturally I told them to piss off. It wasn't two weeks before I started getting calls and emails - "how does this work", "We need to change this report" etc. Last I heard they were back to letting a few hundred Gs slip away every month.

      The people who make decisions rarely have the background or understanding of technology to make good business decisions. They are perfectly happy to lose a million a year rather than give you a $5K raise. The trick is to find a company with people who appreciate your skills and knowledge.

      --
      "None of us are as dumb as all of us." - meeting mantra
  5. Nobody ever looks at Io or REXX... by Dimwit · · Score: 5, Informative

    Two languages missing are:

    Io, which is an awesome, prototype-based scripting language that's super-easy to embed in C applications, and has an incredibly simple and consistent syntax.

    REXX (Regina's just one implementation). REXX makes it incredibly easy to do system scripting, with powerful string-manipulation and I/O redirection.

    Another one's ficl, which is basically an embedable Forth interpreter. (To all you young geeks out there - LEARN FORTH. You may never need to write a line of it ever in your life, but you'll learn a hell of a lot about how computers work. Trust me on this.)

    --
    ...but it's being eaten...by some...Linux or something...
    1. Re:Nobody ever looks at Io or REXX... by quantum+bit · · Score: 4, Interesting

      Another one's ficl, which is basically an embedable Forth interpreter.

      Random bit of trivia: The FreeBSD boot loader has a slightly cut-down version of ficl embedded (and all the boot/kernel loading logic is written in Forth).

    2. Re:Nobody ever looks at Io or REXX... by Almost-Retired · · Score: 4, Interesting



      I haven't coded any job in anything but bash recently, but the most productive code I ever wrote or helped write was in ARexx on an amiga. FWIW, nearly 10 years later, that machine is still doing its job at WDTV-5, running an ARexx script I helped write, which itself is being run by a Cron Jim and I also wrote in ARexx, then compiled to standalone binary with rexxplus. You can see its output on the web page at http://www.wdtv.com under the news category. Its converting the rather laughably formatted teleprompter scripts to news stories you can read, as best it can with limited source information.

      Surely it (REXX) deserved at least an honorable mention.

      Cheers, Gene

    3. Re:Nobody ever looks at Io or REXX... by RevAaron · · Score: 2, Interesting

      Last I looked at it, Io wasn't quite ready for the prime time. It looks like it has moved forward some since then, but in the way of being useful, libraries and the like, it still lags behind a lot of the medium- and big-languages.

      Beyond Io, what would be the scripting language with a primarily prototype-based OOP system with the most usage and libraries? I know of a handful of similar languages, but not sure which one would make the most sense from the standpoint most potential scripters are coming from.

      My favorite is Dialect. It is OSS/FS, but AFAIK, still only on Windows and WinCE. I use it mostly on WinCE, and it is great to use there. Completely source portable between desktop Windows OSes and PocketPC/WinCE. Compiles to an EXE, with everything you need in one file. Unlike some proto-OOP languages, you don't just have prototypes- you have both the structure of a class-based system and the flexibility and power of prototypes, cloning, changing/adding methods or data members on individual objects, etc etc.

      Dialect kind of bills itself as a BASIC-like RAD language, but *do not* be scared away by that. It is a lot more like Python than Dialect in its syntax, and I like it a lot more than Python and especially VB myself. It has some really neet functions- one that comes to mind is like tie() in Perl, but even more powerful!- and is incredibly useful. Best way for writing GUI apps on WinCE hands down, and you can write, test, compile, run and deploy as EXE *everything* on the device itself, no need to use a desktop to write your app.

      A shame no one has ported it to Linux, etc yet- the source is there. Having spoken with the devs some, it sounds like the Win32 GUI, ADO/ActiveX and other stuff will be bound to Windows, but the rest shouldn't be too hard to port. Would make a great VB-like language for Linux, though now with RealBasic, we finally have that.

      Another language that is *really* overlooked is REBOL. It is often overlooked by the OSS community because it is closed source. A darn shame if you ask me, but as a pragmatic programmer (not one driven solely by ideology) I use REBOL and enjoy doing so. At first, it looked kind of gimmicky, a "network" scripting language. But after using it more, I am sometimes caught singing its praises. It is very poweful but the built-in libraries provide a lot of baseline power to programmers and even users. You can write web apps, text console apps or GUI apps- using its own cross-platform GUI toolkit. I have written apps on Mac OS 9 to distribute them to Linux, Windows and OS X and elsewhere to have them run perfectly. I think it is supported on 40-some platforms, though the GUI component- REBOL/View is on fewer, and still lacking on important platforms like WinCE/PPC and Mac OS X.

      REBOL rules- it is a lot like Scheme/Lisp, but without parens- in other words, a great language. It has really nice network protocol support, writing an email client can take a handful of lines of script.

      But... there is hope! A pretty new and slow going project, R-sharp (but nothing to do with .NET!) was released some time back, the start of an OSS REBOL implementation.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    4. Re:Nobody ever looks at Io or REXX... by Daath · · Score: 2, Informative

      Also Small.
      Lisp.
      Scheme.
      Actually just pick one ;)

      --
      Any technology distinguishable from magic, is insufficiently advanced.
    5. Re:Nobody ever looks at Io or REXX... by Almost-Retired · · Score: 2, Informative

      It is a 24/7/365 environment. The box itself usually gets uptimes measured in months, and if we discover its gone away, we have catchup scripts that can bring things back uptodate in just a few minutes.

      We've considered redoing that script in php so we could run it on one of the linux boxes there, but haven't managed to find a round "tuit" yet :)

      Thats the only machine in the place thats still stuck with a bnc type 10BaseT card. Its an elderly 2k, with an FF40 card for brains, a picasso-II video and 32 megs of ram. For all the hoorah about the FF40 card being made without some of the system bus signals, with the version 3.4 Plug-n-go roms for use with os3.1, its been very very bulletproof, for a "migi".

      Usually, when we have to reboot it to get thigs back among the living, we have to reboot the NT server its getting its data from because something in the NT networking has a tummy ache too. The news room clients can access it, but the migi can't until the NT box has been rebooted too. :-)

  6. good but recognized? by 2057 · · Score: 3, Interesting

    Ruby came in second, now lets say i put Ruby on my resume....how much respect will that get? while it was useful to rank the scripts to the author for whatever purpose(prove his point). It is still useless because there is a lack of implentation of 90% of these scripting languages...ergo this changes nothing..my resume is still filled with useless knowledge which won't help me win on jeopardy

    --
    For The Best Jazz/Hip-hop fusion > COlD DUCK
    1. Re:good but recognized? by archen · · Score: 5, Interesting

      That depends. I've heard that Ruby is already more popular in Japan than Python. Much of the ports system in FreeBSD (like portupgrade) is written in Ruby. The fact that Ruby is a pretty young language and has already gained so much support tells much of how good it is. While it might not be quite so useful for a resume, it is good for getting results. I know where I work they don't care about the details, they just want results. Right now I write things in perl, but I have the feeling that once perl 6 comes into the mainstream, I'll be moving to Ruby. You don't have to get very far into the language to realize it's very powerful for writing quick scripts, and can scale VERY well. Aside from that it has taint checking which is also a plus - it's certainly worth it just for doing your own tasks if nothing else.

    2. Re:good but recognized? by Copid · · Score: 4, Insightful

      As somebody who spends quite a bit of time coding in ruby, I can honestly say that it never got me a job. However, there are times when what you can do with a tool is more important than what other people think you can do with it. I like to think that actual results still matter more than promised results every once in a while.

      --
      An interesting anagram of "BANACH TARSKI" is "BANACH TARSKI BANACH TARSKI"
    3. Re:good but recognized? by JamesOfTheDesert · · Score: 4, Insightful
      There are few Ruby jobs, but having it on my resumes almost always leads to a discussion of what it is, why I learned it, and why I use it. It gives me a chance to let the interviewer know more about me, see that I have a genuine interest in CS and software development, beyond simply wanting to know only the marketecture languages and APIs.

      Showing that you are self-motivated, and more interested in using the right tool than the "cool" tool, makes an impression

      --

      Java is the blue pill
      Choose the red pill
  7. What about readability? by BlueCup · · Score: 5, Insightful

    Perl can do a lot, but nothing is more painful than having to look at a perl source code. While a program can be written semi readable, when compared to some others, like PHP or python, they typically make me want to stick very large needles in my eyes.

    --
    WANNAWIKI Wannawiki WannaWiki WANNAWIKI!
    1. Re:What about readability? by DAldredge · · Score: 5, Insightful

      I have seen php code that makes me cry it was so badly written, I have also seen perl code that bad but don't blame the language, blame the idiot who is writing the unreadable code.

    2. Re:What about readability? by shimpei · · Score: 4, Informative
      Bah.. Perl doesn't even have an interactive interpreter..
      perl -de 0
    3. Re:What about readability? by Camel+Pilot · · Score: 5, Insightful

      When you press people on perl and readability they usually quote some exacerbating regular expression. Reg exp are often used in perl since they are are handy and built in. And yes, reg exp tend to be a little cryptic. However taking a little time to figure out something like

      $str =~ /(.*?)\&(\w+)\((.*?)\)/gis

      is a lot easier than understand the 100 lines of code that would be required to accomplish the same task if you where not using a reg exp.

      I would be very interested in hearing what you think PHP provides that enhances readablity over perl.

    4. Re:What about readability? by Nasarius · · Score: 4, Insightful

      Better yet, why not just write a short sentence or two of comments describing what the regex does? This makes it vastly easier to read your code and catch mistakes.

      --
      LOAD "SIG",8,1
    5. Re:What about readability? by Hungus · · Score: 4, Informative
      I don't know where you got your info on the origin of PHP but the official history found at PHP.net states this:
      PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'. As more functionality was required, Rasmus wrote a much larger C implementation, which was able to communicate with databases, and enabled users to develop simple dynamic Web applications. Rasmus chose to release the source code for PHP/FI for everybody to see, so that anybody can use it, as well as fix bugs in it and improve the code.

      PHP/FI, which stood for Personal Home Page / Forms Interpreter, included some of the basic functionality of PHP as we know it today. It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax. The syntax itself was similar to that of Perl, albeit much more limited, simple, and somewhat inconsistent.
      So while its origins lie directly in PERL it was not names Perl Header Pages. So 5 points for effort, -27 points for accuracy
      --
      Bad Panda! No Bamboo for you! In matters of importance ACs will not be responded to. Want to say something critical,OK
    6. Re:What about readability? by Anonymous Coward · · Score: 2, Interesting
      $str =~ /(.*?)\&(\w+)\((.*?)\)/gis

      is a lot easier than understand the 100 lines of code that would be required to accomplish the same task if you where not using a reg exp.

      I think this is a Hacker call of arms. :)

      Presumably, what you want is: Anything but ampersand, followed by ampersand, followed by anything alphanumeric, followed by anything in parenthesis.

      In C:

      int doit(char *in, int limit) {
      char x[256], y[256], z[256];
      char *a;
      a = x;
      while(*in != '&' && limit > 0) { *(a++) = *(in++); limit--; }
      in++; a = y;
      while(((*in >= '0' && *in <= '9') ||
      (*in >= 'a' && *in <= 'z') ||
      (*in >= 'A' && *in <= 'Z')) && limit > 0) {
      *(a++) = *(in++); limit--; }
      if(*in != '(') { return 0; }
      a = z;
      while(*in != ')' && limit > 0) { *(a++) = *(in++); limit--; }
      if(limit > 0) {
      return strcat(x,strcat(y,z)); }
      }

      That's about 20-30 lines of C code. Of course, the comments is what makes something like this readable.

    7. Re:What about readability? by RedWizzard · · Score: 4, Informative

      You're assuming 'limit' is less than or equal to 256 without checking. You're assuming that x, y, and z are set to nulls. You're not handling regional text (i.e. accented alphabetics) or unicode. You also haven't accounted for the fact that the Perl code returns the three bracketed sections of the match in variables.

    8. Re:What about readability? by goon+america · · Score: 4, Insightful
      I personally would much rather somebody came up with a longhand way to do real regexps. The current way (ie, just one string with some special characters) made sense until people started making much more complicated regexp parsers... now we have to re-use special characters, like the ? can mean 0 or 1 or it can mean non-greedy, or it can mean four other different things depending on where it's used...

      I'd much rather have it written out for me in the code what a particular thing is doing, rather than trying to figure out which of the eight different meanings a particular ? could be, much less any of the other pantheon of single-character meaningful regexp modifiers. It's difficult to look up a single character somethingorother like that in a manual. On the other hand, a function name I can look up easily (in the case of php, just type in php.net/function_name and you've got complete documentation in two seconds).

      The same finding holds for much of the perl language. The thought in mind for a lot of perl's syntax design is to omit as writing much as possible. The implicit $_, the unless rather than if not, abbreviated versions of everything, like q//, qq//, qx//, etc. The problem is you can't look up something that's been omitted because you don't know what to look for. When exactly can I use the $_ variable? When a program says "shift;", I can't just look up "shift" in the perl manual somewhere, I have to already know about how @_ works in order to understand what the program is doing. I mean, sure, if you already know perl backwards and forwards, and you're the only one that's ever going to see its internals, then I guess it makes sense for you, but for everything else it doesn't.

    9. Re:What about readability? by RovingSlug · · Score: 2, Funny
      int doit(char *in, int limit) {
      char x[256], y[256], z[256];
      // ...
      if(limit > 0) {
      return strcat(x,strcat(y,z)); }
      }

      Jesus christ. Did you just return a pointer to a stack allocated buffer? Oh. My. God. Please burn this C code and forget you ever wrote it.

    10. Re:What about readability? by Anonymous Coward · · Score: 2, Interesting

      Perl is an acronym, Larry Wall says so - "Pathalogically Eclectic Rubbish Lister"/"Practical Extraction and Report Language".

    11. Re:What about readability? by Cato · · Score: 2, Informative
      Perl is definitely more capable in regexes than most languages, and having regexes in the language makes it easier to do regex-heavy tasks, or use them where most languages would support imperative code. Since Perl's regex support is so strong, it enables commented multi-line regexes using the '/x' modifier at the end of the regex, e.g. (with broken indentation and comment alignment due to Slash/HTML...):
      $str =~ /
      (.*?) \& # Match zero or more characters up to '&', non-greedy
      (\w+) \( # Match one or more word characters up to '('
      (.*?) \) # Match zero or more characters up to '(', non-greedy
      /gisx;
      This is not so quick to type, but still less than the equivalent non-regex code typically, and makes it easier to see what is going on a year later. Perl also has great regex debugging available. Perl is a sharp tool - it enables you to write very concise and unreadable code, just as it enables you to write slightly more verbose and more readable code. With Perl 6 and its Parrot virtual machine implementation, users of Python and other languages should also be able to access the thousands of CPAN modules, bringing the amazing reach of CPAN to a wider audience that doesn't necessarily want the Perl syntax.
    12. Re:What about readability? by brewt · · Score: 3, Informative

      When a program says "shift;", I can't just look up "shift" in the perl manual somewhere,

      You mean, "perldoc -f shift"? wow that was hard!

      I have to already know about how @_ works in order to understand what the program is doing.

      That's just fairly basic Perl.

    13. Re:What about readability? by Karellen · · Score: 2, Informative

      Heh. Not only did he do that, he returned the pointer into an int (which isn't guaranteed to work), and then failed to return any value at all if limit = 0 (which is always fun for the caller).

      Burn your keyboard. And your C manuals. Take up Visual Basic or something :)

      --
      Why doesn't the gene pool have a life guard?
    14. Re:What about readability? by louzerr · · Score: 4, Insightful

      I've been slowly drifting from perl to java (completely different, I know), and on those days when I do go back to my perl code, I quite often end up scratching my head, trying to remember what exactly my code is trying to do. So perl fails - no wait! I fail! I tried to be too clever with my code, and did not provide enough documentation.

      Then, there's my coworker Steve, who's perl code could be printed out and used for documentation! But then, he starts by writing the documentation as his "plan of attack", and then adds the code.

      Long and short, you can't blame the program language for readability, it's really up to the programmer.

      --
      "The large print giveth, and the small print taketh away" -- "Step Right Up", Tom Waits
    15. Re:What about readability? by menkhaura · · Score: 2, Informative

      The function signature is 'int', whereas at this point it is returning a char *... Yeah, burn it!

      --
      Stupidity is an equal opportunity striker.
      Fellow slashdotter Bill Dog
    16. Re:What about readability? by daniel_yokomiso · · Score: 2, Informative

      You can do this in Haskell:

      match-all $ case-insensitive $
      do {
      many (not '&');
      char '&';
      many whitespace;
      char '(';
      many (not ')');
      char ')'
      }

      Not one-hundred lines, descriptive and do, IIUC, what your one-liner does. Functional programming languages (specially Haskell and Scheme) can be both concise and clear. BTW we can easily abstract common regexes away, for example the parenthesis thing above:

      parenthesis pattern =
      do {
      char '(';
      pattern;
      char ')'
      }

      match-all $ case-insensitive $
      do {
      many (not '&');
      char '&';
      many whitespace;
      parenthesis $ many (not ')')
      }

      --
      Disclaimer: If I disagree with you I'm probably trolling...
    17. Re:What about readability? by chromatic · · Score: 3, Informative
      I personally would much rather somebody came up with a longhand way to do real regexps.

      How about Regexp::English in Perl 5 or Perl6::Rules in Perls 5 and 6?

  8. Duh by Beek · · Score: 5, Insightful

    How about the best language for the task you are trying to accomplish?

    I've been using AppleScript for a bunch of stuff lately, but when I hit something that wasn't really intuitive in AppleScript that could easily be done in Perl, then I did it in Perl. Obvious, yesno?

    1. Re:Duh by IrresponsibleUseOfFr · · Score: 2, Interesting

      Yeah, seriously, I wish the "what is the best programming language contests" would come to an end. A programming language is just a tool, and in the big scheme of things, it isn't even the most important tool for the task you are trying to accomplish.

      Things that are likely to have a bigger impact are your ability to aquire quality libraries, documentation for them, and your ability to get help if you hit a roadblock.

      Saying that you choose a programming language is a misnomer, because you don't choose a programming language much like you don't choose a religion. You usually just stick with the ones that you are taught. You might change programming languages, but you usually do so because you wish to join a community and you need to speak their language (i.e. you want to become a kernel hacker so you learn C). Communities are unlikely to pick up new languages (too much history), instead they die and people disperse.

      But really, programming languages nowadays don't really differentiate themselves by what they do, but instead the tradeoffs they make (is this feature in a library or in the language, do we support operator overloading? how? What is our dependence on the run-time system? Do we have a garbage collector?). So I find it hard to argue that one is quanitatively better then another unless you do a study of expert programmers, performance of resulting system, time that it took, and defect rates. We need real apps, comparing "Hello World" programs is a farce and tells you nothing.

      Something like they did in "The Practice of Programming" but with a larger study of people and more controlled.

      --
      Facts are meaningless. You could use facts to prove anything that's even remotely true! -Homer Simpson
    2. Re:Duh by belmolis · · Score: 2, Informative

      I can't speak for other people, but I know that my decisions about what language to use haven't been based just on what I already know and what community I want to join. For instance, my first language was Fortran. After that I learned Basic and assembly language (Mix, just on paper, and the language of a Japanese laboratory minicomputer the model of which I no longer remember. The only documentation I had was in Japanese, which at the time I was just learning. And people complain about man pages!). When I first learned C, it was in a situation in which I could also have used Fortran. I learned C because it looked like it would be a better language and I was interested in trying something new.

      For scripting languages, for many years I used either a shell (sh or csh) or awk. When Perl came along, I read the book and twice made stabs at writing something non-trivial in it, but just couldn't bring myself to do it. I attribute this to my innate sense of good taste. Both the language itself (through non-orthogonality, excessive overloading, and lots of little tricks) and the Perl community (through typical practices and valuing short, cryptic code) encourage unreadable code. At the same time, I knew that AWK was not ideal for some kinds of programs (and I"ve written 500 line AWK scripts, and AWK scripts that write and then execute other AWK scripts) so when Python came along, I was interested. I still use AWK for some things since I know it well and the automatic parsing is handy, but more and more I am using Python. I find that Python encourages good programming practice and provides everything that I would get from Perl. I've also tried Tcl, to the extent of writing a moderately complex (1500 line) program. For some things it is fine, but I don't think it scales up as well as Python.

      So I think that my choices, and probably other people's, aren't just a matter of inertia and general type of programming.

      For me, by the way, in a lot of cases, Unicode support is important. That's a nice feature of Python. Ruby looks interesting, but as far as I can tell doesn't support Unicode. Anybody know if Ruby does, or will soon, support Unicode?

    3. Re:Duh by evilviper · · Score: 2, Insightful

      I don't find it as obvious as you seem to...

      Personally, I spend a bit more time trying to prevent wasting resources... Having a bunch of different scripts, all needing a different interpreter, is a nightmare to me.

      If you are going to write hundreds of perl scripts, stick with perl if at all possible. And what's more, if it's not possible, I strongly recomend using a compiled language instead of using something else that's going to need an interpreter.

      Not only does it waste resources, but it's an absolute nightmare when you need to modify things... Changing something like the file a dozen scripts read isn't too difficult when you are dealing with a single language, but it's quite a mess when 1/4 are bourne, 1/4 are python, 1/4 are perl, and 1/4 are something else that's rather obscure...

      You'd be quite surprised by the long and healthy life of some of the simple programs that you write... In the event that your scripts continue to live on for a few years, it becomes more and more likely that they will be needed on strange platforms, or in unusual environments. Maybe the scripts you are writing will be wanted on the CEO's mobile phone, where there is a perl interpreter. If even 1 of those programs that gets called upon is something that can't be used on the device, it will have to be written from scratch at great expense, and all the while probably with people cursing your name for not sticking with one single language...

      Perhaps I'm just ranting, but you look at your scripts differently when one simple 5-minute script is in use many years later, and installed on thousands of different machines, where it is called by other programs, from a Windows GUI program, to scripts on a webserver.

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    4. Re:Duh by joib · · Score: 4, Insightful


      How about the best language for the task you are trying to accomplish?


      Not necessarily. The problem is that, presuming every problem has a language best suited for solving it, I don't have the time to learn a huge number of languages.

      Now, I'm not saying that you should take the only language Real Programmers use, FORTRAN IV, and do absolutely everything with it. What I'm saying is that e.g. if you know python fairly well, I don't think it's worth learning perl just because some simple regexp matching program can be a few lines shorter.

      For another example, if doing web stuff is 99 % of what you do and you haven chosen php (because every friggin' webhost supports it, there's lots of ready-made code out there, or whatever else makes people chose such an abomination as php), then using php for some simple non-web stuff is probably a better choice than wasting time learning yet another scripting language.

  9. it depends upon the application by humankind · · Score: 2, Insightful

    php for real-time multiuser applications on the high level, C for real performance

    perl for non-real-time application (unless you're slashdot and have oodles of resources at your disposal, even then, it's still inefficient)

    Everything else: you work for Intel, Dell or Kingston

    1. Re:it depends upon the application by KingOfBLASH · · Score: 4, Informative
      php for real-time multiuser applications on the high level, C for real performance

      perl for non-real-time application (unless you're slashdot and have oodles of resources at your disposal, even then, it's still inefficient)

      Most copies of PHP use the equivalent of mod_perl -- i.e. they cache the compilation. Use mod_perl, cache your compilations, and you will find performance is as good if not better than PHP.

  10. Discrepancy... by Polo · · Score: 2, Interesting

    The slashdot descripton mentions that OCaml is the best. ...But when you follow the link, and look at the bottom of the page regarding the first prize winner, This is the proclamation.

    It's not OCaml.

  11. C++ by daserver · · Score: 2, Funny

    C++ was also praised: "C++ is a fine programming tool for many applications."

  12. Scripting with Java by los+furtive · · Score: 2, Informative

    If you'd like to try scripting with Java, then I suggest looking into Mozilla Rhino, which allows one to script Java via JavaScript.

    --

    I'm a writer, a poet, a genius, I know it. I don't buy software, I grow it.

    1. Re:Scripting with Java by Teckla · · Score: 2, Informative

      If you'd like to try scripting with Java, then I suggest looking into Mozilla Rhino, which allows one to script Java via JavaScript.

      Rhino is a JavaScript interpreter written in Java, it's not a Java interpreter.

    2. Re:Scripting with Java by Baby+Duck · · Score: 2, Informative

      los furtive was correct in his statement.

      Rhino is a JavaScript interpretter written in Java, but it is also a JavaScript-Java bridge. So it de facto does indeed allow you to script Java via JavaScript. I do it all the time. The Rhino site even suggests using Rhino for exactly this purpose.

      Beanshell lets you script Java, as well. Those scripts just like Java, with some additional console-friendly global commands thrown in the mix.

      --

      "Love heals scars love left." -- Henry Rollins

  13. PHP by mfh · · Score: 4, Insightful

    I like the ease of PHP and the fact I fully understand it helps. I've wanted to learn Perl, but lack the motivation except to perhaps code some patches for /.

    Anyone feel the same way about either PHP or another scripting language? When you fully learn one, is there a need to switch?

    Remember, when you have more experience with a scripting language, you can pretty much create anything you'll need at a rapid rate. I think that the level of your knowledge determines the effectiveness of the language.

    --
    The dangers of knowledge trigger emotional distress in human beings.
    1. Re:PHP by octavian755 · · Score: 4, Insightful

      Yeah I feel the same way about PHP.

      There are many parts about the language that make it work well for web applications, but there is a time and place for other languages too. For most projects there is no need to use anything else but one language, but if a customer's server only has perl installed and they won't install anything else, then your stuck. So it's a good idea to atleast get to know a couple languages (don't have to master them all) for certain situations like that.

    2. Re:PHP by imroy · · Score: 2, Interesting

      It's been a number of years since I've programmed heavily in PHP. I had learned Perl first, and it eventually took over. If you do learn Perl I think you'll discover the language that PHP is trying to be. Which isn't surprising, considering that PHP originally started off as a perl CGI script. The problem with PHP is that there doesn't seem to have been a lot of thought put into the design of the language. A prime example is the way that Perl has seperate numrical and string comparitors (==/!= and eq/ne) whereas PHP has only the one (==). This recently came up in the story about the Perl periodic table of elements and I even gave my own answer on this problem. Just to rehash: Perl and PHP are loosely-typed languages so the programmer really needs to tell the interpreter how to compare the mixed numerical/string "scalar" type that both Perl and PHP use. But PHP tries to simplify at the expense of introducing ambiguity.

      There are lots of other problems with PHP as well. Not to dwell on them too much, but this includes things like no namespaces (all variables are global? WTF?), modules have to be compiled into the interpreter (is this right? not even dlls/shared libs?), and using associative arrays all the time (leading to more ambiguity). The thing with compiled-in extensions is a big problem since PHP is so popular on cheap hosted web servers. You're entirely at the mercy of the host admin. I mentioned it in my previous post, and this is a very good web page about PHP's problems. PHP is a mess of a language. It really is.

    3. Re:PHP by Tarantolato · · Score: 3, Interesting

      PHP is a mess of a language. It really is.

      PHP: Free Software's answer to Visual Basic.

      (Not a troll, seriously: they're both mind-bendingly hideous, oversimplified hacks that just happen to be ubiquitous because they make life easier for a lot of people.)

    4. Re:PHP by davidsturnbull · · Score: 2, Insightful

      Type-specific comparisons, when needed (rarely), can be made using ===/!==, or you can cast variables c-style.
      Global variables is complete nonsense, it's true that POST/GET variables can be made global in php.ini, but it's not there by default. Function/class/method scoped variables act as they should.

      As to the whinge about modules.. what sort of peon doesn't have their own colocated box these days? They're like $60/mo.

      Of course there are real problems with PHP.
      The only reason to use PHP is that it's sort of like a loosely-typed C clone, with awesome arrays.

      Sometimes you can add $ to all the variables in a C program and it works in php, and mostly you just update a few tiny differences (most of php's unix functions don't have a place for a reference, which sucks btw).

      The arrays are nothing short of elite. I haven't seen any more useful array implementation in any other language (although I'd like to find some!)

    5. Re:PHP by jpkunst · · Score: 2, Informative

      A prime example is the way that Perl has seperate numrical and string comparitors (==/!= and eq/ne) whereas PHP has only the one (==). This recently came up in the story about the Perl periodic table of elements and I even gave my own answer on this problem. Just to rehash: Perl and PHP are loosely-typed languages so the programmer really needs to tell the interpreter how to compare the mixed numerical/string "scalar" type that both Perl and PHP use. But PHP tries to simplify at the expense of introducing ambiguity.

      PHP has == and != for simple comparison, and === and !== for enforcing that the comparants (is that a word?) are also of the same type.

      See http://nl3.php.net/manual/en/language.operators.co mparison.php.

      JP

    6. Re:PHP by imroy · · Score: 2, Insightful
      PHP: Free Software's answer to Visual Basic.

      I think you've got a point there. Both PHP and VB are both languages that us elitists can frown upon and opine things like why do people use such garbage when there are better alternatives? Yes, I'll admit I'm an elitist. But I try not to stray into zealot territory. Zealotry is about emotion and irrational cheerleading. I have (what I consider to be) good reasons for my opinions. And I'm trying to express them here in this thread.

      Perhaps the common thread to a lot of these sub-par pieces of software (VB, PHP, MySQL, Windows, etc) is this: Most people appear to be tolerant of software problems if they understand the software (or think they do). Thus the dominance of simple but horid software for the masses. While I'm fiddling about with infrastructure and obsessing over making the perfect framework, some kid is banging out Yet Another PHP/MySQL web site. *sigh*....

  14. From an ocaml convert: by rsidd · · Score: 4, Informative
    It's an incredible language. I'm writing programs now that are more concise than the Python equivalent and about as fast as C. It's really the holy grail I was looking for. (According to a more thorough shootout, ocaml is competitive in speed with C and often faster than C++, and well ahead of all other competition in speed.)

    The flip side is that before becoming productive one has to get used to a whole new way of thinking about problems: immutable data, everything is a function evaluation, no sequential statements, no side-effects, rely on recursion as much as possible, especially tail-recursion. But ocaml isn't religious about it: it has imperative features, including for and while loops, sequential statements (essentially successive function calls with side-effects and null output), and so on. After a while, though, you find you hardly need any of that. Maybe it's just me, but the sort of work I do is well suited to the functional approach. Also, it has a rich set of data structures and is pretty much agnostic about them: you can use linked lists, hashes, mutable arrays or records, sets, whatever suits your purposes.

    The other drawback is the libraries (modules) aren't as complete as the Perl and Python equivalents (though far ahead of most other competition). I imagine that will get cured with time.

    1. Re:From an ocaml convert: by pikine · · Score: 3, Interesting

      I use O'Caml for about two years now, and I like it immensely. I also know Perl. When I compare the two, I'd say the problem with O'Caml for scripting is that it's more cumbersome to write regular expression matches in O'Caml than in Perl. And I have to say being able to write regular expression matching easily really is the key to many scripting tasks that I'm aware of (not necessarily what I do).

      There is a remedy though. O'Caml comes with camlp4, a Pre-Processor-Pretty-Printer, which basically lets you customize the syntax of your program and add syntactic sugar. I imagine a variant of O'Caml language based on camlp4 that puts regular expression matching in syntactic sugar will make it very suitable for scripting.

      In fact, I itch over this idea badly that I might do it. If I have the time. ;-)

      For the issue of libraries, O'Caml actually has an OpenGL binding before PHP does! Haha.

      --
      I once had a signature.
    2. Re:From an ocaml convert: by gauchopuro · · Score: 5, Interesting
      I suggest you also take a look at Haskell, if you have not done so already. Haskell completely does away with side effects, performing IO operations in a controlled manner through the use of a mathematical concept known as monads. It also adds lazy evaluation. This has some nice capabilities, such as being able to express concepts as infinite lists, which are then only evaluated as far as necessary.

      I have used OCaml a bit, and one of the things that most irritated me about it was its complete lack of operator overloading; having to use "+" for integer addition, and ".+" for floating point addition, just seems so wrong to me. Haskell uses type classes to allow ad-hoc polymorphism in a controlled manner.

      One advantage that OCaml has over Haskell is speed; current Haskell implementations produce code somewhere between imperitive compiled languages and interpreted languages. However, there is another language, called Clean, that is nearly identical to Haskell in many ways, but claims to have speed comparable to C.

      Back to the topic of the discussion, Haskell is probably not the best choice for quick and dirty one time scripting uses. The use of monads for doing IO adds a constant cost that is burdensome for very small programs, and gets payed back only with larger programs where the controlled approach to IO increases robustness.

    3. Re:From an ocaml convert: by wirelessbuzzers · · Score: 4, Informative

      I suggest you also take a look at Haskell, if you have not done so already. Haskell completely does away with side effects, performing IO operations in a controlled manner through the use of a mathematical concept known as monads. It also adds lazy evaluation. This has some nice capabilities, such as being able to express concepts as infinite lists, which are then only evaluated as far as necessary.

      Yes, lazy evaluation can be done in OCaml too, but the syntax is uglier. You use the lazy module.

      I have used OCaml a bit, and one of the things that most irritated me about it was its complete lack of operator overloading; having to use "+" for integer addition, and ".+" for floating point addition, just seems so wrong to me. Haskell uses type classes to allow ad-hoc polymorphism in a controlled manner.

      Haskell's solution to the problem is ingenius, but unfortunately very often requires tagging of those classes, which is slow.

      One advantage that OCaml has over Haskell is speed; current Haskell implementations produce code somewhere between imperitive compiled languages and interpreted languages. However, there is another language, called Clean, that is nearly identical to Haskell in many ways, but claims to have speed comparable to C.

      Looks like Clean has a more powerful set generator than Haskell (it's basically SQL queries), a different class system, and rather different syntax. But it could be useful, I'll check it out.

      --
      I hereby place the above post in the public domain.
    4. Re:From an ocaml convert: by Haeleth · · Score: 2, Informative
      I also like OCaml (learned it in school), although it has a missing feature: you can't for instance define a union type with a member that would have a set of the same type e.g.:

      type t =
      A of a |
      B of t Set
      won't work...


      That's because Set is a module, not a type. Sets are done with functors, you need to instantiate Set.Make with a module whose signature matches Set.OrderedType.

      It's possible to do exactly what you want using recursive modules - in fact, this is the example the OCaml Reference Manual gives for recursive modules:
      module A:
      sig
      type t = Leaf of string | Node of ASet.t
      val compare: t -> t -> int
      end
      = struct
      type t = Leaf of string | Node of ASet.t
      let compare t1 t2 =
      match (t1, t2) with
      (Leaf s1, Leaf s2) -> Pervasives.compare s1 s2
      | (Leaf _, Node _) -> 1
      | (Node _, Leaf _) -> -1
      | (Node n1, Node n2) -> ASet.compare n1 n2
      end
      and ASet: Set.S with type elt = A.t = Set.Make(A)
      As for the lack of overloading, in the few cases where it's actually useful you can normally achieve the same effect by wrapping your types in objects, since OCaml conveniently separates object typing from inheritance.
    5. Re:From an ocaml convert: by srussell · · Score: 3, Informative
      This is not flaimbait: I'm honestly curious.

      About six months ago, I decided I needed to re-learn functional programming, so I did a project in Haskell and learned that. More or less. I still find Modads awkward, and IO is a total pain in the ass, but all in all, I really like Haskell. However, at some point, I noticed the performance issues; Haskell is pretty slow -- slower than some scripting languages, like Ruby, for a lot of tasks.

      So then I looked at OCaml, because OCaml has a reputation for being fast, and it is also a functional programming language that compiles to native executables.

      I have to say, my first (and lasting) impression was: WTF? Look at this:

      1 + 1 (* Add two ints *)
      1. +. 1. (* Add two floats. WTF? Why?
      Is the compiler so stupid that it
      can't recognise floats? *)
      1 + 1.0 (* Error! *)
      1 +. 1.0 (* Error! *)
      let f x y = x + y (* Define a function *)
      let rec f x y = f (x-1) y (* Define a recursive
      function. Again, why? *)

      Why do I have to *tell* the compiler that the function is recursive? The compiler is able to do inferrence type checking; why can't it tell that a function is going to recurse? In fact, why is there "let" anyway? Seriously, the compiler should be able to figure these things out. Haskell's compilers do. And did they decide to end lines with two semi-colons just to add keystrokes? Why? Why? Why?

      The simple fact is that Ocaml requires the programmer to do a lot of the compiler's work for it. I find this to be the most annoying feature of any programming language. Ocaml gets rid of some stupidities, like variable type declarations, but it adds all of this other stupid syntactic cruft that shouldn't be necessary.

      OCaml is popular. It is efficient (lines of code), and it creates fast executables (second only to C). There are a lot of reasons to love it, and I feel obligated to learn it, but I'm having a hard time getting over what superficially appear to be poor language design decisions. So, is there a good reason for the extra syntactic oddness in OCaml, or is it just there because it always has been?

    6. Re:From an ocaml convert: by rsidd · · Score: 2, Informative
      Actually, the infix operators + and +. are themselves syntactic sugar for the prefix operators ( + ) and ( +. ). (Try it.) As for why different operators are needed for floats and ints, it's to make type inference easier for the compiler, I think. In an expression like "let triple x = 3 * x", you don't have to tell the compiler the type of x or triple: it assumes both are ints. If you instead use a float, you get a compile error; if you want floats, you have to write the expression differently. The nice thing is that once you get rid of all these compile warnings/errors, the program usually runs correctly first time.

      As to the double semicolon, it's because the single semicolon is a statement separator (like in other languages, except you don't use it often in ocaml), while the double semicolon is a function terminator. You don't need the double semicolon all that much: using the interactive toploop, you may need it once in a large block (basically to let the toploop know you're done), and when compiling from a file, often even that can be omitted (for example, if the next statement is a "let"). So you could write rather large programs without any double semicolons.

    7. Re:From an ocaml convert: by Rubidium · · Score: 2, Informative

      The use of + versus +. is necessary in OCaml so that the compiler knows what types to properly infer in an expression. Otherwise, if there are nothing else that provides fixed types in the expression which could help limit the types of other parameters and the result of the expression, then explicit types have to be used to force types to those wanted, which is a major problem in SML, which doesn't use + versus +.

      As for the use of let versus let rec, this is necessary as the two scope differently. With let the scope in the function or binding is that before it, whereas with let rec the scope in the function or binding includes the new function or binding. You imply above that let should always have let rec semantics, but this would have the problem that functions could not use previous functions of the same name, and bindings could not refer to previous bindings of the same name, as they would already have themselves in their own scope, which would mask any previous functions or bindings of the same name.

  15. My dear lord, by dotz · · Score: 5, Insightful
    If you want to choose your scripting language by measures like "Program Lengths by Language", "the smallest running program", "access environment variable", "grep with -F -i -h handling, usage, grep'ing many files", then yes, go for it, that report was done for you.

    Me? I'd rather choose my scripting *and* programming language by some other measures, which mainly involve:

    • portability
    • object model
    • ease of writing C/asm extensions (for speed!)
    • extension modules available in default installation
    I have my own choice (not the winner, it's my *choice* - I haven't compared and/or used other ones mentioned too extensivley). I have as portable interpreter, as Java (except it does work, not only claims that), with much smaller footprint; I can code extensions in C using simple syntax (it's very easy); I have already thousands of available modules in the base installation.

    I am pretty sure, that other tools, mentioned in the report, also allow pretty much the same, some of them do that better, some of them are worse, some are not worth using (as we seen, network stack can be written in PHP) - that's not the point. In my opinion, that report seems like comparing pneumatic hammers, ordinary hammers, sledgehammers and hamsters (mainly because "hammer" sounds similar to "hamster", so what the heck, let's compare them) - by something like color or shape, not by the things they can do.

    You shouldn't compare tools like this (well, except for purely academical purposes), it's not useful at all for me. And, if you want to choose your tools basing on such reports, well then, good luck.

  16. Being small is overrated by smallpaul · · Score: 4, Insightful

    if I have to write a script, I have to write it fast, it has to be small (less typing), it should allow me to either debug itself via a debugger or just verbose output mode.

    A big part of being a scripting language is being quick to code. But it seldom happens that you can tell how quick it was to code by how many characters it was. For instance for some tasks (even some scripting tasks), IDEs can help you go faster. Proper, clear error messages and exceptions can help you go faster. etc. The scriptometer didn't measure time to code at all, even though it is much more important than what they actually do measure.

    Also, the definition of "scripting" is totally biased towards sh-based languages. Which language is best for driving a GUI word processor? Which one is best at scraping data from a web site or web service? Which one can tweak an XML configuration file? Which one can transcode from UTF-16 to UTF-8 quickly? Scripting is not just about files and regex filters.

    Of course I probably wouldn't bother to post if my favourite language had won...

    1. Re:Being small is overrated by fireboy1919 · · Score: 2, Insightful

      Another thing along those lines is what you get to use from other people. If you can use other peoples code, you don't have to worry about your own.

      This is where perl is a big winner over everything else. Nothing else even comes close as far as number of available packages.

      I think one of my old professors said it best:
      "Nobody likes to write in perl, but it gets the job done."

      I'm all geared up to make python and ruby my top picks just as soon as they have something like CPAN I can take code from, or until I start doing stuff that doesn't benefit from other people's code.

      --
      Mod me down and I will become more powerful than you can possibly imagine!
  17. MS Conspiracy against Sun/Java by vijaya_chandra · · Score: 2, Insightful

    The article says the smallest java program is 68 chars long just to make it seem double that of C#
    public class smallest { public static void main(String[] args) { } }

    But this would be the smallest Java program. only 56 chars

    public class A{public static void main(String[] args){}}


    (Karma be damned; I am no better than an AC anyway)

  18. I used to think Python was great for _everything_ by krumms · · Score: 2, Informative

    But it really does depend. I'd use Perl over Python for web development any day of the week (exception: Zope seems pretty cool, but I've not fooled with it enough. The 'everything is an object' metaphor is heaps cool though :)). Perl is faster to write and more expressive, Python is easier to read and - IMHO - often better structured.

    PHP is great for hacking web stuff together, but ... yeah ... the language itself seems a little hacked together - PHP5 fixes a lot of things, mind you so my opinion might change in a few months time after I've used it a little more.

    It worries me that a "feature complete" version of PHP instantly becomes a release candidate, rather than stewing in Beta for a while.

  19. pulling a Tcl boner by Anonymous Coward · · Score: 4, Informative
    His Tcl example is not written fairly. The dude should know that that Tcl supports getopts:

    package require GetOpts 1.1

  20. No PHP? by Anonymous Coward · · Score: 3, Informative

    I don't see PHP listed. It's possition on the list is arguable, but it certainly belongs there.

  21. You're right... by rsilvergun · · Score: 2, Funny

    ...I mean, look at all those clear, concise Brainf**k programs out there.

    Seriously, there's something to be said about a programing language that forces good practices (read: python). I indent and comment my code pretty well/consistantly, but a lot of people don't. And while I don't program professionally, I could certainly empathize with people who do debugging Perl code.

    --
    Hi! I make Firefox Plug-ins. Check 'em out @ https://addons.mozilla.org/en-US/firefox/addon/youtube-mp3-podcaster/
    1. Re:You're right... by rsilvergun · · Score: 2, Funny

      Because then I've got to take over maintaining their code.

      --
      Hi! I make Firefox Plug-ins. Check 'em out @ https://addons.mozilla.org/en-US/firefox/addon/youtube-mp3-podcaster/
  22. Why I like perl by Anonymous Coward · · Score: 5, Insightful

    I'm going to stick my neck out and say I like Perl -- so I think this is good news. However, I've always thought of Perl as a text-processing language, and In My Limited Experience, mobile phones can only fit about ten words on the screen. {on the other hand, this could simply lead to phones with bigger screens.}

    There's no denying that you can write really ugly code in Perl, but you can also write beautiul code in Perl. I think some of the people who knock Perl are confusing "undisciplined" with "not anal retentive". Perl was always based around the idea of serving the end rather than the means -- it's about where you're at, rather than how you got there. It does not impose a particular style on the programmer. Thus, for any given task, there could be many, many ways to accomplish it in Perl.

    They're all right.

    Some will be faster than others, some will use fewer resources than others, some will look prettier then others when viewed as source. But if you don't care enough about those things to mention them in the design spec, then they don't matter.

    Now, you can have your fancy object-oriented stuff, but in many ways it's overkill. For instance, if you needed to write a programme involving geometry, you could create an Angle object which would have a value assumed to be in radians and properties for its sine, cosine, tangent and representation in degrees; a Distance object which would have properties for its representation in different measuring units; and assigning a value to any property would affect the object and therefore its other properties. It might be beautiful if you like the OO concept, but it's a bit overkill if you just want to find the missing side of a triangle.

    And does a "disposable" programme -- one that you will run only a few times before forgetting it forever -- really need to look pretty anyway?

    As for PHP, well, it really isn't much different from Perl -- apart from always needing to put brackets around function parameters, the fact that all variables start with a $ sign whether scalar, array or hash and there is no $_. {I happen to love $_. It goes nicely with the concept of an accumulator. If you never did any assembly language, you probably won't know what I'm talking about, though}. That is hardly surprising, because the original PHP was actually written in Perl to be like a kind of subset of Perl.

    Also, one of my little niggles -- and I freely admit that this is just my own opinion -- is the inability to get on with any language that uses the plus sign as the string concatenation operator while letting you freely mix string and numberic variables. {*cough* ruby *cough*} I expect "2" + 2 to equal 4, not 22. Hell, if I have to do something to my variables before I can add them, that just nullified the advantage of having freely-mixable scalar types! It might as well be a strict-typed language and barf on an expression such as "2" + 2!

    As for Python - well, it's not my cup of tea {I guess you like either Perl or Python} but other people seem to have written some pretty good stuff in it, so I shan't knock it.

    1. Re:Why I like perl by davegaramond · · Score: 4, Informative

      Before you cough on Ruby and said "2" + 2 in Ruby will equal 4, have you even tried it? Ruby (and Python) are _strongly-typed_ languages, unlike Perl (and PHP) which are weakly-typed. Ruby protects you from mixing string and numbers in operations like +. You'll have to say "2".to_i + 2.

      And having used all four of those for projects large and small, I can say with confidence that I prefer strongly typed language. Weakly typed language is more dangerous and error-prone.

    2. Re:Why I like perl by JamesKPolk · · Score: 2, Informative

      irb(main):001:0> 2 + "2" TypeError: String can't be coerced into Fixnum from (irb):1:in `+' from (irb):1

  23. Wow that's one wacky grading system. by Retric · · Score: 2, Insightful

    under Tools:
    compilation and execution in one command (20 points) vs
    debugger (5 points)

    Ok, mabe it's just me but the author finds it 4x more important to be able to compile and execute the comand than having a debugger of some sort I mean wow if it's that important maby he should write some sort of script to handle that for him.

    And wow that's a lot of TD's out there maby under Program Lengths by Language. Then again maby when we find somone who can figure out that the "ease of converting between numbers and strings" is less important than say noticing that your string doe not contain a number. "10l0" is realy the same as "RED" so who cares right.

    PS: If you want to compare scripting lanuages try writing somethign that does a grep search for "GET A CLUE" with files of the format USEFULL*INFO## and then sort's the output by the number of ocurances of "FuncoLand" instead of writing hello world is as few chariters as posible.

  24. Read essays by Paul Graham by linuxbaby · · Score: 4, Informative
    Anyone interested in the benefits of different programming languages should read some of the great well-thought-out essays by Paul Graham:
  25. I put Ruby in my resume by Estanislao+Mart�nez · · Score: 2, Informative

    And it made a good impression in one of my job applications, where the contact person knows it pretty well. It won't impress most people, sure, but (a) people who don't know Ruby will understand that means you could do Python, PHP or Perl; (b) people who do know Ruby will think better of you.

  26. These guys aren't fluent in Java... by arch_helmet · · Score: 2, Insightful
    ...Coz you can do this:
    public class A{
    static{
    System.out.println("Hello world");
    System.exit(0);
    }
    }
    (How come <ecode> doesn't preserve whitespace?!)

    ...Which is 95 chars including whitespace and Win$ EOLs.

    Not that it makes any difference, Java was never gonna do well and is totally inappropriate for scripting, but there ya go.

    --Tim
  27. There's a deeper problem by Estanislao+Mart�nez · · Score: 3, Insightful

    Measuring program size in bytes is stupid. Lines of code, though still rife with problems, is a much better measure.

  28. It's not the language it's the library. by killjoe · · Score: 4, Insightful

    You know what language does not matter. I can write a preforking server in perl in one line of code. How? Because somebody else has already done it for me, documented the code, posted in a central library that's available for everybody and is searchable. Not only that I can type "perl -MCPAN -e shell" and "install Whatever::Whatnot" and have it in under 5 minutes. Try that with python, ruby, ocaml or java.

    Maybe python is easier to read, maybe ruby is more object oriented, maybe ocaml is faster, maybe lisp is better then all of them, but I don't care. When I want to get something done I can always get it done faster in perl and it's all because of CPAN.

    Until another language offers what CPAN does I don't care that much about it.

    --
    evil is as evil does
    1. Re:It's not the language it's the library. by OmniVector · · Score: 4, Insightful

      if that were true, all us linux and mac users should just go ahead and switch to windows. i mean after all it has the largest user based, the greatest number of software titles, the most support, and the most development libraries.

      sometimes we prefer to use languages because they are actually easy to code in and read. neither of which perl is good at. and for that reason, it will forever be off my list of languages to consider.

      --
      - tristan
    2. Re:It's not the language it's the library. by killjoe · · Score: 4, Insightful

      "That doesn't go for scripting languages (as far as I'm concerned), which I don't generally feel are appropriate for large projects."

      The topic was about scripting languages.

      "There is nothing magic about perl that makes this work."

      I used to think that too but I have changed my mind. If there was nothing magical about perl then all languages would have a centralized library of objects and a easy way to download and install them (including dependency resolving). I agree with you that all languages should have this none of them do and there must be a reason for it.

      For example. Python and ruby are both MoreObjectOriented then perl. They both have large and active communities. They both have extremely smart and dedicated communities and yet neither one has the equavalent of CPAN. Ruby has an archive at least and python has a half assed repository but all of it poorly documented and can't be installed without manual downloading.

      There must be something magical about perl. Don't know what it is but if it was otherwise all other languages would have done it by now. Think about it. This kind of thing is Ideal for java right? It has objects, beans, EJBs etc. Where is big searchable repository of java beans I can download and deploy in under a minute?

      --
      evil is as evil does
    3. Re:It's not the language it's the library. by killjoe · · Score: 2, Informative

      It's apparent by now you haven't used perl or CPAN. If you had you would know how much jakarta and CPAN differ.

      You seem to confuse a build system like Maven and a package installer system like CPAN. CPAN is more like apt-get and maven is more like make on steroids.

      --
      evil is as evil does
    4. Re:It's not the language it's the library. by drgnvale · · Score: 3, Informative
      Until another language offers what CPAN does I don't care that much about it

      I know it probably doesn't matter to most of you, but even lisp has something like CPAN. Its called ASDF, and there is a library called ASDF-Install. Of course common lisp lacks the huge number of libraries that more popular languages have, but (I have to admit) its getting better (getting better all the time).

      ASDF on cliki

    5. Re:It's not the language it's the library. by SewersOfRivendell · · Score: 2, Informative
      For example. Python and ruby are both MoreObjectOriented then perl. They both have large and active communities. They both have extremely smart and dedicated communities and yet neither one has the equavalent of CPAN. Ruby has an archive at least and python has a half assed repository but all of it poorly documented and can't be installed without manual downloading.

      The answer is that perl came first. Building sophisticated infrastructure like CPAN takes time, and requires a certain critical mass of contributing developers to be effective and useful. As it happens, the Ruby folks are rapidly building a solution of their own devising, already quite usable.

    6. Re:It's not the language it's the library. by rffrff · · Score: 2, Informative

      You're right about docs and the fact that CPAN is more mature.

      You're wrong about the large library: what do you really need and could not find in ruby or python? Ask for it and probably you'll find that it exists.

      db access, pdf/xsl/OOo docs/svg creation, numerical stuff, GUI stuff, ssh/ssl/tsl stuff, smtp/imap/pop/nntp, web libs/templating, csv handling, xml/xsl/Schema/Relax-ng,YAML, SOAP,xmlrpc, Linda/tuplespace/remote objects access, TestUnit, optparse/getopt/GO::Declare.. I really don't have need for something else.

      And ruby has a way to install stuff automatically, it's called rubygems, and it interacts with rubyforge.org. It's a young project, but it's fully functional.

  29. Re:vbscript by TastyWords · · Score: 2, Interesting

    There are a couple of reasons for this. One is that Microsoft squashed NN through a number of maneuvers and sort of knocked it out of first place, right or wrong.
    Second, when the web needed to grow wings and move beyond static HTML and client-side code started coming into play, you ended up with EMCAScript. Netscape owned the keys. Netscape and Microsoft weren't able to come to terms, so Microsoft reverse-engineered it (why can't we do that with their code?) and put it into play with their browsers. That kept them on par with NN. Next, they needed to find something a little less "C-like" for the non-programmers who were HTML-literate to jump to server-side scripted pages. Visual Basic is easy. Let's castrate it a bit and mold it into a scripted language. That stays in their VB-like world. Granted, they support server-side JScript (a better term than JavaScript as they aren't really running JavaScript), PERLScript (why do people not spell it like an acronym any more?), PHP, and practically anything else which has been ported to run under IIS.

  30. I heard someone is looking for Ruby? :-) by rolling_bits · · Score: 5, Informative

    Check out my site for some Ruby GUI stuff:
    (the gotcha is it's mostly in Portuguese. So jump to the "Exemplos Meus" (My Examples) section. Or use babelfish: http://babelfish.altavista.com)
    http://geocities.com/canalruby

    Hey, web stuff is easy with Ruby as well. But I don't have such examples for you. You have to get a taste of Ruby to find about its web capabilities. I Know IOWA has an example:
    http://enigo.com/projects/iowa/index.html

    Further enlightening at:
    http://www.ruby-doc.com
    http://www.rubyforge.org
    http://raa.ruby-lang.org

    You know, once you get addicted, there is no going back! :-)

  31. Re:vbscript by chromatic · · Score: 5, Informative
    PERLScript (why do people not spell it like an acronym any more?)

    It never was an acronym. See an explanation of Perl's name for an explanation of the backronym.

  32. Which Language? by TastyWords · · Score: 4, Insightful

    I've collected a paycheck, one way or another, in almost twenty-five languages (in almost as many years) - the ability to learn new things quickly comes in handy when it comes when someone's got obscure code which needs to be rewritten, fixed, or updated.

    Big Tip: It's not the language. It's the coder. If you know several languages and can apply the best one for a particular language, it's that much easier. If a language is best-suited for libraries, use it for libraries, then use other languages which are better for GUIs to do that and call the libraries as needed. 95% of the people in the industry really don't belong in the industry and their code basically sucks when you get a good look at it. The problem is people like it and think they're good at it. Because there are so many requests and so few people who can fill the slots, no filtering is really needed compared to what should be done. It may appear things are better now than they were twenty years ago, but the bottom line isn't all that different.

    The truly sad part is if you grabbed a large quantity of people who code for a living and put them in a room and said, "All of the good coders go to this side and all of the bad ones go to that side." Which side do you think all of them will go to?

    "You don't have to be good, just good enough." (and that's not good enough)

    1. Re:Which Language? by dmaxwell · · Score: 2, Interesting

      I'd just go to the bad side and be done with it. I've coded some small things in php because we needed them and weren't going to get them any other way. I pretty much learned what html and SQL I know at the same time. I have no trouble admitting this because I'm an admin who occaisionally codes rather than the other way around.

      I've tried to avoid pulling obvious boners but I'm glad none of the machines running these things are exposed to the public net.

  33. Just hired a Ruby programmer by CatGrep · · Score: 4, Informative

    now lets say i put Ruby on my resume....how much respect will that get?

    I just hired my replacement for a contract I was doing (I accepted another offer that was more in line with my field). One of the requirements was that the person hired would have to know Ruby because much of the code base was in Ruby. They hired someone from our local Ruby User's Group.

    So to answer your question: for this particular job if you didn't have Ruby on your resume it wouldn't get a second look. If you had Ruby on your resume, but it became apparent in the interview that you didn't know Ruby... well, the interview was over.

  34. It's what works that counts by rfc1394 · · Score: 4, Insightful
    Every programming languages has its strengths and its weaknesses. PHP is just another (interpreted) version of the C language which is why it's popular (and because it has a module which can be statically linked into Apache.) I presume Perl is popular because it provides fairly complex pattern matching. And there are other scripting languages out there. People will use what they know and what is available to them.

    Every job has its requirements; being a good programmer is being able to use the tools you have to solve the problem in a way that fits the requirements. Being a great programmer is knowing which tool is right for the job - and which isn't - and when they may have to look for something else.

    --
    The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
  35. Learning how CPUs work by SSpade · · Score: 4, Informative

    Forth? No.

    Learning forth will help you learn reverse polish notation, one specific trick for building high-performance interpreted languages and a very lightweight, easily extensible and embeddable scripting language.

    It won't, though, teach you anything about computers work beyond the small amount you'll pick up by learning any new language. Including French.

    If you want to learn how computers work there are far better things to play with. Assembly language, obviously, whether it be a synthetic assembly language such as DLX or a real architecture. x86 isn't the most enlightening assembly language to start with (6502 is excellent, MIPS or for a really nice architecture, Alpha) but it'll run on your PC.

    Books. Patterson and Hennesey, Computer Organization and Design, The Hardware/Software Interface is pretty good for a programmers intro, but Hennesey and Patterson, Computer Architecture, A Quantative Approach will teach you a lot more, as will most texts with Superscalar in the title

    Learn a hardware description language. Verilog is better, but VHDL is OK. Compilers and simulators are freely available for both.

    Get an FPGA development kit. Compile yourself some hardware. You can put full CPUs on a fairly cheap FPGA development board.

    Design your own CPU. It's possible for an individual or a small group to design a CPU and have it fabricated as a tinychip. I've seen individuals design a full, if tiny, CPU at mask level in a couple of months, and a small group put together a fairly decent gate level design in a few more. Commonly done as part of a college course, but an individual can have a tinychip fabricated for around $1000. Not cheap, but cheaper than some hobbies.

    You can do full circuit level design and simulate it using either gate level or spice transistor level simulators and see just why addition or multiplication takes as long as it does.

    As a general rule I've found that some of the best software engineers have some hardware design background, and a good understanding of computer architecture, so even if you never plan to do any hardware design, understanding how it all works is a good idea.

    Of course, I've also found that a large fraction of good software engineers have also spent time working as theatre technicians, so who knows what the correlations are...

    1. Re:Learning how CPUs work by bwalzer · · Score: 3, Insightful
      The original poster said that learning Forth would help you understand how computers work, not just the CPU bit.

      Since doing stuff with the Forth environment involves lots of interaction with bits you tend to learn a whole lot about binary math/logic quickly. Since the virtual machine is understandably simple and different from traditional computer architectures you end up at a place to start thinking about computer architectures. Since Forth is a reasonably productive programming environment you learn that a lot of the stuff they teach you in Computer Science is probably wrong...

      You were talking about the "what" of computers. Exposure to non-traditional environments like Forth gives you a start on the "why" which is a hard thing to come by in the somewhat dogmatic world of computers.

  36. Not really a fair test. by Temporal · · Score: 5, Insightful

    First of all, a pure character-based size count seems unfair. I do not believe that the number of characters in a chunk of source code is directly correlated to the amount of time it takes to write. Most of a programmer's time is usually spent thinking, not typing, and you can thinking just as fast with verbose naming conventions as you can with terse ones, as long as the constructs are the same. And then, if the constructs are different, it's even harder to judge, because if the constructs in one language are more natural, corresponding closely to human thought patterns, then coding in that language will tend to be much faster than coding in more cryptic languages, even if the cryptic language requires fewer keypresses.

    For example, I tend to find that writing in functional languages is easier for me. My functional-language just tends to come out faster and contain far fewer bugs. I'm not entirely sure why, but I suspect it has something to do with the thought-pattern-correspondence idea I mentioned above.

    Second thought... some of these comparisons are clearly unfair. For example, one of the test cases is implementing "grep". The sh version of this case simply calls grep (after validating the arguments, I guess), which seems like a really big cop-out. Any language could just as easily run grep in a separate process. Meanwhile, the OCaml version seems to implement the main loop of grep manually in terms of library functions that are not identical to grep. That is to say, the main thing the OCaml code is doing is translating grep-specific options and semantics to the options and semantics used by its own library functions. To make this comparison fair, one would have to write a library function in OCaml which is identical to grep, then allow that function to be called without counting the library as part of its code.

    I think the only fair and useful way to make comparisons like this would be to hold a contest of some sort. Get an expect Perl programmer, an expert Python programmer, etc., together, then give them a program of some sort to implement. Avoid defining the program to be too similar to one language's library calls. In the end, judge the languages both on how fast the contestant completed the code and on how useful and robust the resulting code turns out to be.

    Probably not going to happen, of course.

  37. Now Java *smaller* than C# by vijaya_chandra · · Score: 3, Interesting

    This is cheating; nevertheless it compiles and runs with sun jdk without any problems

    class A{static{System.exit(0);}}

    Only 32 chars. yay!!

  38. Rapid Development != Scripting by Vector7 · · Score: 5, Insightful

    > Interesting that ICFP contests lately pronounced OCaml as the winner for rapid development.

    Certainly that is interesting, but it has absolutely nothing to do with the subject of the article. "Rapid Development" (or development in general) is not comparable to scripting, and the ICFP contest tasks (which this year was to develop AI code governing ants in a colony) contrast sharply with the sort of scriping tasks in this shootout (compile a file if .o absent, invoke grep on some files, etc).

    [aside]

    This is not intended to rag on scripting or scripting languages, just to note that scripting embodies a largely distinct set of tasks from development in general (and a comparison involving OCaml or the ICFP contest is inappropriate). These sort of tasks that historically have been the domain of shell scripting, although perl seems to have taken over a lot of these things.

    As a lot of what perl is best at is simplifying things that you could almost do from the unix shell (or might be able to do with a script, but would be a pain in the ass..), it always struck me as logical that perl should evolve toward becoming a viable replacement for the unix shell.

    Sadly this doesn't seem to be on the agenda of the perl gods. Instead of evolving to better fill this niche, they seem to be gravitating toward becoming a sort of second-rate Java/Python immitator. I suspect that the underlying technologies they build with Parrot and the Perl 6 redesign will largely fail to convince many folks who aren't already perl users that perl is a useful substrate for developing real systems on top of. At the same time they will have neglected to improve in their original niche of quick and dirty sysadmin hacklets, while other languages will have continued to improve and build momentum.

    Then again, I'm quite possibly wrong. We'll see what happens. Should be interesting..

  39. Re:I used to think Python was great for _everythin by rpbailey1642 · · Score: 3, Funny

    Speaking of web stuff and perl, my (former) boss always said "Perl is great. In fact, if you smash your hands down on the keyboard, you're halfway to having a working web server." Not trolling here, attempting humor.

  40. Re:/Nick 1337h4x0r by Ray+Radlein · · Score: 2, Funny

    I never really thought about it before now, but damn, l337-speak can look like exceptionally grotty perl code when it wants to...

  41. So in summary, by NorthWoodsman · · Score: 4, Insightful

    Sh is the best at doing tasks common in Sh, whereas languages not designed for shell scripting do them less well than sh. Furthermore, languages that aren't even scripting languages are terrible at being sh.

    --
    1p}{ 1 sp34k |33+ +|-|e|\| p30p13 \/\/il| 8e i/\/\pr3553|)
  42. Ocaml isn't a scripting language either! by bhurt · · Score: 3, Insightful

    While it does moderately well on this test (finishing near the middle), you might be surprised at it's weak finish compared to it's reputation as a concise language. Well, as a committed Ocaml advocate, Ocaml isn't a scripting language. I freely admit that it has so-so string handling, no built-in regular expressions, so-so process handling, etc. But this is because it isn't a scripting language- it's an applications language, like C++, Java, and C#. And the only reason it does as well as it does is because it's a signifigantly better language than it's competition.

    If you're writting a quick script to grep through the log files looking for port scanners, Ocaml is the wrong language.

    Brian

  43. By features instead of by language by Tablizer · · Score: 5, Informative

    In a similar vain, I wrote up a scripting language comparison document, but focused more on features rather than particular languages. Comparison Link. I describe the various feature options, and then weigh the pro's and con's of each.

    After years of debating language features, I generally conclude that a lot of it is subjective. No language will ever satisfy everybody.

  44. Re:Isn't that an ill-formed regexp? by jwkane · · Score: 2, Informative

    .*? = snag all chars in non-greedy mode

  45. Re:VBscript seems great... by davegust · · Score: 3, Informative

    nothing in the OS was ever really meant to be scriptable

    That's not really true. Most OS functions are available through COM interfaces. VBScript and JScript interact with any COM interface through the Windows Scripting Host, either in a windowed enviornment (wscript) or a command line environment (cscript). You can manage users, files, ACLs, the registry, network configurations, IIS, application deployment (MSI), multimedia, services, etc. And's it's all done with a nice component paradigm of methods, collections, and properties. Those same COM interfaces are also available for application development to VB6 (native), C++ and .NET.

    We've had this COM environment for 10 years with Windows. In my opinion it's more powerful than the "everything's a pipe" approach.

  46. Ah. by Estanislao+Mart�nez · · Score: 3, Funny

    So perl regexps are cryptic and hard to read even if you know regexps already. Thank you.

  47. You're missing the point. by Estanislao+Mart�nez · · Score: 4, Insightful

    The measure that the comparison is applying is the size of the source code in bytes. If we're talking about the size of the executable, (e.g. bytecode in Java, C# or Python), bytes is the natural measure.

  48. Java? What about Groovy? by SuperKendall · · Score: 2, Interesting

    WHy compare with Java when there is Groovy, the JVM scripting language?

    Here's a simple sample script:

    #!/usr/bin/env groovy
    println("Hello world")
    for (a in this.args) {
    println("Argument: " + a)
    }

    Note that you can run this from a command line, no compiling required.

    Groovy is not just some random basement project either, it's actually a JSR and so will probably become a standard before too long.

    If you want a C3 equivilent, I'm sure some well-meaning but mistaken soul will copy this project as they have tried to do with every other Java project. "C# - only a year behind Java since 2003!".

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  49. Java as a scripting language by _pruegel_ · · Score: 2, Informative

    The BeanShell lets you use pure Java as a scripting language and it's almost trivial to include the BeanShell in your Java application.
    See http://www.beanshell.org/.

  50. Re:vbscript by Yath · · Score: 3, Informative

    You may not be aware of this, but the article you linked to is a copy of this one. In the interest of giving credit where it's due, you might want to give Wikipedia more exposure in the future.

    --
    I always mod up spelling trolls.
  51. Point being? by warrax_666 · · Score: 2, Insightful

    What's your point? The program is shorter shorter when written in sh, more natural and more readable. (Not to mention that it uses lazy evaluation, so that the full input doesn't need to be in memory, just the full list of words).

    --
    HAND.
  52. Re:You're missing the point. (not again) by MoonChildCY · · Score: 4, Informative

    If you bothered to read the article...

    The lines of code needed to achieve a task are measured, as they serve as an indicator on how fast one can create a script.

    If you need 20 lines of C# to check if a file exists, but only one in Perl, then according to the study, Perl should receive a better weighted score for ease of implementation.

    Read the articles people! They are interesting (at least most of the time).

  53. Practical? Bah, humbug. (Pythonic bias warning.) by AlexLibman · · Score: 2, Insightful

    As much as I love programming language comparo's, this one just doesn't hit the spot. Do people actually think a scripting language should only be used for tiny write-only stand-alone scripts? TOOLS: If this section was meant to cover the tools / features that enhance the versatility and convenience of a language, it isn't complete. What about machine code compiler availability / VM support, Web options (CGI, Apache plug-in, Server Pages, etc), editor / IDE support, profiling, RAD features like unit testing, and docstrings, multiplatform support for threading and other features that immature languages might leave POSIX-centered, etc? License openness and multiplatform range should also be considered. And why is shebang awareness, working without which would just require one extra word on the command line, three times more important than an interactive interpreter, debugger, or passing program in command line, which open up some serious time-saving habits. SPEED: Unlike compiled / system programming languages, interpreted speed isn't the most important feature of a higher-level / scripting language. For most tasks on a modern computer, development time is infinitely more precious than execution time. Algorithms matter more than the overhead language speed. For example, since many scripts spend much of their time waiting for file I/O, network response, or user input, a Perl programmer who understands multithreading might end up writing faster apps than a C programmer who doesn't. Another important point is how a language fits into a large modular system. For example, Tcl is easier to embed / extend with C than many of the languages compared, so the real-world apps that are implemented in a combination of C/C++ and Tcl can be optimized as much as is needed. Python has superior profiling, JIT machine code compilation, and VM (IronPython, Jython) implementation than most / all of those scripting languages. Final speed note: the Python version 2.2 used in those benchmarks is ~30% slower than the latest version. L.O.C. COUNT: Program briefness shouldn't be the only measurement of sample code: productivity and readability are each at least equally as important. Like, even though Perl is more compact, I'd bet those sample Python scripts would take less time programmers to write, and far less time to read for a non-Perl-centered programmer. The benchmark should also define a common policy for abbreviation-vs-readability in sample code: many of those examples could be made briefer or more readable regardless of the language. The comparison was missing a number of essential sections: LANGUAGE QUALITIES: how the fundamental language features impact its abilities as a scripting language. This would include language agility, dynamic typing system, garbage collection, high-level non-scalar objects (arrays, hashes, tables, relational features, etc), OO / multi-paradigm abilities, etc. How easy is the language to learn? (Will your non-programmer users be able to make trivial changes themselves?) Does it have any unavoidable annoyances (ex. as much as I love Python's use of whitespace, lack of an alternative block syntax would be a minus here). SCALABILITY: Can it be used for very large applications? Does it break if running more than X instances / threads / CGI hits / etc at the same time? Does it break when asked to allocate 20 gigs of memory for some fancy chemistry simulation with lots of large numbers? AVAILABILITY: How frequently is a language available on a typical shared Web host? How many add-on packages / libraries are available? Does it have any gaps in its library offerings: well-rounded RDBMS support, GUI, regex, multithreading, etc. How easy is it to find related published books, online tutorials / references, and community help? Is there a quality-assured version (like ActiveState), without which a language may not be usable in some commercial situations? Are there many popular / killer-app projects that use the language (ex. Zope). Finally, the comparison was missing PHP, which has full

  54. Hello, 'Best tool...'? by soccerisgod · · Score: 2, Insightful

    What ever happened to the engineer's motto "The right tool for the right job"? I'm not a scripts person, but indubitably, all scripting languages have their specific advantages for specific applications. Imho, this whole thing is made for trolling and flaiming and not for anything else. It's just stupid.

    --
    If a train station is a place where a train stops, what's a workstation?
  55. someone's already done it by Fourier · · Score: 2, Informative

    I searched around a bit, and found that someone's already done it. It uses the PCRE library along with a camlp4 macro that provides an elegant "match ____ with" construct tailored specifically to regexps. I'm impressed.

  56. From a pragmatic point of view... by Not_Wiggins · · Score: 2, Insightful

    the "correct" answer is easy: the one you know best.

    Unless you have other considerations like maintainability, reuse by coworkers, etc. But those considerations are external to any language you might choose.

    --
    Diplomacy is the art of saying, "Nice doggie!" until you can find a rock.
  57. Speed of development! by ultrabot · · Score: 2, Interesting

    Measuring program size in bytes is stupid. Lines of code, though still rife with problems, is a much better measure.

    Where program size counts in a scripting language is the time taken to write the program. As someone said recently, "typing is cheap, thinking is expensive". For me it requires 0 seconds of thought and 0.8 seconds of typing to write "import os" in Python if I use something from the os module.

    Likewise, using things like regexps from a library necessarily implies some typing (function re.search instead of m//), it doesn't require any thought so the path chosen doesn't impact production time. It does impact the readability which counts too.

    I think the referenced "shootout" was a poor idea. Measure things that don't matter, and pretend that they do. A better idea was what was done a while back - measure the size of gzipped source code, which measures the semantic complexity of the code . Python kicked other languages' arses there.

    --
    Save your wrists today - switch to Dvorak
  58. Ocaml with the backstepping debugger by dan_sylveste · · Score: 2, Interesting

    I love the debugger of ocaml. You can backstep, you UNDO the execution of the previous 1, 10, 100, 1000, ... steps. Wonderful if you like me fill the code with asserts. If an assert occurs, just run in the debugger, then backstep until you know why the unthinkable happened and then you fix the bug.

  59. Re:write it fast... by joib · · Score: 2, Interesting

    In a sense you're right in that readability is more important than saving as many charachters as possible when typing. Code is typically read a lot more than written, so readability and hence maintainability are certainly very important.

    However, verbosity can also hurt readability. If the syntax contains too much clutter, you have to concentrate on understanding what all the clutter does, and thus you can't focus as much on what the code is actually supposed to do.

    As an example, take the typical scripting task of reading a text file line by line, and do something with the line. Code in python is like:

    for line in file("filename"):
    do_something(line)

    Compare this with the abomination that is file i/o manipulation in Java.

  60. *My* "practical survey" for scripting languages by ExoticMandibles · · Score: 2, Interesting
    Does the name of the scripting language contain the letters 'P', 'y', 't', 'h', 'o', and 'g', in that order? Score one point for every correct letter. Perl gets 1 point--oh, too bad! Python, with 5 points out of 6, is our highest-scoring language.

    Personally I think that's a better metric than the author's simple-minded "the program in this language was eight characters shorter so it gets a higher score". This was apparently an attempt to measure the expressive power of a language, but done in such a way as to ensure Perl scored well.


    I think there are more important things to keep in mind when selecting a scripting language, like

    • how easy is it to learn?
    • how easy is it to remember how to use everything?
    • how easy is it to read other people's programs
    • how easy is it to read your own code six months from now?
    On these counts Perl loses big time. Its "every combination of punctuation characters does something" language design saves you typing, at the expense of pretty much everything else.

    If the only thing you use the scripting language for was one-off half-page scripts that you use once then throw away, and you wrote those eight hours a day five days a week, then I could see using Perl. For any other purpose I think you're better off using something else. (And, yes, I have a suggestion in mind, and it rhymes with Crython.)


    larry

    p.s. I have a nomination for a shorter Python program to remove #-characters from a file:

    import sys
    system ("sed -i -e \"s/#.*//\" " + sys.argv[1])
    After all, it is precisely as "legal" for the Python program to call sed as it is for the sh program to call sed.
  61. Silly Java mistakes by Decaff · · Score: 5, Interesting

    There are some silly mistakes in this article, suggesting that the author does not really understand the languages he is comparing.

    Here are some examples:

    for 'return exit code error (non zero) if a file does not exist' and 'return exit code error (non zero) if a file is not readable. There is no Java or C# code supplied. Java can easily test this: for example

    new File(filePath).canRead();

    and

    new File(filePath).exists();

    and I'm sure C# can as well.

    There are other omissions:
    Under Java 1.5, the System.getenv() method allows access to environment variables.

    Also, saying Java is completely unusable in a scripting environment is nonsense. The BeanShell system has been around for years, and allows java to be run as if it were a scripting language, both from a command prompt or from script files. Java 'scriptlets' on JSP web pages are very common. Finally, there is a PHP/Java interface.

    I don't know C# well, but I'm sure there are similar facilities for that language.

  62. TCL Got shortchanged by EvilTwinSkippy · · Score: 3, Informative
    I was reading through the criteria, and TCL was docked points for not being able to pass commands through the command line and not having a debugger.

    Both are untrue. TCL will happily take command line arguments, and if you set the execute bit under unix, will happily act as programs. If by "programs can be passed over the command line" that he wants to bang out to the shell, there is the exec command. Of course in his hello world program he uses BOTH features.

    TCL gives you a complete stack dump on every error that is stored in a global variable "lastError", and you can override the background error with the bgError command. That also covers the "FullInterpreter in Debugger". The language was designed AS a debugger to C programs for christ's sake.

    All told that cost TCL 15 points.

    Sure I'm quibbling, but if you aren't going to compentantly seek out features save in all your favorites, you look like an idiot putting these comparisons together.

    (Disclosure: TCL Guru.)

    --
    "Learning is not compulsory... neither is survival."
    --Dr.W.Edwards Deming
  63. They wanted Perl to 'win'. by Qbertino · · Score: 3, Insightful

    What a silly way to try and display 'objectiveness'.
    I get the strong feeling some Perl freaks were involved in the evaluation tables design.

    Where's readability?

    Could it be that readability contradicts with 'programm shortness'?
    Ever tried to read through the shortest possible Perl solution to a problem? Exchange shortness for readability and Python will porbably 'win' hands down.

    And what silly dork drew the line between 'scripting languages' and 'programm languages' ?? With 'Java not being a scripting language' and Python, Perl and Ruby being one. Whatever that's supposed to mean.
    Why this evaluitation may be objective on some narrow areas, in a whole it's somewhat pointless. I can add some other criteria that will have TCL or bash win in no time.

    --
    We suffer more in our imagination than in reality. - Seneca
  64. Pure Shell Grep by Pan+T.+Hose · · Score: 2, Funny

    There's lots of other subtle biases. For example, in the "grep" example, the sh code simply called grep. If he wanted to be pure about the scripting he'd not have had any way of doing a RE in sh (since it doesn't have true RE handling builtin, it only has globs through 'case') and if he was going to use external calls then why didn't he just do 'exec grep "$@"' or otherwise afford the use of external command execution to the other languages too?

    OK, here it is:

    #!/bin/sh

    # 2004-06-13T12:33:55+0000

    # pth shgrep - a minimal shell grep implementation
    # Copyright (C) 2004 Pan Tarhei Hosé, PhD.
    # http://developers.slashdot.org/~Pan%20T.%20Hose/
    # http://developers.slashdot.org/comments.pl?sid=110 875&cid=9411049
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    [ a$1 == a ] && echo "Usage: $0 pattern < file" && exit 1
    while :; do read a || exit; [ "${a/$1/}" == "$a" ] || echo $a; done

    Just a quick hack I wrote right now in less than a minute, I am sure one could write it better. A quick test:

    pth@ws0:43:~/sh/shgrep$ ./shgrep arse < /usr/share/dict/words
    arsehole
    arseholes
    arsenal
    arsenals
    arsenate
    arsenic
    arsenide
    [...]

    Seems to work fine. Is it pure enough?

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  65. Re:Practical? Bah, humbug. (Pythonic bias warning. by Anonymous Coward · · Score: 2, Funny

    Youdon'treallyexpectsomeoneactuallyreadingthatpost ,doyou?

  66. Scripting is good by X-Nc · · Score: 2, Informative
    I was rather surprized at the results of the test. I knew perl would be on top. Whether it's best or not it will always be in the winners circle because it is the "tool of choice" even when it isn't the best tool for the job. ruby was nice to see up there. It's a really good language; kind of what you'd bet if perl and python had a baby. But the real shocker was that sh was picked. In any kind of "test" like this the Bourne shell should always be a run away winner. UNIX shell programing, with all the UNIX command line tools (awk, sed, grep, etc.) if the hands down best generic scripting option for simple to medium level, cross platform, portable scripts. Hell, that's what it was created for.

    One of the down sides to the advancement of the free "as in everything" OSs is that people are learning lots of perl and python and such but not learning shell. Whether you are a developer, sysadmin, user or tinkerer you should learn shell first and always add it to the list of tools to evaluate for any situation that comes up.

    --
    --
    If I actually could spell I'd have spelled it right in the first place.
  67. Re:PerlScript by hattmoward · · Score: 2, Interesting

    Nice to see a monk out here in the wilds! BTW, chromatic, did you look at the code for the Perl tests on the article? They're a little... weird. It looks like his shell took a pass at interpolating the command line before he pasted it into the page, or something.

    I suppose the fact that he includes "perl -le " at the start of so many "tests" isn't really fair either -- most of those interpreters support similar one-liner options, but they got away with just the program code. :\

  68. my gripe is the syntax by CoughDropAddict · · Score: 3, Interesting
    I've tried learning OCaml a few times, and my biggest gripe with it was the syntax. One problem was that it seemed like every time I managed to wrap my head around a new syntactic construct, the tutorial would say "since that's too long to write, we use this shorthand to mean the same thing." So now I have to learn a new construct that does the same thing but also try to remember how it relates to the longer version.

    Another problem is that there is very little punctuation that gives your eye any aid in seeing structure. Very often you get a bunch of keywords and identifiers in a row with no delimeters at all! A simple example of this from the tutorial:

    let cos2 = compose square cos;;

    Come on, cut me some slack! Is this compose(square(cos)) or (compose(square))(cos) or compose(square,cos)? I shouldn't have to think about precedence rules when I'm reading a function call, the syntax should make it clear what's going on! Another example:
    let rec member x btree =
    match btree with
    Empty -> false
    | Node(y, left, right) ->
    if x = y then true else
    if x < y then member x left else member x right;;
    Compare this with a Python-like syntax:
    let member(x, btree):
    match(btree):
    case Empty: False
    case Node(y, left, right):
    if(x = y): true
    elif (x < y): member(x, left)
    else: member(x, right)
    I don't know about you, but to me the second example is a lot more readable. Readability is about making your eye see the structure without even trying. That's one of the reasons I like Python so much: I think it excels at making the structure unavoidably apparent.

    Ocaml's definitely got some cool things going on, and I really respect the fact that smart people seem to gravitate towards it and get useful things done with it. If I ever learn it, I'm going to have to suck it up and deal with syntax I really don't like.
  69. Standard ML is nicer there by Estanislao+Mart�nez · · Score: 2, Informative

    $ sml
    Standard ML of New Jersey v110.42 [FLINT v1.5], October 16, 2002
    - 1 + 1; (* Add two ints *)
    val it = 2 : int
    - 1.0 + 1.0; (* Add two floats *)
    val it = 2.0 : real
    - 1 + 1.0; (* Error! *)
    stdIn:5.1-5.8 Error: operator and operand don't agree [literal]
    operator domain: int * int
    operand: int * real
    in expression:
    1 + 1.0
    uncaught exception Error
    raised at: ../compiler/TopLevel/interact/evalloop.sml:52.48-5 2.56
    ../compiler/TopLevel/interact/evalloop.sml:35.55

    - fun f x y = x + y; (* Define a function *)
    val f = fn : int -> int -> int
    - fun f x y = f (x-1) y; (* Define a recursive function *)
    val f = fn : int -> 'a -> 'b

  70. Re:Java's string manipulation is horrible by Decaff · · Score: 2, Informative

    Beanshell is not Java, so your point is moot..

    I would argue that this is not true. You can type in and execute Java code into the BeanShell prompt and it will execute interactively. BeanShell itself is written 100% in Java.

    You may say its not Java because its not a part of the standard Java APIs, but there are plenty of other scripting extensions to Java that are: Java scriptlets in JSP pages; the Java Standard Tag Library in JSP pages.

    I can complete most string manipulation tasks in Perl in 5 lines as compared to over 100 in Java.

    Yes, Perl is a very consise language that is superb for scripting. For string manipulation and many other tasks it's unbeatable.

    Java is simply not suitable in a scripting environment.

    That was not the point that was being made. The article said 'Java was completely unusable in a scripting environment'. This not true. Perhaps the most widely used example is JSP, the java equivalent to PHP and ASP. You can open up a JSP page, type in Java code, and have that page run immediately as part of a live web application. As with PHP you can add and edit pages containing code without shutting anything down. As far as the developer is concerned there is no compile-edit-run cycle. If that is not scripting, what is?

  71. NewLISP by Crusty+Oldman · · Score: 2, Interesting

    It's faster than bejeepers. I run it on my webhost as a scripting language.

    Simple, fast, elegant.
    http://www.newlisp.org/

  72. Re:I just had my first encounder with a C# program by sevinkey · · Score: 2, Interesting

    I've done both Microsoft coding from back in the day (Win32 API through COM and ASP) and Linux with perl, c, php... and both platforms with Java

    Recently I took a job with a company implementing Microsoft DRM, and selected C# for the new toolsets.

    It was a good choice for Microsoft technologies... basically they took the old Win32 API, and wrote wrapper classes to babysit their crappy code underneith (something I used to do in C++) and it works exceptionally well.

    And I ASP.Net WebMatrix is a good enough free tool to do effective development (if you don't mind command line compiles or just sticking with C# asp.net pages) if you don't want to spend the cash on VisualStudio.

  73. Beanshell: A Scripting Environment for Java by Quantum+Jim · · Score: 2, Interesting

    What about Beanshell! It is a scripting language for Java-based applications like jEdit. Beanshell will interpret ordinary java source files in addition to class files. You can even write a simple web browser in less than 74 lines of code! It surely should have been considered along if languages such as Pike, Lua, and Haskell were thought of.

    This entire analysis seems suspect. Take the first section. For JavaScript, their implementation uses NJS, which hasn't even stabilized with a 1.0 release yet! They also have a unix bias: many applications have no need of the shebang, #!. Even though, a script in another language could easily be written to implement that feature. Shebang support is a trivial and doesn't deserve the 15points awarded. Furthermore, awarding points for "program(s) can be passed on command line" is silly. That is a horrible horrible style of coding guaranteed to make scripts hard to maintain.

    Their second section is not complet and has a heavy bias against Java and C#. The subsections, "smallest" and "hello world," are silly. I never understood why having a small size for the simplest program is important for nontrivial applications. (For that matter, I never understood why programmers wish for the "least typing" in a language. I never never never code for least typing, since that often makes programs unreadable!) Finally, their coding style is inconsistent. For instance, they use for Java:

    public class formatting {
    public static void main(String[] args) {
    int a=1;
    int b=2;
    System.out.println("" + a + " + " + b + " = " + (a + b));
    }
    }

    Yet the authors throw these conventions out with JavaScript:

    a=1; b=2; System.print(a, " + ", b, " = ", a + b, "\n")

    (Also note that the numbers reported and counted don't match, but I may just be missing something.) Why? Java and C# seem destine to loose with the author's methods. As I said, this entire report seems biased and unscientific.

    P.S. /. needs to fix the site's source code white-space style. This is getting ridiculous.

    --
    It is impossible to enjoy idling thoroughly unless one has plenty of work to do.
    - Jerome Klapka Jerome
  74. sh will be always the winner with these rules! by mr3038 · · Score: 2, Interesting
    If we assume GNU tools like the test did, one could implement "find and compile .c files into .o when the .o is old or absent" as
    find -name "*.c" | sed 's/.c$/.o/;' | xargs echo all: | make -f-
    (this is because GNU make is smart enough to figure out how to make .o files out of .c files) and if you know find well enough (unlike I) you'd only need find. The only thing that is "sh" in this piece of code are the pipes.

    Perhaps the "sh" implementation could assume that there's a perl implementation with shebang in a file called "x" in the same directory and make every "sh script" as 'x "$@"'? That would be really effective scripting language! :-)

    --
    _________________________
    Spelling and grammar mistakes left as an exercise for the reader.
  75. Bashless systems? by Pan+T.+Hose · · Score: 2, Insightful

    That's bash code, not sh.

    The examples in the article use bash. They note that the implementation of sh that they use is bash.

    I overlooked that bit. But I didn't notice any bashisms in their code, and it's rather surprising how many bashless systems I've had to deploy existing scripts on (requiring some porting in many cases).

    This is hardly an argument against Bash--now is it? Even despite the obvious lack of omnipresence of Bash, I would bet it is still much more popular than Merd, Lua, OCalm or even Haskell which were also evaluated in the article.

    I have seen more perlless than bashless systems myself. I have seen lots of systems with Perl 4 (there are still new systems shipped with Perl 5.005 (sic!) today which is so 1998) but I would not consider using only Perl 4 syntax in the Scriptometer test because of that.

    Nevertheless, having done it myself too many times, I can perfectly understand your pain in porting shell scripts. As Larry Wall once said, "it's easier to port a shell than a shell script."

    Actually, I don't know of many systems to which Bash has not yet been ported. The systems with Bash I know of are GNU/Linux, FreeBSD, OpenBSD, NetBSD, BSD/OS, BeOS, Sun Solaris, IBM's AIX, SGI, HP-UX, Compaq's Tru64 Unix, Jaguar/MacOS X--just from the top of my head. I would consider it a very strong argument pro Bash.

    To be honest, I don't know what would you expect from a Bash script grepping text file in the linked article. Running an external grep is apparently not good enough even though running external programs is essentially what shells are supposed to do... Fair enough, so I have written a pure Bash script, which in turn is still not good enough since it is a Bash script... Well, I rest my case.

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  76. it's called "currying" or "partial application" by Estanislao+Mart�nez · · Score: 2
    Wow, what a strange way to evaluate functions that take more than one argument.

    You're thinking wrong about it-- conceptually, all functions take a single argument. Well, ok, you can get away with thinking of functions as having multiple arguments most of the time; but the point of the design is that you can apply functions partially:

    # let f x y = x + y;;
    val f : int -> int -> int = <fun>
    # let add1 = f 1;; (* equivalent to let add1 y = 1 + y *)
    val add1 : int -> int = <fun>
    # add1 3;;
    - : int = 4
    I guess that would partially explain why it isn't notated compose(square, cos), because although that's the net effect it isn't actually evaluated that way.

    A further confusion is that it's possible to write functions like this:

    # let g (x,y) = x + y;;
    val g : int * int -> int = <fun>
    # g (2,3);;
    - : int = 5
    The thing is that (2,3) is a single value-- a tuple of two ints (int * int)-- and g is a function from tuples of ints to ints. Tuples don't support partial evaluation like curried functions, but you can pattern match over their contents...
  77. If you know Chinese... by jotaeleemeese · · Score: 2, Insightful

    .... to read Chinese is a real fucking peace of sugary cake.

    Well, Duh!

    Perlmongers believe that everybody is fluent in Chinese.

    --
    IANAL but write like a drunk one.