News for hackers. Stuff that matters.
Re:F-strings for C++26 proposal [pdf] by puffybuf on Sunday February 02, 2025 @06:42PM (#42913084)
I'm pretty sure boost::format can do this, though not inline in the string. Do we really need more complexity in cpp? isn't it complex enough?
Re:F-strings for C++26 proposal [pdf] by mkoubaa on Sunday February 02, 2025 @06:46PM (#42913115)
This is the sort of change that adds complexity to the language but reduces complexity in the code written in the language. We take those
Re:F-strings for C++26 proposal [pdf] by puffybuf on Sunday February 02, 2025 @06:59PM (#42913187)
how would this work with internationalized strings? especially if you have to change the order of things? You'd still need a string version with object ordering I would think
Re:F-strings for C++26 proposal [pdf] by mkoubaa on Sunday February 02, 2025 @07:19PM (#42913346)
I'm skeptical that people would want to do this in a single expression.
Re:F-strings for C++26 proposal [pdf] by rerdavies on Monday February 03, 2025 @03:32AM (#42916149)
Do what? Allow translators to reorder the appearance of arguments in a translated format string? It's a completely routine (and completely necessary) feature when doing translations.
Re:F-strings for C++26 proposal [pdf] by edflsafoiewq on Sunday February 02, 2025 @07:24PM (#42913383)
f-strings are not an internationalization library.
Re:F-strings for C++26 proposal [pdf] by wakawaka28 on Sunday February 02, 2025 @08:16PM (#42913809)
The question was, how would you use this if you have i18n requirements. Format strings are normally part of a translation. I think the bad answer is to embed the entire f-string for a translation as usual. The better answer is, don't use f-strings for this because you don't want translators to monkey around with code.
Re:F-strings for C++26 proposal [pdf] by mkoubaa on Monday February 03, 2025 @08:24AM (#42917960)
C++ is such a narrow skillset that I'd rather not roll the dice on translators knowing what to do
Re:F-strings for C++26 proposal [pdf] by wakawaka28 on Monday February 03, 2025 @08:42AM (#42918124)
Even if you told them, "just copy the names from the original string" it's still asking for trouble, and maybe even security holes if they don't follow instructions. But the biggest problem with the idea is surely that the strings need to be compiled.
Re:F-strings for C++26 proposal [pdf] by hackyhacky on Sunday February 02, 2025 @09:39PM (#42914328)
> This is the sort of change that adds complexity to the language but reduces complexity in the code written in the language. We take those

An admirable statement of policy, but I'm not sure it's possible. Adding complexity to the language means there are more gotchas and edge-cases that a programmer must consider, even if they don't use the feature in question.

Re:F-strings for C++26 proposal [pdf] by verall on Monday February 03, 2025 @12:56AM (#42915389)
> Adding complexity to the language means there are more gotchas and edge-cases that a programmer must consider, even if they don't use the feature in question.

Since this is C++, this is not a problem we have to consider

Re:F-strings for C++26 proposal [pdf] by pjmlp on Monday February 03, 2025 @01:38AM (#42915578)
This is a meme by now, yet it isn't as if Python 3.13 is a simple as Python 1.0, Java 23 versus Java 1.0, .NET 9 with C# 13 versus .NET 1.0 with C# 1.0 and a Framework reboot,....
Re:F-strings for C++26 proposal [pdf] by cylemons on Monday February 03, 2025 @05:24AM (#42916818)
C# has a lot of features but most of them feel like simple syntactic sugar that make the language a joy to use and they interact nicely together.

C++ has lots of features that interact with each other in unexpected ways that could leak memory or access freed memory etc.

Re:F-strings for C++26 proposal [pdf] by pjmlp on Monday February 03, 2025 @05:53AM (#42916972)
C# has already enough material for pub Quiz, and no, not all of them are syntatic sugar, and require deep knowledge of the .NET runtime, and the way it interacts with the host platforms.

I imagine you never went too deep into unsafe, cross language interop, lambda evolution since the delegate days, events infrastructure, pluggable GC, RCW/CCW, JIT monitoring, the new COM replacement, how the runtime and language features differ across .NET Framework, Core, .NET MicroFramework, UWP, AOT compilation, Mono, .NET standard versus Portable Class Libraries, CLS friendly libraries,...

On top of that, all the standard frameworks that are part of a full .NET install on Visual Studio, expected that most C# developers know to at least have some passing knowledge on how to use them.

Re:F-strings for C++26 proposal [pdf] by neonsunset on Monday February 03, 2025 @07:01AM (#42917334)
There is no need to just throw keywords around.

For other readers - more than half of these are irrelevant.

Writing general purpose application code rarely involves thinking about implications of most of these (save for NAOT as of lately I suppose).

Writing systems C# involves additional learning curve, but if you are already familiar with C++, it comes down to understanding the correct mapping between features, learning strengths and weaknesses of the compiler and the GC and maybe doing a cursory disassembly check now and then, if you care about it.

Re:F-strings for C++26 proposal [pdf] by mkoubaa on Monday February 03, 2025 @08:26AM (#42917977)
The original comment was about the divergence of the complexity of a language and the complexity of programs implemented in the language. I think the comment you replied to with all its keywords and jargon beautifully illustrated the point
Re:F-strings for C++26 proposal [pdf] by neonsunset on Monday February 03, 2025 @08:55AM (#42918246)
No one of sane mind accesses even one tenth of these on a daily basis.

They simply do not matter. For example - CLS-compatiblity, seriously? I'd return the favour and ask the interviewer why they disagree with the .NET's team stance that this lost relevance in early .NET versions more than a decade ago.

There are main framework and features to be aware of, there are some that may be relevant to legacy codebases you must avoid like fire, and there are those to which the only appropriate response would be "this never existed, if it did, forget about it".

(to Pjmlp - please do not equate knowing the terms with understanding them, and stop bringing up whatever was left by wayside of history to people who should have no business being bothered by this nonsense, thank you)

Re:F-strings for C++26 proposal [pdf] by pjmlp on Monday February 03, 2025 @10:00AM (#42918811)
Just like not everyone accesses 100% of C++ on daily basis on their work.

I do whatever I please, feel free to ignore my comments, downvote them, or whatever goes on your heart regarding them.

Re:F-strings for C++26 proposal [pdf] by pjmlp on Monday February 03, 2025 @08:48AM (#42918188)
Many of those keywords as you call it, are part of a technical interview in any .NET consulting shop worth their business.

And while I expect any junior not to know half of them, anyone claiming to be a senior better have an answer, regardless of what I throw at them.

Naturally I don't expect anyone versed in desktop frameworks to master backend and vice-versa, but they better know the bits that relate to desktop in that case, across the whole stack.

Re:F-strings for C++26 proposal [pdf] by verall on Monday February 03, 2025 @02:40PM (#42921961)
Yes of course, and I mean it somewhat seriously - C++ engineers are used to the language being too complex for anyone to completely understand. It's worth some more incremental language complexity to support niceties like fstrings without additional overhead.
Re:F-strings for C++26 proposal [pdf] by truncate on Monday February 03, 2025 @12:59AM (#42915403)
Depends on case to case basis. I wouldn't generalize it to every case. As a daily C++ engineer, I think overall many features added over the years have mostly been positive. There are features that I don't use and I don't think it really affects much. That said, I do get the sentiment of language becoming too syntactically complex.

I like this feature as string formatting is something frequently used and this certainly looks cleaner and quicker to write.

Re:F-strings for C++26 proposal [pdf] by HeliumHydride on Sunday February 02, 2025 @06:47PM (#42913126)
C++ also has std::format, which was introduced in C++20. This is just sugar on top of it, except it also returns a container type so that printing functions can have overloads that format into a file or stream directly from an f-string, instead of going through the overhead of a temporary string.
Re:F-strings for C++26 proposal [pdf] by rerdavies on Monday February 03, 2025 @03:37AM (#42916171)
I'm wonder what this mysterious application is that is doing heavy formatting of strings but can't afford the overhead of a temporary string, and therefore requires horrifying and inscrutable and dangerous language extensions.
Re:F-strings for C++26 proposal [pdf] by chlorion on Monday February 03, 2025 @04:02AM (#42916316)
Being able to use string formatting without a heap is pretty cool.

Rusts string formatting machinery does not require any heap allocations at all, you can for example impl fmt::Write for a struct that writes directly to a serial console byte-by-byte with no allocations, and then you have access to all of rusts string formatting features available to print over a serial console!

I'm not sure about the horrifying and dangerous extensions part though, I'm not really a C++ expert so I don't know if there's a better way to do what they want to do.

Re:F-strings for C++26 proposal [pdf] by badmintonbaseba on Monday February 03, 2025 @04:57AM (#42916651)
freestanding maybe? Embedded apps often don't shy away from using something like printf, yet they don't like unnecessary allocations.
Re:F-strings for C++26 proposal [pdf] by gpderetta on Wednesday February 05, 2025 @10:33AM (#42949936)
For example, an high performance logger can ship the tuple object to a background thread for actual formatting and I/O, after converting the capture to by-value.

Formatting on the foreground thread would be a non-starter.

Re:F-strings for C++26 proposal [pdf] by richrichardsson on Sunday February 02, 2025 @06:54PM (#42913154)
So it's less complex bringing in a 3rd party library and having to pass arguments?

fmt library can also do something similar, but still requires the complexity of adding the library and passing arguments.

Re:F-strings for C++26 proposal [pdf] by hyperpl on Sunday February 02, 2025 @07:01PM (#42913199)
especially bringing in boost which isn't allowed in some codebases
Re:F-strings for C++26 proposal [pdf] by krater23 on Sunday February 02, 2025 @07:42PM (#42913533)
boot is not allowed caused by the complexity. So some people disallow boost, here is the solution, just add the complexity directly to the language definition!
Re:F-strings for C++26 proposal [pdf] by nikhilsimha on Sunday February 02, 2025 @06:48PM (#42913129)
just skimmed the proposal, dont see how inline rendered f-strings are more complicated than the alternative.