|
Incoherence posted:(it keeps you from forgetting to clean up after yourself before returning in languages/situations where that matters, at the possible cost of making your logic harder to follow) The lack of RAII is the real horror.
|
# ? May 19, 2011 10:22 |
|
|
# ? May 4, 2024 11:36 |
|
Incoherence posted:As usual, this is sort of a good idea in theory (it keeps you from forgetting to clean up after yourself before returning in languages/situations where that matters, at the possible cost of making your logic harder to follow), but eventually everyone just sort of forgets the tradeoff part of it and it gets upgraded into a Law of Programming. Honestly something like the following isn't too bad if you can't have automatic cleanup for some reason: code:
|
# ? May 19, 2011 10:37 |
|
Another horror: code in a cooperative threading model where pieces of code implicitly require that no blocking operations happen within certain sections.
|
# ? May 19, 2011 12:19 |
|
Critical sections in my co-routines? It's more likely than you think.
|
# ? May 19, 2011 12:40 |
|
Ithaqua posted:Well, "lines of code written per day" obviously isn't a performance metric where you work! That other guy is like 40x more productive than you. code:
code:
Irregardless, I am now 3 times more productive than my predecessor.
|
# ? May 19, 2011 17:51 |
|
enthe0s posted:I'm only into my 3rd year of programming, but my college teaches us to not use multiple return statements and instead create a single variable at the top and return it at the end. Why exactly, I'm not sure, but I hear it's good form. Here's the thing about school that they don't teach you: to think about what you're hearing. In this case, whenever somebody tells you to do the same thing in every instance, you should immediately start coming up with a counter-example and take them to task. This isn't being That Jerk In Class, this is seeing if their case holds up in every instance, or watch them fall apart because what they told you wasn't correct.
|
# ? May 19, 2011 17:59 |
|
NotShadowStar posted:Here's the thing about school that they don't teach you: to think about what you're hearing. In this case, whenever somebody tells you to do the same thing in every instance, you should immediately start coming up with a counter-example and take them to task. This isn't being That Jerk In Class, this is seeing if their case holds up in every instance, or watch them fall apart because what they told you wasn't correct. This is a good point, but if you're learning introductory programming it isn't really worth it. When I was a TA for elementary Java programming, I got a lot of success out of telling the students "here's a rule; treat it as the truth until you learn why it isn't". For example: quote:If you're having trouble with the first few assignments, here's some advice. Every program that you write should have this structure: It let the students concentrate on what they needed to know at the moment and not on the boilerplate magic characters that let their programs compile. Of course by week 3 or 4, they're making classes that don't need a public static void main, but by then they learn why they were inserting that stuff in the first place and why they don't need it now.
|
# ? May 19, 2011 18:30 |
|
Lysidas posted:This is a good point, but if you're learning introductory programming it isn't really worth it.
|
# ? May 19, 2011 18:46 |
|
NotShadowStar posted:Here's the thing about school that they don't teach you: to think about what you're hearing. In this case, whenever somebody tells you to do the same thing in every instance, you should immediately start coming up with a counter-example and take them to task. This isn't being That Jerk In Class, this is seeing if their case holds up in every instance, or watch them fall apart because what they told you wasn't correct. I agree with the first part of this but not the second. It isn't your job to correct the instructor and most of them won't appreciate it. I labored under an instructor for two years who insisted that every function everywhere be SESE all the time. You couldn't argue with her; she was 9000 years old and was programming COBOL and ALGOL before I was even born. She believed in SESE and by gosh you were going to do it whether you liked it or not, and if you didn't, that was points off your assignment. So, yes, absolutely question anything that anyone tells you is a hard and fast rule about anything. Think critically, and if you're invited to give your opinion, go ahead and give it, and if you're not, save everyone the hassle of enduring a fruitless argument between you and the instructor. You may think their argument will "fall apart" when confronted with your awesome counterexample, but they always get the last word, and they get it on your grade roster. I haven't met a CS instructor yet who doesn't have some baffling, bizarre, or just plain wrong opinions about programming. Having done this since I was knee-high to a grasshopper I'm a little set in my ways myself. But the whole thing has to be viewed as any other learning experience, whether it's a classroom lecture, a textbook, or on-the-job training: take the good and leave the bad.
|
# ? May 19, 2011 19:23 |
|
I just replaced about 500 lines of lovely C++ with about 10 of Boost.Spirit. Here's a taste of what I just vanquished (formatting preserved): code:
Lexical Unit fucked around with this message at 20:08 on May 19, 2011 |
# ? May 19, 2011 20:04 |
|
code:
|
# ? May 19, 2011 20:18 |
|
Jabor posted:Honestly something like the following isn't too bad if you can't have automatic cleanup for some reason: They taught me not to use goto code:
code:
|
# ? May 19, 2011 20:31 |
|
MEAT TREAT posted:
|
# ? May 19, 2011 20:31 |
|
Fiend posted:Irregardless There is still a horror in this post. edit: vvv DICTATOR OF FUNK fucked around with this message at 21:07 on May 19, 2011 |
# ? May 19, 2011 20:41 |
|
root beer posted:There is still a horror in this post. I put that there intentionally so people who don't understand c# can still enjoy the post.
|
# ? May 19, 2011 21:02 |
|
MEAT TREAT posted:
Ugh, this is literally every line of code produced by someone here who doesn't let our product being built in C# stop him from writing it in Java. code:
Java: If it's not meaningless, it's not abstract enough. Also, Java: The measure of your code is the count of "design patterns" used. Either of these happen in any language, but I've never seen them embraced so wholeheartedly as in the Java community.
|
# ? May 19, 2011 22:13 |
|
quote:You may think their argument will "fall apart" when confronted with your awesome counterexample, but they always get the last word, and they get it on your grade roster. If the instructor is going to fail you for not doing SESR then you're going to have to do it, but if you take them to task on backing it up and they just can't keep it together, then you know that rule is pretty much poo poo. College is supposed to be more than just grades and not just swallowing whatever retarded poo poo they're telling you to memorize and regurgitate on the exam. CS is applied mathematics, and if you say 'for all' in math, you better drat well better be able to back it up, otherwise you should say 'for all except' and explain the exceptions.
|
# ? May 19, 2011 22:30 |
|
HORATIO HORNBLOWER posted:II haven't met a CS instructor yet who doesn't have some baffling, bizarre, or just plain wrong opinions about programming. I just graduated a few weeks ago. My favorite one of these was the systems architecture professor who told the class that "the memory address 0x100 means zero followed by some stuff that doesn't matter, and ending in 100." That was in the 2nd week of class and after that, I didn't attend it again for the rest of the semester.
|
# ? May 20, 2011 00:40 |
|
ColdPie posted:I just graduated a few weeks ago. My favorite one of these was the systems architecture professor who told the class that "the memory address 0x100 means zero followed by some stuff that doesn't matter, and ending in 100." That was in the 2nd week of class and after that, I didn't attend it again for the rest of the semester. holy poo poo How did this person get a job as a CS professor? You need a PhD, don't you? Jesus christ.
|
# ? May 20, 2011 01:09 |
|
PalmTreeFun posted:holy poo poo Probably does theoretical CS or something like that and doesn't use a computer for anything other than typesetting papers with Latex, but was forced to teach that class anyway. Either that or they had a stroke at some point and no one noticed.
|
# ? May 20, 2011 01:18 |
|
PalmTreeFun posted:holy poo poo I had to show a professor once how to use a debugger. This was in the lab for a more coding- than theory-centered course. He was learning C++ along with the rest of the class, he was just a week or so ahead in the book.
|
# ? May 20, 2011 01:27 |
|
A A 2 3 5 8 K posted:I had to show a professor once how to use a debugger. This was in the lab for a more coding- than theory-centered course. He was learning C++ along with the rest of the class, he was just a week or so ahead in the book.
|
# ? May 20, 2011 01:35 |
|
YeOldeButchere posted:Probably does theoretical CS or something like that and doesn't use a computer...
|
# ? May 20, 2011 01:56 |
|
NotShadowStar posted:If the instructor is going to fail you for not doing SESR then you're going to have to do it, but if you take them to task on backing it up and they just can't keep it together, then you know that rule is pretty much poo poo. College is supposed to be more than just grades and not just swallowing whatever retarded poo poo they're telling you to memorize and regurgitate on the exam. It's true that in an ideal world instruction would be more of a Socratic give and take between teacher and student. I hope that your college experience is or was or will be like that; mine certainly wasn't. The problem is that CS really isn't like mathematics; at least, not in this case. You can't give me a proof that "there are cases where SESE should be violated" any more than you can give me a proof that "there are no cases where SESE should be violated" because it's fundamentally not a falsifiable statement. Give me an arbitrary algorithm and a Turing-complete language to implement it in and no matter what I can do it in either style. The SESE version might be messier but you could hand that mess in to my old prof and she'd smile, nod, and grade it A+. So much for your counterexample! (And heaven help you if your non-SESE code dares to employ a goto.) Convictions are convictions and it's real hard to get somebody to see past the end of their own nose once they've made them. There are two lessons I take from this, and the first is that you don't argue with people's convictions. I don't try to convert anyone to my religion or my political preferences, and I don't try to convince them of the obvious truth that my coding style is superior to theirs. Like I said, if your instructor is amenable to a good debate, more's the better, but don't pick a poor hill to die on. The second lesson is even more important, though, which is to have as few of these convictions of your own as possible. Keep an open mind. Be willing to listen to different points of view without labelling them as wrong or inferior. I'll frame this in another context: in grade school we're all taught a bunch of English rules like: "never start a sentence with a conjunction" and "never end a sentence with a preposition." Today most of us are well aware that's prescriptivist nonsense that has little to no basis in reality. But learning those rules has a certain value, and as you mature as a writer, it'll be explained to you in a pat sort of way that "you have to learn the rules before you can learn when to break them." I have an intuitive grasp of English and nobody ever had to tell me where a comma should go or what word I should use where, but my fifth grade teacher still took points of when I broke her rules. Does that excuse the stance of my professor? No, the fact that she's secretly Ada Lovelace's walking zombie corpse does. But balance your personal knowledge and experience against the people that you have seen, or see, in your CS classes, or even just some of the nonsense we see in this thread. My fellow fifth graders couldn't tell a compound sentence from a complex sentence. Likewise, I walked into my "intro to CS" class with years of experience with C, whereas my classmates wouldn't have been able to mash out a "hello, world" program if you put a gun to their heads and a copy of K&R in their hands. Computer science is hard--really, really hard--for most people. I think the rule of SESE is a particularly archaic one--pretty tough to write a function with more than one entry anymore--but the overall practice of supplying overly-simplistic rules to help elementary learners gain good habits is not an inherently bad one, in my opinion.
|
# ? May 20, 2011 02:19 |
|
If I were a CS professor I'd work my hardest to slip in bad info to confuse students years after their graduation without being detected.
|
# ? May 20, 2011 02:37 |
|
MononcQc posted:If I were a CS professor I'd work my hardest to slip in bad info to confuse students years after their graduation without being detected. Kind of like the Calvin's Dad explanation of something. Something harmless though, like "process handles are the count of handled exceptions by the process."
|
# ? May 20, 2011 02:59 |
|
HORATIO HORNBLOWER posted:Likewise, I walked into my "intro to CS" class with years of experience with C, whereas my classmates wouldn't have been able to mash out a "hello, world" program if you put a gun to their heads and a copy of K&R in their hands. This is, I'm convinced, part of the reason why Scheme became so popular for introductory course sequences: odds are good that the hotshots who have been programming since they can walk don't know Scheme, and odds are at least decent that they aren't familiar with functional programming.
|
# ? May 20, 2011 03:09 |
|
Incoherence posted:This discrepancy is one of the several hard problems in teaching introductory CS in college, because somehow you have to make the hotshots pay attention to the instruction, and at the same time you have to bring the people who are relative newbies up to a reasonable level. Which speaks to how computer science degrees should not be programmer job qualifications and everyone knows this already but no one does anything about it.
|
# ? May 20, 2011 03:14 |
|
Incoherence posted:This is, I'm convinced, part of the reason why Scheme became so popular for introductory course sequences: odds are good that the hotshots who have been programming since they can walk don't know Scheme, and odds are at least decent that they aren't familiar with functional programming. As a TA for a university that does this, I can confirm that this is the primary reason our intro course uses Scheme. It does a pretty good job of leveling the playing field a bit.
|
# ? May 20, 2011 03:18 |
|
brosmike posted:As a TA for a university that does this, I can confirm that this is the primary reason our intro course uses Scheme. It does a pretty good job of leveling the playing field a bit. As someone who TAd an intro course using Java, I think there may be other good reasons for Scheme... namely it being a very minimalist language (though I would be very worried about recursion). It's easy to ignore it for someone with experience, but there is really a LOT of stuff going on in Java that people have to grasp at once to be able to really understand what they're doing --- the most obvious examples being scopes, with both locals and members making a difference, etc. People are also basically forced to try to understand OOP (which is a tool for structuring complicated things) at the time they don't know how to do really simple things /correctly/. ... Though really, bringing back Pascal might actually not be a horrible idea, either (after adding a string type, of course).
|
# ? May 20, 2011 03:24 |
|
OddObserver posted:As someone who TAd an intro course using Java, I think there may be other good reasons for Scheme... namely it being a very minimalist language (though I would be very worried about recursion). It's easy to ignore it for someone with experience, but there is really a LOT of stuff going on in Java that people have to grasp at once to be able to really understand what they're doing --- the most obvious examples being scopes, with both locals and members making a difference, etc. Worried about recursion how?
|
# ? May 20, 2011 06:26 |
|
GrumpyDoctor posted:Worried about recursion how? That people just starting out would have lots of difficulty getting it.
|
# ? May 20, 2011 06:49 |
|
OddObserver posted:That people just starting out would have lots of difficulty getting it.
|
# ? May 20, 2011 07:43 |
|
Incoherence posted:I'm convinced that the only reason people think recursion is hard is because everyone tells them recursion is hard. How ironic.
|
# ? May 20, 2011 08:19 |
|
We were able to squeeze in the first year bachelors: meta-circular interpreters, logic programming, register machine coding, a language implementation in said machine code and finally culminating in a programming project where the students had to program an ARM7 microprocessor and arduino hardware + nokia lcd screen to implement a DDR clone. All in Scheme. It's a teaching horror to just start with "Well ignore all this, but start your programs with 'public static void string args.' Beef fucked around with this message at 09:23 on May 20, 2011 |
# ? May 20, 2011 09:21 |
|
code:
|
# ? May 20, 2011 12:25 |
|
Incoherence posted:I'm convinced that the only reason people think recursion is hard is because everyone tells them recursion is hard. For me, recursion was only hard because I was teaching myself at the time and just didn't "get it" - when my CS teacher actually broke it down and the reasoning for using it, it was much easier to grasp. I think it's less that recursion is hard, but more that the reasons for using it are confusing and hard to grasp. If you can't wrap your head around why you'd want to do something, then it's makes it a bit harder to figure out how to make it work.
|
# ? May 20, 2011 14:32 |
|
BigRedDot posted:Fun fact: I took "Mathematical Methodologies" from Dijkstra when I was an undergrad at UT; he did not have a computer in his office, and I never saw him use one. Didn't Dijkstra have a fairly famous interview where he said basically that when he was in industry he was writing OSes for an instruction set that wasn't fabbed yet and he had to do everything in his head / on pencil, and that's the way you should do it comma drat it?
|
# ? May 20, 2011 14:50 |
|
Beef posted:It's a teaching horror to just start with "Well ignore all this, but start your programs with 'public static void string args.'
|
# ? May 20, 2011 14:59 |
|
|
# ? May 4, 2024 11:36 |
|
Orzo posted:Why? If you really don't know anything about programming, there are certain things you need to understand before method signatures, access modifiers, and argument lists. Have you ever tried to teach any programming to a complete newbie? The entrypoint signature can be overwhelming. Even many introductory books say 'we'll come back to this later, but for now you always need to have this block of code for your program to run.' But at the same time there are languages like Scheme and Python where you don't need to worry about those things at all. The real horror is teaching Java as a first language.
|
# ? May 20, 2011 15:33 |