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
PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane
Not so much bad code, per se, but still pretty frightening:

At least one student in my OS course took the already overly-permissive language policy (you can use C, C++, or Java for assignments) to mean "it can be done in any language" and consequently handed in an assignment written in Python. For an OS course.

And they aren't even going to get a 0 on the assignment!

Frankly, it's stupid that you can write assignments for a systems course in Java, even.

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

PT6A posted:

Not so much bad code, per se, but still pretty frightening:

At least one student in my OS course took the already overly-permissive language policy (you can use C, C++, or Java for assignments) to mean "it can be done in any language" and consequently handed in an assignment written in Python. For an OS course.

And they aren't even going to get a 0 on the assignment!

Frankly, it's stupid that you can write assignments for a systems course in Java, even.

I dunno, there are some assignments that could make sense to do in a non-systems language (a page-replacement algorithm simulator, for example). I had a professor who let me do a little filesystem in Perl, but I had to clear it with him beforehand and he made me use the basic Perl syscall wrappers rather than normal Perl I/O stuff.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

GrumpyDoctor posted:

I dunno, there are some assignments that could make sense to do in a non-systems language (a page-replacement algorithm simulator, for example). I had a professor who let me do a little filesystem in Perl, but I had to clear it with him beforehand and he made me use the basic Perl syscall wrappers rather than normal Perl I/O stuff.

There are three parts to the assignment/series of assignments: simulate a hard disk (read_block, write_block, etc...) with and without cache (LRU cache replacement), then implement a basic (highly restricted) FAT filesystem, and then allow that basic filesystem to be accessed across a network. Other than correctness, there are no requirements (i.e. it can be as inefficient as you like). Given those constraints, I don't think it's unreasonable to expect 3rd-years to complete the assignments in C, given approximately a month to finish each stage.

Certainly, they shouldn't be disregarding the instructions entirely and using Python without explicit permission.

Dijkstracula
Mar 18, 2003

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

PT6A posted:

There are three parts to the assignment/series of assignments: simulate a hard disk (read_block, write_block, etc...) with and without cache (LRU cache replacement), then implement a basic (highly restricted) FAT filesystem, and then allow that basic filesystem to be accessed across a network. Other than correctness, there are no requirements (i.e. it can be as inefficient as you like). Given those constraints, I don't think it's unreasonable to expect 3rd-years to complete the assignments in C, given approximately a month to finish each stage.

Certainly, they shouldn't be disregarding the instructions entirely and using Python without explicit permission.
Boy you sure seem to care a lot about something that in no way affects you. If the assignment can be done in Java (which is as big a "systems language" as Python), there's really no reason to disallow Python.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Perhaps, but how is that a coding horror in any way?

Dijkstracula
Mar 18, 2003

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

MEAT TREAT posted:

Perhaps, but how is that a coding horror in any way?
whitespace syntax :xd:

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Dijkstracula posted:

Boy you sure seem to care a lot about something that in no way affects you. If the assignment can be done in Java (which is as big a "systems language" as Python), there's really no reason to disallow Python.

I suppose; however, it does affect me, since using unapproved languages mean the TAs have to use a different environment to mark the assignments, and may have to read code in language with which they aren't familiar, which holds up the grading in a very serious way (and may result in the TAs being in a bad mood when they mark my assignment).

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


Our OS class projects were all done with a Java fake-OS called Nachos. It was a giant pain in the rear end because, in that Java framework, something as simple as passing a memory address requires you to go through like 5 classes.

Honestly I think most of the C/C++ coding horrors you see are caused by CS programs being taught in Java. People don't understand simple things like pointers.

HFX
Nov 29, 2004

poopgiggle posted:

Our OS class projects were all done with a Java fake-OS called Nachos. It was a giant pain in the rear end because, in that Java framework, something as simple as passing a memory address requires you to go through like 5 classes.

Honestly I think most of the C/C++ coding horrors you see are caused by CS programs being taught in Java. People don't understand simple things like pointers.

Most coding horrors have nothing to do with Java but are because programmers just hack out there code. I've seen C/C++ only programmers who write some of the most horrible code you could ever want. Usually, the best code comes from guys who regularly use functional or declarative languages.

Dijkstracula
Mar 18, 2003

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

HFX posted:

Usually, the best code comes from guys who regularly use functional or declarative languages.
This is entirely because functional and declarative languages are used entirely by hobbyists and Reddit circlejerkers who aren't writing production code.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Proggit creates plenty of horrors of its own, although I can't say how many of them directly involve code

tef
May 30, 2004

-> some l-system crap ->
For example, Cantor did 9/11

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

tef posted:

For example, Cantor did 9/11

