Earlier quoted context omitted.
Sounds like they know what they are doing. How is using c++ with only data classes different from using c with struct
Slightly better ergonomics I suppose. Member functions versus function pointers come to mind, as do references vs pointers (so you get to use . instead of ->)
I stopped everything and started writing C again
81–90 of 475 posts
Re: I stopped everything and started writing C again
#82Despite what some people religiously think about programming languages, imo C was so successful because it is practical. Yes it is unsafe and you can do absurd things. But it also doesn't get in the way of just doing what you want to do.
No, it's because of Unix and AT&T monopoly.
Re: I stopped everything and started writing C again
#83Your brain works a certain way, but you're forced to evolve into the nightmare half-done complex stacks we run these days, and it's just not the same job any more.
Re: I stopped everything and started writing C again
#84[flagged]
completely not! (And yes, I was considering if I should shout in capslock ;) ) I have seen so many fresh starts in Rust that went great during week 1 and 2 and then they collided with the lifetime annotations and then things very quickly got very messy. Let's store a texture pointer created from an OpenGL context based on in-memory data into a HashMap... impl GlyphCache { Yay? And then your hashmap .or_insert_with fa…
Re: I stopped everything and started writing C again
#85I 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…
C++ can avoid string copies by passing `const string&` instead of by value. Presumably you're also passing around a subset of the string, and you're doing bounds and null checks, e.g.
const char* Buf = "Hello World" ;
print_hello(Buf, 6);
string_view is just a char* + len; which is what you should be passing around anyway.Funnily enough, the problem with string view is actually C api's, and this problem exists in C. Here's a perfect example: (I'm using fopen, but pretty much every C api has this problem).
FILE* open_file_from_substr(const char* start, int len)
{
return fopen(start);
}
void open_files()
{
const char* buf = "file1.txt file2.txt file3.txt";
for (int i = 0; i += 10; ++i) // my math might be off here, apologies
{
open_file_from_substr(buf + i, buf + i + 10); // nope.
}
}
> When I develop methods in pure C, I always enjoy that I can concentrate 100% on algorithmic aspects instead of architectural decisions which I only have to decide on because of the complexity of the languageI agree this is true when you develop _methods_, but I think this falls apart when you design programs. I find that you spend as much time thinking about memory management and pointer safety as you do algorithmic aspects, and not in a good way. Meanwhile, with C++, go and Rust, I think about lifetimes, ownership and data flow.
Re: I stopped everything and started writing C again
#86[flagged]
I would use Mojo - you get the type and memory safety of Rust, the simplicity of Python and the performance of C/C++.
Python isn’t simple, it’s a very complex language. And Mojo aims to be a superset of Python - if it’s simple, that’s only because it’s incomplete.
Re: I stopped everything and started writing C again
#87Re: I stopped everything and started writing C again
#88Try zig, it is C with a bit of polish.
Re: I stopped everything and started writing C again
#89[flagged]
completely not! (And yes, I was considering if I should shout in capslock ;) ) I have seen so many fresh starts in Rust that went great during week 1 and 2 and then they collided with the lifetime annotations and then things very quickly got very messy. Let's store a texture pointer created from an OpenGL context based on in-memory data into a HashMap... impl GlyphCache { Yay? And then your hashmap .or_insert_with fa…
Re: I stopped everything and started writing C again
#90[flagged]