3 ms·
The most stupid C bug ever? Pointers. Or rather, value of, rather than dereference by default. Ada got this right, dereference by default, no pointer arithmeti
by spitfire 15y ago
The most stupid C bug ever? Pointers.
Or rather, value of, rather than dereference by default.
Ada got this right, dereference by default, no pointer arithmetic.
- wlievens 15y agoReally? Can you do everything C can do on every platform it's used on, after you've hidden away pointers? Or do you simply want to change the syntax?
- keeperofdakeys 15y agoIt isn't a bug, it is a feature. C wasn't designed to abstract away the reality of pointers, which are the basic building blocks of assembly. If you don't like pointers, then don't use C. All programming languages have their time and place (even something like whitespace). The advantage of not abstracting pointers is that it makes low-level programming much easier. Instead of having to write your operating system kernel in assembly, you can write it in a portable language that is much easier to read!
- exDM69 15y agoEvery language which does not support pointers and pointer arithmetic by default has a more complicated way of doing it. Look at Python, for example. When you want to deal with arrays for interfacing with C code or image processing or just for plain performance gains, you have to deal with Numpy arrays which are even more difficult than pointers (esp. when it comes to C code wrappers). Haskell gets this right. You never write regular Haskell code with pointers but when you need to do some low level stuff, there is a native pointer type and I/O operations peek and poke. The pass by value semantics of C are well suited for the low level language that C is.