TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

190 点作者 cyber1大约 1 年前

25 条评论

Aardwolf大约 1 年前
Unfortunately the first example already re-uses one of the less good parts of C++, the "<<" operator for std::cout, which always was a bit of a hack (including strange order of operations since << normally is left shift)
评论 #39890304 未加载
评论 #39892560 未加载
评论 #39893398 未加载
评论 #39888766 未加载
jokoon大约 1 年前
Someone on reddit said that the cpp2 repo was a bit old, and that is true, although he may have started this as an experiment influenced by typescript and left it on the side at some times.<p>Anyway I have no idea if cpp2 would get support from microsoft or other devs, but cpp2 seems like the most humble and &quot;least risky&quot; solution for the future of C++, and I really want it to be.<p>What I remember the most that Herb Sutter said in his cpp2 talk, is that it aims to avoid 95% of bad coding practices that C++ allows today.<p>It&#x27;s safe to say that beyond the valid criticism of C++, that it quite a good goal and it would improve C++, without using a new language, and that&#x27;s good, because a new language causes problems: new toolchains, new semantics, new specifics, no experience on a new language.<p>Cpp2 is not a new language, it is the same semantics of C++, except it has a new syntax and enforces good practices.<p>One very interesting point: in the future, cpp2 allows a cpp2-only compiler to be born, and it would still live next to C++ binaries without problem. That cpp2 compiler might probably be much faster since the cpp2 is a smaller stricter subset.
评论 #39891551 未加载
评论 #39890953 未加载
评论 #39891369 未加载
superamadeus大约 1 年前
Is there any discussion or in-depth explanation of the syntax choices? I understand that a goal was context free unambiguous parsing. But there are some things that surprise me.<p>For example, string interpolation:<p><pre><code> &quot;Hello, (msg)$!\n&quot; </code></pre> Why “(msg)$” and not “$(msg)”? Surely the latter is easier to parse?
评论 #39888541 未加载
kreco大约 1 年前
&gt; &#x2F;&#x2F; &#x27;BufferSize&#x27; is an object defined as a synonym for the value 1&#x27;000&#x27;000<p>&gt; BufferSize: i32 == 1&#x27;000&#x27;000;<p>So &quot;value : i32 = 10&quot; is variable, but &quot;value : i32 == 10&quot; is a constant.<p>The difference is so subtle I&#x27;m not sure I like it.<p>Later in the documentation you can find &quot;equals: (a, b) a == b;&quot; which is a function but it feels like I need to decipher it because &quot;==&quot; is not for alias in this case.<p>Retaking the example of &quot;equals: (a, b) a == b;&quot; it feels also odd to omit the braces because they are even enforced for if&#x2F;else branches.<p>I have to admit that everything was interesting until the &quot;Summary of function defaults&quot; part.
JNRowe大约 1 年前
Sutter&#x27;s 2022 cppcon talk¹ is a <i>great</i> introduction to the topic, both the problems it attempts to solve and solutions it was&#x2F;is settling on. One of those few talks that left me genuinely enthused about the topic.<p>[It is probably worth watching for the Compiler Explorer interjection toward the end alone -- Matt Godbolt Appreciation Society]<p>¹ <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ELeZAKCN4tY" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ELeZAKCN4tY</a>
grumpy_coder大约 1 年前
It&#x27;s a nice idea, but not clear that it can truly interoperate with vanilla C++ libs which I think is required. Seems to be waiting for modules to be finalized, but whether cpp2 can call cpp, and cpp can call cpp2 without implementing half of a C++ compiler isn&#x27;t obvious. <a href="https:&#x2F;&#x2F;github.com&#x2F;hsutter&#x2F;cppfront&#x2F;issues&#x2F;594">https:&#x2F;&#x2F;github.com&#x2F;hsutter&#x2F;cppfront&#x2F;issues&#x2F;594</a>
评论 #39895329 未加载
typ大约 1 年前
Looks neat and convincing. But I think the goal (and effort) to make it into the C++ standard would hinder the momentum of adoption. I suspect it would have to go through a lot of politics and bikesheding before making any real-world impact. Imagine that if Typescript had insisted to get accepted into the Emca standard before widespread adoption and promotion by Microsoft; it would probably still stay in the &#x27;experimental&#x27; stage.
pciexpgpu大约 1 年前
I wonder how this compares with Carbon -&gt; C++ [0].<p>Carbon is (was?) a fantastic proposal, but not sure if it has lost steam since it was introduced or how well it is being adopted (be it inside Google or outside)?<p>Being able to incrementally&#x2F;interchangeably use&#x2F;call existing C++ code (and vice versa) seems like a great design choice (in Carbon) without having to introspect the actual generated code.<p>Not sure how easy it is to get the cppfront-generated C++ to bridge with existing C++ code (and vice versa)?<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang">https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang</a>
评论 #39888888 未加载
评论 #39888933 未加载
评论 #39888685 未加载
dang大约 1 年前
Related:<p><i>Cppfront, Herb Sutter&#x27;s proposal for a new C++ syntax</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32877814">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32877814</a> - Sept 2022 (545 comments)<p>and also <i>Cppfront: Autumn Update</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37719729">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37719729</a> - Sept 2023 (8 comments)
kreco大约 1 年前
&gt; Because ++ and -- always have in-place update semantics, we never need to remember &quot;use prefix ++&#x2F;-- unless you need a copy of the old value.&quot; If you do need a copy of the old value, just take the copy before calling ++&#x2F;--<p>I actually wish ++ and -- operators were removed. This would simplify everything, nothing to remember whether it&#x27;s prefix or postfix operator, whether it copies something or not, you would just do &quot;value += 1&quot; and be done with it.<p>- Less mental overhead.<p>- Remove an extra way of doing the same thing.
评论 #39889827 未加载
评论 #39888754 未加载
评论 #39888791 未加载
darknavi大约 1 年前
I know some of the arguments around C++&#x2F;cpp2 are flawed, but I do love C++ and a project to move it forward with a step-change is exciting to me.<p>A few of my friends and I did Advent of Code in cpp2 this year and it was a (very buggy) blast.
评论 #39892369 未加载
suby大约 1 年前
I spent the other day writing an archetype entity component system which made heavy use of template metaprogramming. I try to avoid this if possible, but it was an exercise in seeing how performant I could make it, and so I wanted to offload as much work as I could manage to compile time and avoid things like virtual dispatch. API similar to the basic parts of entt.<p>My take away from the exercise is that this is not a language for human beings. I was successful in writing it, but it was extremely difficult and frustrating. Part of the frustration is because conceptually what I wanted to accomplish was not difficult, but figuring out how to express it was a nightmare. I am not new to the language, I&#x27;ve been writing C++ since 2009, it was the first language I learned and I&#x27;ve spent nearly every day of my life since then writing at least some C++ code. Even so, I can&#x27;t say that I truly understand this shit.<p>I&#x27;m hoping cpp2 brings us someplace closer to a language that mere mortals can understand. I don&#x27;t want the next generation writing C++.
评论 #39891837 未加载
评论 #39891762 未加载
skywal_l大约 1 年前
In this kind of thread I always mentionned Circle[0] from Sean Baxter. It&#x27;s worth a look.<p>[0] <a href="https:&#x2F;&#x2F;www.circle-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.circle-lang.org&#x2F;</a>
dfgdfg34545456大约 1 年前
Great new idea in cpp. Automated bounds checking in the hello world example sold me straight away. Try and do that as tersely Haskellers. I hope this project gets momentum.
howtofly大约 1 年前
Any good CMake integration besides <a href="https:&#x2F;&#x2F;github.com&#x2F;modern-cmake&#x2F;cppfront">https:&#x2F;&#x2F;github.com&#x2F;modern-cmake&#x2F;cppfront</a>?
评论 #39896006 未加载
teo_zero大约 1 年前
I like the idea, although many choices are arguable. For example, having to introduce mandatory&#x2F;prohibited white space around binary&#x2F;postfix operators (like &quot;&amp;&quot;) completely spoils the goal of having a more rational syntax.
pjmlp大约 1 年前
The whole story about what cpp2 tries to be, distancing itself from other C++ wannabe replacements is only due to be coming from WG21 chair, which naturally can&#x27;t talk about a C++ replacement as per conflict of interests.<p>Cpp2 isn&#x27;t an alternative syntax to C++, as much as C++ and Objective-C aren&#x27;t alternative syntaxes for C, even though they support a subset of it, and were born exactly the same way, code translators into C.<p>C didn&#x27;t evolve into them, they became their own ecosystem, tainted by the underlying C compatibility.<p>The only alternative that is really a Typescript for C++, is Circle.
ibobev大约 1 年前
I do not understand why there is a push to change the C++ syntax. There are plenty of new natively compiled languages like D, Go, Rust, Zig, Nim, Odin, Crystal, and so on. If you do not like C++ you always can use some of them instead. The problems that make C++ unsafe are semantic and not syntactic ones.
mgaunard大约 1 年前
I don&#x27;t want bounds-checking, so lost interest immediately.<p>This is a step in the wrong direction.
评论 #39893358 未加载
FpUser大约 1 年前
Unless I can step through original source code in debugger, watch variables etc. etc. I could not accept any source to source translator in my practice.
评论 #39889872 未加载
crazypython大约 1 年前
What are the tradeoffs between cpp2 and Carbon?
carlsborg大约 1 年前
At this point the focus should be on making interop with python a first class feature.
cies大约 1 年前
Like Kotlin to Java<p>Or ReScript to OCaml<p>Or Gleam to Erlang
评论 #39888548 未加载
评论 #39888690 未加载
评论 #39891199 未加载
评论 #39890195 未加载
评论 #39888939 未加载
colonwqbang大约 1 年前
Most of my personal issues aren&#x27;t with C++ syntax as such (although it also has many problems). My main gripes are:<p>1. Very slow compilation.<p>2. Poor encapsulation, adding private functions requires recompiling all dependents, see (1).<p>3. Comically huge symbols make debugging much harder than it needs to be -- today gdb OOM&#x27;d my 16GB laptop when trying to form a backtrace of a typical QT application coredump.<p>Unfortunately it doesn&#x27;t seem like cppfront can fix these issues. It may still be a worthwhile effort in other respects, of course.
评论 #39888898 未加载
评论 #39888706 未加载
评论 #39888606 未加载
评论 #39889806 未加载
评论 #39890293 未加载
fancyfredbot大约 1 年前
It was when debugging a memory leak which occurred because I forgot to declare the base class destructor as virtual that I started to think C++ was a rather unfriendly language and not really designed to be easy to use.<p>Then a few years later I read the spec for std::launder that I realised C++ was not really designed to be understood.<p>It&#x27;s a shame because it&#x27;s actually a rather nice language in some ways. Here&#x27;s hoping that this project or something similar takes off and separates the good bits from the bad.
评论 #39889062 未加载
评论 #39888929 未加载
评论 #39890295 未加载