6 ms·
WHYYYYYYYYY No, seriously, why? As far as I can tell, his entire argument is "web development in C is terrible and limiting, but not as quite as terrible and l
by PhasmaFelis 13y ago
WHYYYYYYYYY
No, seriously, why? As far as I can tell, his entire argument is "web development in C is terrible and limiting, but not as quite as terrible and limiting as you might think." I guess that's good news if terrorists are forcing you to write websites in C, but I don't see even an attempt at explaining why you would choose to do this.
- DigitalJack 13y agoThere exists a form of survivalist mindset in some programmers. It goes roughly like this: if you can't boot it, it's fluff programming. The attraction of C to this mindset is that it can be transliterated (vs translated) into machine code. This transliteration is so straight forward that if you know C and are familiar with the basics of the instruction set you can do it by hand. The survivalist mindset fears dependence. VMs and interpreters are the essence of dependence. So those with this mindset always seek find a way to do it in plain C when they can.
- derefr 13y ago> VMs and interpreters are the essence of dependence. I find that an odd perspective. If you can rewrite your VM/interpreter from scratch, are you really dependent on it? I guess I see it less as "use some black-box language runtime to solve this problem" and more as "I will use plain C to solve this problem... by writing an interpreter in plain C for a good DSL to solve this problem in, and then writing the solution in that DSL. But, you know, someone else already did the first part. I'd do it myself if they hadn't, though."
- readme 13y agoOn the next episode of "Doomsday Coders" Programmer writes an entire operating system from scratch in case all the copies of Linux in the world are deleted. A web developer writes his entire application in x86 assembly to prepare for an event in which all the world's compilers and interpreters disappear. And more...
- reinhardt 13y agoReplace "disappear" with "cannot be trusted to not be owned by NSA" and someone might actually take a stab..
- coldarchon 13y agoReplace "disappear" by no support or no updates any longer ..
- pjmlp 13y ago> The attraction of C to this mindset is that it can be transliterated (vs translated) into machine code. This transliteration is so straight forward that if you know C and are familiar with the basics of the instruction set you can do it by hand. Except modern processor architectures are no longer a one-to-one correspondence between Assembly code and C.
- ramchip 13y agoThere has never been a one-to-one mapping (rather one-to-many), but it's still perfectly possible to transform C into assembly by hand. It's not even that difficult.
- pjmlp 13y agoYes, back in the old 8 and 16 bit days, it was pretty much one-to-one for most use cases. Nowadays not any longer if you want to write code that takes advantage of branch prediction, speculative execution, cache lines, vector units, GPGPU ... Just watch this Going Native talk on how sometimes generating code that is 4x bigger than the direct translation can yield up to 30% performance increase. http://channel9.msdn.com/Events/GoingNative/2013/Compiler-Confidential http://channel9.msdn.com/Events/GoingNative/2013/Compiler-Co...
- ramchip 13y agoAuto vectorization can be impressive, but it applies to hard numerical code, not so much in regular code bases. I regularly debug assembly in my job, and in the vast majority of cases it's a fairly straightforward translation of the C/C++ code. Stuff like cache locality or using the GPU is still determined by the C code. I'll concede there's more fine variations to think about than with an 8-bit system, though, with the padding, etc.
- fusiongyro 13y agoMaybe your problem is CPU-bound. Maybe there are good C libraries that solve your problem. Maybe you just want to learn C better. Maybe you have latency limits you need to work within. Maybe you just want to be contrary. Sometimes "why not" is worth more than "why."
- davidw 13y agoPretty much any decent language has a way to call out to C. I wrote a portion of a book on Tcl's C API, for instance, and it's very easy to farm out computationally intensive work to C code, as it is in Python, Ruby and most other things, one way or the other.
- fusiongyro 13y agoI suppose a response to the spirit of the remark as a whole rather than one exemplary detail would be asking a lot.
- davidw 13y agoThe spirit of using C for web applications is: it'd be faster and simpler just to publish your root password and IP address to the web.
- fusiongyro 13y agoInsights like these are so rare. You must have worked really hard for them.
- lmm 13y ago> Maybe your problem is CPU-bound. Maybe you have latency limits you need to work within. Unless you have lots and lots of time to spend micro-optimizing everything, you'll get better performance writing in Haskell. > Maybe there are good C libraries that solve your problem Maybe, but most of the original post is about how lacking the library ecosystem is. I can well believe that you might have some useful domain-specific libraries for the backend, but that calls for writing a backend service in C (and using something like thrift to call it), not "web programming in C". > Maybe you just want to learn C better. If you try and learn on a fake problem you'll pervert your learning. Web development is not amenable to idiomatic C (Cello is a good example - it's not appropriate to the sort of problems C is appropriate for, and if you learn C based on using Cello it will not make you a good C programmer).
- cbsmith 13y agoI should think the reasons are obvious: 1) Whatever language you are most proficient in, that is often the most efficient tool for _you_ to get the job done right. 2) PHP is largely C for people who should never program in C (or PHP ;-). Depending on the nature of what you are doing, and if you use some basic support libraries (and the author mentions a few), your code needn't be that much more work to get done than any other language. In reality, it's not the typing in the code that tends to matter anyway. 3) If you are, for whatever reason, interfacing with a lot of systems components or C API's, there can often be a pretty big win using C as you avoid all the pain of language impedance mismatch. 4) Depending on what it is measured against and the nature of the problem, C can often be significantly more efficient, not just in terms of CPU, but the all important memory consumption these days. Depending on the problem, that can be highly highly relevant. 5) Portability. Okay, you can stop laughing now. ;-) Seriously though, if you talk to mobile game developers who've tried it, C and C++ tend to be the best languages for targeting a plethora of platforms. That goes double or triple for embedded systems. It's really not that hard these days to have very portable C/C++ code, and platforms that insist on making C a second class citizen tend to do themselves more harm than good (even Android ultimately relented). Now, that's not to say that I think everyone should be doing their web projects in C, but depending on the context (the problem, the available tools, and the parties involved), it might well be a good choice.
- justincormack 13y agoIf you need a lot of C interfacing go with something that interfaces well with C. Like Lua.
- cbsmith 13y agoOr, C#? ;-) Sometimes it is hard to beat just doing it in C.
- kryptiskt 13y agoI've done it. The use case was settings web pages on an small wifi audio device. Using a few hundred lines of code more was in all respects preferable to trying to fit some other language runtime into a 6 MB budget. And I don't know why it would need to be so horrible to program web in C, once you have abstracted out common web tasks, using them is as simple as using them in any language, just call a function.
- dysoco 13y agoMaybe he's doing it for fun? There doesn't have to be a reason for doing it.
- Jeema101 13y agoFor a CRUD app, of course it doesn't make much sense and you'd probably have to be a masochist. :) But there are valid use cases I can think of: Anything that's very CPU intensive that would need to run very quickly: dynamic image generation, or something that does a complex series of operations on user input that needs to delivers the results ASAP. Of course it's usually easier and safer to just throw more CPU at it, but at a certain scale that might get too expensive...