- Run what’s called a REPL (Read–eval–print loop), sometimes called a “command-line” interface
- Use a terminal to run a program file
The terminal screenshot below demonstrates both:
You can see what I’m typing at each ‘prompt’, which on my machine is
[~/$]. First I start up the
REPL and run a simple
print() command. Then I
REPL and use a UNIX command
cat to create a little file which contains the same command:
print("I’m talking to Python from a file on my computer.")
There are fancier ways to work with Python, called
IDEs or “Interactive Development Environments” which are like programming editors which can also run code, but still, the two ways of programming demonstrated above are the primary way to interact with Python. It’s my impression that in the case of
R most people rely on
RStudio, which is an
IDE, but again, you’re either using an interactive
REPL or running a program file.
HTML document. So here is a tiny
<!doctype html> <title>A purple-able page</title> <h1>Click this page to make it turn purple!</h1> <script> addEventListener('click', () => document.body.style.backgroundColor = 'rebeccapurple') </script>
If you save this as a text file called
test.html and double click it, it should open in your default web browser. Clicking anywhere on the page should turn it purple. The line beginning
>>> myNewFile = open("my-new-file.txt", "+w") >>> myNewFile.write("Once there was a duck. 🦆\n") 25 >>> myNewFile.close()
And then we have a new file called
my-new-file.txt which contains the text
The lack of programmability of Web pages made them static, text-heavy, with at best images in tables or floating on the right or left. With a scripting language like JS that could touch elements of the page, change their properties, and respond to events, we envisioned a much livelier Web consisting of pages that acted more like applications.
But the way you progam, by running programs “inside” the browser was just straight-up weird to an Python or R programmer.
Here is a convenient chart summarizing my personal opinion of both:
Deno is awesome, and it’s sooo much easier to use than node, and I recommend that anyone who wants to do more command-line style stuff check it out. Maybe we’ll do a workshop on it.
Check this out too: