5 ms·
Featurewise, I don't see why I would move away from i3wm. That said, I always feel love for any project that pitches its code base as being small and in C.
by iqkznnft 4y ago
Featurewise, I don't see why I would move away from i3wm. That said, I always feel love for any project that pitches its code base as being small and in C.
- kelnos 4y agoAs someone who spent many years writing C, every time I go back to it, I wonder why people still write things in C. (I'm exaggerating; of course I know why people still write things in C, but I would have a hard time justifying starting a new project in C these days.)
- uecker 4y agoI used C++ for some time, but then went back to C. Why? Fast compilation, lower complexity, long-term stability, wide support.
- 5e92cb50239222b 4y agoI can name a couple a new projects I'm using heavily myself where using C makes sense (to me at least). Portability might be the most reasonable argument, which is understandable when you're writing things like build systems, e.g.: https://git.sr.ht/~lattis/muon https://git.sr.ht/~lattis/muon Then there are small tools when using anything else just doesn't buy you much, and if you're familiar with C, why bother? e.g. https://git.sr.ht/~kennylevinsen/wlsunset https://git.sr.ht/~kennylevinsen/wlsunset And situations like this one where you need both C API (for maximum compatibility), and manual memory management is a much for various reasons (read the blog post) https://news.ycombinator.com/item?id=19778738 https://news.ycombinator.com/item?id=19778738 https://news.ycombinator.com/item?id=24753626 https://news.ycombinator.com/item?id=24753626
- hawski 4y agoI think that when the code base is small it can be really fitting. Ones I find my favorite do almost no memory allocations. Or allocations are done only for the workset. I do not like that nowadays it seems customary to heap allocate everything and tie object's lifetime to where it keeps its state. Modern C++ with unique_ptrs sprinkled everywhere is like that.
- Thorrez 4y ago>and tie object's lifetime to where it keeps its state What's the objection there? I want the state to be freed when the object's lifetime ends. For something only needed during a function, a local value variable makes sense. For something that needs to last longer, either give it a move operator, or put it on the heap and use unique_ptr. If your point is that people sometimes use unique_ptr<std::string> instead of std::string or std::optional<std::string>, then yeah I agree, that's generally not good.
- eska 4y agoThat’s not his point, but you demonstrated it quite well. C++ use leads to developers that conflate memory allocation and initialization. For contrast, objective C also differentiates between the two.
- hedora 4y agoAllocation and initialization should be atomic. Otherwise, the rest of the program has to deal with uninitialized objects and no invariants hold.
- qalmakka 4y agoIn well written modern C++ there are rarely memory allocations outside of STL containers. I have worked on big embedded projects that only use unique pointers in very few locations, you can do a lot of stuff without using the heap if you really want.
- FpUser 4y agoCan confirm. My latest backend C++ server of decent size has just a single explicit allocation happening upon startup. In my C firmware projects I do not allocate memory at all. Everything is predetermined.
- hedora 4y agoI guess I mostly wrote postmodern C++ then. The stl containers aren't lock free, and std:strings allocation behaviors are too confusing for me. Having said that, "delete" hardly showed up at all.
- msla 4y agoC is the scripting language of the kernel and low-level system libraries. Other languages have approached that status, but in my experience none have gotten to the point of zero-friction integration with libc and kernel syscalls. I understand why (for one thing, not having a real string type is painful) but it helps keep C around for low-level system-call-centric code which doesn't hit on any of the things C does really poorly.
- IgorPartola 4y agoC is just fun. I do t know how else to say it. It feels like you get to really think about what you want the computer to do.
- kelnos 4y agoI don't find it fun at all. I want to focus on what I want my program to do, not on how the computer does it, as long as its doing it reasonably efficiently. I want a successful compile to give me a decent amount of confidence that my program is correct, and is free of some classes of bugs. Life is too short to waste time tracking down double frees, out-of-bounds writes, memory leaks, and weird concurrency issues.
- klyrs 4y agoKinda like riding a fixed-gear bike. To some, the sheer simplicity is a joy of its own. To others, little besides literal tooth-pulling even compares.
- enriquto 4y agoI love this analogy! (Being a fan of C and of bikes). How does it continue? Assembly=walking, fixie=C, regular bike=fortran, electrically assisted bike=C++, electric wheelchair=python, ...
- IYasha 4y ago> electric wheelchair=python :_D You made my day! I'd continue like this: barely moving eye-popping-graffiti-painted squeaky wheelchair with no bearings mounted with duck tape inside a rusty sea container, that is chained to a heavy truck with broken exhaust and flat tires = (you guessed it! :) )
- enriquto 4y ago> barely moving eye-popping-graffiti-painted squeaky wheelchair with no bearings mounted with duck tape inside a rusty sea container, that is chained to a heavy truck with broken exhaust and flat tires If you add a solid rocket booster to this contraption (so that it actually moves) that would be exactly javascript.
- pjmlp 4y agoOutside of UNIX clones due to symbiotic nature with C, and embedded anti-C++ cargo cult which won't even consider C99 in some cases, there is hardly a reason. However this is hardly going to change outside the domains where corporations push for blessed languages on their platform SDKs, people keep being educated that C maps 1:1 to Assembly language and thus the myth continues. Even Microsoft with all their security talk only allows on Azure Sphere OS and Azure RTOS, the reasoning being their target market doesn't wan't anything else.
- gustavorg 4y agoAfter working years in Java, C#, Python, Ruby, and others, I would have a hard time justifying starting a new project without C these days.
- encryptluks2 4y agoWhen it comes to build systems, creating lightweight and efficient binaries that integrate with libraries and couple nicely with package managers... I think C is still one of the best options, although Go has come a long way and Rust isn't too far behind. In terms of security, I believe Rust has an advantage, but I've yet to find any exploits in the C programs that I use that would have somehow been mitigated completely with Rust, and there are a lot of unsafe Rust programs out there as well.
- lionkor 4y agoDefinitely agree. For me these days it's Zig all the way. The flawless and painless C interop is insanely good.
- FpUser 4y agoI write firmware for microcontrollers in C and frankly for these relatively small project C feels just right. On desktops / servers I prefer other languages and would not want to mess with C, at least for the types of products I do.
- mdp2021 4y agoWhat would you have used to write a Window Manager?
- kelnos 4y agoRust, or maybe I'd try something new (to me) like Zig or Nim. Window managers don't do all that much most of the time; I bet you could even write one in Python and not see performance issues. Hell, Go would be more than performant enough.
- mdp2021 4y ago> and not see performance issues And energy efficiency?