热度 24
2014-5-13 18:29
1394 次阅读|
1 个评论
BASIC is that one language that has garnered such bad rap. Edgar Dijkstra and others have famously claimed that a person reared on BASIC was forever damned by the experience. By that reasoning, a baby who dribbles food can never learn table manners, and the old timer who was adept with analog oscilloscopes will be eternally baffled by the new world of the DSO. BASIC got a lot of people into software development. Some shouldn't have gotten involved in that, of course; for others, it seduced them into a career in professional software engineering. My first programming experiences were not with BASIC. I learned FORTRAN in high school and then moved on to Univac 1108 assembly language before picking up APL, LITHP, and many other languages, including (eventually) BASIC. FORTRAN and assembler suffer from the same lack of structure as the original Dartmouth BASIC, so one would think these languages would also be accused of being injurious to a developer's development. And what could be a bigger blot on the software world than APL? My first exposure to BASIC was around 1975, when we bought a couple of Altair 8800s. These arguably jump started the personal computer revolution, though they came into being long before the word "PC" existed. Thousands of serious developers and hobbyists bought the machines, often with a paper tape of Bill Gates' BASIC interpreter. It was very liberating to use an interpreter, rather than going through the incredibly painful process of compiling or assembling code. Even today, every little change requires a tedious recompilation. In the 1970s, there were no hard disks on micros; even floppies were expensive and rare. Recompiling to paper tape or cassette decks ate enormous blocks of time. With BASIC, one could type in a line of code and then "RUN". The edit/test cycle took seconds. BASIC was the lingua franca of the eight-bit computer world. All the machines sold in the late 1970s and early 1980s supported it, and in many cases, it was built into the ROM chips. Often there was no OS; the machine booted to a BASIC interpreter. Even the vaunted IBM PC originally had the language in ROM. Embedded development in the early days was almost always in assembly language, and I suspect there wasn't a manager on the planet who was happy about the low productivity it entailed and the completely cryptic end product that only a pony-tailed engineer who never came in before noon could understand. A lot of people were looking for alternatives. A few C compilers (e.g., MANX C) were available in the early 1980s, but it was not a popular language among eight-bit developers. Everyone was doing it Everyone knew BASIC, so in 1983, I wrote a BASIC compiler (not interpreter) targeted at embedded applications. It was interactive and felt exactly like an interpreter; one entered code with line numbers. "RUN" compiled and started executing the code in less than a second. The compiler generated very tight code and even had built-in multitasking support. It ran under CP/M on 8080 and Z80 systems and comprised about 30,000 lines of assembly language. Multitasking meant all generated code and libraries had to be reentrant, so I hired a college kid to write a reentrant and position-independent floating point package -- quite an accomplishment, given the 8080's architecture. Surprisingly, it took off. Orders showed up and then steamrolled in. It was startling to find checks from people I didn't know in the daily mail. I was working out of a bedroom in the house, but I couldn't handle the order fulfillment, so my wife quit her job to help. Eventually, we moved into the basement, because the upper two floors were filled with manuals, boxes, floppy disks, and (eventually) employees. Later we rented space in an RD park and set up more professional offices. IBM stunned the market when it introduced its PC. I bought one outfitted with everything -- two floppy disks, 128 KB of RAM, etc. -- which cost $7,000. Customers were asking for a PC version of the compiler, so I purchased a Z80 to 8088 assembly translator, which created awful, nasty code because the instruction sets were so dissimilar, and, of course, all the code generation was incompatible. In a hectic couple of months, I recoded it in 8088 assembly. If you had anything for a PC then, it sold, and our BASIC profited from that frenzy. It didn't hurt that Jerry Pournelle was an early advocate who featured it in Byte Magazine. Code generated by the compiler eventually was used at both poles for research instruments, aboard the space shuttle, and even in the nuclear submarine fleet. But embedded C started to gain adherents, and BASIC's demise was evident. The last updates were in 1988, but to this day I still get requests for new versions. I read an awful lot of code our customers wrote in BASIC. Some was pretty terrible, but a lot was as carefully crafted as anything written in C today, within the constraints of the language, giving lie to the belief that BASIC makes for crummy developers. I'll bet a lot of readers got their start in computers with BASIC but today build world-class code. What was your experience with BASIC? Do you feel it poisoned your abilities?