Hacker News new | ask | show | jobs
by matthewwiese 2893 days ago
Fun article! I've gotta give this a try myself.

On a related note (of using BASIC where it doesn't belong), I hacked together a method to convert BASIC code to WebAssembly using BaCon[0], a BASIC-to-C converter, and Emscripten to take the resulting C output and generate some wasm.[1] Much like the linked article, this is a fun diversion to entertain the idea of using BASIC where the language authors couldn't possibly have imagined it. Perhaps I'll get around to actually making a "real" project out of it sometime...

[0]: http://www.basic-converter.org/

[1]: https://github.com/matthewwiese/basic-to-c-wasm-example

2 comments

This is really interesting, thank you! I've been working the last couple of days on getting an old type-in game working and I had some vague thoughts about it being fun to somehow make it playable on the web. I'd have to convert it from Microsoft BASIC to the dialect BaCon uses, but that's definitely an option. Another option I've considered is to see about getting cbmbasic[0] running using a JS terminal emulator. And of course it might be a fun exercise to just convert them by hand to JS or what have you.

[0]: https://github.com/mist64/cbmbasic

Happy that it could get the juices flowing :) The chosen implementation for your project certainly depends on what "vibe" and level of authenticity you're looking to achieve. I'm a huge fan of WebAssembly simply because the idea of writing web-native code in a language of my choosing makes the little computer scientist in me giddy.

That's not to mention the wealth of existing code with potential to be ported to this universal medium; for example, a project porting vim to WebAssembly was posted to HN just over a week ago[0] which reignited my interest in pursuing this avenue further.

[0]: https://news.ycombinator.com/item?id=17487936

It is my understanding that QB64 [1] compiles through C++, although I haven't tried it myself. They in theory support a superset of QBasic, and you could compile the C++ generated files using emscripten (again, in theory).

[1] https://en.wikipedia.org/wiki/QB64

They are active on Twitter as well, https://twitter.com/QB64team.
Oh man, compiling to WebAssembly was exactly what I was thinking while reading the article. :)