Updates from the Repl.it team about the product

← Back to all posts
Recent Changes to JavaScript -> Node.js
timmy_i_chen (1180)

Recent Changes to JavaScript -> NodeJS

We recently made a change that redirected new JavaScript repls to create Node.js repls instead. We recognize that this behavior may come as a surprise, and may cause some frustration when using Repl.it with JavaScript. In this post, we'd like to provide our reasons for making this change, and give workarounds for those who require Browser JavaScript for their work.

At Repl.it, we strive to provide the best experience for our users. To a beginner learning JavaScript, there may not be a big difference between using JavaScript and Node.js, as far as the language itself goes. However, on Repl.it, there are a few key features that make using Node.js the preferred environment:

  1. Package Support: Node.js supports npm package searching and installing on the fly. You can search for any package and add it to your project, generating a package.json file for you, where you can then import it into your program. More on that in our packager announcement.

  2. Consistency: When using our Browser JavaScript repl, it uses whatever flavor of JavaScript your browser is using. This means that a Browser JS repl run on one machine may not run on a different machine, or it may behave differently. However, with Node.js repls, since it runs on a VM in the cloud, behavior is guaranteed to be consistent across browsers and programming sessions. Furthermore, you can safely share it with others, knowing that their experience will be identical to yours.

  3. File Management: Node.js repls allow for users to create files and folders and interact with them, whereas browser JavaScript repls don't. This allows for more versatility in the programs you create, and for more growth in your learning.

  4. Infinite Loop Protection: Finally, if you accidentally write an infinite loop (we've all been there), your browser won't be locked up, since the code is not running on your machine.

So what happens if you need the web browser API, or if you need to test JavaScript that will run in the browser? You can create HTML repls to achieve that. The added benefit of using HTML repls is that you can search and import packages such as jquery, lodash, or moment.js, and then test out those functions within your script.js file. You still have a repl to interact with in the console tab.

One thing you might miss from the JavaScript REPL is the prompt API. While we know that prompt is convenient, it's considered an antiquated API and its use in modern web development is generally frowned upon. If you'd like to do I/O in the node.js REPL you can do so using the readline-sync package which we pre-include in our Node.js image. You can try an example here: https://repl.it/@timmy_i_chen/readline-sync-demo

We made this change because we believe it will be beneficial to Repl.it users, both new and old. We welcome any feedback in the comments below, and we look forward to working with you in the future to create awesome projects.

CharlesLee1 (2)

Just a quick note - I use this to teach JavaScript to beginners. Infinite loop protection is definitely useful, but 1/2/3 are not important, and in fact just muddy the water for beginners. I'm teaching if/else statements, so really do not need to think about npm packages or other files. I'm just trying to work through some basic examples, and the previous JavaScript repls were great for this.

I think a lot of people use Repl.it for classroom/beginner settings, so it'd be great if there was a way to go back. As of now, I just fork my old JavaScript repls. Please don't close that door :).

jmmarco (0)

Like @CharlesLee1 said, I also use this to teach beginners, and believe it or not, prompt was useful when creating simple programs that worked from the console. Once the students feel comfortable, we move away from using antiquated APIs like prompt and alert.

timmy_i_chen (1180)

@jmmarco how would you feel if we polyfilled those two functions to map to readlineSync.question and console.log?

jmmarco (0)

@timmy_i_chen Sure Timmy that could work. I just wonder, isn't just easier to bring the good ol' JS Repl back? I looked at the points you made, they're valid points. Still, if there's no performance impact for you guys, why not re-implement them? I think User Experience is what you should drive your decision, unless there's a performance implication on your side.

Thanks for following up.

themaka (187)

@jmmarco We understand it may not be what everyone wants, but for now you can fork this JS repl:

B0T (16)

YAY! nice stuffs!

gantr833 (163)

That explains it!