Categories
Tools

Basic Tools for Programming — Text Files and Command Line

Spread the love

Building software requires some basic tools. The most basic building blocks are the code.

In this article, we’ll look at how we use plain text for code and other things of value in a software project.

The Power of Plain Text

Plain text is the most transportable file format out there. It’s usable by any operating systems without any program most of the time.

We can open it, edit it, save it, and transport it to different computers and use them.

They can also be checked into source control systems so that we can diff them, review them, merge them, and do many other things with them.

Plain text is just a bunch of printable characters in a form that can easily be read and understood directly by people.

They can be both structured and unstructured. For instance, HTML and JavaScript code have standardized structures.

They’re a higher level than straight binary encoding which are derived directly from the implementation.

Text files use standard character sets to store text data. ASCII and Unicode are standard character sets that are used today.

However, they do have some drawbacks. They may take more space to store than compressed binary files and they may take more processing power to interpret and process.

However, these drawbacks are pretty negligible in today’s world since computing power is plentiful.

The Power of Text

Plain text files have lots of benefits like their portability, their insurance against obsolescence and easier testing.

Human-readable text files will outlive all other forms of data and apps that created them.

As long as the data survives, we’ll be able to use them potentially after the apps that made them become obsolete.

Character sets like ASCII and Unicode are long-living standards and they’ll likely outlive the lives of humans.

Therefore, they can be used as long as they’re stored somewhere. Any popular operating systems will have programs that can read and manipulate them.

Also, any development environment or text editor can run code from text files. This is not so much with binary code files, which probably requires the program that generated the binary to build and run the code.

Storing everything in text files means that restoring things is just as easy as copying some text files to restore a crashed system if needed.

Binary files, on the other hand, will be much harder to deal with. For instance, restoring text-based configuration files is much easier than restoring settings in the Windows Registry for example.

Storing configuration in text files is a great advantage of using UNIX based systems for computing rather than Windows.

Text files can also be checked in source control and the history of the change is tracked easily.

This makes reverting text file changes much easier than binary. Reverting can’t be done easily with binary files if at all.

Diffing text files is also much easier than with binary files. Therefore, text files are also much more beneficial when we need to compare the content of different files.

Text files also make testing easier since they can easily be read by anything either with a program manually or programmatically.

Text files are the most commonly exchanged file type and there’re standards to structure them so that everyone’s on the same page.

The same characteristic don’t apply with binary files. We can’t run Windows programs on Linux without some kind of emulator or Windows API layer for example.

Working With Text Files in the Command Line Shell

At least once in a while, we got to work with text files without a GUI for configuration, automation, or any other purposes.

This means that we got to learn to manipulate with command line text editors.

Programs like nano make things easy for us even though we’re using the command line.

It’s a great text editor and we can live with it. Other people also swear by vi or vim to edit their text files.

That’s another benefit of text files. It can easily be edited without loading any heavy GUI that gets in our way in servers.

There’re many things that we have to do with text files in the shell that we can’t do from GUI portions of operating systems.

Commands like touch , tail , are commands are creating a new text files and chasing the tail of a text file respectively.

Conclusion

We have to know the power of text files if we’re using a text editor.

Code files are all text files, so we got to create and edit them often. They’re great because they can be checked into source control easily.

Also, they can be compared and reverted easily since their change history can easily be tracked.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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