9 ms·
WwwBasic – An implementation of BASIC designed to be easy to run on the Web
- throwaway235478 8y agoA B O M I N A T I O N
- crazygringo 8y agoWow 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.
- themodelplumber 8y agoI had some similar nostalgia and tried out FreeBASIC the other day. It was dead easy to get started. I couldn't believe how simple it was to get up and running, and while I mostly worked on some command line programs, it was really cool to see how GTK and Qt and other GUI tools were made usable as well. After this experience I can easily see how someone could still be writing BASIC for a living in 2018, whether for standalone desktop apps or for web CGI, etc.
- bitwize 8y agoThere was a dialect called Business BASIC that was popular for business apps in the 1970s. It supported things like record-based file I/O (creating a navigational database), the creation of multiple concurrent tasks (on a 64k machine!), as well as exception handling in the form of additional params that specified which line numbers to branch to on error for all I/O operations. Business BASIC was ported to mainstream PCs and other micros as the market for dedicated Business BASIC minicomputer systems waned. It still lives on today in the form of two dialects: ProvideX and BBj. And people are still writing/maintaining applications in it.
- exikyut 8y agooooh. > In the 1980s, Business Basics were ported from their original proprietary environments to many Unix platforms, CP/M, and to DOS. In the 1990s, some Business Basics were ported to Linux and Windows, ... [https://en.wikipedia.org/wiki/Business_Basic https://en.wikipedia.org/wiki/Business_Basic] Know where I might be able to find some of the earlier versions? The DOS and CP/M versions simply for the archival/historic value, but I'd love to play with the Linux version in particular, early Linux software is virtually impossible to find. Early Windows versions would certainly be fascinating as well.
- cm2187 8y agoWell, with .net being ported to wasm, you should soon be able to use vb.net in the browser too.
- vertex-four 8y agoVB.Net has little to do with Basic or Visual Basic - it’s really just an alternative syntax for C#.
- cm2187 8y agoBut it has preserved a lot of the simplicity of the basic language. I think it’s biggest value is that it offers a bridge for business users who’s only programming experience is some VBA to a more sane and modern language.
- lucio 8y ago>it’s really just an alternative syntax for C# That's very true. Either C# or VB.NET, you're programming the NET Framework. All you can do in C# you can do in VB.NET, and even there's some features that are better implemented in VB.NET, like Type.Missing https://blogs.msdn.microsoft.com/eric_carter/2004/04/15/type-missing-c-and-word/ https://blogs.msdn.microsoft.com/eric_carter/2004/04/15/type... Of course any language with "Basic" in its name will be look down, but in today's NET there's no objective reasons to do so. Nowadays, VB is a better choice than C# to develop in-house business management software.
- cm2187 8y agoThat is a bit dated, C# fixed that problem many years ago [1] But there are still instances where the VB.net syntax is nicer than c#, for instance date litterals, or array litterals: C# foreach(var x in new string[] {"A", "B", "C"}) VB For Each x in {"A", "B", "C"} Also switch statements in C# are horrendous. But there are also instances where C# has a better syntax, like "x=>x+1" is way more elegant and practical than "Function(x) x+1". But I think the writing is on the wall. VB will go the way of Winforms, i.e. sort of supported but nothing more. [1] https://en.wikipedia.org/wiki/C_Sharp_4.0#Optional_parameters_and_named_arguments https://en.wikipedia.org/wiki/C_Sharp_4.0#Optional_parameter...
- kerng 8y agoCool idea! I always thought of Python being the modern Basic. Its interesting to see this - could there even be potential for something like this?
- int_19h 8y agoNot really. Like you said, we have better beginner languages now, Python being the most prominent (especially seeing how it has a turtle graphics library out of the box). BASIC is extremely inconsistent for a modern language.
- cm2187 8y agoPython has its own inconsistencies, like any language that has been around for a very long time. Like some collection properties have to be accessed with a function (len()) while other as an instance function. It doesn’t seem to follow any logic.
- int_19h 8y agoBASIC is far worse than that. Like, at least in Python, len() is a regular function. In BASIC, tons of core features are implemented as statements, with rather weird syntax that got even more weird over time. LINE (x1, y1) - (x2, y2), 5, FB Can you remember what it does? (no, it doesn't draw a line; it would, if not for "FB"). Or, for example, MID$ is a function, except when it's not: MID$(s$, 1) = "foo" Then there's stuff like DEFINT and GOSUB and ON STRIG and ... The reason for all this is that BASIC was never designed as a language in which the standard library could mostly be written, or even described, in that language. Thus, most features were implemented as intrinsics, with magic syntax and/or semantics, which varies drastically from feature to feature. This goes even for the standard functions - e.g. MID$ is a function (except when it's not, as above) - but it can take either 2 or 3 arguments, which is not something that you can declare yourself. As a result, when language evolved, it also did so in a haphazard way, as with LINE re-purposed for other reasons. The original BASIC was very simple (but also non-extensible). The BASIC that most people remember - at its peak - was actually more complicated than an equivalent subset of Python.
- orionblastar 8y agoIs 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.
- tomcam 8y agoThis is a fun toy program. VBScript was a pretty comprehensive language built by some of Microsoft’s top compiler people back in the day. It was infinitely more powerful than this and was often used for serious development.
- exikyut 8y agoWhat happened to VBScript? It feels like a kind of BeOS or Amiga within the scripting-on-Windows domain. It's just... disappeared, and tends to either fulfill "it MUST run EVERYWHERE" OCD-backward-compatibility requirements - basically Win32 Perl - or it's used for viruses. Outside highly narrow application/context-specific situations, that is.
- kyberias 8y ago> What happened to VBScript? Nothing. Microsoft Windows [Version 10.0.17134.285] (c) 2018 Microsoft Corporation. All rights reserved. C:\Windows\SysWOW64>cscript Microsoft (R) Windows Script Host Version 5.812 Copyright (C) Microsoft Corporation. All rights reserved. Usage: CScript scriptname.extension [option...] [arguments...] Options: //B Batch mode: Suppresses script errors and prompts from displaying //D Enable Active Debugging //E:engine Use engine for executing script //H:CScript Changes the default script host to CScript.exe //H:WScript Changes the default script host to WScript.exe (default) //I Interactive mode (default, opposite of //B) //Job:xxxx Execute a WSF job //Logo Display logo (default) //Nologo Prevent logo display: No banner will be shown at execution time //S Save current command line options for this user //T:nn Time out in seconds: Maximum time a script is permitted to run //X Execute script in debugger //U Use Unicode for redirected I/O from the console
- xrd 8y agoWhy 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.
- xrd 8y agoThe author has a fascinating discussion of basic on his blog. https://flagxor.com/article/source-code https://flagxor.com/article/source-code I might be coming around to the why of this.
- bcherny 8y agoSidenote, that is one obnoxious color scheme :/
- TomMarius 8y agoAnd width. I have an ultrawide display, really not a good reading experience. Newspapers put text in columns for a reason.
- jlg23 8y agoLooks fine in lynx on a 80x25 terminal ;)
- zem 8y agoI spent a few seconds thinking it was one of those popup overlays and looking for the close button
- jkabrg 8y agoIf you're using Firefox, use the reader mode.
- zokier 8y ago> since it is in the official Google repository, presumably someone at Google was actually doing it on paid time Unlikely. Google (like many companies) assert ownership of everything their employees create, even on their free time. There are plenty of projects under Google organization that have no other affiliation with Google.
- andreygrehov 8y agoOne word. Why? Serious question.
- khazhou 8y agoBecause with this javascript library, you can run BASIC programs on the web. BASIC was for many people their introduction to programming, and it has a simplicity which is nearly unmatched today. By providing a way to run the language inside the ubiquitous web browse, one may hope to spread the usage of BASIC as a learning tool, especially for youngsters.
- andreygrehov 8y agoWhy would Google want to spread the usage of BASIC? From an engineering perspective, this is an interesting project to work on, but I can't find a reason for Google to publish it. I also don't think that BASIC is a good learning tool nowadays. I'm not the only one who thinks so. A quote by Edsger W. Dijkstra: > It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
- jacquesm 8y agoTwo words: Why Not? Just as serious. Programming does not always require a solid reason before you can engage in it, quite a bit of it is like playing. If you actually enjoy programming then it is much nicer to do than if everything needs a financial justification. There is a similar analogy with music, you could make money with it, but you can also simply enjoy it.
- andreygrehov 8y agoSure, I can see it as an engineer's pet project, but why would Google publish it?
- pankajdoharey 8y agoDoesnt even have a repl now. This one will surely take many people back https://github.com/robhagemans/pcbasic https://github.com/robhagemans/pcbasic
- bernardlunn 8y agoI 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
- pedasmith 8y agoNew 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_CompuSoft_Publishing https://archive.org/details/Basic_Handbook_2nd_Edition_1981_...
- ilaksh 8y agoIt would be neat if someone could port some classic basic games to this.
- rzzzt 8y agoDONKEY.BAS is there; I was secretly hoping for GORILLA.BAS.
- xaduha 8y agoThere are much better languages than BASIC, for whatever purpose.
- jacquesm 8y agoThere are now, but BASIC was invented in the 70's, and some very powerful versions of it were used to build just about everything in the 80's and even the 90's. There was BBC Basic on the BBC micro, GFA Basic on the ST and of course MSVB on the PC, which if you have windows is most likely still lurking in your system somewhere. Each of those could be used to write very complete applications including GUIs and such.
- kingkingking 8y agoThis is one of the best test comments ever. Its bigly.
- TickleSteve 8y agoMissed naming opportunity! "gwwwbasic" anyone??
- lioeters 8y agoJust 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/ https://www.salon.com/2006/09/14/basic_2/
- tyingq 8y agoA duinomite could have been an easier path. Natively does basic, has vga, and is pretty cheap. https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE-MINI/open-source-hardware https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE-MI... Edit: Interesting...the Duinomite folks even noted the "Why Johnny Can't Code" post: https://www.olimex.com/Products/Duino/Duinomite/_resources/Example/ https://www.olimex.com/Products/Duino/Duinomite/_resources/E...
- UncleSlacky 8y agoThere's also standalone BBC Basic for the Raspberry Pi: https://www.riscosopen.org/content/sales/risc-os-pico https://www.riscosopen.org/content/sales/risc-os-pico
- lioeters 8y agoI hadn't seen DuinoMite, that looks great for the "child hacker". Funny coincidence that they mention the same article! I've also been enamoured by PICO-8, a programmable virtual game console - its retro aesthetics and ALL CAPS syntax remind me of BASIC. https://www.lexaloffle.com/pico-8.php https://www.lexaloffle.com/pico-8.php
- bencollier49 8y agoOne 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.
- toxik 8y agoI think the font quality is due to pixel density. It looks upscaled.
- tokyodude 8y agoWhy is BASIC a great introduction to programming? Genuinely curious. It's a bad language by pretty much all computer science standards. It only has global variables. In the past it used line numbers not labels. Many Basics only allowed 2 letter variable names. It has almost no library. (I suppose those could be added but they're already available in other languages). AFAIK there is little to no tooling for BASIC (meaning no auto0completion or popup docs that many languages have now) I grew up on basic on TRS-80/Apple II/Atari 800 and I have super fond memories of those times. You can even find lots of my BASIC code in old magazines from the 80s. But, I don't really believe those were better than today with kids with Scratch or Unity or other alternatives. Python or JavaScript (runs everywhere) etc... Maybe even PICO-8/Lua etc... Are there some concrete reason BASIC is actually a good place to start?
- pjmlp 8y agoI wouldn't advise unstructured BASIC, there are plenty of structured improvements to choose from. It is easy to learn because it was the first language to come with batteries. In some 8 bit micros it was as powerful as the underlying Assembly, only slower. So it was relatively easy to prototype. Also the the runtime was the OS. Nowadays a kid needs to learn how to access the development environment, probably configured by an adult and to do more complicated tasks might need some help getting libraries. Maybe stuff like boards with MicroPython will help here.
- ourmandave 8y agoAw, it doesn't have line numbers. Is there at least GOTO?
- jkabrg 8y agoSee the slides example
- netsharc 8y agoWhat 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.
- mdhughes 8y ago[Chipmunk BASIC](http://www.nicholson.com/rhn/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.
- Timucin 8y agoNot sure if anyone mentioned that but WBasic would be a much better name I think. Just like GWBasic and QBasic.