Science and technology

5 methods to study C programming on Linux

There are many theories about why the C programming language has endured for so long as it has. Maybe it is the austerity of its syntax or the simplicity of its vocabulary. Or possibly it is that C is commonly seen as a utilitarian language, one thing that is rugged and prepared for use as a constructing materials for one thing that wants no platform as a result of it is going to be its personal basis. C is clearly a strong language, and I feel its longevity has a little bit one thing to do with the way in which it serves as a springboard for different common applied sciences. Here are 5 of my favourite applied sciences that make the most of and rely on C, and the way they’ll every enable you to study extra about C your self.

[ Download the eBook: A guide to tips and tricks for C programming ]

1. GObject and GTK

C is just not an object-oriented programming language. It has no class sort. Some people use C++ for object-oriented programming, however others stick to C together with the GObject libraries. The GObject subsystem supplies a class construction for C, and the GTK challenge famously supplies widgets accessible by means of C. Without GTK, there could be no GIMP (for which GTK was developed), GNOME, and a whole bunch of different common open supply purposes.)

Learn extra

GObject and GTK are glorious methods to start out utilizing C for GUI programming. They’re well-equipped to get you programming graphical purposes utilizing C as a result of they accomplish that a lot of the “heavy lifting” for you. The courses and knowledge varieties are outlined, the widgets have been made, and all you must do is put all the pieces collectively.

2. Ncurses

If GTK is greater than you want, you would possibly resolve a terminal consumer interface (TUI) is extra your velocity. The ncurses library creates “widgets” in a terminal, making a form of graphical software that will get drawn over your terminal window. You can management the interface together with your arrow keys, deciding on buttons and components a lot the identical manner you would possibly use a GUI software and not using a mouse.

Learn extra

Get began by writing a guessing game in C utilizing the ncurses library as your show.

3. Lua and Moonscript

Lua is a scripting language with entry to C libraries by means of a built-in C API. It’s a tiny, quick, and easy language with about 30 capabilities and only a handful of built-in libraries. You can get began with Lua for system automation, recreation modding and scripting, recreation growth with a frontend like LÖVE, or basic software growth (just like the Howl text editor) utilizing GTK.

Learn extra

The good factor about Lua is that you may begin out with it to study the essential ideas of programming, after which begin exploring its C API whenever you really feel courageous sufficient to interface immediately with the foundational language. If, alternatively, you by no means develop out of Lua, that is OK too. There’s a wealth of extra libraries for Lua to make it an excellent selection for all method of growth.

4. Cython

Lua is not the one language that interfaces with C. Cython is a compiler and language designed to make writing C extensions for Python as simple as writing Python code. Essentially, you may write Python and find yourself with C. The easiest potential instance:

print("hello world")

Create a setup.py script:

from setuptools import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("hello.pyx")
)

Run the setup script:

$ python3 ./setup.py

And you find yourself with a hiya.c and hiya.cpython-39-x86_64-linux-gnu.so file in the identical listing.

Learn extra

The Cython language is a superset of Python with assist for C capabilities, and datatypes. It is not more likely to immediately enable you to study C, nevertheless it opens up new potentialities for the Python developer trying to study and combine C code into Python.

5. FreeDOS

The finest approach to study extra about C is to jot down code in C, and there is nothing extra thrilling than writing code you may truly use. The FreeDOS challenge is an open supply implementation of DOS, the predecessor to Windows. You might have already used FreeDOS, both as a helpful open supply technique of working a BIOS updater, or possibly in an emulator to play a traditional pc recreation. You can do much more with FreeDOS than that, although. It makes a super platform to study C with a set of instruments that encourage you to jot down your personal instructions and easy (or not-so-simple, if you happen to choose) purposes. Of course you may write C code on any OS, however there is a simplicity to FreeDOS that you just would possibly discover refreshing. The sky is the restrict, however even at floor degree, you are able to do some amazingly enjoyable issues with C.

Download the eBook

You can study extra about C in our new eBook, and extra about C on FreeDOS in our eBook. These are collections of programming articles that will help you study C and to reveal how one can implement C in helpful methods.

Most Popular

To Top