[ale] Language Jihad!
Fletch
fletch at phydeaux.org
Tue Jul 17 11:32:38 EDT 2001
>>>>> "Pete" == Pete Hardie <pete.hardie at dvsg.sciatl.com> writes:
Pete> Wandered Inn wrote:
>> That being said, I'd go with Java before I'd try C++ or Perl. I
>> personally found it easier to get going.
Pete> Seconded. C++ is a less-strict OO language, and you are
Pete> constantly tempted to 'cheat' and go procedural, while Java
Pete> has a tighter view of things.
Swiped from an ircquainance's rant against Java, here's the
canonical first program in both Java and perl:
Java:
class HelloWorldApp {
public static void main (String args[]) {
System.out.println( "hello, world" );
}
}
Perl:
print "hello, world\n";
Much easier to start with. All hail Java!</sarcasm> (Just
make sure that you name your source `HelloWorldApp' before trying to
do so . . . :)
OOP is good. OOP has its place. I use OOP regularly (in
perl, of course :), but OOP is not the be-all-end-all paradigm. OOP
is not the solution to every problem.
There are some problems that a procedural approach is a better
fit than an OOP one (and there's some where a functional approach is
better than either). It's not cheating to use a saw to cut wood
rather than a hammer. With Java, you only get a big mallet; with C++
you at least get a claw hammer so you can pull the nails out of your
foot. :) With perl, you get the Swiss Army chainsaw that includes
both a mallet and claw hammer along with all the other gadgetry you
might need.
At any rate, don't limit yourself to one paradigm or one
language. Knowing several different flavours lets you choose the
right tool for the job. Why be a unilingual boor, when you can easily
be a programmatical polyglot? (and with perl you can be so in several
languages simultaneously from the same program :)
---->8 Cut Here 8<----
#!/usr/bin/perl
##
## Requires Inline::C, Inline::Python, and Inline::ASM; all are
## available from your friendly neighborhood CPAN mirror.
##
## http://www.cpan.org/
##
use Inline C => <<'EOT';
#include <stdio.h>
void c_hello( ) {
printf( "hello, world\n" );
}
EOT
## *shudder* :)
use Inline Python => <<'EOT';
def py_hello():
print "hello, world"
EOT
## OK, I cheated and used gcc -S :)
use Inline ASM => <<'EOT', PROTO => { asm_hello => 'void()' };
.LC0:
.string "hello, world\n";
.text
.align 4
.globl asm_hello
.type asm_hello, at function
asm_hello:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
subl $12, %esp
pushl $.LC0
call printf
addl $16, %esp
leave
ret
EOT
sub perl_hello { print "hello, world\n" }
perl_hello();
c_hello();
py_hello();
asm_hello();
exit 0;
__END__
---->8 Cut Here 8<----
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
770 933-0600 x211(w) | scary questions." -- Jules =(___)=
| U
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list