Timecube is more readable than this.

raminasi
Jan 25, 2005

a last drink with no ice

tef posted:

For example, Cantor did 9/11

:psyduck: Is this some sort of elaborate troll or something?

fritz
Jul 26, 2003

GrumpyDoctor posted:

:psyduck: Is this some sort of elaborate troll or something?

No, that's fairly typical math kookery.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

fritz posted:

No, that's fairly typical math kookery.

I remember when I wrote some thing about how gravitational potential energy was a load of crap. The difference is that I was in like 7th grade.

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


Dijkstracula posted:

This is entirely because functional and declarative languages are used entirely by hobbyists and Reddit circlejerkers who aren't writing production code.

Do you mean purely functional? Otherwise, ITA Software might disagree with you.

jandrese
Apr 3, 2007

by Tiny Fistpump

Dijkstracula posted:

This is entirely because functional and declarative languages are used entirely by hobbyists and Reddit circlejerkers who aren't writing production code.

Like Facebook? Last time I used it Erlang was functional.

Erlang is defiantly something that will warp your mind with its whole pattern matching functional specification thing.

If you don't know, here's how Erlang works:

Say you want to create a loop, what you do is create two functions like so:

In Pseudocode because I can't remember the wacky syntax:

code:
foo(0, data)
{
  return
}

foo(x, data)
{
  (do stuff with your data here)
  foo(x - 1, data)
}
So what happens is that you call foo with the number of iterations you want, and the second function will call itself until x gets down to 1, then the call to foo becomes foo(1 - 1, data). 1 - 1 of course becomes 0, and the first foo() will match better and be called, dropping you out of the loop.

This is just a tiny taste of what people do with this syntax in Erlang. You can do error handling by making functions like:

code:
openfile(NULL)
{
  error messages go here
}

openfile(x)
{
  open the file
}
And of course because it's a functional language, it will only be natural to you if you're a mathematician and you would rather be writing proofs instead of code.

Dijkstracula
Mar 18, 2003

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

Wow thank you so much for showing me this magic of "recursion"! This is indeed a beautiful thing that is unique to functional languages let me go grab GHC and convert all my code to monads :rolleyes: Like, really? That's your counterexample? You don't show off higher-order functions or lambdas and say "can your C do that? Look at what I can do with map and foldr!"

But, my entire complaint about functional programming acolytes (where my Reddit circlejerk comment came from) was actually this:

jandrese posted:

And of course because it's a functional language, it will only be natural to you if you're a mathematician and you would rather be writing proofs instead of code.
It's exactly this kind of smug wankery that drives me up the loving wall. The only thing I hate more than people who use their operating system to define themselves are people who use their programming language to define themselves.

Just for the record, I still do a lot of programming in functional languages, and it is indeed cool. (and, indeed, I'm TAing a freshman CS class this term that uses Scheme, and the average quality of code that I see in that class is far higher than what I saw in the other freshman Java class.) But you're loving kidding yourself if you try and correlate a language's "quality" with a self-serving "you must be this smart to enter" metric. And further, you can't compare the "average quality" of code of a language that isn't used in a production setting, with one that is. If Java wasn't used by every half-assed developer and his dog to slap together some lovely business app, then you too could probably look at the average piece of Java code and say, "yes, this is beautifully written."

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

PT6A posted:

There are three parts to the assignment/series of assignments: simulate a hard disk (read_block, write_block, etc...) with and without cache (LRU cache replacement), then implement a basic (highly restricted) FAT filesystem, and then allow that basic filesystem to be accessed across a network. Other than correctness, there are no requirements (i.e. it can be as inefficient as you like). Given those constraints, I don't think it's unreasonable to expect 3rd-years to complete the assignments in C, given approximately a month to finish each stage.

This was a few posts back, but what university is this at? I'm just curious as to whether this is a common thing or just a coincidence since I had the exact same thing for my OS course when I took it, down to function names and allowed languages. If it's McGill, then yeah, that course is a joke and you'd be dumb to do it in anything but C since they give you a piece of code where all you have to do is plug your header file and it tests everything you need to have working.

Dijkstracula
Mar 18, 2003

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

It's a pretty common thing. I did a very similar assignment at the University of Alberta (the LRU cache simulation, but no file system simulation stuff)

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

YeOldeButchere posted:

This was a few posts back, but what university is this at? I'm just curious as to whether this is a common thing or just a coincidence since I had the exact same thing for my OS course when I took it, down to function names and allowed languages. If it's McGill, then yeah, that course is a joke and you'd be dumb to do it in anything but C since they give you a piece of code where all you have to do is plug your header file and it tests everything you need to have working.

Ding ding, you are a winner! It's McGill. Did you have Vybihal for it, out of curiosity?

For those who didn't go to McGill, I'll echo that it's pretty much a joke. As YeOldeButchere described, each assignment consists of writing about six functions, then running the test code to make sure they work as expected. In total, I've written maybe 2000-2500 lines of commented C code, and a lot of that could be cut down with better design. I'm kind of jealous when I hear about people doing non-trivial things in OS classes, in a way.

Getting back to the point about functional languages, I think people who've used them to some degree write better code because it's such a mindfuck when you first get started that you have to really understand what's going on, within the code, and within whatever code you're trying to write. If you can think clearly about your code and the language, you're bound to avoid half of these coding horrors to begin with (specifically, those that don't result from laziness).

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


