Hacker News new | ask | show | jobs
by baby 2521 days ago
It makes code unreadable.

   void lol<A, <B, C<D>>, E>()
2 comments

Pretty much all syntax is unreadable if you don't know the lingo. For example, try presenting the ubiquitous

    for (int i = 0; i < 10; i++) {}
to ten random people without prior programming experience and see how many of them can correctly tell you what all that means. Similarly,

    { a, b in a > b }
is probably not very clear to people who don't write Swift and perfectly lovely closure syntax to people who do.

There's language syntax that's actually unreadable, for instance due to using names that obscure or otherwise don't clearly express what a construct is/does or using the same operator/keyword for too many different context-dependent purposes. I don't quite think the sheer presence of angle brackets makes code unreadable, any more than the sheer presence of curly braces or parentheses do.

You’re missing my point. While other syntactic elements can be learned, generics can be abused to make the code unreadable.
> generics can be abused to make the code unreadable

All features can be abused to make the code unreadable. E.g. all modern languages have regular expressions in their standard libraries, despite complex regular expressions are essentially write-only code.

> While other syntactic elements can be learned, generics can be abused to make the code unreadable.

Substitute "generics" for pretty much any bit of programming syntax, and this statement is still true.

That isn't even close to valid C++.
It is a valid template specialization declaration if you add template<> in front, like this:

template<> void lol<A, <B, C<D>>, E>()