Live data from Hacker News

Web development in C: Crazy?

medium.com

171–180 of 213 posts

Re: Web development in C: Crazy?

#171

A language like Python or Ruby gets you ease of coding and a moderate level of safety; a language like C gets you speed but at a high safety risk. Haskell could get you often similar speed benefits, and there are even a couple of rather interesting frameworks for it (with even things like compile-time template checking), but the barrier for entry is unfortunately high. Thus a language like Rust really comes into its…

I think Julia has the potential to be a contender in this space as well. The advantage over Rust or Go is that you get a dynamic language (with a REPL and everything), and still can have C-like performance. You also get metaprogramming and optional typing (so its there if you want safety but you can ignore it if you just need to crank something out). To me it really feels like a blend of the best of Python/Ruby and statically typed languages.

Re: Web development in C: Crazy?

#172
post #5

So, people can't hardly write safe web apps in PHP without spraying XSS and auth bypasses and arbitrary shell executions and arbitrary SQL injections everywhere, and you also want to hand the attackers the ability to segfault your server or possibly even straight-up run arbitrary code? Anyone smart enough to truly safely code a website in C is smart enough to learn a language to create that website which doesn't get…

Did you even seriously try it before you came up with this highly opinionated post.

Re: Web development in C: Crazy?

#173
post #44

Earlier quoted context omitted.

There 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 depende…

On 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...

Replace "disappear" by no support or no updates any longer ..

Re: Web development in C: Crazy?

#174
post #168
post #120

Earlier quoted context omitted.

I do mostly JVM and .NET based development nowadays, in consulting projects. Sometimes I wish to be part of a C or C++ based project, then I try to imagine how the quality of our offshore guys would map to those languages and realize how lucky I am not to be part of such projects.

Don't you do something wrong, when you consult the company to use (more) offshore guys? I thought that a company is best led, when developers share their knowledge cooperatively and ask their managers to outsource unimportant time-consuming things like api-/file-/conversions, legacy code support, CSVs … (Disclaimer: Don't get my tone wrong please, I'm asking not suggesting, thus I respect your experience.)

That's what is supposed to happen but the MBA asshats use it purely for cost cutting...

Re: Web development in C: Crazy?

#175
post #154

Earlier quoted context omitted.

> If you aren't smart enough [to safely code a website in C...] the first clue that you aren't is that you think that you are Gee, isn't that epistemology at its finest. Personally I've never met anyone who programmed in C because they were too dumb to learn anything else, but who knows. You may however be aware that, before an HTTP packet even makes it to your shiny, scripty web page, it's often processed by a succe…

I've never met anyone who programmed in C because they were too dumb to learn anything else I have. They were too dumb to understand that they were writing unsafe C code because they weren't skilled enough to write safe C code. So it never occurred to them that they had a problem that would be solved by writing part of their system in Python or Ruby or Java. it's often processed by a succession of "segfault-y" and "a…

>They were too dumb to understand that they were writing unsafe C code

"Too dumb to catch vulnerabilities in their code" is a much wider category than "too dumb to learn anything else [besides C]". You're not really providing an example of the second.

>The vast majority of C programmers are much less skilled than Apache and Linux developers

So we agree that at least some C developers can write consistently safe code. So a person is not necessarily "not smart" just because of this language choice.

Re: Web development in C: Crazy?

#176
post #167
post #154

Earlier quoted context omitted.

> If you aren't smart enough [to safely code a website in C...] the first clue that you aren't is that you think that you are Gee, isn't that epistemology at its finest. Personally I've never met anyone who programmed in C because they were too dumb to learn anything else, but who knows. You may however be aware that, before an HTTP packet even makes it to your shiny, scripty web page, it's often processed by a succe…

> it's often processed by a succession of "segfault-y" and "arbitrary-code-running" software such as Apache and Linux. If your web code has ~20 years of security audits and fixes it's probably perfectly safe to use it. If you're adding large new features under tight deadlines I don't recommend it.

Just addressing the OP's point that "if you're smart enough to safely write that C code, you won't".

Re: Web development in C: Crazy?

#177

A language like Python or Ruby gets you ease of coding and a moderate level of safety; a language like C gets you speed but at a high safety risk. Haskell could get you often similar speed benefits, and there are even a couple of rather interesting frameworks for it (with even things like compile-time template checking), but the barrier for entry is unfortunately high. Thus a language like Rust really comes into its…

I think Julia has the potential to be a contender in this space as well. The advantage over Rust or Go is that you get a dynamic language (with a REPL and everything), and still can have C-like performance. You also get metaprogramming and optional typing (so its there if you want safety but you can ignore it if you just need to crank something out). To me it really feels like a blend of the best of Python/Ruby and s…

I fully agree with you!

Personally I use Julia+C for my backends. Haven't decided which language to use for the front-end though, but probably just javascript, python or php.

Re: Web development in C: Crazy?

#178

I wrote a small (~300 line) C program to scrape an email and insert the part I wanted into a Postgres database. I used PCRE for the extraction and ECPG for the Postgres part. ECPG stands for embedded SQL in C for Postgres, and it looks like this: // Open the storage subsystem. void open_storage() { EXEC SQL BEGIN DECLARE SECTION; const char* database = DATABASE_NAME; const char* username = USERNAME; const char* schem…

This made me curious! Why did you do this? To create a database of "signatures" to be used in your contact-list?

Re: Web development in C: Crazy?

#179

When you get 90x the performance using C rather than PHP, the only thing stopping its use is human resources. To put it into perspective, you would need 90 PHP servers to do the same work in the same time as a single C server. Any more debate?

Yes, the cost equation of X PHP developers + 90 servers might be cheaper than the cost equation for Y C programmers + 1 server . Y is almost certainly greater than X .

While that may be true for the short term, what about the power, maintenance, storage etc costs that recur? I'm not sure a C dev's pay is equal to the running costs of a server farm...

Re: Web development in C: Crazy?

#180
post #168
post #120

Earlier quoted context omitted.

I do mostly JVM and .NET based development nowadays, in consulting projects. Sometimes I wish to be part of a C or C++ based project, then I try to imagine how the quality of our offshore guys would map to those languages and realize how lucky I am not to be part of such projects.

Don't you do something wrong, when you consult the company to use (more) offshore guys? I thought that a company is best led, when developers share their knowledge cooperatively and ask their managers to outsource unimportant time-consuming things like api-/file-/conversions, legacy code support, CSVs … (Disclaimer: Don't get my tone wrong please, I'm asking not suggesting, thus I respect your experience.)

Most consulting projects in Fortune 500 companies end up with outsourcing the whole project department to the consulting company, in the cases where IT is not the main business.
Post reply on HN