|
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++ 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.
|
# ? Feb 9, 2024 18:21 |
|
|
# ? May 4, 2024 11:10 |
|
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.
|
# ? Feb 9, 2024 18:22 |
|
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++ 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.
|
# ? Feb 9, 2024 18:27 |
|
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.
|
# ? Feb 9, 2024 19:34 |
|
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.
|
# ? Feb 9, 2024 19:45 |
|
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.
|
# ? Feb 9, 2024 19:58 |
|
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.
|
# ? Feb 9, 2024 21:12 |
|
Certainly there are schools in Sweden of no small renown over here in NA, thinking specifically of Chalmers and KTHIhmemies 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++ 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
|
# ? Feb 10, 2024 14:40 |
|
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.
|
# ? Feb 10, 2024 19:54 |
|
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? 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.
|
# ? Feb 12, 2024 17:12 |
|
Xarn posted:I actually ended up writing more about this here.
|
# ? Feb 13, 2024 15:02 |
|
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
|
# ? Feb 13, 2024 16:30 |
|
roomforthetuna posted:Today I learned <=> is a C++ operator.
|
# ? Feb 13, 2024 17:32 |
|
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
|
# ? Feb 14, 2024 03:31 |
|
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.
|
# ? Feb 14, 2024 03:44 |
|
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.
|
# ? Feb 14, 2024 04:08 |
|
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.
|
# ? Feb 14, 2024 14:24 |
|
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!
|
# ? Feb 14, 2024 19:44 |
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".
|
|
# ? Feb 14, 2024 20:06 |
|
Ah, that makes more sense, thank you. I knew I should have taken some CS courses.
|
# ? Feb 14, 2024 21:29 |
|
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.
|
# ? Feb 14, 2024 21:32 |
|
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.
|
# ? Feb 14, 2024 21:44 |
|
All that and it still can't deterministically order +0.0 vs. -0.0 or NaNs with different values.
|
# ? Feb 15, 2024 19:35 |
|
Just cast that float to a uint8[4] and then to a uint32_t, bingo bango total order
|
# ? Feb 16, 2024 02:40 |
|
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.
|
# ? Feb 16, 2024 11:36 |
|
|
# ? Feb 16, 2024 16:44 |
|
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.
|
# ? Feb 17, 2024 09:33 |
|
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.
|
# ? Feb 17, 2024 10:02 |
|
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. 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.
|
# ? Feb 17, 2024 10:14 |
|
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.")
|
# ? Feb 17, 2024 10:25 |
|
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++..
|
# ? Feb 17, 2024 11:00 |
|
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)
|
# ? Feb 17, 2024 12:44 |
|
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.
|
# ? Feb 17, 2024 15:04 |
|
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.
|
# ? Feb 17, 2024 15:08 |
|
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.
|
# ? Feb 17, 2024 19:36 |
|
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.
|
# ? Feb 17, 2024 19:54 |
|
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.
|
# ? Feb 17, 2024 21:33 |
|
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.
|
# ? Feb 18, 2024 09:13 |
|
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.
|
# ? Feb 18, 2024 13:27 |
|
|
# ? May 4, 2024 11:10 |
|
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. lol games isnt lucrative. hedge funds or tech majors are where you go for money.
|
# ? Feb 18, 2024 14:57 |