Web development in C: Crazy?
141–150 of 213 posts
Re: Web development in C: Crazy?
#142Re: Web development in C: Crazy?
#143Re: Web development in C: Crazy?
#144So, 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…
Using that same logic we shouldn't use C for anything, because we might make a mistake . I wouldn't use this not because of possible mistakes leaking in, but because the higher-level languages have already solved some of the problems you would have to solve yourself, such as handling unicode. There are C frameworks you could use but my point is that you would come across problems that have already been solved, and yo…
Re: Web development in C: Crazy?
#145So, 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…
I use C every day, and I wrote a whole framework for writing websites in C (no longer maintained because I'm no longer that interested in writing websites): http://web.archive.org/web/*/http://www.annexia.org/freeware... What was amazing was that you could write pretty complex dynamic websites that fit into a few K of RAM and could trivially handle huge load. I originally wrote that framework for a chat service. It r…
- It used a scheme for cooperative threading that is similar to coroutines. This meant you could write straightforward code and all the event driven stuff was done automatically behind the scenes.
- Parallelism wasn't so important back in 2001 but you could also do that by forking N reactors (one for each core).
- There was a C string library modelled on Perl. It had lots of string management, vectors and hashes. Buffer overflows were effectively made impossible by the string handling library.
- UTF-8 was used throughout and it was fully i18n-able (using getttext).
- Template library.
- There was a pool-based memory allocator library (similar to Apache's APR / Samba's talloc). Effectively you didn't have to worry about memory allocation at all except in some rare corner cases, mainly when you wanted to store something in a global cache.
- All persistence done through PostgreSQL using a Perl DBI-like library. SQL injection was impossible because it used prepared statements.
- There was a rather experimental system built on top of this that allowed you to embed widgets in webpages so you could write very interactive stuff without using Javascript (something of a concern back in 2001, not so much now). It maintained the widget state transparently across page reloads. AFAIK no one has every done anything like this before or since.
It was, to some extent, a bit crazy that I wrote all of the above in about 6 months, but I was being paid a lot of money, working at a very disfunctional company that was on the verge of going out of business, and didn't have much else to do.
Re: Web development in C: Crazy?
#146Earlier quoted context omitted.
Given the choice C++ is way better than C, given that it allows to use higher level abstractions and replace all unsafe C heritage by library based safe constructs. Of course, the best option would be to replace them by other languages with native compilers. However at the level these languages are used, it will only happen when OS vendors push new languages for their OS. So it will never happen in UNIX land or Mac O…
> Given the choice C++ is way better than C, given that it allows to use higher level abstractions and replace all unsafe C heritage by library based safe constructs. You may have noticed that C++ is not always deemed universally better than C. What language are all the top web servers implemented in? C has library based safe constructs as well, and C++ still has all of C unsafety. You just get to exercise those bugs…
Apache and nginx => C
Tomcat, Jetty => Java
IIS => C++/C#
> Most OS's actually have a pretty small API footprint (Windows being the obvious outlier). If it were really just about the language bindings, it would not be a real impediment. A language runtime can abstract out the OS (as the C runtime does).
If developers aren't forced to use it, then they won't use it, even if made available.
> I'm going to claim this could well be a function of Darwinian forces.
That is my hope, after all we only need a few generations of developers and then the issue is taken care of by itself.
Re: Web development in C: Crazy?
#147Re: Web development in C: Crazy?
#148Earlier quoted context omitted.
Given the choice C++ is way better than C, given that it allows to use higher level abstractions and replace all unsafe C heritage by library based safe constructs. Of course, the best option would be to replace them by other languages with native compilers. However at the level these languages are used, it will only happen when OS vendors push new languages for their OS. So it will never happen in UNIX land or Mac O…
> Given the choice C++ is way better than C, given that it allows to use higher level abstractions and replace all unsafe C heritage by library based safe constructs. You may have noticed that C++ is not always deemed universally better than C. What language are all the top web servers implemented in? C has library based safe constructs as well, and C++ still has all of C unsafety. You just get to exercise those bugs…
The problem C's lacking one of most important primitives - data structures.
Bugs in standard library happen pretty rarely, I guess. So, C++ users have most common data structures for free.
And when I open some C-based project's code the first thing I usually expect and see is some homegrown linked list and/or map implementations (of SIGSEGV fame). I know, there are tons of libraries that offer them, but in my experience of "hey, that server crashed, could you figure out what went wrong"-type tasks, they're very rarely used.
Re: Web development in C: Crazy?
#149His point was that we used to live in a software ecosystem where the conventional wisdom was that if a programming language didn't look like C, it wasn't going to take off. JavaScript (and even more so variants like CoffeeScript) are showing that we've moved on from that sentiment.
In some ways, this article feels like a retreat to that older assumption. As if we somehow are expected to be searching for ways to work C into the modern web app landscape. Perhaps this point may somewhat orthogonal to the topic of the article and the related discussion, but I can't help but ask what problems are we solving by going back to C for web development? Is the assumed performance gain going to outweigh all the other benefits of using a higher level abstraction?
None of the framework examples listed in the article really seem elegant at all when compared to higher level counterparts (Rails, Django, Spring, et al). Of course, I'm saying this without having attempted to build an application with any of them.