3 ms·
Nowadays, it seems difficult to understand how could someone invent something so... awkward. However, keep in mind all the other constraints he had at the time.
by outworlder 12y ago
Nowadays, it seems difficult to understand how could someone invent something so... awkward. However, keep in mind all the other constraints he had at the time. Inventing a sane syntax probably took a backseat ()
Now, the bigger issue is why is the C syntax surviving. I blame Java and now Javascript. This will only get worse as more people get to know it. At least javascript doesn't have so many type shenanigans: try parsing in your head a pointer to a C function that takes a pointer to a struct or something.
Still, C is a pretty nice fallback when you have nailed your algorithm and must absolutely get the last drop of performance (and want to still reason about what the compiler is doing, so C++ is out). Or when you want to interface with anything written in C.
() Then again, he could just have done a Lisp and removed almost all syntax.
- xg15 12y agoI'm no C expert, but couldn't you contain the madness for a good part with a sane code convention and smart use of typedefs? It looks to me as if the part where everything breaks down is mostly with "nested" function pointer types like in the "ultimate" example of the tutorial. (The syntax of "simple" function pointers is quirky as well, but without recursion, you might get the hang of it after a short time) So, couldn't you avoid much of the confusion by mandating that function pointers may refer to other function pointers only through typedefs? Of course this wouldn't work for legacy code...
- outworlder 12y agoYes, that makes it slightly saner by not having to parse the declaration in your head all the time.
- bjz_ 12y ago> Now, the bigger issue is why is the C syntax surviving. I blame Java and now Javascript. This will only get worse as more people get to know it. Thankfully Swift, Rust, Go, Scala, Typescript, and AtScript are all doing away with the spiral declaration syntax.
- SamReidHughes 12y agoJava syntax doesn't have any of the spiral type parsing behavior that C's has. So it's unclear what you have to complain about.