Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> C uses a needlessly confusing spiral rule

Libellous! The "spiral rule" for C is an abomination and not part of the language. I happen to find C's type syntax a bit too clever for beginners, but it's marvellously consistent and straightforward. I can read types fine without that spiral nonsense, even if a couple of judicious typedefs are generally a good idea for any fancy function types.



> fancy function types

If the syntax were straightforward, plain old function types wouldn't be ‘fancy’ :)


Ambiguous parse. I don't mean that all function types are fancy, I mean that some are fancy (when you have a function pointers in the arguments or return value, or several layers of indirection), and that those which are fancy are helped by typedefs.


I maintain — they shouldn't be fancy. ‘Fancy’ is the mark of something your language doesn't support well. They can be _long_, and that's often worth breaking up, but if something is ‘fancy’ it's because it's not clear to read, so you should attach some identifier to it that explains what it's supposed to mean. That's significantly, though not exclusively, a function (ha) of the syntax used to express the concept.

If you're working with Roman numerals, division is a very fancy thing to do.


Fair enough. I think it qualifies as "essential complexity" and in my limited experience it's not a common use case and so doesn't make sense to optimize for.

In fact in my academic and professional career most of the highly "functional" C that I've come across has been written by me, when I'd rather amuse myself than make something readable.

[0] https://en.wikipedia.org/wiki/Essential_complexity


It (this particular example, of function pointer syntax) is absolutely just incidental complexity, though. E.G. Haskell

(a -> b) -> c -> d

becomes C

D (*f(B (*)(A)))(C)

and it's no surprise that the former is considered much less fancy than the latter.

Of course it's not common — because the language makes it painful :) The causation is the other way around. We've seen in plenty of languages that if first-class functions are ergonomic to use then people use them all over the place.


Without curring and closures it certainly will be more painful!

I might write the equivalent signature,

  D f(A, B, C)
and then reorganize things to just pass f around, or make a struct if you really want to bake in your first function.


Right, due to the complexity of the syntax one of the most sensible things to do in C if you're faced with a problem that maps naturally to higher-order functions is to reframe the problem so that the solution doesn't use higher-order functions — basically doing a compilation step yourself. D (*f(B (*)(A)))(C) is definitely a fancy type, after all :)


It's not context free though.


It is context free, just ambiguous.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: