Why Perl? Phillip Thorne Rev 0, 2000-03-06 Point one: programmers are lazy. They don't seek extra work if there's a simpler, faster, pre-existing way. If there isn't, they'll create it themselves, then re-use it later. Any facility in a language that encourages/assists this (libraries, functions, complex data types) is appreciated. Point two: they're anarchic. They don't enjoy being told how to perform a task, especially if they perceive the directive as less efficient/ideal than their own solution. It's possible to perform essentially any task in any language, but some are specialized. But how many hoops will you have to jump? A fundamental ability of most languages is to create subroutines (aka functions) that encapsulate some complex, oft-repeated task inside a simple shell. This encourages code re-use (you needn't type the same sequence of statements in multiple places) and maintainability (any changes are made in only one place). Most modern languages are hybrids, and/or have had portions of other flavors grafted on (with new releases). Fortran-77 is exclusively procedural. C is procedural, but its structs are rudimentary OO; C++ extended them and added features for full OO. Java looks like C++ but is OO from the ground up. Smalltalk, everything is an object. Javascript and VBscript aren't often used to create new objects, but more often to access/manipulate pre-existing arrays (such as the browser DOM). Javascript has some functional notes. SQL-89 is exclusively declarative, but -92 (???) added a few procedural control structures. Procedural languages use primitive data types (integers, decimals, characters) and process them with functions and intermediary variables. Object-oriented languages are procedural in character, but combine (encapsulate) primitives and functions into abstract data types (aka objects) that more adequately resemble the real-world entities they're modelling. Declarative languages (Prolog, SQL) describe what the results should look like, without bothering with flow-of-control. programs in functional languages (LISP, APL) strive to be a single huge nested function in which data flows from one to another without intermediate storage. Most commonly used in artificial intelligence research. Most programs are hybrids of multiple languages. C links to Assembler, Java links to C, a web application is split between client-side Javascript, server-side Perl, and database-side stored SQL procedures. It's simply a matter of assigning subtasks to the language most suited, rather than contorting a single solution into unsuited/unfitting/suboptimal/subpar performance for "purity." As with anything else, programmer can grow attached to a favorite language and may rely on it overmuch when another one might be better suited. Applications, system, scripting, code generation, platforms supported. Primitive types, facilities for roll-your-own, variable typing. Why do so many web coders swear by the programming language Perl, rather than C, C++, Java, Javascript or Visual Basic? Perl is interpreted. Broadly speaking, there are two types of languages: interpreted and compiled. For either, the "development cycle" involves repeated stages of edit-test-debug. With an interpreted language, you can immediately run a program and analyze the results (and any bugs). A compiled language includes an extra step: edit-compile-test. You first have to repair any compile-phase (syntax) bugs before the program itself runs and produces execution- phase (logic) bugs. Perl has regular expressions. When analyzing or processing text, it's useful to describe its "shape" in general terms. For instance, if a question demands a yes/no answer (also valid: y/n, YES/NO), the shape is a y (followed by anything), regardless of capitalization. When generating a document, the components are in a certain order. ... Regular expressions (aka regexps or regexes) offer a powerful way to describe these shapes. They're a small language in themselves, a grammar, for describing structure. Perl is concise. Perl, C++, Java and JavaScript all inherited certain syntax from C. For instance, x++; x = x + 1 x && y; x and y x ? y : z; if x then y else z msg .= "xyz"; msg = msg & "xyz" Perl offers alternatives. A fundamental construct in any programming language is the "branch," whereby the program embarks upon alternative courses of action based on some input. In Perl, a branch is written in one of the following five ways: if(somecondition){ dosomething; }else{ dosemethingelse; } dosomething if somecondition; dosomething unless !somecondition; somecondition || dosomething; somecondition ? dosomething : dosomethingelse; In Visual Basic, there's only one way: if somecondition then dosomething else dosomethingelse endif Perl makes file I/O easy. Perl is loosely-typed. JS variables are untyped, but there are different types. VB has typed variables plus a "variant" that can hold any type. Perl has useful data structures. Arrays and hashes. In JavaScript, these are one structure. Perl ignores formatting. Since statements are terminated with a semicolon, the interpreter doesn't care how much whitespace (spaces, tabs, carriage returns) are in the middle. VB inherits an ancient Fortran requirement that statements fit on a single line, and if not, a line-continuation character (underscore "_") must be used. (Java resource bundles use a backslash "\"). Perl has libraries of utilities, and the CPAN repository. Perl is free, although advanced IDEs customized for it aren't.