That is one of the languages I love the most, it seemed scary at first but when I learnt it, it was easy. It is C++ without OOP and memory handling issues. But it is simple, everything is your fault and your success
That's why I like Rust so much. It’s a compiler that simply refuses to let you pull the trigger if the code isn’t safe.
You still get OOP-style structure, just not in the traditional C++ sense. Instead you have modules, structs, enums, traits. Clear composition without header chaos.
Less implicit magic, almost no undefined behavior, and far stricter guarantees at compile time.
The tradeoff is obvious though: the learning curve isn’t a hill. It’s a wall. You don’t really get to learn topics in isolation. Ownership, borrowing, lifetimes, traits, concurrency they all interact from day one.
So yes, learning Rust is “straightforward”: start with small toy projects. Or do what I did make a neurosymbolic AI your first project.
In that case the learning curve stops being a wall and becomes Olympus Mons on Mars.
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
I love C, dunno about you. Just reach down and mess around with the raw bits if you need to, sure, careful not to get your fingers chopped off by the spinning gears though.
Technically, I guess, it depends on the internal representation of floating point numbers, but I'm guessing they knew it would work on the architectures they planned to support at the time, which was pretty much just x86, no?
Yeah I think you’re right with that, did what they wanted either way I guess but it’s definitely UB, it’s similar to having a union and accessing an inactive member
Type punning though a union is not UB in C. It is UB in C++. Quick inverse square root is type punning through a cast, which is UB in both C and C++ since it violates strict aliasing.
To elaborate, C does not guarantee that type punning through a union will work, but it also doesn't affirmatively mark it as UB. It is implementation defined/unspecified with most compilers supporting it on most platforms. The technical term is "IB with possible trap" iirc
It's technically always UB per the C standard. Every major compiler allows it if you use -fno-strict-aliasing tho, in which case, yeah, it's representation/architecture dependent
I have seen coworkers making memory leaks in c#, doesn’t mean c# doesn’t have memory management. I have seen python and JavaScript code that’s unreadable and requires a minute to decipher a line or two of code..actually I don’t like python and JavaScript, they are not good languages syntactically and JavaScript has bugs.
C and C#, and Java are fine to me and are consistent enough in my opinion that you can write intelligible and readable code.
If a drunk person has a car accident, doesn’t mean the car is not reliable or good method of transportation.
Memory leaks in C# are easy to make. I create them more often than I'd like to admit. Forgetting to unsubscribe to an event is a common cause. One that drove me nuts at one time was not disposing a linked CancellationTokenSource. But the tools for finding them are also very easy. Reflection means looking at the heap in a memory dump usually tells you all you need to know. That said, I've been trying to find a Windows handle leak for years. Native to managed interop can be a beast!
Interop or invoke or win32 api, is usually running c or c++ so the leak is in handling c code. The coworker made c# leaks which are embarrassing, like having an infinite loop and allocating data in the loop without an await. Or allocating new memory over reusing an object until windows crashes or not using using.
Oh and you actually need a pointer to access the actual array element, so *(a+10) would be the equivalent to a[10] (IIRC (a+10) simply grabs the location in memory that the element is at)
Yeah, (a+10) is still a pointer. And that means you can add a value to the pointer if you want to have a function start at some index at an array without having to copy or tell the function it's not starting at the beginning
Exactly, there's zero overhead, everything is just an address and a length and you can do basically anything. The macros are also crazy good and writing C makes me better at all languages because I have to debug with printf instead of being told exactly where the error is.
Arrays are indexed using arr + (sizeof(*arr) * index), so if the type of a is int, then a[10] == *(a + (32*10)) (so if the address of a is 0x1000 (4096 on dec) then a[10] is 0x140000).
78
u/jontsii Feb 11 '26
wdym C is awesome
21
u/i_should_be_coding Feb 11 '26
I love C, dunno about you. Just reach down and mess around with the raw bits if you need to, sure, careful not to get your fingers chopped off by the spinning gears though.
23
u/Hot-Rock-1948 Feb 11 '26
Honestly that's my favorite part of C/C++ lol.
Oh and you actually need a pointer to access the actual array element, so
*(a+10)would be the equivalent toa[10](IIRC(a+10)simply grabs the location in memory that the element is at)5
u/Justanormalguy1011 Feb 12 '26
Seem about right l what is wrong with that
5
u/CommieCucumber Feb 12 '26
Oh, my post is reposted. Thanks for your fork.
3
u/Helmut_v_M Feb 12 '26
HolyC is the only way.
2
u/jimmiebfulton Feb 11 '26
I felt like I was looking at a JavaScript meme.
2
u/EvnClaire Feb 12 '26
this is precisely what makes it good bruh
2
u/nocciuu Feb 12 '26
Programm in C....manage your memory with malloc and free
1
u/dhnam_LegenDUST Feb 12 '26
/s it's called 'syntactic sugar'.
1
u/Mr_Otterswamp Feb 12 '26
See how the brown guy is blurry? That’s because he’s pretty good in C, but on the downside he can’t C#
1
u/Key_River7180 Feb 12 '26
No it isn't, what is the type of a?
Arrays are indexed using
arr + (sizeof(*arr) * index), so if the type of a is int, thena[10] == *(a + (32*10))(so if the address of a is0x1000(4096 on dec) thena[10]is0x140000).Thanks
1
u/APlanetWithANorth Feb 12 '26
C my beloved
1
u/raewashere_ Feb 14 '26
isnt that only if sizeof *a is 1
otherwise 10 is scaled right