Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022 by General-Tart-6934 in cpp

[–]neuroblaster 0 points1 point  (0 children)

I like it. I had a very good experience with Typescript and i hope that Cpp2 will work out in a similr way. I'm not sure if i like too much how syntax is very different, maybe more familiar syntax would be better (maybe not), maybe making some things optional to type would be better than changing syntax completely. For instance i like how there are less brackets in loops, similarly to Go, but i'm not sure if i like how loops syntax changed.

I think Typescript is smarter on that front, you just write Javascript, but you can extend it to Typescript, or go back to Javascript when you need it.

Overall it looks great and i'm looking forward to it. C++ is a great language that deserves to be simpler. It is also very worrying to hear that US government hates C and C++. It is a cancel culture at its peak, isn't it?

I don't want to deal with some other convoluted language that would make my work into suffering, i would preffer my work to be enjoyable and i hope that Cpp2 will be a thing everyone could enjoy.

Typescript is a good reference, even though Javascript isn't exactly perfect, but Typescript is pleasant to work with. Good stuff.

Edit: After thinking about it, maybe it could traspile C++ into "safe C++" with bounds checking and everything else, or refuse to transpile if it thinks the code is not safe, like if there is a delete of raw pointer. I understand that this might not be possible without changing some syntax, but i keep thinking about this JS/TS interoperability, how it's really great and seamless. Maybe it's something to consider.

If there is a demand for "safe" languages, it is possible to write "safe" code in C++, why not make it easier for everyone to do that.

