home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / TNH_PC.ZIP / CHIMENE.NL < prev    next >
Encoding:
Text File  |  1987-01-14  |  2.8 KB  |  105 lines

  1. A Programming Language Approach
  2.  
  3.             Lucian Chimene
  4.          New York IBM PC Club
  5.  
  6. A previous article in our local
  7. newsletter made some entertaining
  8. points in a discussion of BASIC vs.
  9. PASCAL. If you're not a full-time
  10. professional programmer, the thesis
  11. ran, it's absurd to put up with a
  12. language that requires you to enter:
  13. WRITELN("Hello"); just to print to
  14. the screen, when you can use BASIC to
  15. do the same thing with: PRINT
  16. "Hello". If you want to send the same
  17. thing to the printer, you discover in
  18. Pascal that 1)the language doesn't
  19. give you any simple function like
  20. LPRINT, so 2) you have to grit your
  21. teeth, sit down and write it
  22. yourself. You emerge 14 keystrokes,
  23. five semicolons, four parentheses,
  24. two quote sign pairs and a colon
  25. later, with "Hello" in print.
  26.  
  27. In defense of Pascal, it can be
  28. pointed out that this is a
  29. character-building experience and
  30. ought to be encouraged since it
  31. teaches you structured programming;
  32. if you don't like it go learn COBOL.
  33. Nevertheless, if all you need to know
  34. is the time of day, it seems
  35. excessive to have to learn how to
  36. build a watch.
  37.  
  38. Suppose there were an even simpler
  39. language than BASIC. Suppose you only
  40. had to enter 'Hello' to print to the
  41. screen. This would seem worth
  42. investigating!  Well, there is. Not
  43. enough people know about it and not
  44. enough people  who do know about it
  45. know that its whole intent is to
  46. simplify programming and let them get
  47. on with their application. It's
  48. called APL - A Programming Language.
  49. Let me introduce you to it.
  50.  
  51. Let's start by comparing BASIC and
  52. APL.  To get the answer to 2 times 3,
  53. enter:
  54.  
  55. BASIC: PRINT 2*3
  56. APL  : 2x3
  57.  
  58. Note: No PRINT command is needed in
  59. APL; an asterisk is not used for
  60. "times", but an old "times" sign,
  61. (same goes for divide), just like in
  62. grade school.
  63.  
  64. 12÷6
  65.  
  66. And while we're at it, let's look at
  67. a couple of the other math symbols.
  68.  
  69. BASIC     APL
  70.  <=      ≤
  71.  >=      ≥
  72. BASIC: PRINT LEFT$("Hello",4) APL  :
  73.  
  74. 4'Hello'
  75.  
  76. The upward-pointing arrow is the
  77. function called "take". That's two
  78. keystrokes in APL and 15 in BASIC. It
  79. gets better. The "take" works just as
  80. well and simply on a string (or
  81. vector) of numbers as it does on
  82. characters. It will take the first N
  83. rows or columns out of a table ( or
  84. matrix) too. Want the first two rows
  85. of a 5 x 5 table?
  86.  
  87. 2 5  NAMEOFTHETABLE
  88.  
  89. What? No loops? Yes - no loops!
  90.  
  91. There's more juice to be squeezed out
  92. of this one little function. Suppose
  93. you wanted to right justify a string
  94. of text in a 72 character line by
  95. padding it out with blanks:
  96.  
  97. BASIC: PRINT SPACES$(72-LEN(TEXT$))
  98.    +TEXT$
  99.  
  100. APL  : -72  TEXT
  101.  
  102. Want to find out more? Try a book
  103. like "APL, An Interactive Approach"
  104. by Gilman and Rose.
  105.