3 ms·
> Aesthetics in C++ is like /\WRITEME: joke\/. On the contrary, C++ treats user-code aesthetics as a first-class design-decision, moreso than many other langua
by ryanianian 8y ago
> Aesthetics in C++ is like /\WRITEME: joke\/.
On the contrary, C++ treats user-code aesthetics as a first-class design-decision, moreso than many other languages.
In C++ the whole thing is that built-in types aren't special, including ints and operators. This is a deep concept in the design of the language.
The fact that you can express abstract things like matrix multiplication, compile-time unit-conversions, and compile-time range-checking through operator-overloading speaks to how aesthetic the language is.
> It means that different people prefer different ways of doing things for purely visual reasons
I've never seen any sizable project where visual aesthetics of the API aren't relevant. Java's got chained builders and lambdas, Python's got `@property` and various `__foo__` methods, and any sufficiently large Ruby project's syntax is a DSL wrapped in a riddle wrapped in bacon.
User-defined APIs are syntax, so why limit the tokens?
> A good language lets you choose your architecture, and then write an aesthetically pleasing program to match.
C++ does let you do that. You've pointed to an example where there was little or no intentional thought put into the aesthetics of the API. E.g. `avi_` really could own those methods, and the underscores aren't required by the language.
You can argue that C++ gives you too much power or that sometimes it's non-obvoius how to use that power or that you've seen code where the API designers have taken enough rope to hang themselves. But of course it is possible to write "Java" in C++ and avoid any operator-overloading or syntax-sugar if your team decides it wants to do that.
- saagarjha 8y ago> In C++ the whole thing is that built-in types aren't special, including ints and operators. This is a deep concept in the design of the language. Except it needs to interact with C, which significantly limits the extent of this unification.
- gdy 8y agoHow so?
- saagarjha 8y agoThe language standard seems to bend over backward to define exceptions for these to that they kinda fit into the system; for example, if you define a variable like this: SomeType variable; The default constructor gets called, except if it's a built-in type nothing actually happens and variable has garbage in it.
- pjmlp 8y agoThe solution is to wrap anything C related in type safe C++ code.
- tlb 8y agoYes, it's great that C++ enables you to make aesthetic design decisions. What I dislike is the way they interact in complicated ways with architectural decisions. Libraries like MTL (the matrix template library) are completely architected around providing their nifty syntax. They do insane things like have operators return types representing a symbolic computation, so that template specialization can be used to do a kind of peephole optimization. The end-user experience is aesthetically improved, but do not stare into the abyss of the template definitions.
- adev_ 8y ago> The end-user experience is aesthetically improved, but do not stare into the abyss of the template definitions. That is getting better and better with time. C++14 with generic lambda, C++17 with constexpr and C++20 with concepts imrpoved all of that. It made the writing of template expression switch from "obscure C++ gourou dark magic " to "Kinda readable C++ dude".