from Hacker News

WwwBasic – An implementation of BASIC designed to be easy to run on the Web

by lorenzleutgeb on 9/15/18, 5:49 AM with 87 comments

  • by pedasmith on 9/16/18, 6:02 AM

    New versions of BASIC are surprisingly common (heck, I even have one that's gotten some super-nice comments).

    Mind-blowing BASIC example from the 1970's:

        100 A$="ABCDEF"
        110 A$ = REP ("123", 4, 0)
        120 PRINT A$
    
    The result is ABC123DEF -- at position 4 (strings start at 1), replace 0 characters with "123". So the REP function looks at the statement it's part of, finds the variable that is being assigned to, and uses that as the starting string (!). It's kind of like a function, only with a weird implied variable that only works in an assignment.

    You can't just PRINT the result directly, because then how would REP know what the string to change is?

    Nowadays "weird" syntax has some solid foundational reason why it's useful or important. This not-really-a-function, though, simply has no justification whatsoever.

    (This example is from the BASIC embedded in the Tektronix 4050 terminal).

    There are enough variants of BASIC that there's a really nifty handbook with the differences at https://archive.org/details/Basic_Handbook_2nd_Edition_1981_...

  • by lioeters on 9/16/18, 11:09 AM

    Just a couple days ago, I was reading an article by David Brin called "Why Johnny Can't Code" (2016) [0] - where the author laments how difficult it was to find an accessible version of BASIC for his son to play with / learn on (they ended up buying a Commodore 64). Well, now the language runs on the web!

    [0] https://www.salon.com/2006/09/14/basic_2/

  • by xrd on 9/16/18, 4:59 AM

    Why is Google publishing this?

    It's late but I'm confused why anyone would spend time doing this, and since it is in the official Google repository, presumably someone at Google was actually doing it on paid time.

  • by bencollier49 on 9/16/18, 1:47 PM

    One of the reasons that BASIC was such an effective beginners' language was that it often appeared at bootup, so all you needed to do was turn on your machine and type a couple of lines to run a program.

    This isn't that, but withering comments from Dijkstra aside, BASIC is still a great introduction to programming, and this is a fantastic idea; it'll be great to run loads of old type-ins in the browser.

    Could have done with a crisper font, though.

  • by crazygringo on 9/16/18, 4:25 AM

    Wow this takes me back.

    BASIC was how I started programming, 30 years ago.

    Is this the first time someone's implemented BASIC in JavaScript? It seems so... obvious in hindsight.

    I wonder if this has any potential for kids who want to start to learn programming? Or if there are other better, more modern, places to start these days?

    Also... why is this from Google of all places? Seems like more of a personal hobby project.

  • by kerng on 9/16/18, 4:51 AM

    Cool idea! I always thought of Python being the modern Basic. Its interesting to see this - could there even be potential for something like this?
  • by TickleSteve on 9/16/18, 9:14 AM

    Missed naming opportunity!

    "gwwwbasic" anyone??

  • by mdhughes on 9/16/18, 8:22 PM

    [Chipmunk BASIC](http://www.nicholson.com/rhn/basic/) is a nice console-usable BASIC on most platforms. You can work with it line-numbered, or structured, and has some graphics and sound support in the Mac desktop version.

    I started on BASIC on the TRS-80 Model I in 1980, and it was a great introduction.

    That said, newbies are probably better off starting Python (use IDLE for a decent REPL & editor), type `from turtle import *; reset()` to get a graphics window, and learning a nice language from the start.

  • by pankajdoharey on 9/16/18, 5:47 AM

    Doesnt even have a repl now. This one will surely take many people back https://github.com/robhagemans/pcbasic
  • by orionblastar on 9/16/18, 4:59 AM

    Is this similar to VBScript that Microsoft's Internet Explorer used? I used to program in that for one of my former employers using Active Server Pages as well. JavaScript was a lot faster so we switched to that.
  • by ilaksh on 9/16/18, 6:43 AM

    It would be neat if someone could port some classic basic games to this.
  • by netsharc on 9/16/18, 2:54 PM

    What a neat way to encode the "DOS" font at the end of the wwwbasic.js file, including the characters that you can use to draw boxes.
  • by Timucin on 9/17/18, 2:19 PM

    Not sure if anyone mentioned that but WBasic would be a much better name I think. Just like GWBasic and QBasic.
  • by ourmandave on 9/16/18, 2:08 PM

    Aw, it doesn't have line numbers.

    Is there at least GOTO?

  • by andreygrehov on 9/16/18, 5:02 AM

    One word. Why? Serious question.
  • by bernardlunn on 9/16/18, 6:01 AM

    I think this falls between the cracks. Serious programmers (most HN readers) think it is too basic (sic). Non-programmers prefer hacking together cloud apps using Zap or IFTT where no code is needed. Enterprise just want thousands offshore maintaining legacy code
  • by xaduha on 9/16/18, 6:44 AM

    There are much better languages than BASIC, for whatever purpose.