No I'm pretty sure that it's because the kind of people who seek out languages like Haskell and Erlang are the kind of people who tend to design their code well in the first place.

Also GG to the guy who shared the magic of tail-recursion with everyone. Thanks for the walk down memory lane to my high school AP CS class!

shrughes
Oct 11, 2008

(call/cc call/cc)

PT6A posted:

I suppose; however, it does affect me, since using unapproved languages mean the TAs have to use a different environment to mark the assignments, and may have to read code in language with which they aren't familiar, which holds up the grading in a very serious way (and may result in the TAs being in a bad mood when they mark my assignment).

I'm pretty sure the reason I didn't fail my final computer graphics project was that the TA didn't feel like installing GHC and GTK on Windows, so I just got an A instead.

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


But really I think everyone should get a copy of The Haskell School of Expression and work through the excercises. Learning functional programming methodology is valuable even if you never use Haskell again, and drawing snowflake fractals is more fun than "hay guys check out this two-line lazy Quicksort."

tef
May 30, 2004

-> some l-system crap ->

poopgiggle posted:

No I'm pretty sure that it's because the kind of people who seek out languages like Haskell and Erlang are the kind of people who tend to design their code well in the first place.

correlation is causation. thanks for that insight.

Meganiuma
Aug 26, 2003

poopgiggle posted:

But really I think everyone should get a copy of The Haskell School of Expression and work through the excercises. Learning functional programming methodology is valuable even if you never use Haskell again, and drawing snowflake fractals is more fun than "hay guys check out this two-line lazy Quicksort."

What kind of monster underlines a book title without it being a link to more information?

newsomnuke
Feb 25, 2007

Dijkstracula posted:

The only thing I hate more than people who use their operating system to define themselves are people who use their programming language to define themselves.
I take it you've never met anyone who uses their motherboard to define themselves.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
With my AsusTM nForceTM 970 SLI,

Dooey
Jun 30, 2009

Meganiuma posted:

What kind of monster underlines a book title without it being a link to more information?

This kind of monster.

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


tef posted:

correlation is causation. thanks for that insight.

How did you get that from what I said?

If you're offended because you don't know Haskell or something, I should clarify that functional-seeking-programmers are a proper subset of good programmers.

Aturaten
Mar 23, 2008

by elpintogrande
I'm currently modifying the gently caress out of a Zen Cart template my client opted for instead of paying me a grand or two more for the job. One of the requirements was to have an on-page login box in the header. Firstly, the thing replicates itself in the sidebar, so I've no drat idea how to fix that one right now, so I just set its display: to none for now, but the way the module was coded made it impossible to use correctly.

php:
<?
$content = '<div align="right">';

  if(!$_SESSION['customer_id']) {
    echo zen_draw_form('account_box', zen_href_link(FILENAME_LOGIN, 'action=process', 'SSL'));

    $account_box_content = "
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr> 
<td align=\"right\" valign=\"middle\" class=\"boxText\">" . ACCOUNT_BOX_EMAIL_ADDRESS . 
"</td>
<td align=\"right\" valign=\"middle\" class=\"boxText\">" . zen_draw_input_field('email_address', 
'', 'size="10"') . "</td>
<td align=\"right\" valign=\"middle\" class=\"boxText\">" . ACCOUNT_BOX_PASSWORD . "</td>
<td align=\"right\" valign=\"middle\" class=\"boxText\">" . zen_draw_password_field('password', 
'', 'size="10"') . "</td>

<td align=\"right\" valign=\"center\" class=\"boxText\">" . '&nbsp;<input type="submit" value="' . HEADER_TITLE_LOGIN . '" style="width:40px" />' . "</td>

</tr></table><br style='line-height:15px;' />
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>

<td> " . '<a class="menu" href="' . zen_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' 
. ACCOUNT_BOX_PASSWORD_FORGOTTEN . '</a>&nbsp;' . " " . '&nbsp;<a class="menu" href="' . zen_href_link(FILENAME_LOGIN, '', 'SSL') . '">' 
. ACCOUNT_BOX_CREATE_ACCOUNT . '</a>' . zen_draw_hidden_field('securityToken', $_SESSION['securityToken'])  . "</td></tr>
</table></form>
    ";
  } else {
    $account_box_content = '
        <a class="headerNavigation" href="' . zen_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . ACCOUNT_BOX_ACCOUNT . '</a>&nbsp;' .
        '&nbsp;<a class="headerNavigation" href="' . zen_href_link(FILENAME_LOGOFF, '', 'SSL') . '">' . ACCOUNT_BOX_LOGOFF . '</a>&nbsp;'
    ;
  }

  $content .= $account_box_content;

  $content .= '</div>';
