5 ms·
Cool see this here! But let me provide some context: This is a program PG wrote with his kid. He asked me to build into Repl.it a classic Basic implementation a
by amasad 6y ago
Cool see this here! But let me provide some context: This is a program PG wrote with his kid. He asked me to build into Repl.it a classic Basic implementation and make it really easy to do graphics programming. So I wrote an interpreter and called it pg-basic
Try it here: https://repl.it/l/basic https://repl.it/l/basic
Docs: https://docs.repl.it/misc/basic https://docs.repl.it/misc/basic
Interpreter source code: https://repl.it/@amasad/pg-basic https://repl.it/@amasad/pg-basic
PG's tweet: https://twitter.com/paulg/status/1256526589300441093 https://twitter.com/paulg/status/1256526589300441093
However, we realized that we can do a much better job on syntax and other features. So in collaboration with PG, we're evolving the language to make it more expressive and cleaner without losing the magic that makes Basic a great introductory programming language.
- marcell 6y agoThanks for making this, I'll try it out. I've been trying to do Pyxel (via repl.it) with my kids. They really like coding that draws things, and I really appreciate how easy it is to get started. Downside is that some of the syntax is a bit confusing. Kids have a hard time with whitespace for indent, and the Pyxel draw loop is not really intuitive for them. I'll try out this Basic interpreter to see if it's a bit better for them.
- amasad 6y agoYes try Basic. But even if you want to use Python, I would started with our Python Turtle environment which would be a lot less confusing than Pyxel: http://repl.it/l/python_turtle http://repl.it/l/python_turtle
- parhamn 6y agoThats awesome! Have you ever written a blog post or anything about the how repl.it works? Its not typically a JS reimplementation right? I always assumed a container/nsjail.
- amasad 6y agoYes so regardless of what language or where the language runs, we give you a container, inside that container we drop in a server that's responsible for most of the functionality including editing, collaboration, hosting, etc. A little about that here: https://blog.repl.it/collab https://blog.repl.it/collab The IDE is built on top of a window-tiling manager abstraction we built in React.js: https://blog.repl.it/ide https://blog.repl.it/ide Now, as for languages, most of them do run inside the container, which is built from our base image polygott (https://github.com/replit/polygott https://github.com/replit/polygott). However, a select-few are better suited to run on the client. We have a client-side jail called: replbox (https://github.com/replit/replbox https://github.com/replit/replbox). Basic, for example, runs on replbox because I wanted to graphics to be instant. For something like PyGame or LOVE frameworks we had to go with VNC streaming but that's not ideal for obvious network reasons. There is a lot more to it -- it sometimes feels like building an entire city -- and you can find some more posts on our blog: https://blog.repl.it/ https://blog.repl.it/ (which incidentally is hosted on Repl.it).
- qnsi 6y agopg and amasad colab is like a childhood dream of seeing Batman and Robin
- amasad 6y agoHa!
- RodgerTheGreat 6y agoFor many years I've recommended Repl.it for beginners and used it in a pinch from public computers. It's a great service that makes programming more accessible. Aside from celebrity tweets, what is your process for adding support for a new language? I've observed, for example, that Repl.it wraps some open-source interpreters like ngn/apl and JS-Forth.
- amasad 6y agoAwesome -- thank you! We wrote about the process it takes to add a language here: https://blog.repl.it/elisp https://blog.repl.it/elisp But also, since we announced `.replit` which allows you to configure the run button you can pretty much build your own environment without waiting for us to support it natively: https://docs.repl.it/repls/dot-replit https://docs.repl.it/repls/dot-replit What are you looking to add?
- RodgerTheGreat 6y agoDoesn't look like you have K. I'm the author of a JS-based K implementation[0], and ngn has another which is implemented in C[1]. Many of my projects involve making browser-based development environments or compilers in one form or another[2]. [0] http://johnearnest.github.io/ok/index.html http://johnearnest.github.io/ok/index.html [1] https://bitbucket.org/ngn/k/src/master/ https://bitbucket.org/ngn/k/src/master/ [2] https://github.com/JohnEarnest/Octo https://github.com/JohnEarnest/Octo
- russellbeattie 6y agoThat's crazy! I hate to be critical about something so well intentioned, but I've taught young children to program and they do perfectly well without line numbers! What is PG thinking? Nostalgia is great and all that, but this is just teaching bad habits in an extinct form of programing. (That said, teaching kids using Scratch, which doesn't give them any real idea at all of how important syntax and spelling is, nor how computers normally make loops and subroutines, isn't all that great either.)
- amasad 6y agoWe just started from Basic because a) it's a good starting off point and b) it's good to be compatible with something so many people are familiar with. However, now are evolving the language towards something more modern. To that end, line numbers are optional :-) Here is the same program with no line numbers: https://repl.it/@paulgraham/repeat-nolines https://repl.it/@paulgraham/repeat-nolines
- pvg 6y agoSince this is the grousing thread, the thing that jumped out at me was the JS array in place of a BASIC-like array - 'array' is maybe a better name than 'DIM' but the declaration of a multidimensional array seems less clear and the semantics of the JS array are different enough that it would be confusing to someone, say, typing in old BASIC code they dug up on the internets.
- ashleyn 6y agoIf anything, I would suggest looking to Microsoft Quickbasic for a model of how this can be potentially refined. Quickbasic itself was a refined version of 1980s Basics, it removed line numbers in favor of optional line labels and featured structured programming constructs like the SUB/FUNCTION statements. The IDE was an early rich development environment akin to Eclipse or Netbeans, which would do realtime syntax checking and allow the user to navigate code semi-visually (by listing functions in a dialog). All the while, Quickbasic had a "standard library" of sorts that made drawing graphics and playing (PC speaker) sounds relatively accessible for the beginner programmer. It still had its rough edges (string manipulation was godawful), so a straight port of Quickbasic idioms probably isn't in order, but as far as refining Basic to be a bridge between beginner and advanced, I still feel like it never quite had a proper successor.
- stevekemp 6y agoI hacked up a simple BASIC interpreter in golang a while back, tons of fun. https://github.com/skx/gobasic https://github.com/skx/gobasic I also added a simple HTTP-server, with a <textarea> inside it for writing your program. I figured that server should be called "visual basic" since it allowed you to plot graphs, etc ;)