Live data from Hacker News

I stopped everything and started writing C again

kmx.io

251–260 of 475 posts

Re: I stopped everything and started writing C again

#251

Writing code in C is very unpleasant, verbose and repetative. For example, if I want to have a structure in C and have a way to print its contents, or free its memory and memory of nested structures, or clone it recursively, it is very difficult to make automatically. I found only two options: either write complicated macros to define the structure and functions (feels like writing a C++ compiler from scratch), or de…

Simplify.

If you try to write the same complicated mess in C as you would in any other language it's going to hurt.

Not having a package manager can be a blessing, depends on your perspective.

Re: I stopped everything and started writing C again

#252
post #3

So this is a journey where starting in ruby, going through an SICP phase, and then eventually compromising that it isn't viable. it kinda seems like C is just the personal compromise of trying to maintain nerdiness rather than any specific performance needs. I think it's a pretty normal pattern I've seen (and been though) of learning-oriented development rather than thoughtful engineering. But personally, AI coding h…

Because Ruby can't handle most of the problems C is used for?

Because they're implementing Ruby, for example?

Re: I stopped everything and started writing C again

#253

Maybe the moral here is learning Lisp made him a better C programmer. Could he have jumped right into C and had amazing results, if not for the Journey learning Lisp and changing how he thought of programming. Maybe learning Lisp is how to learn to program. Then other languages become better by virtue of how someone structures the logic.

I would definitely recommend any programmer to learn both Lisp and C at some point.

Re: I stopped everything and started writing C again

#254

Earlier quoted context omitted.

Modern C++ has goodies like consteval that are supremely useful for embedded work. STL and the rest of the stdlib on the other hand depends on heap and exceptions for error reporting which are generally a no go zone for resource constrained targets. You can productively use C++ as C-with-classes (and templates, and namespaces, etc.) without depending on the library. That leaves you no worse off than rolling your own…

Can't you disable exceptions?

Yes, but the C++ library becomes inherently broken because there is no error reporting.

Re: I stopped everything and started writing C again

#255
post #244
post #227

Earlier quoted context omitted.

Sure, that's a pretty common pattern in use in C to this day. It's a useful pattern, but it's still all manual. Forget to fill in a function pointer in a struct? Crash. At least with C++ it will fail to compile if you don't implement a method that you have to implement.

At least in C it's only plain old function pointers. You don't have to think about exceptions, overloaded operators, copy constructors, move semantics etc.

You still need to think about error handling, and it's not standardized because everyone else will also have to think about it ad hoc.

You'll also still need to think about when to copy and move ownership, only without a type system to help you tell which is which, and good luck ensuring resources are disposed correctly (and only once) when you can't even represent scoped objects. `goto` is still the best way to deal with destructors, and it still takes a lot of boilerplate.

Re: I stopped everything and started writing C again

#256
post #244

Earlier quoted context omitted.

At least in C it's only plain old function pointers. You don't have to think about exceptions, overloaded operators, copy constructors, move semantics etc.

You still need to think about error handling, and it's not standardized because everyone else will also have to think about it ad hoc. You'll also still need to think about when to copy and move ownership, only without a type system to help you tell which is which, and good luck ensuring resources are disposed correctly (and only once) when you can't even represent scoped objects. `goto` is still the best way to deal…

But you have a choice, you don't have to implement all of C++/Rust.

The beauty of C is that it allows you to pick your level of complexity.

Re: I stopped everything and started writing C again

#257
post #185

Earlier quoted context omitted.

The single best feature (and I would say the _core_ feature separating it from C) that C++ has to offer is RAII and zig does not have that. So I don’t know which good parts of C++ they kept. Zig is more of its own thing, and they take from wherever they like, not just C++.

Zig has defer, which is arguably way simpler. Is there something RAII can do that defer can't? Not everyone likes RAII by itself. Allocating and deallocating things one at a time is not always efficient. That is not the only way to use RAII but it's the most prevalent way.

defer can't emulate the destructors of objects that outlives their lexical scope. Return values and heap objects are examples of these since they outlive the function they were created in. defer only supports enqueuing actions at lexical boundaries.

If you destroy an object that outlives the lexical scope it was created in, then you have to clean up manually.

Re: I stopped everything and started writing C again

#258

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.

[flagged]

Re: I stopped everything and started writing C again

#259
About a year ago, I had gotten fed up with what felt like overlyb strict context requirements basically giving me to abandon years of work and thought I'd try my hand at C++ again.

I wanted to do this on Linux, because I my main laptop is a Linux machine after my children confiscated my Windows laptop to play Minecraft with the only decent GPU in the house.

And I just couldn't get past the tooling. I could not get through to anything that felt like a build setup that I'd be able to replicate in my own.

On Windows, using Visual Studio, it's not that bad. It's a little annoying compared to a .NET project, and there are a lot more settings to worry about, but at the end of the day VS makes the two but very different from each other.

I actually didn't understand that until I tried to write C++ on Linux. I thought C++ on Windows was worlds different than C#. But now I've seen the light.

I honestly don't know how people do development with on Linux. Make, Cmake, all of that stuff, is so bad.

IDK, maybe someone will come along and tell me, "oh, no, do this and you'll have no problems". I hope so. But without that, what a disgusting waste of time C and C++ is on Linux.

Re: I stopped everything and started writing C again

#260
post #5

Earlier quoted context omitted.

Except complexity of language

You can ignore most of the complexity that's not inherent to the program you're trying to write. The difference is C also lets you ignore the inherent complexity, and that's where bugs and vulnerabilities come from.

In Rust/C++ you can't, it's forced upon you.

In C you can ignore whatever you feel like, and that bothers some people so much that they have to stop everyone else from doing it.

Post reply on HN