A Modern C Development Environment

3 years ago by JimmyWorldEater to c/c_lang

Spinning up a C development environment using CMake, Docker, Unity, and GitHub Actions.
CameronDev 9 points 3 years ago

What is the benefit of these containerised dev environments?

path: 0 2328050, hotness: undefined, score: 9, children: 7
Ramenator 2 points 3 years ago

I guess the biggest benefit is that you can ship it directly from there and don't have to rewrite your application because Debian ships with an outdated version of some core library

path: 0 2328050 2330999, hotness: undefined, score: 2, children: 4
vrighter 5 points 3 years ago

So it's not a dev environment at all. It's a runtime.

If your code only works on your machine, to the extent that you literally have to ship a copy of your entire machine, your code sucks.

"it works on my machine" is an excuse. And a shitty one at that.

edit, and this way, after a week or two, your container will be the one using an outdated version of a library, not the system.

path: 0 2328050 2330999 2331391, hotness: undefined, score: 5, children: 1
TheTrueLinuxDev 0 points 3 years ago

I concur, there was a few problems that might come up on various platforms like Windows not implementing C11 standard threads and other stuff, you would instead use TinyCThread library that works like a polyfill.

All problems and challenges are workable, if the problem with Debian is out of date library, you could set up CI/CD for release build that rebuild your software when update occurs and static link the updated dependencies.

Back to your point, if they didn't design their code and architecture to be multiplatform like in C, they need to re-evaluate their design decisions.

path: 0 2328050 2330999 2331391 2337914, hotness: undefined, score: 0, children: 0
CameronDev 5 points 3 years ago

But then your shipping your entire Dev Env as well? Including vscode? Seems a bit antithetical to what docker containers are meant to be? Or do you then just strip the container back down again?

path: 0 2328050 2330999 2331084, hotness: undefined, score: 5, children: 1
sekhat 1 point 3 years ago

With vscode's "Remote Containers" plugin at least, it's clever enough to install that into the container after building the image. So the image built from the dockerfile doesn't contain the vscode stuff.

path: 0 2328050 2330999 2331084 6547882, hotness: undefined, score: 1, children: 0
suprjami 1 point 3 years ago

The advantage is that you can have a reproducible development environment regardless of the underlying platform.

You use Debian and a workmate uses Fedora? No problem.

Someone joins with Mac or Windows? No problem.

Your laptop dies and you're using something temporary for a while? No problem.

No more differences of system libraries or "Well it works on my laptop" bullshit. Everyone is using the same libraries and compiler so there is no difference in any developer's experience.

path: 0 2328050 2342441, hotness: undefined, score: 1, children: 1
CameronDev 3 points 3 years ago

So it's a different way to get a standard operating environment.

Could you not achieve something similar by making the build and test happen in the docker container, while keeping the IDE etc separate? Bundling the IDE seems a bit overkill.

Fwiw, in my experience, "it works on my laptop" is a great way to shake out bugs/API implementation quirks, so that's a benefit for our team. Plus we have a mishmash of IDEs, so prescribing one or the other would probably cause more problems than it solved.

Still, interesting solution for those who have the problem.

path: 0 2328050 2342441 2362036, hotness: undefined, score: 3, children: 0
vrighter 3 points 3 years ago

it's "modern" all right, in that it tries using all the buzzwords.

But why?

path: 0 2330259, hotness: undefined, score: 3, children: 1
monomon 1 point 3 years ago

Convenience and reproducibility

path: 0 2330259 2358833, hotness: undefined, score: 1, children: 0
leviosa 1 point 3 years ago

Using platform independent package managers instead of relying on system libraries seems like a more straightforward solution to a good part of the problem at least. It's often good to use multiple compilers as well, which would add to the bloat of the container. There are probably some gnarly situations where pros outweigh the cons though.

path: 0 2375432, hotness: undefined, score: 1, children: 0
c_lang
c_lang

@programming.dev

login for more options
1359
104
35

Welcome to the C community!

C is quirky, flawed, and an enormous success.
... When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.
... The only way to learn a new programming language is by writing programs in it.

© Dennis Ritchie

🌐 https://en.cppreference.com/w/c

go to feed...