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
Jabor
Jul 16, 2010

#1 Loser at SpaceChem

senrath posted:

As long as they knew ahead of time that they'd be graded on speed I don't think it is. If the assignment explicitly said it needed to run quickly then an inefficient implementation doesn't meet what was required.

Nah, a zero for the code being too slow is just bad pedagogy. This is an academic exercise, not a programming competition.

Relying 100% on the autograder (and then farming out giving feedback on the actual code to the other students in the course instead of giving it yourself) sounds like a incredibly lazy prof.

Adbot
ADBOT LOVES YOU

QuarkJets
Sep 8, 2008

ExcessBLarg! posted:

As the rest of the thread is kind of beating around, it's interesting to me that this course uses C++ as the language of instruction. Most schools switched to Java or C# some 20 years ago, because even back then C++ was a language with a lot of legacy and baggage, and the nuances of C++ aren't easy for a novice to decipher and, simultaneously, distract from the actual learning of data structures and algorithms.

Back then, I think that made sense. But today it feels like Java has just as much baggage as C++ did back then. If you're going to choose a compiled language for course instruction I think C++ would be the better choice today

CPColin
Sep 9, 2003

Big ol' smile.
Teach 101 using Motorola 68000 assembly, imo

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug
If you're not learning assembly then why even bother learning anything at all? /s

Ihmemies
Oct 6, 2012

Hammerite posted:

could this fellow student have gone to the professor or to teaching assistants to get feedback and help on why their code ran so slow? the op refers to "peer feedback". That's all very well, but shouldn't the student be able to get help from the people actually teaching the course? Something seems a bit lacking, but it's possible I misunderstand (perhaps for example it is a case where they can't provide specific help on the exercise until after the deadline for submission, because it's part of the assessment for the course)

If the student understands nearly everything they need to understand, but not the particular thing they missed here, it seems a poor show if they can leave the course none the wiser when it could have been pointed out and corrected. that is the point of teaching surely.

Actually no. ”does this make sense” or “what would be a good choice when implementing X” are very forbidden questions. “Why is this so slow”.. haha, they always say you have to figure it out yourself. If something literally doesn’t work they might give some advice, after a while.

Never got any answers from course personnel, I have tried. They’re all like “we have taught the theory, now it is your task to apply it in practice”. So if you did not understand something, too bad!

Peer review is feedback we have I give to other students after the project deadline has passed. That plus automated testers save course personnel’s time.

StumblyWumbly
Sep 12, 2007

Batmanticore!
First you should learn goto statements, then you should learn why you should never use goto statements

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

ExcessBLarg! posted:

As the rest of the thread is kind of beating around, it's interesting to me that this course uses C++ as the language of instruction. Most schools switched to Java or C# some 20 years ago, because even back then C++ was a language with a lot of legacy and baggage, and the nuances of C++ aren't easy for a novice to decipher and, simultaneously, distract from the actual learning of data structures and algorithms.

Also, I don't think an autograder running on a correct, but inefficient program should result in a failing grade unless the student has access to the autograder ahead of the assignment due date (it wasn't clear to me if this was the case here), and even then I'm not sure it should do that. Like, a student inefficiency using an O(n) search where a O(1) lookup is warranted is a common mistake to the point that the autograder should be aware of it.

It's a data structures and algorithms course. Understanding the difference between a linear scan and a hashmap/etc lookup and when you'd use one over the other is precisely what they're being graded on. That's probably the best subject matter to have runtime-based tests for since if someone's time complexity is higher than it ought to be it's easy to blow it up.

Also how would you teach stuff like trees and linked lists in a 'friendly' language without pointers like java or python?

Ihmemies posted:

Actually no. ”does this make sense” or “what would be a good choice when implementing X” are very forbidden questions. “Why is this so slow”.. haha, they always say you have to figure it out yourself. If something literally doesn’t work they might give some advice, after a while.

Never got any answers from course personnel, I have tried. They’re all like “we have taught the theory, now it is your task to apply it in practice”. So if you did not understand something, too bad!

