Let's Hear it for BASIC
- davidcarew19

- 2 days ago
- 4 min read
A few months ago, I wrote a routine program that displays the UNICODE (ASCII) values for the most common 128 characters. It is something that I have done many times as part of learning a new programming language. It is particularly instructive (I believe) to write a program that forces one to touch every character that you will ever encounter in that language. In this case, I was coding in Go, a relatively recent programming language, originating from within Google corporation. Below is an example ASCII table, giving the numeric code values in decimal numbers.
ASCII CHART - Decimal
Val Chr Val Chr Val Chr Val Chr Val Chr Val Chr Val Chr Val Chr
------- ------- ------- ------- ------- ------- ------- -------
000 NUL 016 DLE 032 048 0 064 @ 080 P 096 ` 112 p
001 SOH 017 DC1 033 ! 049 1 065 A 081 Q 097 a 113 q
002 STX 018 DC2 034 " 050 2 066 B 082 R 098 b 114 r
003 ETX 019 DC3 035 # 051 3 067 C 083 S 099 c 115 s
004 EOT 020 DC4 036 $ 052 4 068 D 084 T 100 d 116 t
005 ENQ 021 NAK 037 % 053 5 069 E 085 U 101 e 117 u
006 ACK 022 SYN 038 & 054 6 070 F 086 V 102 f 118 v
007 BEL 023 ETB 039 ' 055 7 071 G 087 W 103 g 119 w
008 BS 024 CAN 040 ( 056 8 072 H 088 X 104 h 120 x
009 HT 025 EM 041 ) 057 9 073 I 089 Y 105 i 121 y
010 LF 026 SUB 042 * 058 : 074 J 090 Z 106 j 122 z
011 VT 027 ESC 043 + 059 ; 075 K 091 [ 107 k 123 {
012 FF 028 FS 044 , 060 < 076 L 092 \ 108 l 124 |
013 CR 029 GS 045 - 061 = 077 M 093 ] 109 m 125 }
014 SO 030 RS 046 . 062 > 078 N 094 ^ 110 n 126 ~
015 SI 031 US 047 / 063 ? 079 O 095 _ 111 o 127 DELThe source code for that program is short-- I have a copy on my C drive showing a length of but 4932 characters, coded in Go. HOWEVER, executable size of the compiled binary output is over 2 million bytes (!?)
Why so long? Who knows? There seems to me to be no good reason for such bloat, but young languages are indeed examples of the well-known heuristic that goes by the saying, "First get it right" Then later, one can optimize and pare down to a reasonable smaller size. And in any case without compiler source code and lots of hours of study, there is not anything that I can do about Golang's bloated output.
The reason I bring this up is that just today I spent some time revisiting (re-learning) BASIC language, which was once quite popular for ordinary business programming. BASIC originally was an acronym for "Beginner's All-purpose Symbolic Instruction Code". It is truly a simple and elegant language; albeit one which has a reputation of being slow, because it is usually deployed as an interpreter. I spent what probably amounts to most of my professional life creating solutions for small business and non-profit enterprises, such as the San Diego Zoo, which wanted to plan breeding of captive species so as to maximize preservation of genetic diversity. Many species are disappearing in the wild, bringing up issues of re-introduction of some species-- preservation of genetic diversity within a species is a noble goal, which might make a difference of non-extinction.
Anyway, I (that is we, our coding team) did much of such work using BASIC language. It has a good quality of being straightforward, a format in which it is easy to isolate and correct coding errors without exotic tools such as complex debuggers. The result is a quite real quality of extra productivity. We were careful to use high-quality BASIC language compilers, which produce executable binary code that is faster (usually much faster) than implementations such as Microsoft Quick BASIC, a well-known BASIC interpreter, popular for games and for students learning to program.
So by way of review, I coded an ASCII Chart program in an open source, compiler-based version of BASIC, known as FreeBASIC. It produces output that is absolutely identical to the Go program. And lo, behold its source was quite substantially larger than that of Go (aka Golang, to distinguish it from the common English language verb, I guess). HOWEVER, the compiled .exe (executable binary) form of the program is only 40, 960 bytes long, as opposed to over 2.1 million, an amount that calculates to be less than 2 percent of Golang's bloatware!
Both programs produce output in similar (sub-second) run times. And anyway its output is of reference value-- one would have to benchmark runtime difference by arranging to run the code over and over thousands of times, measuring an accumulated difference across many runs repeated-- while in fact ASCIIChart.exe is actually used only occasionally when the programmer needs to know that the '@' character is stored as the bit pattern value 64 in two's complement binary, which is not all that often. Low level bit-twiddling does need to be done, but not every day all day long, especially if one is a programmer for business/enterprise purposes (higher level code).
I am considering writing a book, which would involve a non-trivial amount of coding. As of now, I will be planning to write the code in FreeBASIC and not Go. Its results will be identical, but I will spend considerably less time on the actual code and debug labor, allowing me to concentrate on the writing itself. And God knows I need to do the writing at my very best.

Comments