Remix.run Logo
tryfinally 4 hours 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 3 hours ago | parent | next [-]

It 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.

Yoric 3 hours ago | parent | next [-]

Sadly, that is exactly my experience.

usrnm 3 hours ago | parent | prev [-]

And 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 2 hours ago | parent | next [-]

Lisp 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 2 hours ago | parent [-]

The 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.

varjag 2 hours ago | parent | prev [-]

It's because DSLs there reduce cognitive load for the reader rather than add up to it.

usrnm 2 hours ago | parent [-]

Well-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 an hour ago | parent [-]

Sure 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++.

rramadass a minute ago | parent | prev | next [-]

This 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.

deliciousturkey 3 hours ago | parent | prev | next [-]

In 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 26 minutes ago | parent [-]

Scala is a meta language. It's really a language construction toolkit in a box.

m-schuetz 3 hours ago | parent | prev | next [-]

"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 2 hours ago | parent [-]

Standard library modules: 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 2 hours ago | parent [-]

Last 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.

z0ltan 2 hours ago | parent | prev [-]

[dead]