Live data from Hacker News

I stopped everything and started writing C again

kmx.io

51–60 of 475 posts

Re: I stopped everything and started writing C again

#51
post #47

Earlier quoted context omitted.

Try doing C with a garbage collector ... it's very liberating. Do `#include ` then just use `GC_malloc()` instead of `malloc()` and never free. And add `-lgc` to linking. It's already there on most systems these days, lots of things use it. You can add some efficiency by `GC_free()` in cases where you're really really sure, but it's entirely optional, and adds a lot of danger. Using `GC_malloc_atomic()` also adds eff…

Which GC is that you’re using in these examples?

I'm not OP but the most popular C GC is Boehm's: https://www.hboehm.info/gc/

Re: I stopped everything and started writing C again

#52
post #11

I fully understand that sentiment. For several years now, I have also felt the strong urge to develop something in pure C. My main language is C++, but I have noticed over and over again that I really enjoy using the old C libraries - the interfaces are just so simple and basic, there is no fluff. When I develop methods in pure C, I always enjoy that I can concentrate 100% on algorithmic aspects instead of architectu…

About 16 years ago I started working with a tech company that used "C++ as C", meaning they used a C++ compiler but wrote pretty much everything in C, with the exception of using classes, but more like Python data classes, with no polymorphism or inheritance, only composition. Their classes were not to hide, but to encapsulate. Over time, some C++ features were allowed, like lambdas, but in general we wrote data clas…

Sounds like they know what they are doing. How is using c++ with only data classes different from using c with struct

Re: I stopped everything and started writing C again

#53
post #18
post #4

[flagged]

That really depends what you want to do. All that security in Rust is only needed if there is a danger of hacks compromising the system. The moment you start building something that's not exposed to the internet and hacking it has no implications, C beats it due to simplicity and speed of development .

> All that security in Rust is only needed if there is a danger of hacks compromising the system.

Rust's safety features help prevent a large class of bugs. Security issues are only one kind of bug.

> C beats it due to simplicity and speed of development

C being faster to develop than Rust is a ludicrous claim.

Re: I stopped everything and started writing C again

#54
post #11

I fully understand that sentiment. For several years now, I have also felt the strong urge to develop something in pure C. My main language is C++, but I have noticed over and over again that I really enjoy using the old C libraries - the interfaces are just so simple and basic, there is no fluff. When I develop methods in pure C, I always enjoy that I can concentrate 100% on algorithmic aspects instead of architectu…

I completely agree with this sentiment. That's why I wrote Datoviz [1] almost entirely in C. I use C++ only when necessary, such as when relying on a C++ dependency or working with slightly more complex data structures. But I love C’s simplicity. Without OOP, architectural decisions become straightforward: what data should go in my structs, and what functions do I need? That’s it.

The most inconvenient aspect for me is manual memory management, but it’s not too bad as long as you’re not dealing with text or complex data structures.

[1] https://datoviz.org/

Re: I stopped everything and started writing C again

#55
Here's what kc3 code looks like (taken from [1]):

    def route = fn (request) {
      if (request.method == GET ||
          request.method == HEAD) do
        locale = "en"
        slash = if Str.ends_with?(request.url, "/") do "" else "/" end
        path_html = "./pages#{request.url}#{slash}index.#{locale}.html"
        if File.exists?(path_html) do
          show_html(path_html, request.url)
        else
          path_md = "./pages#{request.url}#{slash}index.#{locale}.md"
          if File.exists?(path_md) do
            show_md(path_md, request.url)
          else
            path_md = "./pages#{request.url}.#{locale}.md"
            if File.exists?(path_md) do
              show_md(path_md, request.url)
            end
          end
        end
      end
    }
[1] https://git.kmx.io/kc3-lang/kc3/_tree/master/httpd/page/app/...

Re: I stopped everything and started writing C again

#56
post #32

Earlier quoted context omitted.

Rust is not free of trade offs and you're not helping the cause the way you think you are. Just a few off the top: - Rust is a much more complex language than C - Rust has a much, much slower compiler than pretty much any language out there - Rust takes most people far longer to "feel" productive - Rust applications are sometimes (often?) slower than comparable C applications - Rust applications are sometimes (often?…

> Rust is a much more complex language than C Feature wise, yes. C forces you to keep a lot of irreducible complexity in your head. > Rust has a much, much slower compiler than pretty much any language out there True. But it doesn't matter much in my opinion. A decent PC should be able to grind any Rust project in few seconds. > Rust applications are sometimes Sometimes is a weasel word. C is sometimes slower than Ja…

Good for you. Like the grandparent commenter said, for others these tradeoffs might be important. E.g.:

> I am disappointed with how poorly Rust's build scales, even with the incremental test-utf-8 benchmark which shouldn't be affected that much by adding unrelated files. (...)

> I decided to not port the rest of quick-lint-js to Rust. But... if build times improve significantly, I will change my mind!

https://quick-lint-js.com/blog/cpp-vs-rust-build-times/

Re: I stopped everything and started writing C again

#57

Earlier quoted context omitted.

Rust is not free of trade offs and you're not helping the cause the way you think you are. Just a few off the top: - Rust is a much more complex language than C - Rust has a much, much slower compiler than pretty much any language out there - Rust takes most people far longer to "feel" productive - Rust applications are sometimes (often?) slower than comparable C applications - Rust applications are sometimes (often?…

> helping the cause Rust evangelism is probably the worst part of Rust. Shallow comments stating Rust’s superiority read to me like somebody who wants to tell me about Jesus.

it's not unique for Rust, C/C++ devs probably aren't just used to it, since there hasn't been anything major new for decades.

If you already dislike this, I ask you to read C-evangelism with respect to the recent Linux drama about Rust in Linux.

Re: I stopped everything and started writing C again

#58
post #32

Earlier quoted context omitted.

Rust is not free of trade offs and you're not helping the cause the way you think you are. Just a few off the top: - Rust is a much more complex language than C - Rust has a much, much slower compiler than pretty much any language out there - Rust takes most people far longer to "feel" productive - Rust applications are sometimes (often?) slower than comparable C applications - Rust applications are sometimes (often?…

> Rust is a much more complex language than C Feature wise, yes. C forces you to keep a lot of irreducible complexity in your head. > Rust has a much, much slower compiler than pretty much any language out there True. But it doesn't matter much in my opinion. A decent PC should be able to grind any Rust project in few seconds. > Rust applications are sometimes Sometimes is a weasel word. C is sometimes slower than Ja…

> C takes me more time to feel productive. I have to write code, then unit test, then property tests, then run valgrind, check ubsan is on. Make more tests. Do property testing, then fuzz testing.

So … make && make check ?

Re: I stopped everything and started writing C again

#59
post #32

Earlier quoted context omitted.

> Rust is a much more complex language than C Feature wise, yes. C forces you to keep a lot of irreducible complexity in your head. > Rust has a much, much slower compiler than pretty much any language out there True. But it doesn't matter much in my opinion. A decent PC should be able to grind any Rust project in few seconds. > Rust applications are sometimes Sometimes is a weasel word. C is sometimes slower than Ja…

Real projects get into the millions of lines of code, Rust will not scale to compile that quickly.

Not quickly, no. But neither does C++ (how long does it take to compile Clang?) and people manage fine.

Faster would obviously be better, but it's not big enough of a deal to cancel out all the advantages compared to C.

Post reply on HN