?>
I ended up stripping the tables out, and now it works fine. This is a module last updated a week ago.

tef
May 30, 2004

-> some l-system crap ->

quote:

If you're offended because you don't know Haskell or something,

I am offended by haskell. Turns out that disliking functional programming is obviously my dirty secret. Maybe I should stick to PHP.

quote:

I should clarify that functional-seeking-programmers are a proper subset of good programmers.

A good programmer seeks functional languages (in that they attempt to understand various methodologies of programming), but seeking functional languages will not make you a good programmer.

I would posit that the reason we don't see as many bad programmers using functional languages is that they aren't as popular.

BigRedDot
Mar 6, 2008

I guess we've just run out of coding horrors then?

tef
May 30, 2004

-> some l-system crap ->

poopgiggle posted:

But really I think everyone should get a copy of The Haskell School of Expression and work through the excercises. Learning functional programming methodology is valuable even if you never use Haskell again, and drawing snowflake fractals is more fun than "hay guys check out this two-line lazy Quicksort."

On the other hand if you're looking for a short and useful introduction to the language, I would recommend Programming Haskell.

I found it focused on the concepts of the language rather than trying to get you to draw pictures and sounds.

Plorkyeran
Mar 22, 2007

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

tef posted:

A good programmer seeks functional languages (in that they attempt to understand various methodologies of programming), but seeking functional languages will not make you a good programmer.
So you agree with him and are bad at reading or something, as that's exactly what he said.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Plorkyeran posted:

So you agree with him and are bad at reading or something, as that's exactly what he said.

Well no, it rather isn't. There is a difference between looking at functional languages due to some intrinsic quality of theirs that you believe makes them superior to languages that take other approaches or a mix thereof*, and looking at functional languages because you want to understand many of the different approaches to solving problems and managing complexity that have taken hold in the programming world (in this case you would also look into some more-or-less pure OOP languages like smalltalk, and exemplars of other methodologies as well). poopgiggle didn't explain what he meant or distinguish between these cases, or any other scenario he may have meant. He just laid out 'good programmers do x, bad programmers do y', then called out a prolog wizard for being butthurt about 'not getting' functional or declarative programming.



*fp techniques are a lighter-weight and simpler way to achieve modularity and re-usability, suck it object orientards

jandrese
Apr 3, 2007

by Tiny Fistpump

Dijkstracula posted:

Wow thank you so much for showing me this magic of "recursion"! This is indeed a beautiful thing that is unique to functional languages let me go grab GHC and convert all my code to monads :rolleyes: Like, really? That's your counterexample? You don't show off higher-order functions or lambdas and say "can your C do that? Look at what I can do with map and foldr!"

Way to miss the point. The example there was to show off the weirdness that is running pattern matches on your function calls, the recursion bit was just there because that's how Erlang works!

poopgiggle
Feb 7, 2006

it isn't easy being a cross dominate shooter.


Otto Skorzeny posted:

poopgiggle didn't explain what he meant or distinguish between these cases, or any other scenario he may have meant. He just laid out 'good programmers do x, bad programmers do y',

Alright next time I'll write 3 paragraphs that explicitly spell out what I mean so that pedants can't pick my wording apart.

To be clear: saying "all good programmers use functional languages" is retarded, but programmers who seek out less-popular languages because they require them to think about problems in a different way are generally better. Saying "functional programming leads to good code design" isn't quite correct, but I've found that using functional style in languages like Perl or Java makes the code easier to understand and debug.

quote:

then called out a prolog wizard for being butthurt about 'not getting' functional or declarative programming.

I had no loving idea who that is. Guess I should lurk moar.

poopgiggle fucked around with this message at 19:46 on Nov 29, 2009

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

poopgiggle posted:

Alright next time I'll write 3 paragraphs that explicitly spell out what I mean so that pedants can't pick my wording apart.

Admittedly, my initial response was rather terse too.

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