Search code examples
javascriptv8

How to compile Javascript console application locally?


I am a beginner in Javascript, I decided to practice Javascript by problem solving using it, I found an online judge that accepts Javascript V8 4.8.0 code.
So, I searched online to get that version of Javascript V8 on my machine, but I couldn't find any easy way, All the pages were explaining how to build it, and it seems to be a process that I don't need to go through.

Is there an easy way to compile and run command line apps written in Javascript on my machine?

Note: I don't want to use node.js because I tried using it's I/O and as a beginner I think it is complex in some way.

Update: I found that package manager pbox.me which provides a version of V8 JavaScript Engine and I managed to install it.

Yet another problem appeared: whenever I try to run a js file writing d8 myfile.js in command line nothing happens as if it is an empty program, knowing that I tryied to d8.exe file and it is working, and I made sure the PATH is inserted in the environment variables.

What am I doing wrong?


Solution

  • The easiest way to get started with JavaScript is probably to use it in a browser. You can type simple things directly into the browser's JavaScript console (check the menu); or you can embed your code in a simple HTML document.

    If you want, you can even pretty easily implement the readline()/print() functions, so you can pretend to be doing stdin/stdout based I/O: just read from an array of strings, and send output to console.log (or create DOM nodes if you want to be fancy and/or learn how to generate dynamic website content by hand).

    Side note: V8 4.8 is severely outdated, don't use it to execute code you haven't written yourself.