Comment by blt
7 years ago
Special keywords like `fn` make parsing simpler. Trailing return types are useful in languages that support generic programming, because they make it easier to write a function whose return type depends on the types of its generic inputs. Even C++ has this feature now, using decltype and arrow notation:
template<typename T, typename U>
auto add(T t, U u) -> decltype(t + u)
{
return t + u;
}
C++ is notoriously hard to parse. Consider the "most vexing parse", or the fact that refactoring tools for C++ are always flakier than their Java / C# / Go equivalents, or the fact that https://cdecl.org/ exists. New languages in the "expressive, high performance" niche cannot continue to be held back by C++ syntax.
C# and Java as you mentioned use very C++-like syntax.
To a first approximation, yes. But consider that the C++ grammar has ~100 more rules than Java (~170 vs. ~280), and parts of the C++ grammar are strongly context-dependent, which isn't true in Java.
Tools can use LLVM infrastructure to get ast. No need to parse it yourself.
The AST is still really complex though (in terms of corner cases to cover).