Introduction to KotlinProgramming Practice TutorialsThe command line

The command line

When I started programming, there were no graphical displays. All computer input and output was done using text.

A computer was shared by many users. Each user was connected to the computer from a terminal (which is called this way because it is the endpoint of the connection from the computer to the user).

The earliest terminals looked like a combination of a printer with a keyboard. (When I was in middle school, I was sometimes allowed to play with a computer that used such a printing terminal.)

A printing terminal

The printers were later replaced by CRT displays that could typically display a matrix of 25x80 characters (the ASCII alphabet with letters, digits, and some special graphical characters).

A terminal with CRT display

Users interacted with the computer by typing a command on the keyboard. The computer responded by "printing" the output of the command on the terminal.

That's where the name of the Kotlin function println ("print line") (or print in Python, or printf in C) comes from—a long time ago output was really printed on paper.

The first home computers, like the Commodore C-64, were still text-based. When the IBM PC came out in the early 1980s, it used a text-based operating system (MS-DOS) until Windows 3.1 appeared, about 10 years later.

In graphical user interfaces, which became wide-spread about 25 years ago, users interact with the computer by clicking with the mouse. That looks easier than writing textual commands, but it is also much more limited. You can express commands in text that perform quite complicated operations that would take you hundreds of mouse clicks to do by hand. And therefore the command line is still commonly used in software development, and some other places: the standard interface used by travel agents, for instance, is a command line interface.

In this course we will run and debug Kotlin programs from the command line (at least at the beginning of the course).

To start the command line in Windows, press Windows+R (that is, hold the Windows-key and press on "R"). You should see a text field where you can enter a command. Type cmd to start the Windows command shell.

(If you are using Mac OSX or Linux, you can simply open the "terminal" program. Many of the commands listed below are different, though. For instance, instead of dir you should say ls.)

As always in this tutorial, don't just read this. Try it now.

Here is a list of the most important commands:

You can usually get help on a certain command by typing the name of the command followed by /?, for instance like this:
C:\Users\otfried\Documents>rename /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

Please try this now, and familiarize yourself with interacting with your computer through the command line. You can use the Tab-key to complete a filename, after typing the first one or two characters of the filename. You can also use the Up and Down keys to repeat previous commands.

Introduction to KotlinProgramming Practice TutorialsThe command line