Reading

This article on talent is a good read I’ve sent to many.

It is targetted towards artists, but one thing you will realize that good programmers are not really that different from what process goes into making good artists and often the same advice works for both (like my sister has used programming advice to give to artists and is a very talented programmer herself despite being entirely art side).

Upgrade from the shell

So far you did everything in the shell. Which was nice, but you noticed how quickly it could get annoying and frustrating. Lukcily for you pretty much every single frustration programmers encounter they will always fix, so if you ever find one it’s pretty much always solved.

What all is there

There are different levels of tools that programmers use while writing their programs. I’ll explain a couple.

  • Interactive shell - what you were using so far, you write out a single line of code and see the result - great for experimenting but it gets old quick. The one we used was called IDLE. These are called REPL (Read-Evaluate-Print-Loop) as well.

  • 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. Ex. Nano, micro, vim, emacs.

  • IDE - stands for Integrated Development Environment - these have file exploring, terminals, code editors, tools, generators, git etc. and many of the tools programmers use in one application for high productivity. These are great and I love them, but I suggest against these for people starting out precisely because they do so much. I will get you moving up in that direction soon enough though. Ex. Visual Studio, PyCharm, IntelliJ

  • Notebooks - These are interactive shells but you can execute a bunch of lines at a time (4-5 generally), and these are mostly used for statistics, machine learning and other data work because it shows plots and tables very nicely. We’ll do some of this when we get to data work, don’t worry about this yet. Ex. R notebooks, Jupyter notebook.

What you will learn

  1. Micro - very simple and great to start with
  2. Vim - slightly more complex but a great text editor many programmers use.
  3. Visual Studio Code - a bridge between text editors and IDEs
  4. PyCharm - a full featured and very complex ide, once you’re pretty good at python you will really appreciate this

I’ll keep introducing these over time. Right now let’s learn micro.

Micro

Micro is based on a 1000x improvement from another standard text editor called nano.

I like it because it’s quite simple yet it’s pretty decent for getting started without much of a learning curve. You can use simple keyboard shortcuts you are used to and simple mouse stuff. I like it for it’s simplicity.

Download

$ brew install micro

Note that when there is a $ in instructions it means run it in the command line.

Using it

  1. Opening it. We can open it anywhere saying micro <name of file>. If you don’t give a file name it asks you later.
    $ micro hello.py
    
  2. Code Here’s an example. You can write any python program this way
    print("Hello World")
    
  3. Save. Hit Command+S on your keyboard to save the program.

  4. Quit. Hit Command+Q and you’re back. If you forgot to save it’ll ask you y/n to decide if you want to save.

  5. Run your program. You can execute any python program using python <name of file>
    $ python3 hello.py
    

    Which shows the output

    Hello World
    

Exercise

Write a program that adds two numbers which are user input on micro. The whole point is to give you practice with this.

The output will look something like

Enter one number: 5
Enter one more number: 20
The sum: 25