Hacker Newsnew | past | comments | ask | show | jobs | submit | joebaf's commentslogin

Here's the direct link to the blog post on the book:

https://www.cppstories.com/2023/init-story-print/

And the book at Leanpub:

https://leanpub.com/cppinitbook


Do you have more examples where zip is handy? I've noticed it's a quite common feature of other languages like Python...


Do you us std::initializer list in your code?


is ChatGPT actually the most important thing that happens... not just for C++, but in terms of all programming languages? How will it affect programming?


I’ve seen ChatGPT spit out both correct and incorrect code.

The idea that you’d rely more on tools is in a sense the Java approach. Java is somewhat more verbose than other languages, in practice, and you deal with the verbosity by making more use of code snippets / templates, autocompletion, etc. Basically, your IDE writes more of the code for you. I think this was, in general, a dead end in language research for various reasons, and improving code generation (via ChatGPT or some successor) does nothing to solve the actual problems with using generated code.

At the end of the day, somebody has to at least read the code and verify that it does what is requested.

Maybe at some point, someone will hook a more formal front-end to ChatGPT or something similar, so you can write the interfaces and specs, and the AI will generate the implementation. That may take a while, however.


> Basically, your IDE writes more of the code for you. I think this was, in general, a dead end in language research for various reasons, […]

I think language researchers would strongly disagree.

Something like that is likely the future of programming!

For example:

https://www.youtube.com/watch?v=X36ye-1x_HQ

From the video description:

> In Idris, types are a first class language construct, meaning that they can be manipulated and computed like any other language construct. It encourages a type-driven style of development, in which programmers give types first and use interactive editing tools to derive programs.


I tried using GPT to write code and it was very impressive but this cartoon cuts to the truth of it: https://www.reddit.com/r/ProgrammerHumor/comments/zdvpwb/how...


is ChatGPT actually the most important thing that happens... not just for C++, but in terms of all programming languages? How will it affect programming?


on the other hand with more options you can express more and write safer code (for example with constinit which solves static order init fiasco...) And if you don't have enough knowledge you can just stick to const.

What re alternatives for a system programming language? (Rust seems to be fine, but still it's not super easy...)


and std::print is already voted into C++23!


Hi, Author here - I went to lambdas because I got some compilation issues... because some stupid mistakes the code with std::apply(printImpl<Args...>, tp) didn't compile...

But now I see the issue and it's improved. So the version:

template <typename... Args> void printTupleApplyFn(const std::tuple<Args...>& tp) { std::cout << "("; std::apply(printImpl<Args...>, tp); // << std::cout << ")"; }

is fine and probably the easiest


Yep, smart pointers are essential for modern C++, and they provide improved security over raw pointers.

How do you use smart pointers? What’s your common use case to refactor into smart pointers?


Do you have any better use cases for those constexpr techniques? maybe we could make simpler code to CRTP?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: