8 ms·
This is where C++ is headed anyway. There's just a little bit more work that's needed in c++23, but it's planned, and that will make it possible to use a lot mo
by nickysielicki 6y ago
This is where C++ is headed anyway. There's just a little bit more work that's needed in c++23, but it's planned, and that will make it possible to use a lot more of the STL in consteval/constexpr contexts.
I think this is a killer feature. Between execution policies and constexpr-all-the-things, I really think C++ is set to pull away in a way that other languages will have difficulty competing with.
- closeparen 6y agoHow does this differ from code generation?
- humanrebar 6y agoIt's portable and doesn't add any new build dependencies. No need to model extra phases in your build system either.
- closeparen 6y agoIt would seem that most mainstream languages other than C/C++ have already bit the bullet on fancy build systems, due to dependency management, so codegen is not that expensive.
- bhawks 6y agoAny code you compile can now execute arbitrary syscalls, shell out to git, interact with the user's terminal, host a web service or whatever else as you build it and then write the results to your final executable code? While most ecosystems are moving to hermetic, reproducible builds this is going full steam on the other direction. Goodbye 'it works on my machine' hello 'it works on Jane's machine when Ryan builds it on Tuesdays. Oh Ryan WFH on Tuesday so it gets built on his home machine!' I wanted to like this but it seems to have gone way too far. It is a college project gone wild.
- Reelin 6y agoIf you do any codegen can't all of that already happen though? Many (most?) build systems can already execute more or less arbitrary logic. Reproducible builds are only guaranteed if you actually verify the signature of the output. There's also runtime reflection in most dynamic languages, and don't forget self modifying code! No technical restriction can prevent people from writing bad code at the end of the day because bad code is really a social issue.
- bhawks 6y agoThe difference is that code generating build actions are necessarily and explicitly called out in build systems - with the opportunity to observe their declared dependencies and sandbox their execution. In circle compiling any cxx file executes arbitrary code and emits different results. There's no way to reason about what will happen during the build without manual inspection and that really doesn't scale past trivial projects. I'd imagine most static analysis and ide tools would be significantly hindered understanding circle code. It is concerning that one of the first dozen examples of the language show how the compiler can request input from the terminal mid-compilation. Amazingly powerful feature put forward without any commentary about how / when it should be used or not used - let alone if it should exist at all. As I said it feels like a college experiment - it doesn't feel like they asked how these features would make it easier to write clear, understandable, maintainable code - they just implemented them.
- ekelsen 6y agoI think reading through all the examples https://github.com/seanbaxter/circle/blob/master/examples/README.md#abstract https://github.com/seanbaxter/circle/blob/master/examples/RE... makes it clear that the author has put quite a deal of thought into how these features make it easier to write clear, understandable and maintainable code. Even the example you point to goes to say: "Let's use the integrated interpreter to define a useful build tool. Software is the subject of constant revisions, and it's useful to mark a distributable with the exact version of the source-control archive it was built with." It's clear (to me) that the developer is not advocating using terminal input in the middle of a build. I haven't used terminal input since I was a child; I don't think the developer expects anyone to take that as a serious example.
- ori_b 6y agoIt doesn't generate artifacts that you can examine and debug.
- logicchains 6y agoCircle seems to have compile-time printf, which would make it easier to debug than normal C++ compile-time code.
- pjmlp 6y agoDepends if one is on the IDE camp or rather programs like PDP-11 was around.
- clord 6y agoThis works during template instantiation. So your macros can respond to types and values from such parameters. Also it seems to know about scopes.
- armitron 6y agoThe only place C++ is pulling away towards is oblivion.
- FpUser 6y agoSure, sure. As soon as you replace megatons of code running all kinds of stuff. I'd suggest finishing off COBOL for starters.
- virtualritz 6y agoWhen I read the first sentence I thought this was sarcasm. Then I realized it's not. I can't help but think C++ will be one of these things digital archeologists will look back in disbelief. And I mean both amazed as well as flabbergasted disbelief.
- dman 6y agoThe disdain about C++ is now so overdone that I think that people who actually sit down with the language will be pleasantly surprised.
- naasking 6y agoPleasantly surprised at how different every C++ project is because they each have to mandate their own C++ subset in order to tame it's ridiculous complexity? I get what you're saying, C++ is worlds away from where it was even 15 years ago. Don't downplay it's complexity though.
- dman 6y agoI dont think I made any references to complexity in my tweet. All I was trying to say is that the bad news with respect to C++ is priced in and the language only has to be marginally better than what its detractors make it out to be.
- kmonsen 6y agoAll the old c++ is still here though, as always is a language where it’s hard to understand all of it.
- gpderetta 6y ago> each have to mandate their own C++ subset in order to tame it's ridiculous complexity? this one of those things that keeps getting repeated, but at least personally I have never seen in the wild.
- badsectoracula 6y ago
- enricozb 6y agoI can already imagine trying to debug a templated type error with code that was generated at compile time...
- atilaneves 6y agoNo need to imagine, it happens all the time in D, and it's not that bad.
- sesuximo 6y agoThe errors aren't that bad. It's just a log of what you tried to do. Usually the first error is the only one that matters anyway
- scollet 6y agoIs this a benefit or a crutch or a mix or an implementation trade-off? I am still learning modern cpp.
- MauranKilom 6y agoC++ meta classes will primarily be useful for library authors. It is not expected that you have to write them yourself. They can document and enforce some pattern (e.g. an interface) or provide boilerplate that would currently need either macros or, well, boilerplate. But I don't understand what you mean with "an implementation trade-off"?
- TeMPOraL 6y agoToday I stumbled upon metaclass proposal for C++ [0]. All I can say is that there should be a variation of Greenspun's tenth rule: Any sufficiently complicated programming language becomes an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. Still, I want to have that C++. -- [0] - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0707r3.pdf; http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p070... the examples from the later parts of the paper show how great it would be to have something like that in C++.