home *** CD-ROM | disk | FTP | other *** search
- A Programming Language Approach
-
- Lucian Chimene
- New York IBM PC Club
-
- A previous article in our local
- newsletter made some entertaining
- points in a discussion of BASIC vs.
- PASCAL. If you're not a full-time
- professional programmer, the thesis
- ran, it's absurd to put up with a
- language that requires you to enter:
- WRITELN("Hello"); just to print to
- the screen, when you can use BASIC to
- do the same thing with: PRINT
- "Hello". If you want to send the same
- thing to the printer, you discover in
- Pascal that 1)the language doesn't
- give you any simple function like
- LPRINT, so 2) you have to grit your
- teeth, sit down and write it
- yourself. You emerge 14 keystrokes,
- five semicolons, four parentheses,
- two quote sign pairs and a colon
- later, with "Hello" in print.
-
- In defense of Pascal, it can be
- pointed out that this is a
- character-building experience and
- ought to be encouraged since it
- teaches you structured programming;
- if you don't like it go learn COBOL.
- Nevertheless, if all you need to know
- is the time of day, it seems
- excessive to have to learn how to
- build a watch.
-
- Suppose there were an even simpler
- language than BASIC. Suppose you only
- had to enter 'Hello' to print to the
- screen. This would seem worth
- investigating! Well, there is. Not
- enough people know about it and not
- enough people who do know about it
- know that its whole intent is to
- simplify programming and let them get
- on with their application. It's
- called APL - A Programming Language.
- Let me introduce you to it.
-
- Let's start by comparing BASIC and
- APL. To get the answer to 2 times 3,
- enter:
-
- BASIC: PRINT 2*3
- APL : 2x3
-
- Note: No PRINT command is needed in
- APL; an asterisk is not used for
- "times", but an old "times" sign,
- (same goes for divide), just like in
- grade school.
-
- 12÷6
-
- And while we're at it, let's look at
- a couple of the other math symbols.
-
- BASIC APL
- <= ≤
- >= ≥
- BASIC: PRINT LEFT$("Hello",4) APL :
-
- 4'Hello'
-
- The upward-pointing arrow is the
- function called "take". That's two
- keystrokes in APL and 15 in BASIC. It
- gets better. The "take" works just as
- well and simply on a string (or
- vector) of numbers as it does on
- characters. It will take the first N
- rows or columns out of a table ( or
- matrix) too. Want the first two rows
- of a 5 x 5 table?
-
- 2 5 NAMEOFTHETABLE
-
- What? No loops? Yes - no loops!
-
- There's more juice to be squeezed out
- of this one little function. Suppose
- you wanted to right justify a string
- of text in a 72 character line by
- padding it out with blanks:
-
- BASIC: PRINT SPACES$(72-LEN(TEXT$))
- +TEXT$
-
- APL : -72 TEXT
-
- Want to find out more? Try a book
- like "APL, An Interactive Approach"
- by Gilman and Rose.