Recent Changes to JavaScript -> Node.js
h
timmy_i_chen (946)

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.

You are viewing a single comment. View All
themaka (177)

@jmmarco We understand it may not be what everyone wants, but for now you can fork this JS repl:
https://repl.it/@themaka/Native-JS