4 ms·
I always wonder whether C++ syntax ever becomes readable when you sink more time into it, and if so - how much brain rewiring we would observe on a functional M
by tryfinally 11mo ago
I always wonder whether C++ syntax ever becomes readable when you sink more time into it, and if so - how much brain rewiring we would observe on a functional MRI.
- sigmoid10 11mo agoIt does... until you switch employers. Or sometimes even just read a coworker's code. Or even your own older code. Actually no, I don't think anyone achieved full readability enlightenment. People like me just hallucinated it after doing the same things for too long.
- usrnm 11mo agoAnd yet, somehow Lisp continues to be everyone's sweetheart, even though creating literal new DSLs for every project is one of the features of the language.
- vkazanov 11mo agoLisp doesnt have much syntax to speak of. All of the DSLs use the same basic structure and are easy to read. Cpp has A LOT A of syntax: init rules, consts, references, move, copy, templates, special cases, etc. It also includes most of C, which is small but has so many basic language design mistakes that "C puzzles" is a book.
- lmz 11mo agoThe syntax and the concepts (const, move, copy, etc) are orthogonal. You could possibly write a lisp / s-exp syntax for c++ and all it would make better would be the macros in the preprocessor. The DSL doesn't have to be hard to read if it uses unfamiliar/uncommon project specific concepts.
- vkazanov 11mo agoYes, sure. What i mean is that in cpp all the numerous language features are exposed through little syntax/grammar details. Whereas in Lisps syntax and grammar are primitive, and this is why macros work so well.
- varjag 11mo agoIt's because DSLs there reduce cognitive load for the reader rather than add up to it.
- usrnm 11mo agoWell-designed abstractions do that in every language. And badly designed ones do the opposite, again in all languages. There's nothing special about Lisp here
- varjag 11mo agoSure but it's you who singled out Lisp here. The whole point of DSL is designing a purpose formalism that makes a particular problem easy to reason about. That's hardly a parallel to ever-growing vocabulary of standard C++.
- bee_rider 11mo agoI continue to believe Lisp is perfect, despite only using it in a CS class a decade ago. Come to think of it, it might just be that Lisp is a perfect DSL for (among other things) CS classes…
- Yoric 11mo agoSadly, that is exactly my experience.
- m-schuetz 11mo ago"using namespace std;" goes a long way to make C++ more readable and I don't really care about the potential issues. But yeah, due to a lack of a nice module system, this will quickly cause problems with headers that unload everything into the global namespace, like the windows API. I wish we had something like Javascript's "import {vector, string, unordered_map} from std;". One separate using statement per item is a bit cumbersome.
- delta_p_delta_x 11mo agoStandard library modules: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2465r3.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p24... I have thoroughly forgotten which header std::ranges::iota comes from. I don't care either.
- m-schuetz 11mo agoLast time I tried, modules were a spuriously supported mess. I'll give them another try once they have ironclad support in cmake, gcc, clang and Visual Studio.
- deliciousturkey 11mo agoIn my opinion, C++ syntax is pretty readable. Of course there are codebases that are difficult to read (heavily abstracted, templated codebases especially), but it's not really that different compared to most other languages. But this exists in most languages, even C can be as bad with use of macros. By far the worst in this aspect has been Scala, where every codebase seems to use a completely different dialect of the language, completely different constructs etc. There seems to have very little agreement on how the language should be used. Much, much less than C++.
- speed_spread 11mo agoScala is a meta language. It's really a language construction toolkit in a box.
- z0ltan 11mo ago[dead]
- rramadass 11mo agoThis is just a low-effort comment. > whether C++ syntax ever becomes readable when you sink more time into it, Yes, and the easy approach is to learn as you need/go.
- pelorat 11mo agoIt's very readable, especially compared to Rust.
- Mond_ 11mo agoI love how the haters of Rust's syntax can be roughly divided into two groups: (1) Why doesn't it look like C++? (2) Why does it look so much like C++?
- abbefaria27 11mo agoIt does get easy to read, but then you unlock a deeper level of misery which is trying to work out the semantics. Stuff like implicit type conversions, remembering the rule of 3 or 5 to avoid your std::moves secretly becoming a copy, unwittingly breaking code because you added a template specialization that matches more than you realized, and a million others.
- verall 11mo agoThis is correct - it does get easy to read but you are constantly considering the above semantics, often needing to check reference or compiler explorer to confirm. Unless you are many of my coworkers, then you blissfully never think about those things, and have Cursor reply for you when asked about them (-: