Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Ihmemies
Oct 6, 2012

Well, I've looked at Chalmers many times for some reason or another, and even that looks a lot more professional than what we have in Finland. Sorry for the derail, I will stop now. So much stuff I've missed which I didn't know I should probably learn during CS studies. I don't even know how to use templates with C++ :sigh: Generics were basically skipped in all core programming courses here, apparently it's up to the student to learn to use them after they discover they exist and realize they need to learn them.

Adbot
ADBOT LOVES YOU

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


The difference in curricula across universities has less to do with what topics are covered and more to do with how much material you can cover in a single class and how hard you can push the students. The median student at an elite university might be comparable to the 80th percentile student at a big state school and that means the bar has to be set lower in that second case.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Ihmemies posted:

Well, I've looked at Chalmers many times for some reason or another, and even that looks a lot more professional than what we have in Finland. Sorry for the derail, I will stop now. So much stuff I've missed which I didn't know I should probably learn during CS studies. I don't even know how to use templates with C++ :sigh: Generics were basically skipped in all core programming courses here, apparently it's up to the student to learn to use them after they discover they exist and realize they need to learn them.

generics are syntactic sugar and have little to do with CS unless youre in a class on programming languages; and theyre not going to be the focus in the first languages class you take anyway

CS education doesnt teach programming, it teaches data structures, algorithms, queueing theory, etc. only enough programming is taught so students are able to work through the coursework.

Volte
Oct 4, 2004

woosh woosh
My CS curriculum (Canada) had a few classes that were shared with the Software Engineering curriculum and I think one rudimentary C++ course was the only programming-oriented course we had in the entire curriculum. Other courses either did not directly involve programming at all (e.g., theory of computation, numerical computation, linear optimization) or they had programming-based projects but you had to either learn Python on your own time or else submit in whatever language you wanted.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ultrafilter posted:

The difference in curricula across universities has less to do with what topics are covered and more to do with how much material you can cover in a single class and how hard you can push the students. The median student at an elite university might be comparable to the 80th percentile student at a big state school and that means the bar has to be set lower in that second case.

Yeah. My grad school coursework was almost all co-taught with undergrads, and it was mostly the same subjects I took in undergrad, so I saw pretty directly how different the expectations were at different schools. (There was also a quarters-vs-semester difference in play, though.) It was pretty night-and-day: CMU classes covered a lot more than Portland State and had much higher expectations for classwork. I especially remember the assignments in Algorithms, which were all like “answer questions 5, 6, and 7 on page 112”; I’d look at questions 8 and 9 and think, “yeah, the professor clearly decided these were too hard for PSU students”. Nobody wants to teach a weed-out class at a school like that.

OddObserver
Apr 3, 2009
Another difference between universities is whether grad classes are co-taught or not :p. I did my undergrad at a smaller (but still research university) school so a lot of the undergrad advanced classes were co-listed with grad classes w/one less project, which was pretty good for me then... Then during my (unsuccessful) grad school stint I was at a much larger (and more prestigious) program, which meant grad classes were standalone, more advanced (an algorithm class that actually did algorithm *design* and didn't just have it in the title!), but therefore a lot less likely to be taken by undergrads.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

OddObserver posted:

Another difference between universities is whether grad classes are co-taught or not :p. I did my undergrad at a smaller (but still research university) school so a lot of the undergrad advanced classes were co-listed with grad classes w/one less project, which was pretty good for me then... Then during my (unsuccessful) grad school stint I was at a much larger (and more prestigious) program, which meant grad classes were standalone, more advanced (an algorithm class that actually did algorithm *design* and didn't just have it in the title!), but therefore a lot less likely to be taken by undergrads.

Yeah, co-listing can definitely go both ways. Co-listed grad classes at CMU were great as an undergrad, although I didn’t get as much out of them as I should’ve. I had a couple different teachers who clearly just decided to cover for me despite knowing I’d done nothing all semester. In my defense, lambda calculus is extremely boring to cover for like sixteen weeks.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Certainly there are schools in Sweden of no small renown over here in NA, thinking specifically of Chalmers and KTH

Ihmemies posted:

So much stuff I've missed which I didn't know I should probably learn during CS studies. I don't even know how to use templates with C++ :sigh:
Every topic covered should be necessary for building a strong CS foundation, but even the best curriculum, alone, is not going to be sufficient for doing so.

If you think there's something that you weren't taught that you ought to know, that's great, because you've at least built up enough good taste to reach that conclusion yourself :eng101:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Also, instruction on specific language features (and restrictions on what features you can use) is mostly a first-year thing. In higher-level classes, the assumption is that you’re comfortable enough in the languages you’re using that you can teach yourself whatever other features you feel you need, and the only restriction is not to confuse the graders.

Xarn
Jun 26, 2015

Xarn posted:

What do y'all think about the C++20 changes around comparisons, specifically the expression reordering (so when compiler sees a == b it will also look for overloads fitting b == a at the same time), and the std::foo_ordering?

Because when I was recently writing some application code, being able to just default the comparison operators was nice, and not having to think about both overloads for cases where I was comparing across different types was also nice. And I don't think I needed to care about the ordering specifics...

But as library dev, I think both can go die in a fire and their authors as well. I burned good week figuring out why some tricky code was fine in C++17, but not in C++20. Turns out, me, being an absolute fool that I am, expected that given ExprLhs<T> == U, I could constrain the overloads of operator== under the assumption that ExprLhs<T> will be on the left. Except that's not how it works anymore, and for bonus points the switched overloads are not SFINAE automatically, so they can easily cause compilation error.

And the requirement that an ordering can only compare itself to literal 0 is still causing me grief right now, but that would be a longer rant :v:

I actually ended up writing more about this here.

Issues 1, 2, and 4 are all caused by C++20's <compare>.

-e-

One fun fact, MSVC still can't compile the code, because they do not implement P2564. But if you are using clang-cl with their stdlib, it should work.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Xarn posted:

I actually ended up writing more about this here.
Today I learned <=> is a C++ operator.

Xarn
Jun 26, 2015
Yep, it is called the spaceship operator and because this is C++, it returns one of std::strong_ordering, std::weak_ordering, and std::partial_ordering. These are not to be mistaken with std::strong_order, std::weak_order and std::partial_order :v:

Brexit the Frog
Aug 22, 2013

roomforthetuna posted:

Today I learned <=> is a C++ operator.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Xarn posted:

Yep, it is called the spaceship operator and because this is C++, it returns one of std::strong_ordering, std::weak_ordering, and std::partial_ordering. These are not to be mistaken with std::strong_order, std::weak_order and std::partial_order :v:
Thanks for making a thing that seemed neat into a thing that seems horrifying.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

rjmccall posted:

I had a couple different teachers who clearly just decided to cover for me despite knowing I’d done nothing all semester. In my defense, lambda calculus is extremely boring to cover for like sixteen weeks.

I’m scandalized here, and might take down the rjmccall poster I have hung on my bedroom wall.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

roomforthetuna posted:

Thanks for making a thing that seemed neat into a thing that seems horrifying.

It's certainly not the most elegant thing out there, but it lets algorithms like sorting that need a strong ordering to express that in the type system. std::strong_order and std::strong_ordering both existing is awkward but they are at least things that go together and just not totally unrelated types.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Plorkyeran posted:

It's certainly not the most elegant thing out there, but it lets algorithms like sorting that need a strong ordering to express that in the type system. std::strong_order and std::strong_ordering both existing is awkward but they are at least things that go together and just not totally unrelated types.
Oh, I see, the idea is you can have separate overrides of the operator for "fast and loose" or "slow and strong" ordering and sort algorithms can select (or be selected) based on what's available/better. That's not so bad.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

So like if you have multiple sort keys and some of the secondary ones are expensive to compute, you could do a sort just on the cheap primary key if that suffices for the purpose?

It seems useful enough, but I’m surprised that it’s a common enough concern to have standard library support for it!

nielsm
Jun 1, 2009



That's not in general what a strong or weak ordering refers to.

A strong ordering is a comparison of elements in a set, where two elements with distinct values will also always have an explicit ordering: One of them always comes before the other. The result of a strong order comparison of two non-equal elements is either "less than" or "greater than".

A weak ordering can have elements that compare non-equal still be considered equal for the ordering. The result of a weak order comparison of two non-equal elements is either "less than", "greater than" or "same".

A partial ordering can have element pairs that are not comparable for ordering. The result of a partial order comparison of two non-equal elements is either "less than", "greater than", "same", or "unordered".

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Ah, that makes more sense, thank you. I knew I should have taken some CS courses.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
A float is the standard example of a partial ordering. The whole thing is an attempt at fixing the problem where calling std::sort() on a range that contains NaN is UB and any code which compares floats which doesn't explicitly handle NaN tends to do super broken things if given NaN. Because it's C++, std::sort is not actually updated to do different things depending on the type of ordering the comparison function returns.

Xarn
Jun 26, 2015
Funnily enough, IEEE 754 actually defines a total ordering. However, since this is different from the expected behaviour of <, and C++ really likes its operator<, floats drop into partial ordering instead.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
All that and it still can't deterministically order +0.0 vs. -0.0 or NaNs with different values.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Just cast that float to a uint8[4] and then to a uint32_t, bingo bango total order

Xarn
Jun 26, 2015
That's no less UB than casting it directly.

Use memcpy, it has magical aliasing powers and the compilers are smart enough to elide it anyway.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Okay so I posted in August or so about starting a new project in C++, something I've not worked in since my high school days.

My current progress: how the hell am i suppose to know any of this poo poo in C++?

We were able to find someone in our company who is experienced with C++ to take a look at our PRs and he has been pretty helpful.

I wrote a class as a simple storage class. Basically a dict to handle values. I created basic constructor/destructor functions that didn't do anything so I left them blank.

He wrote up a whole thing suggesting how we should set those constructors/destructors to default (i.e. `Dict() = default;`, `~Dict() = default;`) because this allows the memory APIs to be able to set std::is_trivially_copyable_v<T> to return true. This apparently allows std::memcpy, and std::memmove to copy the object faster. He also says even if you're not using your class for much, this is just good practice in his opinion.

I guess my question is: regardless of what you think about his opinion.. is this something I should actually know while I'm working in C++? granted I've only been doing this for maybe half a year but is this just how it is with C++? As you write more code you just kinda figure out these details about C++?

I'm not sure exactly if I just haven't studied enough about C++ or this is just how it is until you gain enough experience writing C++ code. Interested in what people have to say because it just seems like something you'd never know about until you ran into it.

When I posted in here originally people suggested I look at cppreference.com which I went to look at after I found out about that tidbit above and lo and behold it does mention it in the Classes section of the site about triviality, but short of looking for this information I probably wouldn't have found it. Hell even reading that section, I probably would have read it, thought, "okay I guess I need to know about this" but probably would have written my code the same way.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
C++ is essentially an unending cascade of exposing you to a feature and then telling you that the obvious way to use it is wrong, yes. Like, you’ve learned a bunch of stuff about constructors now, but I promise there’s so much more random stuff to learn about them, like that single-argument constructors default to creating an implicit conversion from the parameter type, or that initializing a member using the special syntax as the start of a constructor is significantly different from just assigning to it later, or that those member initializations get silently reordered.

The way you learn this stuff is you either build up a lot of hard-won experience or you listen to / read a book by someone who’s already gone through it.

Not So Fast
Dec 27, 2007


Strong Sauce posted:

Okay so I posted in August or so about starting a new project in C++, something I've not worked in since my high school days.

My current progress: how the hell am i suppose to know any of this poo poo in C++?

We were able to find someone in our company who is experienced with C++ to take a look at our PRs and he has been pretty helpful.

I wrote a class as a simple storage class. Basically a dict to handle values. I created basic constructor/destructor functions that didn't do anything so I left them blank.

He wrote up a whole thing suggesting how we should set those constructors/destructors to default (i.e. `Dict() = default;`, `~Dict() = default;`) because this allows the memory APIs to be able to set std::is_trivially_copyable_v<T> to return true. This apparently allows std::memcpy, and std::memmove to copy the object faster. He also says even if you're not using your class for much, this is just good practice in his opinion.

I guess my question is: regardless of what you think about his opinion.. is this something I should actually know while I'm working in C++? granted I've only been doing this for maybe half a year but is this just how it is with C++? As you write more code you just kinda figure out these details about C++?

I'm not sure exactly if I just haven't studied enough about C++ or this is just how it is until you gain enough experience writing C++ code. Interested in what people have to say because it just seems like something you'd never know about until you ran into it.

When I posted in here originally people suggested I look at cppreference.com which I went to look at after I found out about that tidbit above and lo and behold it does mention it in the Classes section of the site about triviality, but short of looking for this information I probably wouldn't have found it. Hell even reading that section, I probably would have read it, thought, "okay I guess I need to know about this" but probably would have written my code the same way.

There's a series of books by Steve Meyers (Effective C++ etc.) that collect a bunch of his articles on best practices for using the "new" C++11 features, that are an invaluable extension of just using cppreference or SO.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Also https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines. (Basically, "yeah, it’s a f*cked up language, here's what to do to make it semi-usable.")

Ihmemies
Oct 6, 2012

Best thing is that we have a parallelism course at university, and of course all the examples use only C++, and all exercises must be done with it. Love doing multithreaded apps with C++..

Nalin
Sep 29, 2007

Hair Elf
lol, watch out though, because if you explicitly default the destructor, copy-constructor, or copy-assignment operator, then the compiler won't implicitly generate a move constructor or move assignment operator for you.

https://en.cppreference.com/w/cpp/language/rule_of_three (see: rule of five)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Nalin posted:

lol, watch out though, because if you explicitly default the destructor, copy-constructor, or copy-assignment operator, then the compiler won't implicitly generate a move constructor or move assignment operator for you.
This is probably my most hated thing about C++. I can at least rationalize *why* it would do anything else annoying, but this one is annoying *and* nonsensical.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

roomforthetuna posted:

This is probably my most hated thing about C++. I can at least rationalize *why* it would do anything else annoying, but this one is annoying *and* nonsensical.

backward compatibility before move. if you dont have move and you do have copy, you may be in a codebase that doesnt know about move, and only expects copy. so moving and invalidating will likely break code. esp for libraries written to old standard interoperating with newer code.

Presto
Nov 22, 2002

Keep calm and Harry on.
Don't worry about it too much, Strong Sauce. You're not doing anything *wrong*, per se. Writing C++ is an eternal quest about writing your code and then figuring out how you can make it better.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
As someone who likes to understand wtf is going on, C++ is intensely frustrating. But I've gotten to the place where I'm no longer surprised to learn about a new footgun, I'm just disappointed. So yeah I feel for ya op.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

leper khan posted:

backward compatibility before move. if you dont have move and you do have copy, you may be in a codebase that doesnt know about move, and only expects copy. so moving and invalidating will likely break code. esp for libraries written to old standard interoperating with newer code.
Ah, thank you, that does make sense of it, and now I even appreciate it, backwards compatibility is a wonderful thing. (That grpc, protobuf and other things mostly caused by google don't give enough of a gently caress about.)

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Thanks everyone for your sympathetic words. I kinda avoided this thread today because I was pretty exhausted from dealing with C++ at work that I wrote that out of frustration and didn't want to deal with anything C++ today.

I do feel like I'm a bit too old to be putting so much more esoteric knowledge into my brain. I'm stalling a bit in my career right now and I honestly don't know if trying to become an expert on C++ is the thing that reinvigorates my enjoyment of programming or of my job. There are probably lucrative jobs to be had with this skillset but I do not have the mathematical chops to do game programming, and I can't imagine Enterprise C++ apps are any better than Enterprise Java apps.

I guess it also doesn't help that we're basically supporting multiple platforms off the bat, and dealing with all the issues between each system, and that we're also reducing the team in half because we're having to reallocate resources.

Not So Fast posted:

There's a series of books by Steve Meyers (Effective C++ etc.) that collect a bunch of his articles on best practices for using the "new" C++11 features, that are an invaluable extension of just using cppreference or SO.

I'll look into this.. maybe get my employer to buy these books.

InAndOutBrennan
Dec 11, 2008
Just random thoughts from a hobby c++ writer here. My production code tends to be written in stuff you would expect in the data place.

But poo poo is it interesting to dip in and out every 6 months to learn something new. Looking at some code I have in both python and C++ the difference is really minimal in structure these days.

15 years ago it would have needed so many "helper" functions and classes that now are part of the std.

Yes you can dip down and roll your own poo poo when needed but from someone where every project is greenfield it's just so nice these days.

TLDR: Haven't used new or malloc in ages. And yes I understand, different strokes.

Adbot
ADBOT LOVES YOU

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Strong Sauce posted:

Thanks everyone for your sympathetic words. I kinda avoided this thread today because I was pretty exhausted from dealing with C++ at work that I wrote that out of frustration and didn't want to deal with anything C++ today.

I do feel like I'm a bit too old to be putting so much more esoteric knowledge into my brain. I'm stalling a bit in my career right now and I honestly don't know if trying to become an expert on C++ is the thing that reinvigorates my enjoyment of programming or of my job. There are probably lucrative jobs to be had with this skillset but I do not have the mathematical chops to do game programming, and I can't imagine Enterprise C++ apps are any better than Enterprise Java apps.

I guess it also doesn't help that we're basically supporting multiple platforms off the bat, and dealing with all the issues between each system, and that we're also reducing the team in half because we're having to reallocate resources.

I'll look into this.. maybe get my employer to buy these books.

lol games isnt lucrative. hedge funds or tech majors are where you go for money.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply