23 June, 2011

How Are Students Learning Programming ?

A recent ComputerWorld article "How are students learning programming in a post-Basic world ?" (It should be BASIC, not Basic) reminds me of the time I first learnt programming.
Yes, with BASIC. When there were very few PCs in Ahmedabad.

I learnt programming with BASIC. The credit goes to my elder brother, Santosh, who convinced me (against my self-doubts) that I could learn computer programming. And once I started, it was SO EASY (I topped the class).

Thank you , Santosh.

Here's a YABASIC program I wrote in 2007 to help my son solve a puzzle (and I don't remember the details of the puzzle) :

`print "The problem of 3 daughters"print  "Find 3 numbers whose product equals the desired number"input "What is the product of the 3 integers ?"  productof3DIM AM(productof3,4)RN=1FOR I =1 to productof3IF INT(productof3/I) =  (productof3/I) THENFOR J =1 to productof3IF INT(productof3/J) =  (productof3/J) THENFor K = 1 to productof3 IF INT(productof3/K) =  (productof3/K) THEN#       print "Testing ", I , J , K        DOESEXIST=0      IF (I * J * K) = productof3 THEN#           print "Possible Answer : ", I , J, K, " :  With the Sum as : ", S\        FOR ARRCHK =1 to RN            S = I + J + K            IF ( (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=I AND AM(ARRCHK,3)=J AND AM(ARRCHK,4)=K) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=I AND AM(ARRCHK,3)=K AND AM(ARRCHK,4)=J) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=J AND AM(ARRCHK,3)=I AND AM(ARRCHK,4)=K) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=J AND AM(ARRCHK,3)=K AND AM(ARRCHK,4)=I) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=K AND AM(ARRCHK,3)=I AND AM(ARRCHK,4)=J) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=K AND AM(ARRCHK,3)=J AND AM(ARRCHK,4)=I)  )  THEN#                   print "..............   Numbers ", I, J, K, "  have already been checked"               DOESEXIST=1               BREAK              ENDIF        NEXT ARRCHK                IF DOESEXIST=0 THEN                  AM(RN,1)=S                  AM(RN,2)=I                  AM(RN,3)=J                  AM(RN,4)=K                  print "Possible Answer : " , AM(RN,2), AM(RN,3), AM(RN,4) , " : With the sum : ", AM(RN,1)                ENDIF         RN = RN +1     ENDIF  ENDIFNEXT KENDIFNEXT JENDIFNEXT I `

Or an example of a program to test a number for whether it is a Prime (very simplistic, not using any of the algorithms -- like the Sieve of Eratosthenes that I used when I wrote a program in the BASIC class in 1985 -- or was it in 1984) :
`print "hello world"# Testing for Prime Numbers#assignpresult=0input "Which number ?"  numtotestprint "You entered :  " , numtotestfor I=2 to numtotest/2IF (numtotest/I) = int(numtotest/I) THEN# print "Testing division of ", numtotest, "by ", I , " : Is Not a Prime"presult=1BREAKELSE# print "possibly a prime when testing division by  ", IENDIFNEXT Iclear screenif presult=0 thenprint colour("red","blue") numtotest,  "   IS A PRIME NUMBER !"ELSEprint colour("green") numtotest,  "   is not a prime number !"ENDIFinput "Enter to exit  " mentr `

I have also studied xBase (dBASEIII+), Pascal, C, C++ and Java (besides SQL and PL/SQL). Guess which language I dislike ? It is a 4 letter word.

UPDATE 01-Jul-11 : Here's an article by Joel Spolsky (albeit dated 29-Dec-05) : The Perils of JavaSchools.

.
.
.

Anonymous said...

hello,
why you dislike it?

Joel Garry said...

I was fortunate to learn 5 other languages first, so I was more amenable to structured programming in my first paying job - learning DEC BASIC+ and BASIC+2 on the job, untangling the spaghetti.

word: stersa

Hemant K Chitale said...

Anonymous,
Why I dislike Java ?
Garbage Collection means that you can afford to be lazy about memory management.
Bytecodes and JVMs are slow. Java survived only because of processor advances by Intel.
Java code doesn't look neat.
Every time I see an error message from a Java program I puke. Completely meaningless messages.

Hemant