Hacker News new | past | comments | ask | show | jobs | submit login

I don't see how type aliasing negates anything of what I am saying. Types are an abstraction but C++ allows you to extract its pointer, to make a sizeof() of it, to do pointer casting and arithmetics.

You can go low level with most high level languages, what sets C++ apart is that using low-level instructions have generally zero overhead. ptr2 = static_cast<uint8_t*>(ptr)+5; pretty much maps to the assembly code you would expect.




> Types are an abstraction but C++ allows you to extract its pointer, to make a sizeof() of it, to do pointer casting and arithmetics.

And the semantics of those operations are dictated not by what the underlying machine does but what the C++ abstract machine does, which is very different. The underlying memory is still typed.

> You can go low level with most high level languages, what sets C++ apart is that using low-level instructions have generally zero overhead.

That's true for the JVM, .NET, even JS...

> ptr2 = static_cast<uint8_t*>(ptr)+5; pretty much maps to the assembly code you would expect.

No, it doesn't, not after optimizations and undefined behavior. It's perfectly acceptable for the compiler to turn that into a no-op if, for example, "ptr" was a null pointer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: