[HN Gopher] Show HN: Atto - BASIC computer that runs in the browser
___________________________________________________________________
Show HN: Atto - BASIC computer that runs in the browser
Author : James-Livesey
Score : 43 points
Date : 2021-07-03 19:44 UTC (3 hours ago)
(HTM) web link (jamesl.me)
(TXT) w3m dump (jamesl.me)
| iddan wrote:
| When opening in iOS I get this great thoughtful message:
|
| atto can't run in this browser :(
|
| Unfortunately, your browser doesn't support the features that are
| required to run atto. If you're on mobile, try using atto on a
| desktop computer. Otherwise, please use the latest version of
| Chrome or Firefox, which are known to work with atto.
|
| If you're using Safari, then it's doubtful that Apple will ever
| implement the required features due to their constant reluctance
| to modernise their browser. If you work for Apple/are on the
| WebKit dev team, please implement lookbehind in regex so we can
| make atto work for everyone!
| montroser wrote:
| I share the frustration about lookbehind regex not being
| supported in WebKit.
|
| The XRegExp[1] library can be a great option in these
| situations if you're okay adding another dependency to your
| project to make up for Apple's negligent shortcomings...
|
| [1]: https://xregexp.com/
| jchw wrote:
| You just keep running into BS when it comes to supporting
| Safari. It's the only browser I'm aware of that's still
| maintained that has WebAssembly support but doesn't support
| streaming. It's been years. Not to mention terribly lagging
| support for free formats. I've heard the argument over and
| over that Safari is good because it's one of the main
| remaining contenders to Chrome, but as an iOS user, I'm just
| about done using Apple products on the whole due to Safari
| alone. It really does feel like the modern Internet Explorer;
| that thing you _have_ to support that is consistently worse
| than its peers. And I don't even want to bother with its
| extension ecosystem.
|
| edit: To be clear: I get not supporting ridiculous stuff like
| WebMIDI or WebBluetooth and maybe more obscure WebAudio
| features. But not supporting free formats? Not supporting
| WASM streaming, regex features, lagging on object insertion
| order for years? Safari feels like it only ever follows
| standards begrudgingly.
| James-Livesey wrote:
| Yup, you've pretty much summed up Safari really well there.
| I've come across sooo many annoyances when supporting
| Safari that I do wonder how the developers of the Apple
| website etc. don't get annoyed at the lack of useful
| support of their own browser themselves!
| [deleted]
| thom wrote:
| I dunno about anybody else, but I still read $ in my head as
| 'string'. Anyway, this is nice, not sure I can quite work out
| saving and loading, but there's enough here to be nostalgia- and
| kid-friendly.
|
| I've been very impressed with Gambas if anyone's looking for a
| more mature BASIC environment on Linux or elsewhere:
|
| http://gambas.sourceforge.net/en/main.html
|
| Bindings and UIs enough that it'd be a while before you really
| needed to break out into another language.
| zozbot234 wrote:
| Interestingly, the basic CLOAD and CSAVE instructions (load and
| save to tape) could perhaps be implemented most easily. You
| don't need anything other than the simple file handling you get
| in all browsers, via "open" and "save" dialogs.
| tyingq wrote:
| I imagine people would like a jsfiddle style way of saving
| things with a url that you could share with others though...
| James-Livesey wrote:
| It's all there! Try the `import` and `export` commands.
| Ctrl+O and Ctrl+S work as well, provided that the files end
| with .atto (unless you set your file open dialog to search
| for all files). `share` also lets you distribute your code
| via a copyable link, too!
|
| I was thinking it would be quite fun to hook up a USB floppy
| disk reader to my computer and save/load atto programs the
| oldscool way... Possibly could use one of those backup tape
| drives, too!
| James-Livesey wrote:
| Try using Ctrl+S and Ctrl+O for file save/load. There's
| `import` and `export` commands as well to do this, and there's
| even a `share` command to share your code via a URL!
|
| eg.
| https://jamesl.me/atto/?code=10%20print%20%22Hello%2C%20Hack...
|
| Edit: Funny to hear that you still read $ as string! Still kept
| that tradition in atto, though the use of $ on the end of
| variables is optional (variables with $ on the end will be
| casted to string, but sigil-less variables can be any type. %
| is used to cast to a number).
| thom wrote:
| Awesome stuff, just stumbled on your Twitter bot too
| (apologies if that was premature!)
| voidnullnil wrote:
| Great, now when I search "atto" the search engine will bring up
| another thing I'm not looking for.
| gus_massa wrote:
| It's nice that it has instructions, but nobody read the
| instruction. tl;dr: type "run" to run the program.
| 10 print "Hello, world!" 20 goto 10 run
|
| Also: What is the tech stack? Which basic version are you
| emulating?
| James-Livesey wrote:
| I wanted it to be as lightweight as possible, with only a few
| support libraries to show the Markdown content for docs etc.
| It's all done with vanilla HTML/CSS/JS and I put the new
| JavaScript modules functionality to good use to make my project
| less messy/more maintainable. The BASIC version is actually all
| custom; it's my own style with a few additions/changes to
| normal BASIC, and it's all tokenised/parsed/evaluated/executed
| in my JS code.
| zupreme wrote:
| Forgot about 10 goto 10 eh?
| James-Livesey wrote:
| You should find it works! Once you type run, the caret will
| disappear as the program does nothing infinitely. Press Esc
| to break the program to carry on!
|
| But it should be 20 goto 10 if you want to print the same
| text again and again.
| tyingq wrote:
| Looks like their own basic interpreter. There's a list of
| keywords here: https://github.com/James-
| Livesey/atto/blob/main/commands.js#...
|
| There are some drawing commands, getpixel, etc.
| mattlondon wrote:
| Love the font and colours. Took me right back to the old spectrum
| days. I assume this was deliberate - good work!
| James-Livesey wrote:
| Thank you! That was exactly what I was opting for -- I was
| looking for a good terminal font for this project which is nice
| and rounded, and I came across Brass Mono, which seems to fit
| the job really nicely. Though it unfortunately doesn't contain
| all of the lovely characters from 80s machine charsets, it'll
| fallback to your system's monospace font so you can use any
| Unicode character you like!
| roywiggins wrote:
| Something has gone terribly wrong with the keyboard-handling,
| half the time it misses a keystroke, or doubles a keystroke, or
| has very noticeable delay.
|
| This is on Firefox. It doesn't seem to have those problems on
| Chrome.
| James-Livesey wrote:
| Interesting! I've just loaded it up on my latest Firefox and I
| see what you mean -- there's quite a lot of input lag going on
| there. I mainly develop in Chrome but I've tested this in
| Firefox before and it was alright. I better do a bit of bug
| fixing tomorrow!
| montroser wrote:
| I think it's not lag -- it's that on `keydown`, the value of
| `hidInput` doesn't yet reflect the new input from the pressed
| key. Seems like on `input` would do better for that event
| listener...
| bcrl wrote:
| The non-display of spaces in Firefox is disconcerting. CTRL-C
| doesn't work on the quintessential test of 10 print "Hello
| world" 20 goto 10
|
| Doing that on one list as 10 print "Hello world" ; goto 10
| doesn't work as the semicolon seems to be misinterpreted as
| part of the PRINT statement rather than separating multiple
| statements as most BASICs did. Edit: my memory was wrong - it
| should be :. It's been a while...
|
| The END keyword seems to be missing. Simple loops using IF
| don't seem to work, and I'm not sure why.
| krylon wrote:
| Same here on Firefox, I have not tried another browser.
|
| Makes me feel all warm and tingly with nostalgia, though.
| James-Livesey wrote:
| Glad to hear that despite the weird behaviour with Firefox,
| you enjoy the nostalgia! If it helps, if you want to write
| really long programs, it's possible to create .atto files in
| a text editor and then import them into atto by pressing
| Ctrl+O. Writing long programs in atto is nice, too (since you
| get the syntax highlighting), but of course it's somewhat
| hard in Firefox at the moment. Chrome/Chromium-based browsers
| work well with atto, though, since that's my primary testing
| target (Firefox second, then Safari third if I can be
| bothered with it!).
|
| Testing atto myself in Firefox seems to be consistent when I
| type in sentences, just that there's a bit of rendering delay
| which may feel a bit unnatural. Of course, it's hard for me
| to investigate how the problem manifests for you; but is it
| basically like this for you?
| James-Livesey wrote:
| Hi there! I'm the creator of this programming language. I've
| designed this language to resemble the style of the BASIC
| programming languages of the 80s, but with the modern
| functionality of today (syntax highlighting, rich editing, fast
| runtime, runs in browser etc.). It's a bit of a side project of
| mine, but ultimately I think it's a great way for beginners to
| learn programming, and for more advanced users to tinker with!
|
| You can get help by using the `help` command, and we have many
| tutorials to get you started with, in addition to a command
| reference. Whilst our documentation is still work-in-progress,
| your feedback is most welcome -- let me know what you think is
| good about the documentation, but also what you think could be
| improved, too.
|
| atto is open source, so feel free to check out (and maybe star!?)
| the GitHub repo: https://github.com/James-Livesey/atto
|
| There's also an official Twitter account (with a bot coming very
| soon(tm) -- edit: it should all work now), so be sure to follow
| it for updates: https://twitter.com/codeurdreams
| ncmncm wrote:
| The only things you really need to implement in a browser BASIC
| are PRINT, GOTO, and FOR, because that is all anybody will type
| into it to try it out. (Some use GOTO, some FOR.)
|
| I don't know the name for that sort of completeness.
___________________________________________________________________
(page generated 2021-07-03 23:00 UTC)