Hacker News new | ask | show | jobs
by 19wintersp 1663 days ago
It's a read-only "IDE" of sorts; it's effectively a disk image stored in the cloud, which when run will create a VM and send the output back to you. If you create an account, you can fork that repl to create your own editable version of it, and access the full IDE.
1 comments

Yes, but, to quote Paul Buchheit, how does it *actually* work? What is the non-handwave-y explanation?

> "IDE" of sorts...*effectively* a disk image...a VM (what kind?)

If you want a fuller explanation, I'll just ramble about some random bits. Replit will let you create an account, with which you can create "repls": on their own, they are the "disk images" I mentioned; they store files and a few other bits on Replit's servers. You can open this repl if you own it, and edit it in the in-browser (Monaco-based) IDE. Because you own it, Replit will spin up a VM on its servers to handle your session. Your changes sync in real-time with the permanent files in the repl, as well as the live (and ephemeral) filesystem of the VM. All of this happens over the WebSocket-based protocol I mentioned. What you're seeing with this post's link is a repl owned by someone else; in such a case, you see the "Spotlight View", which is read-only. You can fork it to create your own copy of the repl, which you can edit. The list of files is a read-only view of the repl's files. When you run it, it'll spin up a VM similarly to how it does for you with the IDE. The VM I've been mentioning is a restricted Docker container running on some GCP container instances, managed by Replit. It runs Ubuntu 20.04 LTS (I think) if that's what you want to know. The desktop you see when you run this post's link is a VNC connection to a Fluxbox desktop on the VM. The console is sent from the VM to your browser (again, all of this is over that WebSocket protocol) and rendered by xterm.js. Overall it's a bit of a messy system, and there's quite a few other things not mentioned; they'll occasionally talk about this on the blog (https://blog.replit.com/). If you want something more specific explaining, I'll probably do a better job at that.
I think the OP is looking for an explanation that would allow him to know the behavior of the program if he edited the code.

1. The option menu on the outer emulator window (File, Edit, Snapshot, Settings) is some kind of retro operation system (not the inner x64, and not ubuntu). What is it? Is the code I'm writing being executed in this operating system?

2. What VNC program is running a retro operating system in a docker container and why is it so slow?

3. What is the VNC client (security!) and what can I, as a developer, do when things like the VNC client dimensions go wrong, as they do in this example?

The problem with developing on a closed-source code-running platform is that in the end, there will be an error at a layer of abstraction you don't have access to. You've done an excellent job of piecing it together from the blog posts and "?debug=1" hack, but they need to make your job easier.

1. It is an emulator program that has nothing to do with Replit, it is just being run on Replit.

2. To repeat, the VNC program is not running the retro OS, that is the emulator. The emulator is a program which runs on Linux and opens a window to show you the emulated computer's screen. That program is being run on Replit, and you can see the screen because it is being connected to you via VNC. I can't answer for why it's slow; that could be the repl, the VNC connection or the emulator itself.

3. The VNC client is no-vnc (I think) and is encrypted. If there's a bug with it, report it to Replit.

The whole point of Replit is to abstract all of this; at the end of the day it just gives you a browser interface to a VM in the cloud, with a filesystem you can save to between sessions. You just interact with it as you would any other Linux system, as all of these layers of abstraction you don't have access to are just providing this simple interface. You don't even interact with anything outside, so there is absolutely no point in using it when developing anything other than for the Replit system itself.

The problem is that there will always be bugs, and you can't abstract away details unless you provide a clear and consistent interface. Replit neither provides an exact spec for how their system works, nor open-sources their codebase to let developers read how it works. There will be cases when it's impossible to know, "is this is a bug?" That's the definition of undefined behavior.