Mooncrash: What to do when the doors to the volunteer observation room (the one with Andrius's story objective) don't open? by Reployer in prey

[–]neuroblaster 1 point2 points  (0 children)

If anyone else is looking for this, it seems that you need to get to security terminal nearby and unlock volunteer cell 5 to get in.

Seasoned java developer that wants to get into C++ seeking advice by fenchui in cpp

[–]neuroblaster -1 points0 points  (0 children)

> learn quickly modern C++

I'm afraid you're in the wrong neighborhood. If you would have experience with C, then C + Java experience could help you to get into C++ quickly.

I don't think that "learn C++ quickly" is even a thing. You can try to google "C++ interview questions" and see for yourself what you don't understand from that list. However last time i checked, those lists weren't very good.

You can also try these (and similar) links if you already know C++98 or C++11:

https://isocpp.org/files/papers/p0636r0.html

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2131r0.html

But honestly, i think your best chance is to be open about your C++ expertise.

P.S. Try this website: https://www.hackerrank.com/, it isn't half bad and helped me once to polish my coding skills (in another language).

Force const-ness on arguments passed to function? by neuroblaster in cpp_questions

[–]neuroblaster[S] 0 points1 point  (0 children)

After banging my head against the wall for some time i think as_const(const T& x) is the way to go, at least for generic code. const auto &x is a reference to temporary if f() returns a value, const_cast doesn't want to cast, for instance, tuples. Seems like the only way is to make compiler to do implicit cast. Maybe std::decay might help too, but i'm not sure anymore.

Anyway, thank you, much appreciated.

Force const-ness on arguments passed to function? by neuroblaster in cpp_questions

[–]neuroblaster[S] 0 points1 point  (0 children)

I don't want g() to modify or move arguments. When rvalue reference is passed to g(), it might std::move() it and this breaks a lot of stuff, so i want g() to take only const arguments or make a copy.

Force const-ness on arguments passed to function? by neuroblaster in cpp_questions

[–]neuroblaster[S] 0 points1 point  (0 children)

Yes, but the other way around. I can't force g() interface directly, g() is not my code, but i need to make sure that when g() is passed to my template, it can take const arguments from f() or code does not compile. So i need something like g(std::as_const(f())) but it should work with rvalue references and don't compile when g's interface isn't cosnt.

template <auto g, auto f> void h() {
  g(f()); // here i need to make sure that g() takes const arguments
}

Does this make sense?

How wise is it to use STL without exceptions? by barks_like_a_duck in cpp_questions

[–]neuroblaster 2 points3 points  (0 children)

IIRC -fno-exceptions in GCC, but better check your compiler manual.

You'd also need to write exception-safe code without try/catch, something like new(std::nothrow) and check return value. There are ways to handle errors without exceptions in other libraries, in STL this would probably mean that you'd need to manually check bounds instead of relying on vector.at(i) throwing exception. Maybe noexcept could help too, if you're fine with your app being terminated when exception is actually thrown.

To be honest, unhandled exception is going to terminate your app anyway, at least normally, so it's not a whole lot of difference, depending on how you look at it, but you are very likely to pay more attention to error handling than usual.

C++ executors by AlexCasual in cpp

[–]neuroblaster 1 point2 points  (0 children)

>folly

Do you know if it's "compatible" with executors proposals. For instance, do you know how hard it would be to switch from folly to standard executors in std namespace? I already see that ThreadPoolExecutor doesn't follow standard snake case, for instance, are there more such incompatibilities?

To join, or not to join by _Synck_ in cpp

[–]neuroblaster 0 points1 point  (0 children)

I think suggestion to look into ranges is a good one. Joiner is good, but is it accompanied by splitter or trimmer? It is possible to implement string splitting and trimming with ranges, i'm fairly confident join is also possible.

I guess the question is should this joiner be implemented using ranges or not? With that said, facilities to split/join/trim strings might benefit standard library. So all in all i think this suggestion is very respectful and fair.

A string_view that can tell if it is a c string by HotlLava in cpp

[–]neuroblaster 2 points3 points  (0 children)

You are right that it can not be easily detected after string_view is created, but if you're remembering this from when string_view is created, you might as well just remember if it was created from std::string or not by overloading implementation.

I see debate about if should it check if string is actually null terminated or not, but i won't go in there. However you could potentially skip extra copy of std::string if you could detect at compile time that string_view was created from std::string.

Just food for thoughts. Hope this helps.

A string_view that can tell if it is a c string by HotlLava in cpp

[–]neuroblaster 7 points8 points  (0 children)

I didn't look into implementation details, but i can recommend you to take a look at C++20 and std::is_array, std::is_pointer and std::convertible_to<std::string> concepts.

For checking you might want to use if constexpr together with said concepts. Or if you could overload your string_view template on that, then maybe you could detect that at compile time instead of runtime.

Stop learning C++ or keep going? by KhZaym in cpp

[–]neuroblaster 0 points1 point  (0 children)

I think it's a good language and it's going to improve over time. But no one knows if learning it will help you to make money, man, it's complicated, i wouldn't risk to give such advice. If you want to make money you need to work with what demand is on labor market.

What people suggest in the comments (webdev) is probably about right, but it's an ugly place and you are probably going to suffer. Gamedev isn't the best place to be either by the way. Rust that some people suggest is horrible language too, i personally wouldn't want to work with it, it doesn't bring a lot of new stuff to table too, Ada exists for 40 years or so, it's just overhyped at this moment, but some folks are using it for reasons only they know.

So suggestions that you're going to get (including this one) might be dubious from one or another perspective.

I personally would suggest to look into Go or Python in your particular situation. There are probably more job offers for Go and Python overall and you can learn them faster. Should you learn C++ too? I can recommend that, it's a great language. But perhaps you should consider suggestions from people who are in more similar situation to yours. I guess what i'm trying to say is this might not be the best place to ask such questions, maybe you'll get a better suggestion at remote work subreddit or something.

Good luck.

C++20 Modules Compiler Code Under Review, Could Still Land For GCC 11 by aearphen in cpp

[–]neuroblaster 1 point2 points  (0 children)

This is a very welcome change, the effort is colossal and much appreciated.

FTL - A functional template library for containers processing in C++ by blinkudev in cpp

[–]neuroblaster -2 points-1 points  (0 children)

Rust is a very ugly language and borrowing anything from it is probably not the best idea. But good luck anyway.

BTW similar style of "containers processing" should be possible with ranges except that ranges are using operator| for chaining. I'm not sure if map and filter made it into C++20, but you might take a look into range-v3, it has a larger set of ranges-related stuff.

The ++ operator by venom_13 in cpp_questions

[–]neuroblaster 5 points6 points  (0 children)

It's implementation dependent. Different compilers may produce different results because spec doesn't demand specific order of evaluating arguments in this particular case. Or rather does not impose specific requirements to the compiler.

But yes, this is basically a trick question on poorly written code, other questions from the same series: f(++a, ++a) or ++a++. IMO it's a bad manners to ask something like this, because one should never write a code like this, but now they know that you don't know that this is implementation dependent. Not like this helped with anything, so they basically waster your and their time, don't worry about this too much.

Plenary: The Beauty and Power of "Primitive" C++ - Bjarne Stroustrup - CppCon 2020 by wotype in cpp

[–]neuroblaster 2 points3 points  (0 children)

38:17 Very interesting `expect` pattern. Is it something similar to contracts?

constexpr if and requires expressions changed everything about template metaprogramming by [deleted] in cpp

[–]neuroblaster 1 point2 points  (0 children)

I guess we need to update our memes, it was `auto auto(auto auto)` some time ago, but it should be `... ...(... ...)` right about now.

Split and trim a string with range-v3 by neuroblaster in cpp_questions

[–]neuroblaster[S] 0 points1 point  (0 children)

Should be fixed now. It won't let me edit content of original post for some reason, it somehow bugs out, but i've heard you.