7 ms·
What's your C migration plan?
- __david__ 15y agoIt really depends on what you are writing. If you're trying to write the next great startup web app then, yeah, use python or ruby or perl--C is probably too finicky for the fast pace of a web startup. But if you're writing systemd (an "init" replacement) you'd be the object of ridicule if you wrote it in any of those languages.
- coliveira 15y agoThis is just nonsense. C is perfect for what it is supposed to do: systems programming, the kind of software you write when creating operating systems, debuggers, and device drivers. It will hardly ever stop being useful for these tasks. People that make this kind of complaint were using C for the wrong type of software. If you want to write a web application in C you just need to reevaluate your tool set.
- jvehent 15y agoWhile I agree with your comment, I would also point out that the fastest, most reactive and most scalable webapps have seen were written in C. Some people out there actually know how to use C, and instead of battling with async JS do get a 5000hits/s hello world, they code a webapp that can easily handle hundreds of thousands of requests/sec without a blink. Granted, it's less and less common.
- ajross 15y agoExactly. It's sad that in the modern world there are people (smart, productive people even) who are so far removed from system stuff that they just plain forget that this software still needs to be written. Now, is C the best possible tool for these jobs? Certainly not. But it's the one we have and it's got a pretty fantastic track record.
- tptacek 15y agoAs regards quality and reliability in consumer software, C has a godawful track record. The heart valve code inherits constraints that make C a lot safer: it has an extraordinarily limited feature set, its functional interfaces are simple, it changes rarely, and the time - to - market pressures it faces are dwarfed by other factors like certification and manufacturing. Consumer software is richly functional, has complex interfaces, changes constantly, and is written under ridiculous scheduling pressure. In that environment, C does indeed give you software that is as likely to enable someone to install a trojan on your system as it is to properly render an image.
- bmastenbrook 15y agoTo say that wingo has forgotten that systems software needs to be written is both insulting and flat-out wrong. He is a language implementor (Guile). Of course he knows that it is still needed and what it is needed for.
- tptacek 15y agoThis objection is a hyperbolic response to an imprecisely phrased blog post. The author points out that C is gradually being superseded by languages like Python. The author is right. Every year, less new C is being written, and for good reason. You point out that there are obviously environments (like your life support valve driver, as Julio Capote says) where C is going to be the most appropriate choice for years to come. We can be reasonable people and accept that there's truth to both of these sentiments, or we can synthesize a phony controversy in which we compete to defend extremes and get nowhere. If we're reasonable, I think the author's point is well taken. Less C/C++ is written every year. In part that's due to the web and the increasing power of (what we used to think of as) "embedded" environments. But in part, it's because people who would have reached for C as their go-to language for some cases are (properly) going to stop doing that. As someone who spends most of his working days looking at other people's projects for flaws like the stuff this guy is alluding to, particularly for Python and Ruby projects --- when you want to find something particularly fun and gruesome, you go straight for the C extensions.
- eaurouge 15y agoGoing purely on the number of processors that run exclusively on C code, I'd say more new C is being written, and for good reason. I'm referring to the firmware running on the dozens of devices you have in your home, the ones you don't see, don't even know exist. These devices will only continue to grow, so more C will be written not less. More Python, Ruby etc will be written too, because more software will be written in general. The proliferation of software isn't a zero sum game and probably won't be for a very long time.
- bitops 15y agoI doubt that the tech industry will ever move completely away from C. (I had a friend who was doing graduate work in physics and he was required to do all his work in Fortran, believe it or not, so old languages do stick around). For "mainstream" (read: enterprise) software, yes, C may fall out of favor, but it's a great language and here to stay. There are just too many cases where C is the right tool for the right job and it would be silly to use a different language. I'm thinking particularly of embedded software. While languages like Lua are great for embedded scripting, they still need something to script against. So, C isn't going anywhere and I expect that 100 years from now it will still be a worthwhile language to program in. (Also, C is very much the Latin of modern programming. Learning it helps your understanding of so many other things. In case you're curious, Lisp is Greek and I mean that affectionately).
- tptacek 15y agoYou think in 100 years we'll be writing in a language whose only real data type is an integer, overloaded to represent human language, memory addresses, and (by extension) the identities of functions? What a depressing thought. I love writing C code (the model of programming where virtually anything is possible by modifying and reinterpreting integers is often a fun one), and it's my best language, but I hope we grow out of it sooner than later.
- yew 15y agoC will go away alongside modern hardware design "standards." Until that happens someone will always find a use for talking as directly as possible to the hardware (which, of course, doesn't care about types at all). Whether that'll take a hundred years, or a thousand, or ten I don't know. Of course it's possible to write a lot of things in, say, Python, then rewrite the slow bits in C. The number of programs that absolutely must be written close to the metal is pretty small in absolute terms.
- statictype 15y agoAs long as we're running our software on a Von Neumann machine, there will be a need for a language which is just a thin layer on top of it. Considering we already have one, it seems hard to believe that it will go away without a fundamental change in how computers work. (Which is not to say we won't have better languages - just that we will always have the bare-metal one as well)
- thepointyhat 15y agoI don't get it - I've had the same screwdrivers since I was 15. Why would you just throw a lot of knowledge and a perfectly good tool out? If you know what you are doing, C is perfectly safe. If you don't know what you are doing, even the safest language is a grenade without the pin in. I've written a few web apps which are just inetd spawned C which shifts JSON out with printf's and handles POST data as a hash table. Utterly simple and surprisingly scalable.
- hkarthik 15y agoC is the best thing we have that's truly cross platform and has consistent performance everywhere without any company to claim ownership of it. Until that changes, C is here to stay.
- blackhole 15y agoChanging languages will not save you from security holes, only change the kind of mistakes you have to worry about. Only knowing how to write secure code can save you from security holes. You cannot ignore how computers work, no matter how many layers of abstraction and libraries you pile on in an effort to shield yourself from reality.
- tptacek 15y agoChanging languages will absolutely save you from classes of security holes. Java programmers do not have to keep a working model of object memory lifecycles in their head to build safe programs. C programmers, on the other hand, still do have to care about the metacharacters of the HTML DOM and SQL. In fact, because it's a bitch to rewrite retained char* strings in place without pegging malloc() to the top of your gprof profile, C programs are actually slightly more prone to the kinds of security holes you're implying plague languages like Java. Even if you stretch to find a class of flaw that only affects a language like Perl (for instance, the ease with which Perl allows you to write code where metacharacters will allow an attacker to stuff commands into a shell), you simply have to go back 10 years or so to see the 8lgm posts that did the same thing to C programs all over the Internet.
- blackhole 15y agoAnd yet, this still ignores the rather amusing fact that the more libraries and VMs and whatnot in between you and the computer hardware, the more chances your program will suffer a security hole because of a mistake in one of those libraries. Not too long ago someone found a bug in PHP that would cause it to go into an infinite loop if you put in a wrong number. These kinds of things happen, so if your going to write secure code, the only thing that will save you is being really good at writing secure code on whatever platform you are choosing to write code for. The only thing that changes is the types of security holes you have to worry about. Instead of buffer overflows, you have to know that function x does x and in some cases function y is more secure but only if there's a solar eclipse, etc. The higher level language you use, the more complexity the system has, which increases the possible security flaws even as the languages reduces other security flaws. The end result is simply that any given language will move the problem around, not actually solve it.
- forrestthewoods 15y agoAs a game developer this post is rather amusing. I have far more questions about what happens behind the scenes on the python line than the C line.
- jrockway 15y agoYou know what I've learned over the years? While many people are very bad about writing C, I'm pretty good at it. So C is not a bad language; there are just a lot of bad programmers around using it. (And if you're wondering how to write good C? Make object ownership explicit. Never have malloc and free more than a page of code apart. Don't expose data structures as API. Make errors put your routine into a defined state that the caller can understand. Use bstrings instead of cstrings. And although I don't write much C++, the more I learn about it, the more I believe it's possible to write good C++. Most people won't spend the time to write good software, and when you do that in C or C++ it's an absolute disaster. But if you go slowly, plan, think, exercise care, and review your work regularly, you can get good code that runs fast. You can write a safe Haskell application in 10x less time than you can write a safe C++ application, though.)
- tptacek 15y agoIf defects are at best constant over number of lines of code, then just the extra situps C makes you do are inevitably going to create reliability issues. But we all know that it's not that simple, and that some languages are more defect-prone than others; that leaves you to make the case that C is more resilient than most high level languages. Amusingly (just in this context), when Joe Damato makes fun of Ruby reliability, what he's actually making fun of is the terrible C code MRI is built out of. It's interesting to look at how Apple has dealt with this problem. iOS developers write a dialect of C --- in fact, a dialect that is nominally less safe than C++. But idiom in iOS keeps most iOS programs away from unsafe code patterns. You can try to tokenize a string in an iPhone program by taking it's char* (even that is a pain to get because of character encoding) and then strsepping it, but the whole rest of the programming environment works against you when you do.
- kev009 15y agoC is a language for people that care about programming. Like, you treat it as a lifestyle, not a career or side activity. You read books on it cover to cover. You continually seek to simplify and make your code more clear. If that describes you, it's a damn fine tool.
- kmm 15y ago
- sbov 15y agoI've been recently using Python more rather than Java, and I find myself writing C more than ever. I always seem to find some speed/memory issue in my programs that when rewritten in C goes away. Maybe I'm just not proficient enough in Python to avoid them yet. I would say its still a net gain over raw C.
- swah 15y agoIs it that easy to write in C and call from Python that you don't think twice about it?
- Kliment 15y agoYes, it actually is. Writing Python extensions in C was always easy, but now there's ctypes, and you don't even need to do that anymore. You can just call a shared library function directly from Python.
- lucian1900 15y agoYou might want to use a profiler first, then try PyPy. Then Cython.
- sbov 15y agoI didn't mean to imply I didn't profile (otherwise I wouldn't know what parts to write in C). I've been doing profiling (and trying various non-C ideas on what may help first). I'll have to look into PyPy and Cython, thanks.
- zmanji 15y agoI am unable to load the article. Is there a mirror?
- mappu 15y agoGoogle Cache seems to have it. http://webcache.googleusercontent.com/search?q=cache%3Ahttp%3A%2F%2Fwingolog.org%2Farchives%2F2011%2F10%2F13%2Fwhats-your-c-migration-plan http://webcache.googleusercontent.com/search?q=cache%3Ahttp%... Plain text copy: http://c-migration-plan.pen.io http://c-migration-plan.pen.io
- klochner 15y agoIt's fitting that his site is timing out.
- mansr 15y agoThe author of that (badly timed, btw) post probably does not know that Python is implemented in C.
- tptacek 15y agoThe author of that post is a C programmer. This isn't just snark; it's dumb snark.
- mansr 15y agoA C programmer posting that kind of nonsense is even more stupid than a non-C programmer doing it.
- Aramgutang 15y agoNo, CPython is implemented in C. Python has been implemented in many languages, including C# (IronPython), Java (Jython) and in Python itself (PyPy). The latter, I might add, is maturing incredibly rapidly.
- tptacek 15y agoThe nice thing about an article like this is that anyone who is receptive to it truly shouldn't be writing C code, and anyone who should be writing C code is (in almost all likelihood) not receptive to it.
- user911302966 15y agoMy suspicion is that this is not a C programmer at all. Claiming that you've "written loads of it" certainly lends the author a cloak of credibility, but I don't buy it. "This one, you really can't tell." A competent C programmer can absolutely discern what is happening... more importantly, though, is that the two examples don't do the same thing. I stopped reading at that point.
- tptacek 15y agoUpon hitting his website, you were one single click away (the "software" link, next to "about") from learning that he's the co-maintainer of Guile, a C implementation of Scheme.
- trbecker 15y agoWhat this can possibly mean? Because C is everywhere. It is in the code that runs the VM of your favorite language. It is in most compilers. It provides basic system services. Why should we have a plan to migrate from something that is everywhere?
- swah 15y agoBut I don't want to use his language, I want to hack on it with him. To see how he solves problems. So, C. Unless its something like Factor, where most of the implementation is written in Factor.