7

I am a Java developer, and I rarely write GUI program in C. However, I noticed that many GNU's projects, such as PSPP, R, Dia, etc., are written in C, instead of Java or C++.

I personally don't mind this, but I am really curious why GNU favors C so much. My understanding is that C is the one that supports the least in object-oriented programming, and today's CS education really emphasizes OOP, as OOP really makes codes more reusable. In this case, why would so many developers choose to develop in C instead of C++ or Java.

Does anyone know why GNU's software are so exclusively written in C? Do you think or GNU's software should be written in C++ or Java so that the source code could be more useful to people? Why or why not?

  • I guess for the same reason most Apache software is written in Java. – Random42 Jun 03 '14 at 06:45
  • 4
    It's debatable that OOP makes code more reusable, especially in practice but also in theory. But as whatsisname pointed out in his answer, it's a non-issue; all of the popular OOP languages were either unavailable or not mature at the time. That aside, where a higher level language is needed, GNU's official recommendation is to use Guile, which is their Scheme interpreter. From my understanding this came about from the successful use of Lisp in Emacs. – Doval Jun 03 '14 at 11:15
  • @Doval: Good observations! So the GNU approach is "Use C for the low-level stuff and Lisp for the high-level stuff". Both are standard and free. It makes sense. – Giorgio Jun 03 '14 at 17:36
  • In addition to whatsisname's answer, I'd like to add that C is generally used for a lot of low-level code such as what you might find in OS tools. Since all the system calls are "C-style" calls anyway, you don't benefit from C++ a whole lot anyway. Also, C is considered to be slightly faster than C++ for this kind of task. – CaptainCodeman Jun 03 '14 at 08:18
  • Yo, who downvoted? If you know something I don't know, at least have the courtesy of sharing your knowledge rather than hitting and running. – CaptainCodeman Jun 03 '14 at 10:29

1 Answers1

13

The primary reason is because C is the lingua franca of software, the GNU project has been around for quite some time and the GNU project and FSF, above else, value freedom of their software over any other consideration. Performance, modularity, code 'elegance', bug fixes, etc, all take a back seat to software freedom as far as the GNU project is concerned.

For much of GNU's history, C was the only language available that could fulfill that goal. The GNU project began IIRC in 1984. One of the initial development efforts was to make a GNU toolchain, and C was the obvious choice. Depending on a proprietary compiler beyond the short-term was unacceptable, and C ia a simple yet very effective language that was suitable for general purpose software development, and thus a reasonable target for the initial GNU compiler.

In the meantime, C++ was only a year old, and it would still be many years until dependable compilers were even available, and it wasn't until 1987 that GCC came around, and it didn't have C++ capability until a year after that. For many years, Java was a "trap", in that all Java software required a non-free runtime in order to execute, so Java was not an option, even if it had existed at the time.

whatsisname
  • 27,463
  • 14
  • 73
  • 93
  • 8
    Originally, GNU was motivated by the desire to create clones of Unix tools, and Unix tools were all written in C. (As C was invented to build Unix.) – Gort the Robot Jun 03 '14 at 05:22
  • 1
    _Since this article was first published, Sun (now part of Oracle) has relicensed most of its Java platform reference implementation under the GNU General Public License, and there is now a free development environment for Java. Thus, the Java language as such is no longer a trap._ – Soner from The Ottoman Empire Apr 14 '19 at 21:58