6 ms·
I'm curious- why C? Strings, scoped objects and C++11 move operators seems much safer and clearer from an API perspective. The complaints about C++ seem to mos
by randomfool 11y ago
I'm curious- why C? Strings, scoped objects and C++11 move operators seems much safer and clearer from an API perspective.
The complaints about C++ seem to mostly be around the ability to abuse the language, not specific issues that C solves. Something like https://github.com/facebook/proxygen https://github.com/facebook/proxygen seems like a better API.
And I don't quite buy portability- if it's not a modern compiler with decent security checks then I'm note sure it should be building web-facing code.
- luikore 11y agoWhy not? I'd love to build web applications on a router with pure C.
- tomcam 11y agoMan, me too. I feel more comfortable knowing where all my memory is, and that my types are being checked at compile time.
- pjmlp 11y agoDo you really know where all you memory is being used without Valgrid?
- nitrogen 11y agoValgrind should definitely be a part of every C developer's workflow, if possible integrated into the unit and integration tests.
- pjmlp 11y agoIt doesn't help that is isn't available in all platforms, e.g. embedded, real-time OS, commercial UNIXes, mainframes.
- askfakasdsfsfk 11y agoTwo of those, embedded and real-time, Valgrind should help very little as you shouldn't be allocating anything anyway apart from statically.
- pjmlp 11y agoWell, there are still the other pointer misuses that are so common in C code.
- nitrogen 11y agoThat is unfortunate, but in those cases, if C or C++ is the only option, I would advocate writing cross-platform code and running the tests under a Valgrind-supported platform. This is a bit more difficult for kernel-level code running on an RTOS, as there might be a lot more unique APIs to stub out, but it can still be done.
- pjmlp 11y agoYou are no longer testing the same code under the real execution conditions, thus missing out possible leaks on the original code path. Although you can add that better test that than nothing, assuming that the respective OS vendor doesn't offer tooling similar to Valgrind, which I fully agree. EDIT: added some clarifications.
- ossreality 11y agoI'm sorry, but this comment is just hilarious
- gizi 11y agoC++ is just one of the many failed attempts to improve on C. So, yes, C has its issues, but C++ is certainly not the solution. The long story. There are three dominant Turing-complete axiomatizations: numbers (Dedekind-Peano), sets (Zermelo-Fraenkel) and functions (Church). The Curry-Howard correspondence shows that all Turing-complete axiomatizations are mirrors of each other. If "everything is an object", it means that there must exist a Turing-complete axiomatization based on objects. Well, such axiomatization does not exist at all. Nobody has phrased one. Therefore, object orientation and languages like C++ are snake oil. They fail after simple mathematical scrutiny. C++ is simply a false belief primarily inspired by ignorance.
- bch 11y agoC is ripe for integrating with other higher level languages, and the no-fuss license encourages this. I'm looking forward to checking this out further. Good luck Kore!!
- byuu 11y agoI've been building an HTTP/1.1 server in C++11. Along with a C++ wrapper around SQLite, I've been having a lot of fun putting some lightweight forum software together. I definitely enjoy the code structure and compile-time safety over PHP. Using a threaded model with tiny stacks, and std::lock_guard for atomic operations. The biggest downside is you have to run the same OS your server uses on your dev box (which is what I do); or you have to upload the source and compile the binaries on your server directly. (or have fun with cross-compilation, I guess.) To answer the inevitable "why?" -- for fun and learning. Kind of cool to have a fully LAMPless website+forum in 50KB of code. Not planning to displace nginx and vBulletin at a Fortune 500 company or anything. Still wishing I could do HTTPS without requiring a complex third-party library.
- imron 11y agoThe biggest downside is you have to run the same OS your server uses on your dev box You should check out Docker.
- Veratyr 11y agoDocker only helps with portability between Linux distributions, not operating systems. You can't run it on Windows, Mac or the various BSDs without a VM, at which point you're running "the same OS your server uses".
- sneak 11y agoThat's not true; Docker runs great on OSX natively. You can't run the containers there, but the client itself is fine and largely abstracts away the whole "where am I building" issue.
- imron 11y agoMinor nitpick - Docker runs great on OS X, but it doesn't run natively, it runs on a minimal Linux VM - Boot2Docker. I agree that the reality of the situation is that it's abstracted away enough that the distinction isn't really all that meaningful.
- pjmlp 11y agoThe only valid reason is for those embedded devices where C and Assembly are the only languages being supported by the vendors SDK. But I doubt such tiny processors are being used in boards with network capabilities.
- perdunov 11y agoIt seems that people are so intimidated by the infamous complexity of C++ that they don't even want to bother getting more familiar with it. So, although technically the existence of C doesn't make sense, as it is superseded by C++ (except couple of things), C is winning in the branding department.
- pron 11y agoI don't know if this is the reason why people choose C over C++ for some projects, but if language complexity is the reason, it isn't that people are just "so intimidated by the infamous complexity of C++ that they don't even want to bother getting more familiar with it". In the 90s, C++ was much more popular than it is now. It was used as the go-to general purpose language for all kinds of "serious" software (not addressed by VB or Delphi). Early on, almost everyone was very impressed with the power C++ brought, but after a few years, as codebases aged, it became immediately clear that maintaining C++ codebases is a nightmare. The software industry lost a lot of money, developers cried for a simpler, less clever language, and C++ (at least on the server side) was abandoned en-masse -- almost overnight -- in favor of Java, and on the desktop when MS started pushing .NET and C#. So while today C++ is servicing its smallish niche quite well, as a general-purpose programming language for the masses it actually proved to be an unmitigated disaster. It is most certainly not the case that C++'s infamous complexity is "intimidating"; C++'s complexity is infamous because of the heavy toll it took on the software industry. Which is why, to this day, a whole generation of developers tries to avoid another "C++ disaster", and you see debates on whether or not complex, clever languages like Scala are "the new C++" (meant as a pejorative) or not.
- pikachu_is_cool 11y agoI also feel like a lot of people are biased because of Stallman and Torvald's stance on C++. I kind of have an irrational distaste towards the language, mostly due to their influence.
- nothrabannosir 11y agoAnd Yosef Kreinin. Not arguing for or against the FQA, but its mere existence catalyzed (not fed) my journey of critical thinking towards C++.
- bjourne 11y agoEmbedded systems. For example a surveillance camera could have a small web interface for configuring it and allowing remote access. Nowadays, even cameras have enough power to run real web servers with Ruby on Rails, but for smaller embedded systems, like a pacemaker, a web app written in C could make sense.
- SamReidHughes 11y agoMy impression has mostly been that on weird embedded platforms you'll just have some bad C compiler available, and that's the reason. Is it more than that?
- rwmj 11y agoActually C with a pool allocator is an excellent language for writing a web server. I wrote one in C 15 years ago, and the code is very elegant and simple: http://git.annexia.org/?p=rws.git;a=tree http://git.annexia.org/?p=rws.git;a=tree
- swalsh 11y agoI don't know if this is very heavy, so i might be wrong here. But one thing I can think of is embedded applications that want to have a web UI?
- techar 11y agoC++ is really horrible, everything feels like an after thought. The new unique_ptr and shared_ptr ends up with really ugly code, the concept is good but wow... Can we move away from this horrible language already? http://harmful.cat-v.org/software/c++/ http://harmful.cat-v.org/software/c++/ http://harmful.cat-v.org/software/c++/coders-at-work http://harmful.cat-v.org/software/c++/coders-at-work http://harmful.cat-v.org/software/c++/linus http://harmful.cat-v.org/software/c++/linus http://harmful.cat-v.org/software/c++/rms http://harmful.cat-v.org/software/c++/rms
- ludamad 11y agoC++ is a swiss army knife that works with C, which I have learned very well and have great tools for. I understand the concern, but moving away is not so simple. That being said, I prefer well-designed C-style libraries in a lot of cases, since C++ libraries often have opinionated styles (the language is huge, after all).
- pmelendez 11y agoI don't know about your case, but most of the time I found complains like yours , is from people who never actually tried the language, or just heard a bad story or have one bad experience reading a bad legacy code. I think Torvalds and Stallman fall in that category actually. Stallman even mention generics which C++ doesn't have and it is very different to the templates mechanism that C++ does have. As for the people who actually uses the language (specially after C++11), most of them would tell you that there is a great subset of the language that works for them. A valid argument I have heard before is that subset is different with each people and the problem arises when maintaining somebody else code. Well that happens with every language (Have you ever had to debug a memory corruption bug in an old C code with void* all over the place? Hint: it's not pleasent ) C++ is a language that allow you to use abstractions with a very reasonable performance and very reasonable resources, and in that niche there is not a real alternative. Yes, you can have a fine tuned VM running Java or .Net code that might be comparable with C++ but with a cost in memory. I don't think Rust or D are ready yet to be a real competitor. So... no... we can't move away from this "horrible" language yet.
- 11y ago
- tim_sw 11y agoIsn't nginx written in C?