The sentiment of this web page is delightful but doing web programming in C or any other language where you do your own memory management is asking for so much trouble. You’re trading the incidental complexity of [insert hipster web language + framework here] for the incidental complexity of valgrind, asan, tsan, etc.
I wish there was an efficient memory-safe language that had the history and cachet of C among communities with the OpenBSD ethos - like Pascal or Oberon, had they survived the 90s in any meaningful sense. At least one of the useful languages from the current PL renaissance in industry will undoubtedly be in this position in 20 or 30 years - C won’t keep eating its children forever :)
“I wish there was an efficient memory-safe language that had the history and cachet of C among communities with the OpenBSD ethos”
ocaml comes close to being that. It’s a language with a strong type system (with type inference and everything), automatic memory management, and a very straightforward compiler. I don’t know that any C compiler beats ocamlopt in how easy to debug the generated code is.
There is even a book on Unix system programming in OCaml :):
You could slot Oberon (or OCaml, Go, LuaJIT, Rust - CGI scripts don’t discriminate) into this stack right now and it would work just fine - the fun of using C for this is that there’s some unquantifiable value in saying “we use one language for the bulk of work on or in this system moving forward, and it’s a language that’s suitable for any job you can throw at it.”
I imagine it could be rust, but there’s a degree of fetishism which I think is detrimental. People learned C without first having to learn to love C. There’s a trend now, however, that you can’t just learn a tool, you must love it. The hype turns off a lot of potential practitioners.
There are some other not C languages I enjoy. But I arrived here without people telling me how much better life would be if only I made the switch.
The Rust community is definitely strongly in favor of its language of choice, and while I think the core of the community (the Rust teams, developers of major Rust libraries, major language contributors) are appropriately careful about the rhetoric they use and claims they make, others in the community are often not so careful. Part of this comes from misunderstanding of the guarantees Rust provides (“no data races” becomes “no race conditions,” for example, which is a stronger claim), and part of this comes from people being imprecise in the words they use, even if they do understand the actual guarantee being made.
I am looking forward to the results of the Rust Belt project, which is looking to formalize Rust, and provide a stronger and clearer description of what sort of guarantees Rust provides. There also ongoing efforts by the Rust teams to provide a stronger description of what behaviors are considered safe vs. unsafe, and to generally tighten up both their own understand of the language, and to improve the explanations official Rust documents provide. My hope is that this formalization will provide something clearer and stronger to reference when people discuss Rust and what it can offer them.
EDIT: I should also say that I think a lot of people in the Rust community come by the excitement honestly. Personally I can be very effusive about Rust, and have to regularly remind myself to tone it down when pitching Rust to people. It is a cool language that does a lot of things I appreciate, and that feels “right” to me in a way that engenders a strong desire to encourage its use elsewhere, if only to give me more opportunities to write in it.
I mostly agree with tedu on this. I like rust but there is a huge “fetishism” right now in the hype cycle. Reminds me a lot of what golang went through up until people realized where go didn’t fit in.
Different languages sure, but yes everyone is excited but all the “you not writing in rust is bad and you should feel bad” (i’m paraphrasing) articles start to make me want to throw out regular old C more. Its not great, but after 40+ years with some minimal tools you can fairly easily mitigate most problems.
An example of something Rust doesn’t provide but gets brushed over far too often: guarantees that you don’t have a memory leak. Memory leaks are by definition “memory safe”, but that isn’t all that interesting when it occurs. Its great it won’t break the program, but rust isn’t solving every class of problems around memory allocation. It is really tough to pierce the fanboy attitudes around the enthusiasm. It is great people are enjoying it, but lets come down to reality and evaluate based on facts not “c isn’t memory safe”. On its own that is correct as a statement, but just as meaningless as saying having a memory leak is “memory safe” IMO.
Don’t get me wrong, rust is a good language, just could use more of the enthusiasm at a 7 not an 11. I’m not going to convert the 3k lines of C I’ve written this year to rust just because rust exists. (kernel module so no rust isn’t a great option even at this stage)
Rust is my go-to language right now, and I also agree with tedu. My point was trying to a) clarify that, unfortunately, the broader community is not as careful and measured in their proselytizing for Rust as the core community is, and b) this will almost certainly get better over time, particularly as Rust’s guarantees are give a more precise and formal treatment.
Yep no worries, my bigger gripe is “memory safe” is really quickly turning into a rust thought terminating cliche at times.
I think that “fetishism” is typical of early adoption of most tools. I would love to be able to read the discourse around C and Unix between 1970 and 1980, for example, where I imagine C went through the same hype cycle in a relatively tight-knit community, so it left few artifacts.
It’s so rare that a tool is truly unequivocally better than its predecessors that effusive praise tends to help people tamp down the cognitive dissonance of recognizing the areas in which it’s worse. I take your point, though - it would be nice if the discourse around new tools wasn’t this way.
Within living memory, I can recall python going from being an also-ran to mainstream, but with very few people constantly telling me “I can’t believe you’re not using python already.” I do believe there has been a change in attitude that didn’t exist before. Online communities grant status and standing to pretenders. Just look at how easy it is to gain karma by shit talking PHP, even when one has had zero experience with PHP, or any programming language!
Would Go be an alternative? e.g. this seems convincing (I’ve only skimmed it, though).
Lua is a very viable alternative - all the power of C, none of the issues. OpenRESTY and LAPIS both run very well on OpenBSD too ..
What does all the power of C mean? A good FFI?
If you haven’t considered Go, I’d encourage you to do so. It checks the boxes. It’s a memory safe language, not too far away from C, relatively efficient. And to top if off, it does provide builtin tooling to supplant tsan via go build -race.
go build -race
If that’s not your cup of tea, Rust seems to have all those benefits of memory safety and thread safety.
C++? The best thing about C++ is “You only pay for what you use”. It is as C like or Java like as you choose. At my work we use it in a very C like way, but we get the advantage of free RAII, basic containers like list, vector, map, and simple to use strings. This all means simpler, terser code which is easier to reason about, maintain, and debug.
I wish there was an efficient memory-safe language […]
I wish there was an efficient memory-safe language […]
C++ lacks memory safety.
I’m not sure if it’s lost on the authors or maybe that’s the point, but doing this would be the hipster thing to do in 2016.
Yeah, some of us have been doing this for decades though, already, so: not really, not hipster, no ..
Yes, just like some people have been riding fixies and growing mustaches for decades. :-)
So… You were doing it before it was cool?
No, before there were hipsters.
You, Trevor, are the proto-hipster.
Awesome. The kids (and human psychology?) these days expect example snippets, so I hope kristaps will be able to expand on this over time.
I can already see myself in a hoodie that reads /biːtʃəz/ in large letters and subtle URL somewhere. I’m holding an OpenBSD mug filled to the brim with hot chocolate and I’m wearing a fabulous hat. No pants, though. SAY NO TO PANTS!
Not /bitʃəz/? I’m disappointed.
I’m still not sure if that’s a joke or the actual thing…
Yeah, I’m still not sure whether this is a joke or what. “hipster-free” made me lean towards it being a joke, but who knows. Individually, these are some solid tech choices. But together? Web programming in C? That’s so early 2000s, which is to say, didn’t we move from that for a reason?
I thought this was a joke when I first saw the site. The name itself reads like “bitches” to me.
I wonder if it could be http://c2.com/cgi/wiki?HaHaOnlySerious
Sweet… I’m totally already running a BCHS stack for my command line primer blog! –well, except the C part.
I think C can be exchanged to ksh(1) in smaller projects ;-)