What is a Terminal in Coding

A terminal – sometimes called the “command-line” or “command prompt” – is a text-based interface that you can use to perform many commands. As well as providing users with the ability to efficiently navigate filesystems and automate menial tasks, it also can serve as an ideal environment for coding, thanks to how rapidly you can perform tasks.

My name is Jamie Lewis. Having first picked up Linux over a decade ago, I now use the terminal every single day. At an earlier age, I also dabbled with DOS and the Windows command prompt, and it’s fair to say that I found it pretty intimidating!

This article will give you an overview of not just what the terminal is but also how you can use it, as well as its role in the world of coding.

So get yourself a coffee, relax, and prepare to be informed!

What is a terminal or command line?

As we covered above, the terminal is just your computer’s command-line interface (CLI). You could also refer to it as a “text-based” environment, but CLI is much more common.

Way before the graphical user interfaces (GUI) of the Apple Lisa and Windows 3.1, personal computers were still too primitive – not to mention the fact that they were also incredibly constrained in terms of their processing power – to provide a nice, intuitive interface for users.

As computers evolved, the GUI became the status quo regarding how its exponentially larger user base would interact with their systems. This was a good thing, as it meant that you no longer had to be a “tech guy” to become competent in utilizing your operating system.

While it’s (for the most part) been superseded by the GUI, the terminal has continued to persevere; in Windows, Mac (from OS X onwards), and Linux especially, the command prompt can still be easily accessed to allow quick navigation of filesystems and operations. 

What Can You Use Terminals for?

Today, the terminal is still used for a broad spectrum of tasks. Many of today’s “power-users” have incorporated the terminal into their workflow so extensively that they can efficiently perform tasks it was never supposed to be used for in the first place. These include:

  • Browsing the web– The most popular terminal-based browser is Lynx, and it does a fine job of rendering popular websites such as Wikipedia and CNN lite.
  • Spreadsheets– Yes, believe it or not, there are actually nice spreadsheet editors which exist entirely within the terminal environment. The most popular of these is SC.
  • Play Games– You can play many of the most popular roguelikes (like Nethack and Brogue) in the terminal. Alternatively, you can enjoy simpler Tetris and Pong clones too.
  • Read eBooks– I used Benawi Adha’s EPR app for a while to read a book from the command prompt. You’d be surprised how enjoyable this can actually be!
  • Writing Code–  And last but not least, it’s a great environment to write code in.

There’s a plethora of other activities which you can perform from the command prompt, and a quick search of Github will lead you to many useful – and sometimes funny – discoveries!

So, What is a Terminal in Development?

When we use the term “terminal” in a development context, we’re talking about utilizing the CLI to edit code in a primarily text-based environment. The vast majority of people who like to code in the terminal also choose to compile and execute their code there, too.

Think about it: if you need to navigate your IDE with a mouse, it means having to visually locate options and actions, manually clicking on them, and waiting for new windows to load and render. The command prompt, on the other hand, allows you to access directories and options almost immediately.

As we mentioned earlier, so-called “power-users” of the terminal will use it to perform as many tasks as possible. This is also true for coding in the text-based environment, as you can easily script and automate your build processes without needing to navigate sub-windows to find the options you’d like to implement.

How do you write code in the terminal?

You can use the terminal to write virtually any text-based programming language; you can produce everything from C++ to MySQL and HTML using any of the myriads of terminal-based text editors.

For a quick start, you can start writing code in Nano and save it with the appropriate file extension (for example, “*.py” or “*.c”). This will be as usable as any file you produce using a GUI-based text editor.

If you want to start looking at a completely text-based coding environment, you’ll just need to ensure that you’ve installed the requisite software. Most of the time, when you install a new development environment on your computer, you’ll also have the terminal tools you need to get started right away. 

This is usually a painless process on Linux; you can type “python” in the command line to see if Python is installed; alternatively, “gcc” will let you know if your C compiler is ready to be launched from the prompt.

For Windows, it might be a bit more complicated. We’d recommend the following tutorials for setting up some of the more popular languages:

Another excellent option for Windows users is the Windows Subsystem for Linux. Setting up terminal development environments on Linux tends to require less configuration, so you might want to just set up a Ubuntu subsystem; it’ll require more work in the short term, but it will probably make your life easier!

Coding Terminal Linux – Which is Best?

An almost endless array of terminal emulators exists within the Linux software ecosystem. 

For new users, the default configuration – whether the GNOME terminal emulator or something else – will usually be enough to get you started with working this way. This will allow you to get used to the commands and usage while avoiding having to use any overly-complicated features.

When you’re ready to speed things up, though, I’d strongly recommend looking at some of the more capable options; for me, Terminator’s ability to split the terminal horizontally and vertically (to create multiple sessions) has always been incredibly useful.

Another popular option is tmux, which allows splitting and includes some cool additional features such as advanced scripting capabilities.

If you get really serious, you might want to go ahead and look at a tiling manager such as i3-gaps. These can be particularly useful for coders, as they allow the user to easily switch between – or simultaneously view – multiple terminal windows, meaning you can have one for editing, one for building, one for testing, and so on.

Coding in Terminal Mac?

For an operating system that has historically always emphasized the importance of easy-to-use, graphically-driven interfaces, macOS still has a pretty competent terminal.  In fact, as Mac is based on the Unix OS, many of the same commands that you can use in Linux also work in the exact same way. 

The default Terminal application will still be more than sufficient for new users; once you’ve got the basics down, though, it’s definitely worth looking at some of the more-capable third-party options on offer.

For example, iTerm2 by George Nachman brings many of the common features found in the more-popular Linux terminal emulators. It allows you to split windows, organize workspaces using tabs, and even easily access the terminal from any other window by simply hitting the F4 key.

It’s particularly useful to coders thanks to its autocomplete functionality (if what you’re typing looks like something you’ve entered before, a neat little dropdown will appear with suggestions you can quickly select), allowing you to avoid typing the same statements over and over. Likewise, its searchability will always be handy when you need to jump to a specific line during debugging.

Even better, iTerm2 is freely available to download (though we’d definitely recommend donating a few bucks to George if you find his software useful)

Another good option for mac users is Hyper, which bills itself as  “a beautiful and extensible experience for command-line interface users.” The neat thing about Hyper is how incredibly extensible it is; those of you with an interest in web development might do well to try this app out, given that it’s built using popular web technologies.

Closing Thoughts

The terminal provides a much more efficient way to control your computer using a text-based environment. While it inherently requires a significant investment of time and effort to learn to use, this is most likely going to pay off in spades as you use it to streamline your own workloads.

Leave a Reply

Your email address will not be published. Required fields are marked *