Comp 101 Interactive vs. Stored Programming

Interactive vs Stored Programming

Interactive Programs

Interactive programming is a great way to test out new ideas or try different pieces of code without having to actually create a new project in VS Code.

In this class to program interactively navigate to the class REPL (in Google Chrome!) and then press Control + Shift +J if you're on Windows or Command + Option +J if you're on Mac.

This will open a console where you can run JavaScript code interactively!

But wait... what's a REPL?

Glad you asked!

REPL stands for Read, Evaluate, Print, Loop. In this process, the computer takes your command (read), processes it (evaluate), gives you back the result (print), then lets you enter another command (loop).

Interactive programming is nice if you're testing things out or just want to try some new things. The catch with interactive programming is that once you refresh the page, your previous commands will be lost! If you're writing code you think you might want to come back to at some point, writing stored programs might be a better choice than interactive programming.

Stored Programs

When you write a stored program, you're writing and saving your code in a file. Stored programs, unlike interactive programs, won't give you immediate results with each line of code you enter. The computer only evaluates your code once you save and execute the file. Once you do this, you'll get the results of all the code you entered, even though the computer still runs through each line individually. 

When you are in the process of writing a stored program, you're telling the computer each step of what you want it to do, but the computer only does these commands after you save the program and tell it to execute.

After you save your program and run it, the computer actually follows the directions you wrote and does what you specified. Each time you restart the program, the computer starts from the beginning and evaluates everything in the file all over again.

The good thing about stored programs is that you can save the file so you won't lose your code and can come back to it. All problem sets will be done as saved programs.