Damn, someone beat me to it. I knew Cmake's ExternalProject had a lot of hidden potential!
I still think there's more that can be done with convention over configuration, but not every package will switch to a new convention until shown the benefit, even then...but Rome wasn't built in a day.
I actually used python to make distribution easier. Otherwise, I would need to write Debian/RPM packages for linux, update homebrew for the mac, and windows installer for windows. So with python I just create one pypi package. It helps save time, since this is entirely a volunteer effort. Perhaps in the future, this could be written to run natively.
If C wants to remain competitive against up-and-coming systems languages in the next 5 years (ahem rust), we need something like this. Half of the packages in any linux distro would be straight-C packages in a sane universe.
I understand the counterargument that 'C compiles to every architecture' and that's the key to its persistence, but hard-to-use library importing is such a high bar for new developers to learn a system. All the new talent is going to use what's easy.
That's funny, because I think C libraries and applications are, by and large, much easier to build and install than software written in any other language. I've written distribution packages for a lot of free software, and the ol' ./configure && make && make install dance rarely gives me problems, unlike all of these "modern" build systems that are also language-specific package managers that do not even have the concept of a configure phase. This is a really bad regression in software development.
edit: I should note that the ./configure && make style of building a la Autotools is not C specific. I've seen other projects written in other languages use it and building their software is just as easy as a C project.
> ./configure && make && make install dance rarely gives me problems, unlike all of these "modern" build systems that are also language-specific package managers that do not even have the concept of a configure phase.
./configure && make && make install is wonderfully simple -- iff your system already has all of the package's dependencies installed.
Otherwise you're left to manually track down ./configure && make && make install every dependency, and all of their dependencies, etc.
In reality nobody does this, and system package managers are imperfectly providing for C/C++ what language-specific, cross-platform package managers are providing for the communities of Rust, Ruby, et al. Consequently the C/C++ community is more balkanized/less integrated across platforms.
There's certainly a strong Old School mentality in the C/C++ that says that you throw code into a repository somewhere with build instructions, and if other people want to use it in their project it's on them to package it for their system and worry about coordinating, building, and installing other dependencies. There is no "language community" so much as a Debian community and an Arch community and an OS X community and a Windows community and each and every platform should attempt to "Package the World" and solve this problem in its own way. The author cares not.
Count me among the New School that feels that if you want to share your code, you package it yourself, declare its dependencies in a standard way and throw it into a central, community organized place and the whole community immediately benefits from it using a standard tool that pulls down your package and its dependencies on demand, regardless of platform.
Having come to the New School from the Old School, it moves so much faster, and there is infinitely less friction when it comes to sharing code. To point at an obvious example, Common Lisp post-Quicklisp is an infinitely more pleasant and vibrant community to work in than it ever was previously.
If you use Arch Linux, you get CMake files and headers for every library you can install, built right into the package, as well as all the dependencies you'll need for those packages.
C/C++ with CMake is honestly a joy. It's really wonderful. The issue is that it's not the most popular thing to use right now. The hype train has wandered off into the realms of JS, Go, and Rust. A lot of money goes into super-convenient tooling for these newly relevant languages. So perhaps I've made it clearer as to why C is less popular now.
I've been using CMake off and on for years now, including recently. I feel no joy using it. The syntax is ridiculous, the semantics are worse, and the documentation is poor, even in 2016. It gets the job done, but it is a royal pain in the butt. Whenever feasible, I'll use something else. These days, that usually means writing a quick build script generator in Python. I've been around for a while, so I remember using a lot of different build tools, from monstrosities like autotools (which has good points), hand-written makefiles, to "modern" designs like Jam, SCons, NAnt. CMake is basically the least usable of all of these (except autotools), but at the same time it is the only one which solves the desired task.
I wouldn't say that it's just a matter of money and popularity. C and C++ are both quite popular these days. The problem is that the tooling is so different between platforms. You want to build a shared library? Hah, the process is quite different on Windows, and there are non-trivial differences between OS X and Linux too. You need to change your header files on Windows depending on whether the library is static or dynamic, and you even need to worry about things like "who calls free()" because as soon as you make a DLL you can't be sure that the person calling your code has the same malloc that you do.
With JS, Go, and Rust, the toolchain is identical on all platforms, there are no header files, et cetera.
We've had decades to try and make C tooling nice and easy, and it simply hasn't happened, despite the language's overwhelming popularity. The most usable solution we've really come up with is writing C on your favorite Linux distro, where you can just apt-get whatever you want and pkg-config it into your build system. But once you want to build on OS X, you get to choose between the insanity of Homebrew or the insanity of building your own packages. On Windows, things are even harder, because suddenly all the shell scripts that propped up your build system stop working.
Your experience on Arch just reflects the reality of cross-platform development: it's awesome if you can avoid it. I do most of my development on a Linux system as well and I can reasonably call it a "joy" right up to the point when I need to finish the Windows and OS X ports. I don't think that you can truly experience the horrors of CMake if you stick to Linux. Heck, on Linux, you can hand-write makefiles fairly reasonably, if you know what you're doing.
On Windows I was rather successful with developing C apps with msys2 which comes with a Posix envirronment and pacman package manager. Most source that use posix compliant apis compile on windows and mingw provides a few handy adapters. It's obviously not going to run docker containers but it's really handy, I was successful compiling quite a lot of c projects from scratch, including some Gtk3 apps.
> So perhaps I've made it clearer as to why C is less popular now
C is "not popular" (that's relative) because C is verbose, practical C is ugly and just dangerous if not in expert hands. I'm not a fan of Go but Go doesn't have C memory management problems. The complexity of C development is also in the tooling, Cmake, make, autotools , autogen and co ... imagine you're a beginer today , you need to write a server . It's like 4 lines in Go then you just type Go build.
With C you'd have to install the proper library, then choose a build tool, then learn another language like make , then learn m4 macros ; then learn to do proper memory management , ... it takes way more than a day to get started, it takes months ... C lacks of a lot of modern features such as namespaces, simple string support, ... C isn't going away, Linux kernel is written in C so it will always be a dependency but explaining why C is the last choice when developing applications is pretty easy.
Try writing a JSON api in pure C backed by a NoSQL db , then try the same with Go or Rust. You might be an C expert so ask someone that is a noob in software development to do the same, from scratch and watch the amount of time it takes to do so. Now give him Go to write the exact same thing ...
While the problem space where C would be appropriate has been shrinking, this rant is nonsense.
> With C you'd have to install the proper library, then choose a build tool, then learn another language like make , then learn m4 macros ; then learn to do proper memory management
What library? The libc that is on every OS? Build tools and Makefiles aren't exclusive to C; any non-trivial project is going to have tooling, no matter the language [1]. Also, if you don't understand memory management, then why do you think starting a new project in C would be appropriate...?
> Try writing a JSON api in pure C backed by a NoSQL db
That's rather under-specified (what kind of JSON API?), but there are very few cases where you would actually want to write such an API in C, maybe unless you're actually working on the DB bindings themselves, and assuming the DB is in C/C++. Even then, it's arguable whether JSON is the ideal serialization. Choose the right tool for the job.
[1] I'd argue that Makefiles and M4 are still very useful on their own and it'd behoove developers of all kinds to learn them anyway... maybe we'd have less (poorly done) reinvention with idiosyncratic, flavor-of-the-day build systems.
The OP specifically talked about the "hype train". There is no hype train at all. The new languages like Go and co are the answer to problems that exist with using C as a language for writing servers.
> That's rather under-specified (what kind of JSON API?), but there are very few cases where you would actually want to write such an API in C
Again the OP said all these new language were just hip. I answered than no, they are not, because of the reason you just exposed. We agree, you just didn't understand the point of my message and what I was responding to.
Dismissing Go and co as "hype" and then talking about the awesomeness of C is certainly non sense.
The issue is that your criticisms of C range from superficial, to incorrect, to straw men.
> Dismissing Go and co as "hype"
I didn't read OP as dismissing Go &c, just an acknowledgement that they are getting a lot of attention, along with their tooling.
OP didn't say what he was using C/C++ for either, so it's weak to make a comparison where none was implied eg, JSON API. That entire post was a very roundabout way to quibble about the use of the word "hype" by going on an otherwise unprovoked diatribe against C.
24 comments
[ 3.5 ms ] story [ 41.1 ms ] threadI still think there's more that can be done with convention over configuration, but not every package will switch to a new convention until shown the benefit, even then...but Rome wasn't built in a day.
I understand the counterargument that 'C compiles to every architecture' and that's the key to its persistence, but hard-to-use library importing is such a high bar for new developers to learn a system. All the new talent is going to use what's easy.
edit: I should note that the ./configure && make style of building a la Autotools is not C specific. I've seen other projects written in other languages use it and building their software is just as easy as a C project.
./configure && make && make install is wonderfully simple -- iff your system already has all of the package's dependencies installed.
Otherwise you're left to manually track down ./configure && make && make install every dependency, and all of their dependencies, etc.
In reality nobody does this, and system package managers are imperfectly providing for C/C++ what language-specific, cross-platform package managers are providing for the communities of Rust, Ruby, et al. Consequently the C/C++ community is more balkanized/less integrated across platforms.
Count me among the New School that feels that if you want to share your code, you package it yourself, declare its dependencies in a standard way and throw it into a central, community organized place and the whole community immediately benefits from it using a standard tool that pulls down your package and its dependencies on demand, regardless of platform.
Having come to the New School from the Old School, it moves so much faster, and there is infinitely less friction when it comes to sharing code. To point at an obvious example, Common Lisp post-Quicklisp is an infinitely more pleasant and vibrant community to work in than it ever was previously.
Agree to disagree, I guess.
C/C++ with CMake is honestly a joy. It's really wonderful. The issue is that it's not the most popular thing to use right now. The hype train has wandered off into the realms of JS, Go, and Rust. A lot of money goes into super-convenient tooling for these newly relevant languages. So perhaps I've made it clearer as to why C is less popular now.
I wouldn't say that it's just a matter of money and popularity. C and C++ are both quite popular these days. The problem is that the tooling is so different between platforms. You want to build a shared library? Hah, the process is quite different on Windows, and there are non-trivial differences between OS X and Linux too. You need to change your header files on Windows depending on whether the library is static or dynamic, and you even need to worry about things like "who calls free()" because as soon as you make a DLL you can't be sure that the person calling your code has the same malloc that you do.
With JS, Go, and Rust, the toolchain is identical on all platforms, there are no header files, et cetera.
We've had decades to try and make C tooling nice and easy, and it simply hasn't happened, despite the language's overwhelming popularity. The most usable solution we've really come up with is writing C on your favorite Linux distro, where you can just apt-get whatever you want and pkg-config it into your build system. But once you want to build on OS X, you get to choose between the insanity of Homebrew or the insanity of building your own packages. On Windows, things are even harder, because suddenly all the shell scripts that propped up your build system stop working.
Your experience on Arch just reflects the reality of cross-platform development: it's awesome if you can avoid it. I do most of my development on a Linux system as well and I can reasonably call it a "joy" right up to the point when I need to finish the Windows and OS X ports. I don't think that you can truly experience the horrors of CMake if you stick to Linux. Heck, on Linux, you can hand-write makefiles fairly reasonably, if you know what you're doing.
C is "not popular" (that's relative) because C is verbose, practical C is ugly and just dangerous if not in expert hands. I'm not a fan of Go but Go doesn't have C memory management problems. The complexity of C development is also in the tooling, Cmake, make, autotools , autogen and co ... imagine you're a beginer today , you need to write a server . It's like 4 lines in Go then you just type Go build.
With C you'd have to install the proper library, then choose a build tool, then learn another language like make , then learn m4 macros ; then learn to do proper memory management , ... it takes way more than a day to get started, it takes months ... C lacks of a lot of modern features such as namespaces, simple string support, ... C isn't going away, Linux kernel is written in C so it will always be a dependency but explaining why C is the last choice when developing applications is pretty easy.
Try writing a JSON api in pure C backed by a NoSQL db , then try the same with Go or Rust. You might be an C expert so ask someone that is a noob in software development to do the same, from scratch and watch the amount of time it takes to do so. Now give him Go to write the exact same thing ...
> With C you'd have to install the proper library, then choose a build tool, then learn another language like make , then learn m4 macros ; then learn to do proper memory management
What library? The libc that is on every OS? Build tools and Makefiles aren't exclusive to C; any non-trivial project is going to have tooling, no matter the language [1]. Also, if you don't understand memory management, then why do you think starting a new project in C would be appropriate...?
> Try writing a JSON api in pure C backed by a NoSQL db
That's rather under-specified (what kind of JSON API?), but there are very few cases where you would actually want to write such an API in C, maybe unless you're actually working on the DB bindings themselves, and assuming the DB is in C/C++. Even then, it's arguable whether JSON is the ideal serialization. Choose the right tool for the job.
[1] I'd argue that Makefiles and M4 are still very useful on their own and it'd behoove developers of all kinds to learn them anyway... maybe we'd have less (poorly done) reinvention with idiosyncratic, flavor-of-the-day build systems.
The OP specifically talked about the "hype train". There is no hype train at all. The new languages like Go and co are the answer to problems that exist with using C as a language for writing servers.
> That's rather under-specified (what kind of JSON API?), but there are very few cases where you would actually want to write such an API in C
Again the OP said all these new language were just hip. I answered than no, they are not, because of the reason you just exposed. We agree, you just didn't understand the point of my message and what I was responding to.
Dismissing Go and co as "hype" and then talking about the awesomeness of C is certainly non sense.
> Dismissing Go and co as "hype"
I didn't read OP as dismissing Go &c, just an acknowledgement that they are getting a lot of attention, along with their tooling.
OP didn't say what he was using C/C++ for either, so it's weak to make a comparison where none was implied eg, JSON API. That entire post was a very roundabout way to quibble about the use of the word "hype" by going on an otherwise unprovoked diatribe against C.
Yet that exactly what he did.