View Full Version: Which language is better?

Haven Of Wiidom > Rantings and Ravings > Which language is better?


Title: Which language is better?


DataSnake - January 15, 2008 04:31 PM (GMT)
LISP: LISt Processor. Capable of doing anything, and doing it WELL, given a sufficiently skilled programmer. An elegant language, from a more civilized age.
PERL: Practical Extraction and Report Language. Described as a "Swiss-Army Chainsaw". Quick-and-dirty solution generates quick-and-dirty programs. Marked similarities to other programming languages.

PROGRAMS IN EACH LANGUAGE (SAME FUNCTION)
-----------------------------------------------------------

LISP

(define (count-change p)
(define (h-loop x h)
(define (q-loop x q)
(define (d-loop x d)
(if (= d 0)
(+ x (max-n p h q d) 1)
(d-loop (+ x (max-n p h q d) 1) (- d 1))))
(if (= q 0)
(d-loop x (max-d p h q))
(q-loop (d-loop x (max-d p h q)) (- q 1))))
(if (= h 0)
(q-loop x (max-q p h))
(h-loop (q-loop x (max-q p h)) (- h 1))))
(h-loop 0 (max-h p)))

PERL

#!/usr/bin/perl
sub countchange
{
my($amount)=@_;
$result=0;
for($h=maxh($amount);$h>=0;$h--)
for($q=maxq($amount,$h);$q>=0;$q--)
for($d=maxd($amount,$h,$q);$d>=0;$d--)
$result += (maxn($amount,$h,$q,$d)+1);
return $result;
}

both assume existence of functions giving the maximum number of half-dollars, quarters, dimes, and nickels available for a given amount of change.

DataSnake - January 15, 2008 04:36 PM (GMT)
For some reason, it didn't indent the programs properly. Let me try this:
LISP
CODE

(define (count-change p)
  (define (h-loop x h)
    (define (q-loop x q)
      (define (d-loop x d)
        (if (= d 0)
            (+ x (max-n p h q d) 1)
            (d-loop (+ x (max-n p h q d) 1) (- d 1))))
      (if (= q 0)
          (d-loop x (max-d p h q))
          (q-loop (d-loop x (max-d p h q)) (- q 1))))
    (if (= h 0)
        (q-loop x (max-q p h))
        (h-loop (q-loop x (max-q p h)) (- h 1))))
  (h-loop 0 (max-h p)))


PERL
CODE

#!/usr/bin/perl
sub countchange
{
  my($amount)=@_;
  $result=0;
  for($h=maxh($amount);$h>=0;$h--)
    for($q=maxq($amount,$h);$q>=0;$q--)
      for($d=maxd($amount,$h,$q);$d>=0;$d--)
        $result += (maxn($amount,$h,$q,$d)+1);
  return $result;
}

Wingman - January 15, 2008 05:43 PM (GMT)
I know next to nothing about computer code or writing computer code. I was born in 92, so when I was old enough to use computers, you no longer had to feed lines of code to make it do something. You just used the mouse, keyboard, and went to town.

DataSnake - January 15, 2008 06:55 PM (GMT)
QUOTE (Wingman @ Jan 15 2008, 05:43 PM)
I know next to nothing about computer code or writing computer code. I was born in 92, so when I was old enough to use computers, you no longer had to feed lines of code to make it do something. You just used the mouse, keyboard, and went to town.

It is still a useful skill, and a lot of fun once you get used to it.

Wingman - January 15, 2008 06:59 PM (GMT)
QUOTE (DataSnake @ Jan 15 2008, 01:55 PM)
QUOTE (Wingman @ Jan 15 2008, 05:43 PM)
I know next to nothing about computer code or writing computer code. I was born in 92, so when I was old enough to use computers, you no longer had to feed lines of code to make it do something. You just used the mouse, keyboard, and went to town.

It is still a useful skill, and a lot of fun once you get used to it.

I could try it sometime. Hey, check out my US vs CHina fight. Hamboy and I are sure to get into a whopper of an argument there. B) :P :P

Wingman - January 15, 2008 09:53 PM (GMT)
If you really wanted my honest opinion...*grins an evil grin*

English is the best language.

DataSnake - January 16, 2008 02:59 PM (GMT)
QUOTE (Wingman @ Jan 15 2008, 09:53 PM)
If you really wanted my honest opinion...*grins an evil grin*

English is the best language.

Some marketroid actually made a programming language called "English" once, sp that their company's computers could be advertised as "programmable in English." The language sucked.

Wingman - January 24, 2008 01:38 PM (GMT)
QUOTE (DataSnake @ Jan 16 2008, 09:59 AM)
QUOTE (Wingman @ Jan 15 2008, 09:53 PM)
If you really wanted my honest opinion...*grins an evil grin*

English is the best language.

Some marketroid actually made a programming language called "English" once, sp that their company's computers could be advertised as "programmable in English." The language sucked.

That sounds really dumb.

SilverSurfer092 - January 24, 2008 10:02 PM (GMT)
I'm learning Java right now. My friends already know VB, but I didn't take that class. Right now, it looks as if LISP is better.

hamboy - January 24, 2008 10:04 PM (GMT)
*Takes on look atb the opening post*
Remind me to drop computers when I go to college. I'm not touching that with a ten foot pole.




Hosted for free by zIFBoards