1. Comparing languages
I'm still finding goodies buried in my new Linux system, including a lot of
compilers.
To get started learning them, I wrote this simple program in various languages
(skipping
perl, forth, and intercal!) The simularities and differences are kinda
interesting:
# Payroll program in Python - 8 lines
# (comments and blank lines not counted)
tax = 25.00
print 'Payroll in Python'
hours = input("Enter hours worked: ")
rate = input("Enter hourly rate: ")
gross = hours * rate
net = gross - tax
print 'Gross pay: %8.2f'%gross
print 'Net pay: %8.2f'%net
/* Payroll program in C - 14 lines - compiles to 25K bytes */
#define TAX 25.00
float gross, net, hours, rate;
main()
{
printf("Pay written in C\n");
printf("Enter hours worked: ");
scanf("%f",&hours);
printf("Enter payrate: ");
scanf("%f",&rate);
gross = hours * rate;
net = gross - TAX;
printf("Gross pay: %8.2f\n",gross);
printf("Net pay: %8.2f\n",net);
}
{ Payroll program in Pascal - 14 lines - compiles to 30K bytes}
program Payroll (Input, Output);
const tax = 25.00;
var hours, rate, gross, net : real;
begin
writeln('Payroll in Pascal');
write('Enter hours worked: ');
readln(hours);
write('Enter hourly pay: ');
readln(rate);
gross := hours * rate;
net := gross - tax;
writeln('Gross pay: ', gross:10:2);
writeln('Net pay: ', net:10:2);
end.
10 REM Payroll program in BASIC - 8 lines
20 TAX = 25
30 PRINT"Payroll written in BASIC"
40 INPUT"Hours worked: ";HOURS
50 INPUT"Payrate: ";RATE
60 GROSS = HOURS * RATE
70 NET = GROSS - TAX
80 PRINT"Gross pay:",GROSS -- sorry, I can't remember the syntax for
PRINT USING
90 PRINT"Net pay: ",NET
-- Payroll in Euphoria - 20 lines
include get.e -- Euphoria was the only language to require "outside support"
for this simple task.
constant TAX = 25.00
atom hours, rate, gross, net
function input(sequence prompt) -- note the hoops we have to jump thru to get
keyboard input.
object result
puts(1,prompt)
result = value(gets(0))
puts(1,"\n")
if result[1] = GET_SUCCESS then
return result[2]
else return result[1]
end if
end function
puts(1,"Payroll in Euphoria\n")
hours = input("Enter hours worked: ")
rate = input("Enter payrate: ")
gross = hours * rate
net = gross - TAX
printf(1,"Gross pay: %8.2f\n",gross)
printf(1,"Net pay: %8.2f\n",net)
Question: Euphoria knows hours has been defined as an atom | sequence | object.
Why cannot the next version of Euphoria include a proper built-in input()
function
which will handle these things better? It would make learning and using he
language a bit
easier.
Regards,
Irv
2. Re: Comparing languages
What flavor of Linux do you have? I had RedHat Linux 5.0 and I didn't like it
very much.
Albert
3. Re: Comparing languages
On Mon, 16 Nov 1998 15:32:10 EST, Albert Brauneis <Dajawu36 at AOL.COM> wrote:
>What flavor of Linux do you have? I had RedHat Linux 5.0 and I didn't like it
>very much.
>
Ditto, and ditto: I couldn't make RedHat work no matter
what I tried. I loaded Slackware with almost no trouble
(had to download a new driver for the video) and it works
great.
Now I'm trying to compile Pete's Portable Euphoria for
Linux, but get dozens of errors.
Irv
4. Re: Comparing languages
>What flavor of Linux do you have? I had RedHat Linux 5.0 and I didn't like it
>very much.
I've only used Linux rarely - I thought Red Hat was okay, my friend who
uses it at work to run DNS and other services, swears by it. Does
require a big(ish) disk to install on I recall.
My personal hate was Slackware - very messy installation I thought; that
was a while ago - may be better now.
5. Re: Comparing languages
I just set up 3 Dell 300Mhz boxes running RH 5.1 to serve www.claus.com.
They expect over 2 terrabytes of traffick by the first of the year.
It's already getting *slammed* and doesn't even feel it.
-Darrell
-----Original Message-----
From: Bown, John [mailto:John.Bown at UK.ORIGIN-IT.COM]
Sent: Tuesday, November 17, 1998 6:15 AM
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: Re: Comparing languages
>What flavor of Linux do you have? I had RedHat Linux 5.0 and I didn't
like it
>very much.
I've only used Linux rarely - I thought Red Hat was okay, my friend who
uses it at work to run DNS and other services, swears by it. Does
require a big(ish) disk to install on I recall.
My personal hate was Slackware - very messy installation I thought; that
was a while ago - may be better now.