Peer review is feedback we have I give to other students after the project deadline has passed. That plus automated testers save course personnel’s time.

This part really sucks though. I understand not giving students the answers but they should point em to profiling tools or something

RPATDO_LAMD fucked around with this message at 03:21 on Dec 10, 2023

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

ultrafilter posted:

This doesn't seem to be a particularly well-designed course.

Jabor posted:

Nah, a zero for the code being too slow is just bad pedagogy. This is an academic exercise, not a programming competition.

Relying 100% on the autograder (and then farming out giving feedback on the actual code to the other students in the course instead of giving it yourself) sounds like a incredibly lazy prof.

Yes, he did say that it was a university course. This sounds about right for that. The professor would never lower themselves to actually look at any student classwork, that's what they have TAs and grad students for.

F_Shit_Fitzgerald
Feb 2, 2017



I took an algorithms and data structures course with an assignment pretty similar to that one (maybe the same school as OP? I'm not sure but probably not :tinfoil:). While we were only operating on relatively bite-sized blobs of data (say, a spellchecker program), I don't think my professor would have failed us for slow code. The point was more to understand how to use the map interface and iterators than getting the perfect O(n log n) runtime.

My school also used C++ for CS courses and only touched fairly briefly on Java. A friend who was pursuing a graduate degree in CS in another school thought that was odd, since C++ is relatively 'old hat' these days (now Java is relatively 'old hat' in comparison to Python).

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

RPATDO_LAMD posted:

Also how would you teach stuff like trees and linked lists in a 'friendly' language without pointers like java or python?

code:
class Node {
    Any value;
    Node? succ;
}

QuarkJets
Sep 8, 2008

F_Shit_Fitzgerald posted:

I took an algorithms and data structures course with an assignment pretty similar to that one (maybe the same school as OP? I'm not sure but probably not :tinfoil:). While we were only operating on relatively bite-sized blobs of data (say, a spellchecker program), I don't think my professor would have failed us for slow code. The point was more to understand how to use the map interface and iterators than getting the perfect O(n log n) runtime.

My school also used C++ for CS courses and only touched fairly briefly on Java. A friend who was pursuing a graduate degree in CS in another school thought that was odd, since C++ is relatively 'old hat' these days (now Java is relatively 'old hat' in comparison to Python).

If every assignment in an algorithms course can be completed by just writing the dumbest slowest poo poo then what's the point in taking an algorithms course

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

CPColin posted:

Teach 101 using Motorola 68000 assembly, imo

Z80 IMO, but yeah

ExcessBLarg!
Sep 1, 2001

RPATDO_LAMD posted:

Also how would you teach stuff like trees and linked lists in a 'friendly' language without pointers like java or python?
Both Java and Python use object references when assigning non-primitives.

Foxfire_
Nov 8, 2010

ExcessBLarg! posted:

Both Java and Python use object references when assigning non-primitives.
Which are just pointers with better branding and syntax that removes a few footguns

redleader
Aug 18, 2005

Engage according to operational parameters

Foxfire_ posted:

Which are just pointers with better branding and syntax that removes a few footguns

ok?

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
The syntax is a lot worse when it doesn't differentiate between reference and value types like that imo.
But C++ has the same sin with its own references.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Why would you need to distinguish when literally everything is a reference? Take your criticism to C# where it's actually warranted.

Ihmemies
Oct 6, 2012

Or use Rust, like pro’s do. There it is clear if variables are mutable or immutable, variable lifetimes, cloning, references, borrowing etc… with some other languages all that is just a big mystery.

Xarn
Jun 26, 2015

Plorkyeran posted:

I think Stepanov's decision to make iterators the primitive data structure instead of ranges has proven to be the biggest mistake. You don't lose any generality with ranges and it makes many things infinitely less clunky.

The public API does not expose what you need, but it would not be impossible to implement a O(log N) lookup in a map given a pair of iterators. The STL's free functions could have done the more optimal thing that the member functions do even with their current API had that been a design requirement from the beginning. I'd like to think that if the STL had gone through another iteration or two before it got standardized and thus frozen that would have been one of the problems he would have solved.

Dunno, I have been using v3 ranges for a while and I am not particularly impressed. Yes, it is harder to misuse them (for some cases, in other cases we get views::filter), but the compile times are awful and the resulting codegen is often not great.

Xarn
Jun 26, 2015
Re performance testing: I think that's perfectly fine for some courses. You probably don't want to do it in "how to program 101", but when you are doing algo course and are talking about hashing, why shouldn't you fail students who are doing linear scan of the hash maps?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Ihmemies posted:

Actually no. ”does this make sense” or “what would be a good choice when implementing X” are very forbidden questions. “Why is this so slow”.. haha, they always say you have to figure it out yourself. If something literally doesn’t work they might give some advice, after a while.

Never got any answers from course personnel, I have tried. They’re all like “we have taught the theory, now it is your task to apply it in practice”. So if you did not understand something, too bad!

Peer review is feedback we have I give to other students after the project deadline has passed. That plus automated testers save course personnel’s time.

What the hell? this sounds like a terrible way to teach anything at all. is this sort of approach common on computer science/software courses?

(I work as a professional software developer but my degree is in maths and stats)

Soricidus
Oct 21, 2010
freedom-hating statist shill

RPATDO_LAMD posted:

Also how would you teach stuff like trees and linked lists in a 'friendly' language without pointers like java or python?

Possibly java.util.LinkedList and java.util.TreeMap might contain some hints

F_Shit_Fitzgerald
Feb 2, 2017



QuarkJets posted:

If every assignment in an algorithms course can be completed by just writing the dumbest slowest poo poo then what's the point in taking an algorithms course

True.

raminasi
Jan 25, 2005

a last drink with no ice

GABA ghoul posted:

I'm not a coding horror perpetrator, BUT ...

IIRC the .NET hashmap actually throws an exception when a key is not present. So for someone coming from that neck of the woods that would be good code.

There is a TryGet method too, so you don't actually have to write the above every time. But I don't know how long it's been there

I just looked this up because I was curious and it was introduced in .NET Framework 2.0, which was 2005.

Plorkyeran
Mar 22, 2007

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

Xarn posted:

Dunno, I have been using v3 ranges for a while and I am not particularly impressed. Yes, it is harder to misuse them (for some cases, in other cases we get views::filter), but the compile times are awful and the resulting codegen is often not great.

If you use Ranges v3 exactly like you use the standard library's iterator-based functionality you get identical codegen and the only compile-time hit is from the concepts checking. The view adaptors have proven to be too complicated for compilers to handle reasonable, but that's something which people basically gave up on doing with iterators.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Hammerite posted:

What the hell? this sounds like a terrible way to teach anything at all. is this sort of approach common on computer science/software courses?

(I work as a professional software developer but my degree is in maths and stats)

I was just a master's student and occasional TA but it's not how I'd describe any of the courses I took or had any sort of finger in teaching. Then again this was in Sweden; my understanding is we do grading very differently from a lot of US colleges. Anyhow, for my experience: hand-in exercises were pass/fail with a lot of hand-holding, chance for revisions and answering any questions no matter how banal. Hand-ins may have required passing some automated tests which may include performance, said tests were included in code given to students. Grade was 100% determined by final written exam (which was anonymous, I never had any idea which student wrote anything I explicitly graded). I'm sure this varies wildly between different countries, universities, etc.

There was one course I took in parallel functional programming were they had explicit rankings for speed on the two hand-ins, in addition to pretty strict work-those-cores pass requirements on performance. This still didn't impact grade in any way, but the fastest solution for each did get a bottle of champagne.

Xarn
Jun 26, 2015

Xerophyte posted:

answering any questions no matter how banal

The most wtf question I ever got during an exam was "what is a leap year?". I needed a few moments to keep my poker face, but I did answer :v:

Athas
Aug 6, 2007

fuck that joker

Xerophyte posted:

There was one course I took in parallel functional programming were they had explicit rankings for speed on the two hand-ins, in addition to pretty strict work-those-cores pass requirements on performance. This still didn't impact grade in any way, but the fastest solution for each did get a bottle of champagne.

This sounds fun. Which university was this?

Ihmemies
Oct 6, 2012

I guess teaching methods vary greatly. Usually at least half of the automated tests are also “private”, so they will only say if you passed, or failed. No extra feedback. Would love to do a Swedish parallel processing course. Or any good course on the subject which awards ECTS.

I began doing another algorithm course, where we have to implement 100 different algorithms, and get 10 ECTS. Course is offered free by University of Helsinki. [url] https://cses.fi/alon/list/[/url]

Ihmemies fucked around with this message at 20:35 on Dec 10, 2023

QuarkJets
Sep 8, 2008

My required undergrad software training was computational physics. It was taught in C, and this was in the 2000s when the entire compsci department had already moved over to Java. The professor was apparently a comp-phys wizard but refused to teach anyone how to code so it was up to the few students who already understood the basics of how to write and compile software to teach everyone else how to do this poo poo after class. I had taken the EE department's intro to C course as an elective, because writing software was a complete mystery to me and I wanted to learn something about it. So it was like me and 1 other guy, both novices but armed with one semester of knowledge, helping the rest of the class figure out how to write a Hello World program for the first time (the first assignment was not "write a hello world program", it was "use software to find the thermal equilibrium state of this situation, here is the equation you should be iteratively solving"). This was a big weed-out class for the major, it was such bullshit and for no reason. Later I learned that most scientists are largely self-taught when it comes to coding, including the group that basically invented CUDA, and that's when things began to click - that professor believed that not knowing anything about the tools is required, because that's what he went through.

And then in grad school the same thing happened, but this time the professor didn't give a poo poo what language you used and merely encouraged C. He didn't care what language you chose because he wasn't going to teach you how to write code, the purpose of the course was to solve specific physics problems with software. Most of the students had either never written code or hadn't written code since their 1 semester of undergrad comp-physics and had mentally blocked the experience, so it again fell to the students with any amount of experience to teach the others basic things like writing their first hello world application.

OddObserver
Apr 3, 2009
The (American) college I was a TA in required various levels of intro CS classes for various kinds of engineering majors, with some majors encouraged to take the MatLab versions if they just wanted to do some computation stuff. I don't know how often people who studied physics or the like took advantage of that.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
I took an elective "number theory and cryptography" course where the professor was in that same "I don't care about what language you use just get the math parts right" stance. We had to implement a bunch of things in software like various prime factorization algorithms, and eventually asymmetric key encryption.
However at my school it listed a CS course as a prerequisite. I feel like I was the only one there using Python (it has native arbitrary-precision integers! so nice for this.) while everyone else was struggling with some third party C++ BigInt library since the prereq class taught C++.

redleader
Aug 18, 2005

Engage according to operational parameters
C# code:
var dateTime = new DateTime(2023, 12, 01, 00, 00, 00);	// 2023-12-01T00:00:00
var offset = TimeSpan.FromHours(10); // UTC+10
var dateTimeOffset = new DateTimeOffset(2023, 12, 01, 00, 00, 00, offset); // 2023-12-01T00:00:00+10:00
var result = dateTimeOffset == dateTime;
i would say any of these outcomes are at least defensible:
  • result = false, since dateTime has no offset
  • result = true, since the date and time components are equal
  • throw an exception, since you're comparing two fundamentally incomparable types
  • compile-time error when comparing DateTime and DateTimeOffset

.net came up with a superior solution, which is to make this depend on the machine's time zone. result is true if the machine is running in UTC+10, otherwise false

sure, the code does look suspicious when laid out like this. but life is life, and the situation i ran into this in wasn't as straightforward. instead of ==, it was <, and so tests failed in CI (UTC) while passing on my machine (UTC+13). the cherry on top is that i'd have found this locally if i'd done the work 3 months earlier! my test data included UTC+13 cases, and 3 months ago i'd have been in UTC+12. i love time and time zones and daylight saving time

QuarkJets
Sep 8, 2008

Gonna remember that one the next time someone asks me why my code is the way it is. "life is life"

nielsm
Jun 1, 2009



Keep in mind that a .NET DateTime value can be either "Local", "UTC", or "Unspecified".
If you have a Local and call ToUniversalTime() on it, it will adjust the time offset and give you the DateTime for that time given in UTC.
If you have a UTC and call ToLocalTime() on it, ditto.
If you have an Unspecified and call either on it, it will just assume the time-part is already whatever you asked for and do no conversion, only setting the Kind property.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

redleader posted:

C# code:
var dateTime = new DateTime(2023, 12, 01, 00, 00, 00);	// 2023-12-01T00:00:00
var offset = TimeSpan.FromHours(10); // UTC+10
var dateTimeOffset = new DateTimeOffset(2023, 12, 01, 00, 00, 00, offset); // 2023-12-01T00:00:00+10:00
var result = dateTimeOffset == dateTime;
i would say any of these outcomes are at least defensible:
  • result = false, since dateTime has no offset
  • result = true, since the date and time components are equal
  • throw an exception, since you're comparing two fundamentally incomparable types
  • compile-time error when comparing DateTime and DateTimeOffset

.net came up with a superior solution, which is to make this depend on the machine's time zone. result is true if the machine is running in UTC+10, otherwise false

sure, the code does look suspicious when laid out like this. but life is life, and the situation i ran into this in wasn't as straightforward. instead of ==, it was <, and so tests failed in CI (UTC) while passing on my machine (UTC+13). the cherry on top is that i'd have found this locally if i'd done the work 3 months earlier! my test data included UTC+13 cases, and 3 months ago i'd have been in UTC+12. i love time and time zones and daylight saving time

well, could be worse. you could have not had the tests to tell you it was wrong.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Athas posted:

This sounds fun. Which university was this?

Chalmers University of Technology. It would've been more fun if someone who actually drinks won* the bottles, but at least my mom was very appreciative. I have no idea if they ever did it again, it's the sort of fun thing a prof might get politely told not to repeat.

* I think I came in 1st and 2nd, but the #1 was a postdoc who was just sitting in and decided to disqualify himself. Also thinking back I think only one was ranked on perf, the other winner-gets-a-bottle assignment was writing a sample application and tutorial for one of the Haskell parallelism libraries.

redleader
Aug 18, 2005

Engage according to operational parameters

nielsm posted:

Keep in mind that a .NET DateTime value can be either "Local", "UTC", or "Unspecified".
If you have a Local and call ToUniversalTime() on it, it will adjust the time offset and give you the DateTime for that time given in UTC.
If you have a UTC and call ToLocalTime() on it, ditto.
If you have an Unspecified and call either on it, it will just assume the time-part is already whatever you asked for and do no conversion, only setting the Kind property.

agreed, the .net date/time APIs are dogshit

GABA ghoul
Oct 29, 2011

raminasi posted:

I just looked this up because I was curious and it was introduced in .NET Framework 2.0, which was 2005.

That's when they introduced generics, so I guess it has always been there.

Now that I think about it, their approach to throwing an exception in case of a missing keys actually makes a lot of sense. For value types anything a GetKey method could return for a missing key could be confused for an actual value, i.e. am I getting back a 0 because the inventory for this productID is 0 or because the productID is not in the hashmap at all?

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

GABA ghoul posted:

That's when they introduced generics, so I guess it has always been there.

Now that I think about it, their approach to throwing an exception in case of a missing keys actually makes a lot of sense. For value types anything a GetKey method could return for a missing key could be confused for an actual value, i.e. am I getting back a 0 because the inventory for this productID is 0 or because the productID is not in the hashmap at all?

golangers will tell you that this isn't actually a problem

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