Friday, July 20, 2012

Small Basic

I was looking around for a C compiler for Microsoft Windows and stumbled across Small Basic (not what I was looking for, but...). In a few minutes I had this « hello world » program running, that can be published online and run from the web.



Try typing into the console above and hitting return.  (The color change doesn't seem to work in the online version.)

Here is the code: 


Microsoft said they made small basic as an easy introduction to programming and to make programming fun.  It is a free download; here is a link if you are curious. 

BASIC was the first programming language I started learning and using, back in the 80s from a book that came with a commodore 64.  In fact I learned to type by programming BASIC.  Typing commands like goto seem automatic, even today.

And, it even has graphics!



And here is a program to calculate prime numbers.  One of the first programs I ever came up with was one like this.




Prime numbers never end in 2, 5 or 0, because we have a base 10 counting system. Once I tired writing a prime number generating program that used base 12, which has many more factors (2, 3, 4, 6) than 10 (2, 5) and could rule out primes based on the final digit rather than trying factors, but it was very inefficient to convert to base 12 and turned out to be slower.

No comments: