There are different levels of editors that programmers use while writing their programs. I’ll explain a couple.
Interactive shell - you write out a single line of code and see the result. Great for experimenting, but these can get tiring for real programs. These are also called REPL (Read-Evaluate-Print-Loop). E.g., most built-in interactive shells for programming languages. For Python, just type
pythonwith nothing else, and web browsers have a js shell on their dev tools (F12).
Text editor - these are for writing out programs as files. You write out the entire program and then execute it. These often have syntax highlighting and some special language support. Generally, these are quite simple and barebones. E.g.
IDE - stands for Integrated Development Environment. These have file exploring, terminals, code editors, generators, git, and many other tools programmers use in one application for high productivity. These can be heavy and confusing if you don’t get what they’re doing. E.g. VSCode, Visual Studio, PyCharm, IntelliJ
Notebooks - These are interactive shells where you can execute multiple lines at a time (generally 4-5). These are primarily used for statistics, machine learning, and other data work because they can show plots and tables very nicely. We’ll use these when we get to data work, so don’t worry about this yet. E.g., R Notebooks, Jupyter Notebooks.
We picked Visual Studio Code since it is a bridge between text editors and IDEs. It isn’t the heaviest in terms of features, and you can use it as a plain text editor pretty quickly and take advantage of IDE-like features. It also works great with
ssh systems and will be helpful for many UIUC CS classes. VSCode is a good starting point for exploring the wide variety of programming tools out there.
The language support for
TypeScript is quite strong, and there are multiple extensions that can help you out as well.
Follow the instructions here and web search any specific errors you find. Feel free to ask around on the forum if you’re still stuck.
Opening VSCode can be done like any typical application or by typing
codein the command line. I usually give it
.as an argument to open the IDE in the current folder.
$ code . $
Create a new file in the folder. You can click on the name of a folder (if any), and it will show a bar with a create file button. You can also try Control/CMD+N to make a new file and then pick
Pythonas a language.
Code Here’s an example of a program. Type this out. You can write any Python program this way.
Save. Hit Command+S on your keyboard to save the program. VSCode also has autosave which I think everyone should enable unless they have a good reason not to.
Run your program. You can execute any Python program using
python <name of file>or
python3 <name of file>, depending on which version of Python you’re using.
$ python hello.py Hello, World! $ python3 hello.py Hello, World!
Which shows the output
VSCode has many more complex use cases, and the internet is an excellent place to find good tutorials. Honestly, I think most of it you can learn as you go from trying things yourself, though.
VSCode is also nice because of all the extensions it has. Feel free to explore around but here are a few recs from us.
Rainbow Brackets - very useful in matching brackets and dealing with nesting
Python Official support - a collection of helpful python things
TabNine Autocomplete - an experimental AI-based take on autocomplete. The normal VSCode one is pretty good, but this might work nicely for some people.
Write a program that adds two numbers which are collected via user input on VSCode. The point of this
is to give you practice using the editor. Remember that in Python, we use
input() to collect keyboard input.
The output should look something like
Enter the first number: 5 Enter the second number: 20 The sum is 25!
Contributors: Harsh, Maaheen