What is the most versatile programming language?

The most versatile language is obviously assembler. Since it defines the semantics of any language, it is suitable for any programmable application. Except that there are different assemblers, depending on the processor architecture. So, versatile but not universal.

For interpreted/compiled languages, we cannot talk about their versatility if they do not allow to write a kernel efficiently. Without a kernel, there are no applications! Neither desktop, frontend, backend, or other volatiles … Nor even compilation.

C allows to write an efficient kernel, it’s normal it was defined by K&R for this purpose. And as it is universal (independent of the processor architecture), it is a good candidate.

In fact we can observe that almost all current operating systems are written in C (or one of its extensions). On the other hand, in almost all application domains C or C++ is commonly used. It is also remarkable that the syntax of C influences most of its main competitors, except Python.

The C/C++ language is thus, in fact, the most versatile.

But there is a domain that escapes C/C++ and all compiled languages : “scripting”, that is to say the “programming of the use” of an application. This is a domain where diversity reigns: SQL for database systems, Javascript for web browsers, shell for operating system control, VBA for Office, PHP for web servers, … Python, lua, Lisp, … Some of these scripting languages have a domain of application that goes far beyond scripting (for example Python, Javascript and Lisp), but none of them allows, to this day, the efficient writing of a kernel.

Personally, I’m leaning towards C and C++ languages. Besides OS (Windows, ..), a huge number of desktop applications are in C/C++. And that, in all domains. But, clearly, the trend is moving towards Java, Javascript, Python… some of which are written in …. C

In answer to Philippe’s comment…

Either we don’t have the same definition of versatility or we don’t have the same sense of humor. For me, this is indeed not a joke. For the rest, let’s consider that C is a subset of C++ (even if I’ll hear some purists howling at the wolf). But let’s stay high level !!!

  • OS: Windows is essentially in C++ , Max OS partially, Symbian OS is written in C++, just like Apple iPhone iPod Touch and iPad OS . Linux is written in C. The Android kernel is written in C/C++.
  • Browsers: the most used browser (Google Chromium) is written in C++ (open source by the way) Other Google applications are also in C/C++. Windows Explorer, Safari and FireFox are written in C++.
  • Office Suite: Word, Excel, … are written, essentially, in C/C++. LibreOffice is mainly written in Java while Corel Office, Apache OpenOffice are written in C/++.
  • Database: Oracle, MS SQL Server, IBM Db2, MongoDn, Mys SQL (more than 100 Million copies in the world) are written in C/C++. SQlite, which is used by hundreds of millions of people, is written in C with a C++ wrapper. Financial, telecomm, government, health, web databases are based on these libraries
  • EMail: ThunderBird, Outlook and Lotus Notes are written in C++. The big standard SMTP libraries are written in C/C++.
  • PDF documents: most Adobe applications are written in C++. Many PDF utilities available as freeware are in C++.
  • Linux distribution: CDE Desktopn, and KDE are written in C++
  • Games: the list of games written in C++ is so long that it is impossible to close it (DoomIII, StarCarft, Warcarft, Kings Quest, Football Pro, …..)
  • Java: the Java VMs are written in C++. It’s quite funny to see that applications like Java need C++ kernels to work
  • Fligh Similator: FlightGear is written in C++
  • MultiMedia: Photoshop, Illustrator, WinAmp, VLC, … are written in C/C++. The main graphic libraries are written in C.
  • Scientific and mathematical software: Matlab is written in Java for the user interface and in C/C/++ for the core software
  • Telephony: most large companies use C++ applications
  • Industrial automation: the OPC protocol (used in millions of industrial systems) is written in C/C++. It allows to connect incompatible machines in a transparent and high performance way. Personally, I have developed a freeware OPC client (TGMDev Genesis) in C++ based on these libraries.
  • Text editor: Notepad++, the best freeware in its category, is written in C++.
  • Compilers: compilers are often, at least originally, written in C/C++.
  • Embedded systems: most of the car technology is based on firmwares written in C/C++: data display, brake management, sensor management, tire pressure detection, cruise control, airbag, …
  • Industrial instrumentation: many instrumentation firmwares (which allow to configure the equipments) are written in C

The list could be extended almost to infinity but it would become really, really long. It is, in my eyes at least, a beautiful image of versatility.