5 ms·
I honestly don’t like C++ at all as a programmer, “C” is way better for hacking. For example: I understand why the standard was written the way it was but synt
by swiley 7y ago
I honestly don’t like C++ at all as a programmer, “C” is way better for hacking.
For example: I understand why the standard was written the way it was but syntactic closures in C++ are way worse than GNU C.
- saagarjha 7y agoWhat are syntactic closures in GNU C?
- swiley 7y agoThis [1] explains how to create them using nested functions. Near the end is a quick blurb about the implementation which is probably why c++ doesn’t do it that way. [1] https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
- saagarjha 7y agoOh no, nested functions are a terrible, insecure hack that are far too verbose to be ergonomic closures :(
- swiley 7y agoOf course, that’s why I said it’s good for hacking. Although I’m not sure I agree about the “ergonomic” thing.
- amiga_500 7y agoWouldn't you just use a lambda nowadays?
- im3w1l 7y agoNot in C you wouldn't.
- geofft 7y agoDon't GNU C's closures/nested functions require an executable stack or something? I remember GNU GRUB going through and getting rid of all of them.
- saagarjha 7y agoYes, because that’s where they put trampolines that are generated on the fly. (They don’t need to do this, but that’s how it’s currently implemented.)
- Gibbon1 7y agoI use them. The executable stack bit doesn't bother me since I'm on an ARM Cortex. Would be nice if they fixed that because they are kinda handy once you get used to them.
- geofft 7y ago> The executable stack bit doesn't bother me since I'm on an ARM Cortex. I'm not familiar enough with ARM - what does ARM Cortex give you here?
- Gibbon1 7y agoIt's what it doesn't give me. Doesn't have a memory management unit, so no stack execution protection. So no protection against classic stack smashing attacks. I saw a talk about weird machines. The upshot of it is if you can clobber the return address on the stack you can usually create a weird machine that you can then program[1]. Leads me to believe that if you are putting entrusted data and return addresses on the same stack you're in a state of sin security wise. https://en.wikipedia.org/wiki/Weird_machine https://en.wikipedia.org/wiki/Weird_machine [1] Also saw an exploit on an embedded system where they leveraged that even though the memory was locked you could set the program counter and read/write registers via jtag. Using that they were able in short order to recover the devices security keys and re-flash it with their own code.
- 7y ago
- JustSomeNobody 7y agoI don’t like C++ anymore. I used to love it but now it’s just a bloated mess of a language. I get it, you don’t have to use every part of the language but I really don’t like any of the newer bits and that’s what everyone wants to use.