News for hackers. Stuff that matters.
Re:The original source code of Microsoft GW-BASIC from 1983 by RcouF1uZ4gsC on Thursday May 21, 2020 @08:13PM (#23267242)
From a comment in the source

> ORIGINALLY WRITTEN ON THE PDP-10 FROM FEBRUARY 9 TO APRIL 9 1975

Wow! I did not realize that it was written so quickly. Two months that literally changed the PC landscape forever.

Re:The original source code of Microsoft GW-BASIC from 1983 by kristopolous on Thursday May 21, 2020 @11:33PM (#23268419)
Paul Allen flew down to New Mexico where MITS was without ever having tested Basic on a real Altair 8800.

It was on essentially ticker-tape, which was the medium at the time (wikipedia's photo: https://en.wikipedia.org/wiki/Altair_BASIC#/media/File:Altai...)

Paul Allen was still "writing" it on the plane which in this case meant taking careful notes, cross-checking it very carefully and then manually punching holes into the paper. This is 1975, laptops are many years away.

It'd take about 30 minutes to load into the machine. Paul Allen claims they were the longest 30 minutes of his life. The MITS people were just smiling and waiting patiently, eager to see the cool software while Allen, on the other hand, had absolutely no idea whether it would work or not (they wrote it on an emulator after all).

After the 30 minutes it was ready to go and bam, everything worked. Bill and Paul had a company. Microcomputer software was now a thing.

Maybe I should do a computer history podcast ... I just checked and I don't really like most of them ... The video game crash of 1983 for example, I'd do at least 10 30 minute episodes on. The NES came out of it. I mean yeah, at least 10 episodes. I'll pick something super small (for example the HP 9100a) and see how it goes

Re:The original source code of Microsoft GW-BASIC from 1983 by bluedino on Thursday May 21, 2020 @08:29PM (#23267363)
Well...remember it is 'just' a BASIC interpreter.

Woz wrote Apple integer BASIC in the evenings while working at HP in just a few months. Guys were writing crazy stuff at the time. The original version of DOS that Microsoft bought to license to IBM for the PC was written in 6 weeks.

Re:The original source code of Microsoft GW-BASIC from 1983 by Tehdasi on Thursday May 21, 2020 @09:09PM (#23267675)
Expectations of complexity were much less in those days. Like, a programming language that is limited to 40 character variable names would be considered amateur hour, but back in the day it was prolly considered luxuriant. Also given the memory constraints, it also limited the amount of complexity you could put in your code.
Re:The original source code of Microsoft GW-BASIC from 1983 by vidarh on Friday May 22, 2020 @04:17AM (#23269774)
More than luxuriant. Commodore BASIC (effectively 6502 Microsoft BASIC under license with tweaks) on the C64 only looked at the first two characters of variable names. It allowed them to be longer (don't remember how long), but would ignore subsequent letters.
Re:The original source code of Microsoft GW-BASIC from 1983 by guenthert on Friday May 22, 2020 @12:09PM (#23273603)
This is getting off-track, but while the pitfalls of two relevant characters out of potentially many are obvious and only excusable due to technical limitation of the platform, insisting on more than 40 relevant characters is likewise contraproductive. Who (which human) will readily distinguish two character strings more than 40 characters in length sharing the first 40?

I feel often the need to remind programmers, that they don't write code for the computer. The computer will make it obvious, whether it understands you or not. You write for the poor sod tasked to maintain your code three years from now, when you're at your next gig.

Re:The original source code of Microsoft GW-BASIC from 1983 by panzagl on Friday May 22, 2020 @01:20PM (#23274553)
Does namespacing count? com.mycompany.class.classfactory.factory.initializer.StaticGlobal

Sure you can usually use import/aliasing to narrow it, but sometimes you just need to grab some random global from somewhere.

Re:The original source code of Microsoft GW-BASIC from 1983 by KCUOJJQJ on Thursday May 21, 2020 @10:20PM (#23268089)
>The original version of DOS that Microsoft bought to license to IBM for the PC was written in 6 weeks.

Is this actually true? From https://en.wikipedia.org/wiki/Tim_Paterson

When a book appeared in 2004 claiming that 86-DOS was an unoriginal "rip-off" of CP/M,[6] Paterson sued the authors and publishers for defamation.[7][8] The judge found that Paterson failed to provide any evidence regarding "serious doubts" about the accuracy of the Gary Kildall chapter.

Re:The original source code of Microsoft GW-BASIC from 1983 by mrunkel on Friday May 22, 2020 @01:39AM (#23268971)
Even a "rip-off" takes time to write. I'm not sure what you're questioning.

It wasn't a direct copying of the code, but the API was largely similar to CP/M.

Re:The original source code of Microsoft GW-BASIC from 1983 by staycoolboy on Thursday May 21, 2020 @08:47PM (#23267505)
I try to gauge the complexity of a task like this with a period view. On the one hand, BASIC was quite simple, and the 8-bit CPU had an instruction set that could be easily memorized (days before protected mode and 64 bytes worth of potential extended instruction decode prefixes!). On the other hand, debugging, code entry and documentation was sparse. (And there was no Stack Overflow.) So when I think to myself: How hard was this task compared to my for-fun projects? I really don't know what to think in today's inflationary terms. Thoughts?
Re:The original source code of Microsoft GW-BASIC from 1983 by calccc on Friday May 22, 2020 @04:13AM (#23269747)
Also, Spinellis' obfuscated C contest winner (the dds entry with LANDER.BAS):

https://www.ioccc.org/years.html#1990

Re:The original source code of Microsoft GW-BASIC from 1983 by jhallenworld on Thursday May 21, 2020 @11:09PM (#23268314)
Well this was way before the IBM PC.. Microsoft clearly had a plan in those days. They implemented all of the popular languages for microprocessors: Fortran-80, Cobol-80, Basic, PASCAL- but not C. They bought C from Lattice.

(I started with 6800 / 6809 assembly language, and then Microsoft C 4.0).

Also: PDP-10 (TENEX) was awesome to use, was a very nice development platform.

Re:The original source code of Microsoft GW-BASIC from 1983 by RcouF1uZ4gsC on Thursday May 21, 2020 @11:16PM (#23268347)
The PC in the comment was referring to “personal computer” in the generic sense.

It is interesting now to see Microsoft going back to its roots as a provider of developer tools for multiple platforms.

Re:The original source code of Microsoft GW-BASIC from 1983 by copperx on Thursday May 21, 2020 @08:21PM (#23267299)
It's funny how stuff that got put together quickly like GW-BASIC and JavaScript got so much success because of luck and popular appeal. It's like music. The best music has never been in the top of the charts. The best movies have never won Oscars.

This is pop computing.

Re:The original source code of Microsoft GW-BASIC from 1983 by smacktoward on Thursday May 21, 2020 @10:35PM (#23268166)
It wasn’t luck or popular appeal, it was like they say in real estate: “location, location, location.” JavaScript came bundled with every Web browser, and GW-BASIC came bundled with every IBM PC clone. A language that everybody in the world already has a copy of is going to get a lot of use, whether it’s good or not.
Re:The original source code of Microsoft GW-BASIC from 1983 by int_19h on Friday May 22, 2020 @11:54PM (#23279764)
Not just IBM PC, but also hobbyist microcomputers. Few people could afford to have the real thing at home... but they could afford Spectrum or Commodore. And then those BASIC skills would readily translate to PC.
Re:The original source code of Microsoft GW-BASIC from 1983 by sradman on Friday May 22, 2020 @04:30AM (#23269845)
I think they were riding a wave as it was beginning to form; the microprocessor wave. It was very much part of a place in time but they made some exceptional choices given that context. I don’t think that their success was due to luck or popular appeal, it was due to vision and the ability to execute on that vision.
Re:The original source code of Microsoft GW-BASIC from 1983 by tomcam on Thursday May 21, 2020 @08:51PM (#23267548)
Well, some of us think that acts like Kanye, Jay-Z, Amy Weinstein, the Beatles, and Led Zeppelin were pretty great even though they had the crassness and audacity to make it to the top of the charts
Re:The original source code of Microsoft GW-BASIC from 1983 by unnouinceput on Thursday May 21, 2020 @11:43PM (#23268456)
Please don't mix Kanye and Jay-Z with Beatles and Led Zeppelin, they are in different leagues.
Re:The original source code of Microsoft GW-BASIC from 1983 by BoiledCabbage on Friday May 22, 2020 @12:53AM (#23268750)
Sounds like you don't know music.
Re:The original source code of Microsoft GW-BASIC from 1983 by m463 on Friday May 22, 2020 @12:15AM (#23268566)
Think what you could do with a little time off and your own agenda to write something meaningful.
Re:The original source code of Microsoft GW-BASIC from 1983 by TheOtherHobbes on Thursday May 21, 2020 @08:33PM (#23267395)
GW-BASIC was more of a reinterpretation of DEC's PDP-10 BASIC source code than a clean room reconstruction - ironic considering what happened next.

Gates and Allen had already been working on PDP-8 and Data General versions for a while.

Re:The original source code of Microsoft GW-BASIC from 1983 by ken on Thursday May 21, 2020 @09:49PM (#23267907)
For one person working 8 hours a day, that's roughly one line of assembly language per minute. If you know assembly language, and you know the algorithms you're implementing, that doesn't seem especially fast.
Re:The original source code of Microsoft GW-BASIC from 1983 by HeyLaughingBoy on Thursday May 21, 2020 @09:58PM (#23267964)
You find me someone who can code assembly for 8 hours a day continuously for two months and I'll hire them on the spot.
Re:The original source code of Microsoft GW-BASIC from 1983 by unnouinceput on Thursday May 21, 2020 @11:40PM (#23268444)
There are plenty that do, especially in embedded. I did assembly at Siemens half the day (the other half was C) when I worked for Siemens VDO in 2005-2006. It's not that hard, especially if you do simple stuff, opposed to high algorithms I usually implement these days in higher programming languages.
Re:The original source code of Microsoft GW-BASIC from 1983 by ken on Friday May 22, 2020 @01:31AM (#23268926)
Is that a serious offer? It's been a couple years but I'm sure with a little practice I could get up to speed again, and (like half the country) I do happen to find myself out of a job right now.
Re:The original source code of Microsoft GW-BASIC from 1983 by HeyLaughingBoy on Friday May 22, 2020 @10:12AM (#23272247)
No, I was trying to make a point. Namely, that no one produces that kind of output consistently over time.

I apologize for not taking current economic conditions into consideration with what was clearly a poorly-worded post.

Re:The original source code of Microsoft GW-BASIC from 1983 by CamperBob2 on Friday May 22, 2020 @12:49AM (#23268731)
I've had jobs where that level of productivity would have gotten me fired for goldbricking. Gotta love the game industry...
Re:The original source code of Microsoft GW-BASIC from 1983 by m463 on Friday May 22, 2020 @12:16AM (#23268570)
how long would it take you to write a fast circle routine in assembler?

(with stack overflow blocked)

Re:The original source code of Microsoft GW-BASIC from 1983 by vidarh on Friday May 22, 2020 @04:59AM (#23270006)
In general I'd rely on symmetry per 1/8th I think, because within each quadrant you can mirror half by swapping x and of offsets. Then basically use the same approach as Bresenhams line algorithm adapted to integer, but instead of calculating a fixed slope, look it up in a table and adjust based on radius.

There is Bresenham's circle algorithm - I don't know it, but I'd guess it's not that far off the above, because the above is a pretty obvious solution when you know even the idea behind Bresenham's line algorithm and you know basic trigonometry.

Basically "everyone" that has done anything graphics related pre-fast floating point and pre-fast general multiplication/division in CPUs are used to the fact that you can boil anything involving trig down into tiny tables of number of steps in one direction before the next step in the other direction to avoid multiplication. You can often forego the tables for a few shifts, but it's often not worth it. You then look for mirroring as a means to avoid replicating computations wherever possible.

It'd certainly take a bit of time to get it just right, but at a few dozen instructions at least, you have a reasonable amount of time to figure it out. But more importantly: Most of the code will include a lot of pieces that takes far less than a minute per instruction.

I wouldn't be able to do it fast enough now given that it's 30+ years since I last wrote much assembler by hand and it'd take me a few days to get back up to speed, but this isn't a difficult challenge. Of course it'd also depend on CPU.

One thing you need to keep in mind is that the code density of assembler is very low. Once you know you need to add two 16 bit numbers together on an 8 bit CPU for example, you know what to write for several instructions. E.g. you might end up with something like this (roughly 6502, though I don't remember all the details of the assembler syntax; I'm assuming the use of <var to address the low byte of a 16 bit pair, and >var to address the high byte as at least some assemblers used that as shorthand to indicate address offsets), assuming two 16 bit values in var1 and var2, with result stored in var1

    CLC           ; Clear carry flag; can be ommitted if you know carry will be clear
    LDA <var1   ; Low byte of var1
    ADC <var2  ; Add with carry of low byte
    STA <var1
    LDA >var2   ; High byte
    ADC >var2
    STA >var2
That's 7 instructions that you'll do "automatically" when you're programming these CPUs daily and know you need an addition.

But even on much higher level CPU's like the x86 or M68k the density of high level concepts to assembly instructions is pretty low.

Re:The original source code of Microsoft GW-BASIC from 1983 by m463 on Friday May 22, 2020 @06:36AM (#23270593)
Wow, pretty good. I mentioned that because the first source file I pulled up was a circle drawing routine written in assembler.

I wrote a routine to do it once for fun -- in python -- and it took me some time to get it right. I also had access to wikipedia and stack overflow, so I was able to get the integer method going with guidance.

for example, the middle of the main loop was:

  x += 1
  if d > 0:
      y -= 1
      d = d + 4 * (x - y) + 10
  else:
      d = d + 4 * x + 6
(btw I was doing this not to draw a circle as much as draw a moon)

But when I read the source code I thought... writing geewhiz basic would take a long time now, let alone 1975 when there was no instantaneous communication of acm papers and computers were rare and graphical computers rarer.

Re:The original source code of Microsoft GW-BASIC from 1983 by vidarh on Friday May 22, 2020 @09:06AM (#23271581)
It's one of those things where you relatively quickly get used to a specific way of thinking, and while we didn't have instantaneous communications of papers, we did have endless numbers of computer magazines with actual listings in them that often also discussed fairly in depth algorithms.

Mostly it boils down to learning patterns for common things, and things like basic trig replacement was a staple of the demo scene.