[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]

/prog/ - Programming

Programming

Name
Email
Subject
REC
STOP
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
Archive
* = required field[▶Show post options & limits]
Confused? See the FAQ.
Options

Allowed file types:jpg, jpeg, gif, png, webp,webm, mp4, mov
Max filesize is16 MB.
Max image dimensions are15000 x15000.
You may upload5 per post.


e7c6e5 No.5134

Discuss and share C++ related talks/questions here. All early and later standards are welcome (be explicit).

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
Post last edited at

134a04 No.5140

C++ keeps getting new features and new revisions, but it's not going to be great until they fucking ditch SFINAE. It was a useful hack at the time, but since being embraced by the standards committee, it's depressingly the accepted idiomatic way for compile-time introspection. It's fucking disgusting. Until there is a way to completely replace SFINAE, C++ remains a painful fucking mess to use at any high level.

And it's my favorite language, too (I do unironically love Rust, though. I can't use it primarily until they fix fucking dynamic linking and dynamic loading, though. Not being able to dynamically load a Rust library that doesn't present a C interface is a fucking headache, and static linking everything breaks down when you have 100MB of fucking dependencies and need to create, for instance, a whole suite of tools with those dependencies. Suddenly, you have 2 GB of tools that could have been 120MB together).

All I want is an unironic C++2. I want a new language with all the good new stuff about C++ and none of the terrible old stuff, simplified semantics for all the different pointer types and construction semantics (there are 8 fucking types of object initialization off the bat, and then you mix that up with const, move, reference, default, initializer lists, whether the object is POD, whether it's inherited, whether it has a vtable, etc, and you end up with several dozen different possible semantics for initializing a fucking object), but that doesn't try to hit new paradigms, stuff in GC, remove important features like generics, or anything else that the other C++2 attempt languages (D, Rust, Go to a degree) have done. I just want a boring C++ with a standard half the size.

C++ sucks, but modern C++ has a very good language inside of it. I just want that language without the stupid terrible shit.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

e7c6e5 No.5141

>>5140

What you mention sounds like they will undoubtedly confront this issue with the language in the future at some point. If you think you have a valid case is there any way to present your proposal/change to the committee or whomever looks over the language and its revisions? Take a look at this for example https://mreinhold.org/blog/forward-faster

It's not the same language but this is another person talking about the "direction" of the mentioned language. From what I understand GC with them have been always disliked but in many instances voiced to be changed. How familiar are you with any "future plans" regarding C++? And when you mention modern C++ and C++ at the end are you referring to when it first started out compared to today? Correct me if I am wrong but wouldn't a smaller standard mean less features or am I misunderstanding? Like smaller semantics?

.. Would an interpreter only meant for you improve your way of life? Trying to give you ideas here.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

134a04 No.5142

>>5141

I'm not sure if they will. They still like keeping massive amounts of the language backwards compatible at all costs, which is the biggest issue. That's the reason that SFINAE is still there, because there aren't a lot of better ways to manage type traits that don't break BC. Concepts can help a lot when they finally come (C++20), but they don't fully fix the problem. You'd really need traits as a core language concept rather than a template hack to make it not disgusting at this point.

It wouldn't mean fewer features, it would mean that a lot of existing features that can be expressed in many dozens of ways would be reduced to only being expressible in a few ways. It would mean looking at an object's initialization and knowing exactly what is happening without having to consult 5 different sections in the standard document. It would mean not having to fight with the compiler to know why your object doesn't have specific default constructors in some situations but does in others. You can cut out over half of what is in the C++ standards without reducing functionality at all.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

134a04 No.5143

>>5142

And again, I do love C++. I use a ton of programming languages at work, and every time I use another one, I'm refreshed by the simplicity and power of the other languages, but I'm disappointed by the lack of power compared to C++. There's no reason that trimming C++ down means that it needs to lose any amount of power or flexibility. Going back to C++ is refreshing because of all the shit that I can do and how easily it's done, but then turns into pain every time I have to fuck with trying to get a specific kind of initialization, figure out why my templates aren't working the way I want, fuck with SFINAE (especially if I'm trying to specialize on return value, because C++ isn't built to allow that).

Rust is the closest thing to a better C++ that we have (D is alright, but it's more of a native Java than a better C++ for several reasons, and the stupid struct/class thing in it disgusts me), but it's probably a good 5 to 10 years from actually being better than C++ for every use case that C++ fills right now.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5144

>>5143

Can I ask you a more personal question? Why is it seemingly impossible to find good/interesting programmers to talk to on the internet or in real life? I really dislike those sites like stack overflow where you just ask questions. That isn't a real community of any sort in my point of view. Can never really seem to find "regulars" to talk to about progress with personal projects. I have 1 person like that online but they have their own life and aren't reliable for immediate feedback or just talking regularly. In one way or another I either only see programmers who are assholes, teenagers, or some other stupid trait that isn't wanted. What should I do? I love to talk about code (or try to) but I never have the opportunity or chances to. The problem is that if I can't share it in private I just don't feel motivated. It's bad enough I can't relate to anyone in my own age group :-/ If you don't have any ideas don't feel obligated to answer.

And thanks for giving more insight about Rust/C++. There's always retarded comments about every other language and unless you've used it yourself generally you start to believe in the jokes. I take it bothering with C might be a waste of time for me then since C++ is like an extension of more useful libraries and whatnot? Mainly using it for just learning/recreational purposes but I would like make some practical applications at some point.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0ccfd5 No.5145

>>5144

I think it's the nature of the field, being a largely technical and academic field. It's the same with math, classical musical instruments, and other technical fields. If you're shit at video games, you can still hold a good discussion about video games, and the really skilled people have an existing community to have higher level discussions in as a result. People who are shit at programming can't hold a high level programming conversation (so they get evangelical and play language wars without understanding what they're talking about), though, so any community has to be either largely expert or only really educational for novices. SO isn't much of a community, more of a community-driven tool. There's Reddit's /r/programming, but that suffers the same flaws as most of the rest of Reddit (censorship, circlejerks, reference humor culture), and is actually mostly people who are completely uneducated pretending to be experts (what /tech/ calls "roleplayers"). Halfchan's old /prog/ was 100% shitposting and no actual programming discussion.

The best I've ever been able to find is in IRC. /agdg/ used to have a decently-active channel on Rizon which wasn't too bad, and there are some really good channels on freenode (I lurk in #C++, C++-general, #opengl, #vulkan, and used to lurk in the rust channels), and several of them encourage general discussion instead of just language talk. That said, I miss when this board was more populated. I'd like to see it get back to a good pace.

Most languages have specific strengths and weaknesses; very few are actually totally useless, and absolutely none of them are universally ideal.

C is not useless. It actually has far different semantics from C++ in a lot of ways, guarantees much smaller executables, and is more easily useable from esoteric platforms (especially doing embedded programming, like for the NES or Gameboy, neither of which can handle C++). You probably won't find yourself using it much for general application development. It's worth knowing, and it's really easy to learn (but hard to use) compared to most other languages, due to its simplicity.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d55113 No.5146

For the anon looking for a smaller languge inside C++ I'd say:

Hi Bjarne! I didn't know you shitposted on 8ch.

Cool.

Heh, might I also suggest you have a look at the C++ Core Guidelines?

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

>"Within C++ is a smaller, simpler, safer language struggling to get out."

>t. Bjarne Stroustrup

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5151

>>5146

I always start reading that document, then start to think a bit

>Surely I shouldn't have to wade through mountains of rules and gotchas just to write a damn program? Surely a well-designed, good language shouldn't need all this shit?

Then I end up writing my program in literally any other language (unless I am at work).

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d55113 No.5152

>>5151

>wah! learning a big language is hard!

As Bjarne explains rather clearly early on, this is mainly a human-readable set of docs primarily intended for implementors of checkers.

Not receiving from the 'mountains' of wisdom offered freely by generations of highly knowledgeable men in this language, is ofc your own perogative.

I for one spend regular time reading through these guidelines, because I intend to get paid at the end of the day.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5158

>>5152

Ok, sure - perhaps learning a big language (in terms of number of language features) *is* hard. Perhaps to be great C++ programmers, we should read this document all the time, as well as other sacred texts which tell us the correct way to write code. However, given the choice between languages, surely you would be much more productive in another language (still suited to your problem domain) where you don't have to do this shit. What is the advantage of C++, if for all these extra features of the language, they do not serve to guide good application development without the addition of all these extra rules?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d55113 No.5161

>>5158

Developer isn't typically a high priority in either C or C++. There are plenty of Coffee Languages for that priority, and filled with the commensurate expected numbers of Pajeets & Stronk Indepyndynts. But for the areas of critical systems performance, scalability and solid industry chops, these are the goto languages.

Google's number one expense is electricity (they literally build their own nuclear power plants now). Developer productivity is basically a non-issue compared with compute performance.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d55113 No.5162

>>5161

>Developer productivity isn't*

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

245670 No.5175

Why hasn't anyone posted the single most important reference to the C++ language known, namely cppreference.com?

https://en.cppreference.com/w/

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5177

>>5175

Don't forget the ISOCPP faq:

https://isocpp.org/faq

However if you really want answers to burning questions such as

>Why is the language full of multiple ways to do things?

>Why is the language a pile of dog shit?

etc. see the C++ FQA:

http://yosefk.com/c++fqa/

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

245670 No.5179

>>5177

>grousing faggot

kek. C++ is the single greatest language in history. Prove me wrong w/o a shitty site link.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5180

>>5179

Why does the "greatest language in history" have pointers _and_ references?

C array, std::array, _and_ std::vector?

No algebraic data types?

No GC?

A compilation model from the 1970's which to this day limits the way you structure your code, and required header guards?

A context-sensitive, undecidable grammar which makes it impossible to write a compiler that is not slow as molasses?

Incomprehensible template errors when you miss something as trivial as a semicolon?

A lack of homoiconicity which makes meta-programming a pain in the ass?

No standard networking library?

The very concept of rvalue references, perfect forwarding, and RVO which no other language has to worry about?

Two separate attempts at implementing smart pointers which are both in the language?

Other retarded shit like SFINAE and PIMPL?

No reflection?

Exceptions, which require you to write "exception safe code"?

etc.

inb4

>he fell for the bait

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

134a04 No.5181

>>5180

>Why does the "greatest language in history" have pointers _and_ references?

You can't reassign a reference.

>C array, std::array, _and_ std::vector?

C array for C compatibility. std::array is stored on the stack.

>No algebraic data types?

There are. It depends which ones you want. You have std::variant in c++17 for sum types, but pattern matching admittedly still sucks, depending on operator overloading. If you want something better in this field, Rust or D are better choices.

>No GC?

Bit every language needs GC. We still have a need for non-GC languages and C++ is a part of that set for a reason.

>A compilation model from the 1970's which to this day limits the way you structure your code, and required header guards?

This does suck. It's that way because of history. Modules will make it better, whenever the fuck they finally land.

>A context-sensitive, undecidable grammar which makes it impossible to write a compiler that is not slow as molasses?

History. C++ parsing sucks because of decades of old shit that isn't needed anymore and a template language that's a convoluted mess.

>Incomprehensible template errors when you miss something as trivial as a semicolon?

Clang does better than g++ here.

>No standard networking library?

On the way eventually.

>The very concept of rvalue references, perfect forwarding, and RVO which no other language has to worry about?

Historical shit.

>Two separate attempts at implementing smart pointers which are both in the language?

Historical shit.

The rest is more of the same. Nobody is claiming C++ is perfect. Being the best programming language (which I wouldn't claim anyway; Rust is honestly a better language, and even that one has a few years of growing to do before being really generally useable) doesn't mean it can't be better.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

aa2662 No.5296

I would love an alive /prog/ board or thread like this one, is there somewhere everyone went, or are there simply not enough programmers on this website? /agdg/ is the only place i know with some rudimentary programming discussion from time to time, mostly in the /v/ general. /tech/ is always very quick to devolve into language wars or other shitposting, but the audience is there.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0f6151 No.5297

>>5296

There isn't anything better than these options at least in 8chan. Problem with 8chan is that it's completely under the thumb of goon types, they can shit up every board and manipulate people and the mods into bending to their will and nobody is willing to learn to recognize and ban them.

It's strikingly reminiscent of real world, they're completely ruining our home, but people will defend those guys because they've been manipulated into thinking that unless you let people do whatever they want then you're an evil rulecuck 4chan jew kike femitranny newfag who hates fun and doesn't understand 8chan culture and we need to migrate to a new board that's exactly like /b/.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

aa2662 No.5298

>>5297

Well, either way this board certainly doesnt suffer from any kind of overpopulation. On topic, a couple of questions:

<Do you use C++ at work?

For me its part hobby part work, graphics programming and geometry processing. Im working towards my Bachelors in CS and wonder if C++ is a good specialization choice, career-wise. I like it for the performance and flexibility, and can‘t really warm up to the other big players like Java or C#, but i have used them. Reading the FQA >>5177, the points make sense, but there isn‘t really a good alternative. Would be interesting however to test if he is right about flawed shared_ptr use and superfluous pass by values outweighing the penalty of a managed language and GC, in the average project.

<Preferred C++ subset

A lot of RAII, shared_ptr and stl containers. Usually not a single new/delete in the entire project, a lot of auto, limited amounts of templates. Little OO and inheritance. Heavy use of ECS architecture, but that is very application specific. No singletons or static initialization at all.

<Preferred and recommended libraries

>cereal - Easy, fully featured serialization, barely any code necessary

>EnTT - Great, very fast ECS with very useful bonus features

>ImGui - Stateless, immediate mode GUI, shit documentation though

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

299e9e No.5300

https://spit.mixtape.moe/view/a58b07a8

Why the unexpected behavior here? Instead of segfaulting it "fails" silently. Please excuse my lack of understanding here.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5305

>>5300




#include <iostream>
using namespace std;

void swap(int * p, int * q){
int temp;
temp = *p;
*p = *q;
*q = temp;
cout << "Hello" << endl; //this is the unexpected behavior point; cout does not work if int is passed to int* but it also doesn't just crash or not compile; why the unexpected behavior?
}

int main(){
int c = 5;
int d = 10;
swap (c, d); // this should be swap(&c, &d) yet this DOES swap the values but does not cout as expected or segfault
cout << "c is set to: " << c << endl;
cout << "d is set to: " << d << endl;
return 0;
}

It's because you are not calling swap, you are calling

std::swap
. It's getting included indirectly through the
#include <iostream>
, and when you write
using namespace std;
the entire contents of
std
gets brought into the global namespace. You have written a
swap
with a new signature, so that is fine, it just becomes a new overload. When looking at the
swap
call, the compiler performs overload resolution, and decides to call
std::swap
because that is the overload of
swap
which matches your arguments.

See https://en.cppreference.com/w/cpp/algorithm/swap.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5306

>>5305

>>5300

You can prove this to yourself by deleting your swap function, the code still does the same thing.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

fb0d52 No.5320

>>5305

I swear, everytime I see a post like this, C++ is involved. But seriously I think this explains why "using namespace std;" is a bad idea. Beware of what you make implicit.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5412

>>5320

>everytime I see a post like this, C++ is involved

this is a mistake even easier to make in C anon, as you and anon just demonstrated. The value semantics of good C++ as (opposed to anon's C-with-classes code) eliminates this issue. For example, this behaves as anon expected and calls his fubar version instead.

#include <iostream>

void swap(int a, int b) {
// fubar
}

int main() {
using namespace std;
int a{1}, b{2};
cout << a << b << '\n';
swap(a, b);
cout << a << b << '\n';
}
and as you said, beware of ignorance.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



[Return][Go to top][Catalog][Nerve Center][Random][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]