C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Universal Variable Types C++ Addition

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Fri, 25 Apr 2025 10:25:44 +0200
Your proposal reminds me a lot of BASIC (which tries to be beginner friendly) and dynamically typed languages. There is a reason why dynamically typed languages are slower than C++. One of the reason is the kind of types you are proposing. I don‘t feel like this aligns with the goals of C++ (performance). It would ensure the zero overhead principle (you don‘t pay for what you don‘t use). But, the only reason to introduce this kind of type would be to make it beginner friendly. However, from my experience programmers resort back to the “easy” things if something doesn’t work. It would be really bad (maybe even detrimental) for C++ if it is used in this way and would loose its reputation for good performance. C++ is definitely not a beginner friendly programming language. But, we should teach programmers proper C++ (and maybe also make proper C++ easier to write) instead of introducing a “new” C++ that is a lot slower. Without its performance there aren’t many good reasons to use C++. (Other languages provide the same features with nicer syntax if it is not about performance.)

BTW, knowing yvals_core.h is a weird flex. I bet that almost no one knows this file. You also should not learn good style from STL implementations. Most of them are quite old, written against the C++98 standard. Also, these libraries are doing things that are forbidden for the normal programmer (leading double underscores are reserved for library use!). Most likely they also heavily use macros. With modern C++ there are a lot less reasons to use macros. And you should certainly avoid macros if you can. Also, these libraries put performance (with a valid reason) above readability. Unless you have a reason to do so (always measure, don’t just assume) you should write your own code for readability/maintainability.

PS: You get a lot of what you actually want by just using ‘auto’ to declare variables. It doesn’t allow you to change the type of a variable at runtime (and honestly: you shouldn’t even if you could), but other than that it just works.

On Apr 25, 2025, at 12:24 AM, Paul Robert Stackhouse via Std-Proposals <std-proposals_at_[hidden]> wrote:

Hello,

I’m an up-and-coming programmer, who is making making their way through college. I am just about to complete an intro to C++ course. I have a few additions that I would like to propose. If needed, I can supply the code that I’ve worked on to make them a reality for myself.

For some context, I know classes, templates, vectors, linked lists, recursion, etc. I know how to construct a variable from a class object and make it return different values by default, without using any class functions. I know about preprocessor directives, and I’ve seen some of the files for things like the iostream file, so I know how to use the yvals_core.h file to make a custom std-namespace-based file. That should provide you enough information to be able to see the capabilities of what I’ve made.

As for what I’m recommending, it is a two-fold recommendation on making a universal variable type. The first is a universal value type. This can store any value inside itself and return any value stored in it to another variable. It is a universal value, since while it can store any individual value, it cannot store any structure of values. The other - and you’ll see how they are connected - is to make a universal storage type, that can store anything of any value inside itself. It would have to be able to store lists and vectors as well as maps, and it would have to be able to use only one set of storage for them. Additionally, as it would be a universal storage type, it would have to be able to store any individual values, like the universal value type. This would allow C++ to process complex and complicated documents with ease.

Thank you for your consideration.
paulrobert_at_[hidden]

P.S.
If the sender address looks like it does not match the actual email name of paulrobert_at_[hidden], that is intentional. I use the paulrobert_at_[hidden] name to create accounts, but any email sent to it gets redirected to the above email. I just thought I should let you know.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-04-25 08:25:58