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
Soricidus
Oct 21, 2010
freedom-hating statist shill

rjmccall posted:

Which is silly, because you write it in exactly the same way you would write any other self-reference within a struct definition: with "struct foo" instead of whatever typedef you're about to introduce. (Or you just typedef a forward declaration before defining the struct.) Anybody who has written a tree in C should be completely comfortable with this.

Are you saying a programmer ... was bad? :monocle:

Adbot
ADBOT LOVES YOU

Spatial
Nov 15, 2007

rjmccall posted:

Which is silly, because you write it in exactly the same way you would write any other self-reference within a struct definition: with "struct foo" instead of whatever typedef you're about to introduce. (Or you just typedef a forward declaration before defining the struct.) Anybody who has written a tree in C should be completely comfortable with this.
Yeah I've since unfucked it into a forward declaration.

There was another silly issue like this in the codebase. The main struct that defined the table of event callbacks was defined through a macro with two parameters: the extern declaration name (part of the macro) and maximum number of events. However both of these had to be constants and there was no need for the macro to exist.

The macro defined the type name by concatenating with something else. Because it hid the type name all references to it were through void pointers which were cast to the appropriate type when needed. How did they cast it without knowing the name, you ask? They declared a different struct without using the macro and used that name! Good thing the original layout never changed.

There was another macro with the same name in a different header which declared the same struct but with a couple of different member names. Three definitions of the same struct in one codebase! :v:

As an added bonus, there was another definition of this struct documented outside the code and it didn't match what I found in the code. Hah.

Spatial fucked around with this message at 01:18 on May 9, 2015

Look Around You
Jan 19, 2009

Joda posted:

I always cast to void*, didn't know you could cast to char*. I don't really see how it matters when you always tell it how the data is formatted anyway? Or maybe I have been the horror all along.

Converting to char * requires an explicit cast, while converting to void * is implicit. Basically using void * for 'generic data' makes everything a lot cleaner, especially if it's a function parameter:

code:
// void *memcpy(void *, void *, size_t)
// void *malloc(size_t)
int a[] = {1, 3, 5, 7};
int *b = malloc(4*sizeof(*b));
memcpy(b, a, 4*sizeof(*b));
is a lot cleaner than:

code:
// char *memcpy_c(char *, char *, size_t)
// char *malloc_c(size_t)

int a[] = {1, 3, 5, 7};
int *b = (int *)malloc_c(4*sizeof(*b));
memcpy_c((char *)a, (char *)b, 4*sizeof(*b));

// or
char *c = (char *) a;
char *d = (char *) b;
memcpy_c(c, d, 4*sizeof(*b));
e: you're right that it doesn't matter, and the only real reason to convert to char * is if you actually need to gently caress with the data instead of just passing around an opaque pointer to an unknown blob of data

Look Around You fucked around with this message at 08:46 on May 9, 2015

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

fritz posted:

How does this hypothesis explain having 8 bit bytes but 7 bit characters?

7 bit plus parity.

Amberskin
Dec 22, 2013

We come in peace! Legit!

Jeb Bush 2012 posted:

It's less weird when you know that historically a byte was defined as the space it takes to store a single character, rather than either meaning "8 bits" or "the smallest addressable unit of memory" like it tends to nowadays.

Well, in PDP-10 parlance, a byte was just an arbitrary string of bits contained in a single (36 bit) word. The byte oriented instructions in that architecture toke an address (word address), a bit offset and a length as parameters.

qntm
Jun 17, 2009
Which is why many people use "octet" for specificity.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
One of my own here...
C# code:
if (methodOrStoredProcedureName.ToUpper() == "PRICEREQ")
{
    XmlElement priceRequest = doc.CreateElement("PriceReq");
    priceRequest.SetAttribute("Customer", item.Customer.Id);

    XmlElement priceElement = doc.CreateElement("Price");

    main.AppendChild(priceRequest);

    priceElement = BuildPriceRequest(priceElement, item, newPrice);
    priceRequest.AppendChild(priceElement);
}
else // priceReq
{

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
php:
<?
    function checkPgStatus($db, $r, $msg) {
        if ($r) return 1;

        if (strstr($msg, "NOERRORS:")) return 0;

        if (ini_get("display_errors")) echo "<br><B><I><font color=red>\n";

        if (strstr($msg, "DONTEXIT:")) {
            if (ini_get("display_errors")) {
                echo str_replace("DONTEXIT:", "", $msg);
                echo(pg_ErrorMessage($db));
            }
            return 0;
        }

        if (1 || ini_get("display_errors")) {
            print_backtrace(debug_backtrace());
            echo "<br>$msg";
            echo(pg_ErrorMessage($db));
        }

        $footer=getenv("FT_FOOTER");
        if (strlen(@$footer)) include $footer;
        echo "SQL error occured, exitting.\n";
        exit(1);
    }
?>
I don't even know.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Maybe someone was playing a game of "how many places can we stash global state"? Now they've checked off environment variables, the most obvious place to put your footer.

xzzy
Mar 5, 2009

My favorite is the first line.

Why pass a value that never gets used except to bail out?

:psyduck:

Soricidus
Oct 21, 2010
freedom-hating statist shill

xzzy posted:

My favorite is the first line.

Why pass a value that never gets used except to bail out?

:psyduck:

$r must be the return value of another function, so if the other function succeeded then this one returns 1, and if it failed then this one either returns 0, prints a message and then returns 0, or prints a message and then terminates the program. I guess doing it this way means you can sometimes save a conditional when calling this function or something.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

Soricidus posted:

$r must be the return value of another function, so if the other function succeeded then this one returns 1, and if it failed then this one either returns 0, prints a message and then returns 0, or prints a message and then terminates the program. I guess doing it this way means you can sometimes save a conditional when calling this function or something.

Yeah, $r is supposed to be the result from pg_query().

Man, I sure do love it when a function call can indiscriminately terminate the entire script.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
I'm not familiar with PHP, so does the expression (1 || ini_get("display_errors")) mean what I think it does coming from C/C++? I.e. always evaluating as true?

necrotic
Aug 2, 2005
I owe my brother big time for this!

Joda posted:

I'm not familiar with PHP, so does the expression (1 || ini_get("display_errors")) mean what I think it does coming from C/C++? I.e. always evaluating as true?

Yes.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

Joda posted:

I'm not familiar with PHP, so does the expression (1 || ini_get("display_errors")) mean what I think it does coming from C/C++? I.e. always evaluating as true?

E: fb. And I'm dumb at 5AM. You're right, it's always true.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Remember that OS course I'm taking with the baddish faculty?

The final project was due tonight at midnight. The provided test suite turned out to have so many bugs that I was basically passing all the tests I should have failed and failing all the tests I should have passed. They got fixed tests up this morning (after 2 full weeks of complaining from students), and then after I spent 6 hours fixing my project decided it was a great time to announce they were extending the deadline by 2 days. After I'd already burned a vacation day at work and fixed my code to pass all the tests.

Previous to this there had been 0 communication from TAs and they didn't respond to any questions on the discussion board.

Also it turns out the professor overseeing this mess definitely wrote his own wikipedia page. The page is way too complementary about the zombie novel he wrote, and talks up a bunch of patents for technologies that haven't been in use since the 90s.

I'd love to post some of the test code (it's a python horror) or link the wikipedia page, but I'd rather not burn any bridges before I get my final grade :)

edit: Oooh, I forgot one of the best parts. The final statement in the final project specification was "Regarding validating the data within a file-type inode's datablocks: Obi-wan says these are not the droids you're looking for".

After about 4 questions on the class discussion board and a student actually stalking the professor down via skype, he finally clarified that this meant "You don't have to validate the data in files, just fix the inodes if metadata is screwed up". He was really indignant about it too. Maybe don't let trying to make nerd jokes take priority over actually educating your students?

The MUMPSorceress fucked around with this message at 05:08 on May 13, 2015

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

LeftistMuslimObama posted:

edit: Oooh, I forgot one of the best parts. The final statement in the final project specification was "Regarding validating the data within a file-type inode's datablocks: Obi-wan says these are not the droids you're looking for".

After about 4 questions on the class discussion board and a student actually stalking the professor down via skype, he finally clarified that this meant "You don't have to validate the data in files, just fix the inodes if metadata is screwed up". He was really indignant about it too. Maybe don't let trying to make nerd jokes take priority over actually educating your students?

Cultural education is important too. It's like applying for a programming job without having seen Office Space: we can see your neck-beard but you can't hide you're not one of us.

itskage
Aug 26, 2003


IT BEGINS posted:

php:
<?
    function checkPgStatus($db, $r, $msg) {
        if ($r) return 1;

        if (strstr($msg, "NOERRORS:")) return 0;

        if (ini_get("display_errors")) echo "<br><B><I><font color=red>\n";

        if (strstr($msg, "DONTEXIT:")) {
            if (ini_get("display_errors")) {
                echo str_replace("DONTEXIT:", "", $msg);
                echo(pg_ErrorMessage($db));
            }
            return 0;
        }

        if (1 || ini_get("display_errors")) {
            print_backtrace(debug_backtrace());
            echo "<br>$msg";
            echo(pg_ErrorMessage($db));
        }

        $footer=getenv("FT_FOOTER");
        if (strlen(@$footer)) include $footer;
        echo "SQL error occured, exitting.\n";
        exit(1);
    }
?>
I don't even know.

Is calling ini_get("display_errors") twice also as dumb as I think it is?

Edit: Ohh, it's in there three times.

Edit2: I guess it's not as bad as I was thinking since the ini values are saved in the RAM and it's not actually accessing the file system each time it's used?

itskage fucked around with this message at 15:52 on May 13, 2015

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Edit: nm

ExcessBLarg!
Sep 1, 2001

LeftistMuslimObama posted:

Also it turns out the professor overseeing this mess definitely wrote his own wikipedia page.
Alright so I had to dig this guy up. Never heard of him, which makes sense given his general lack of academic accolades in computer systems and waning industry relevance.

I'm also not sure how there's a dead link to the final project description on the course page but I found it eventually. It's insufferable. His poor attempts at comedy just comes off as patronizing and unprofessional, if not causing ambiguity and generally making learning far more difficult than needed. Sucks you had to slog through that poo poo all semester.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

ExcessBLarg! posted:

Alright so I had to dig this guy up. Never heard of him, which makes sense given his general lack of academic accolades in computer systems and waning industry relevance.

I'm also not sure how there's a dead link to the final project description on the course page but I found it eventually. It's insufferable. His poor attempts at comedy just comes off as patronizing and unprofessional, if not causing ambiguity and generally making learning far more difficult than needed. Sucks you had to slog through that poo poo all semester.

Yeah, all of the project descriptions are a mess. Just walls of text with lots of asides. Guy has apparently heard of <li> or something.

I ended up learning a lot anyway, because the projects at least pointed me at stuff I could then google or post about, but I feel like I could have gotten way more out of it if the author of our textbook was still teaching the class. Multiple times the TAs referred us to video recordings of that professor's lectures to get clarification on topics.

I'm tempted to screenshot the current state of the course message board to post later, because it's been a shitshow the last couple days. The students finally snapped with no working tests to code against and started posting poverty ghost memes and such. I'm one of the only people actually answering questions about the assignment (the TAs sure aren't). It's a horror show! One of the TAs even had the nerve to say "We're busy with our homework too!". gently caress that dude. I have a full-time job where we're on a major release deadline (release in June) and I still found time to show up in class and do my homework.

ChickenWing
Jul 22, 2010

:v:

LeftistMuslimObama posted:

One of the TAs even had the nerve to say "We're busy with our homework too!". gently caress that dude. I have a full-time job where we're on a major release deadline (release in June) and I still found time to show up in class and do my homework.

I think you'll find that the TA probably has more work than you.


Grad School: Not Even Once

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

ChickenWing posted:

I think you'll find that the TA probably has more work than you.


Grad School: Not Even Once

Maybe normally, but it's release crunchtime. I'm doing 75 hours a week plus class plus homework. I think everyone would forgive the bugs and understand he's busy (I say "he", but there's 6 TAs for this class), but what puts it over the edge is that they ALL went MIA and didn't respond to questions for 2 weeks and then pulled that excuse.

VikingofRock
Aug 24, 2008




LeftistMuslimObama posted:

Maybe normally, but it's release crunchtime. I'm doing 75 hours a week plus class plus homework. I think everyone would forgive the bugs and understand he's busy (I say "he", but there's 6 TAs for this class), but what puts it over the edge is that they ALL went MIA and didn't respond to questions for 2 weeks and then pulled that excuse.

The fact that all the TAs disappeared at once means that it's probably TA crunchtime too.

ChickenWing posted:

Grad School: Not Even Once

shodanjr_gr
Nov 20, 2007

LeftistMuslimObama posted:

Maybe normally, but it's release crunchtime. I'm doing 75 hours a week plus class plus homework. I think everyone would forgive the bugs and understand he's busy (I say "he", but there's 6 TAs for this class), but what puts it over the edge is that they ALL went MIA and didn't respond to questions for 2 weeks and then pulled that excuse.

Think about it this way. The TA probably spends 20 hours a week on his TA assignment, another 20 hours a week on coursework, 10 hours a week attending classes and probably another 10+ hours trying to romance an advisor into funding him/her. All while making $20k a year.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Yet another reason I am glad that a master's degree is not even remotely a requirement in this industry. I have friends who work in higher ed and are now working on their PHds and still making sub-40k. That's some true bullshit.

I just wish that, if they knew they were going to be busy, that they'd prepared the project earlier and taken the time to thoroughly test their tests. We were told the project description wasn't even done until the day before it was assigned.

shodanjr_gr
Nov 20, 2007

LeftistMuslimObama posted:

Yet another reason I am glad that a master's degree is not even remotely a requirement in this industry. I have friends who work in higher ed and are now working on their PHds and still making sub-40k. That's some true bullshit.

I just wish that, if they knew they were going to be busy, that they'd prepared the project earlier and taken the time to thoroughly test their tests. We were told the project description wasn't even done until the day before it was assigned.

Completely agreed. I'm just saying that, as a soon to be former grad student, if you think you have it bad, your TA has it worse :haw:. Also, my experience has been that organizational problems with the class are almost always the fault of the teaching professor and not the TA.

ChickenWing
Jul 22, 2010

:v:

LeftistMuslimObama posted:

Yet another reason I am glad that a master's degree is not even remotely a requirement in this industry.

I've had more than one TA that I've chatted with talk to me about pursuing a Master's. I basically politely laugh in their face every single time.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

shodanjr_gr posted:

Completely agreed. I'm just saying that, as a soon to be former grad student, if you think you have it bad, your TA has it worse :haw:. Also, my experience has been that organizational problems with the class are almost always the fault of the teaching professor and not the TA.

Gotcha. I'm pretty comfortable blaming the professor for not getting them to work ahead. It looks like ExcessBlarg! already found his wiki, but I'll link it after I get my final grade.

I also went ahead and took a dump of the course website so I can post that if they take it down after the semester :).

edit:
To give you an idea of how this guy operates, on a previous project (which he also didn't make the spec for until the day it was assigned), we were writing a slab memory allocator and a freelist based memory allocator. The specification required us to use a specific void * value as our magic number in allocated block headers. Two months later, he posted on the course message board with the title "Contest, since nobody asked." He offered a free signed copy of his zombie novel to the first person to guess what the number was. It turned out to be the number for one of his patents. Which he also pimped up a lot on his wiki article that he totally wrote.

This is the same guy who bragged he hadn't bothered to learn x86 assembly until this year, and only did it because he had to to teach this course.

The MUMPSorceress fucked around with this message at 17:43 on May 13, 2015

shodanjr_gr
Nov 20, 2007

ChickenWing posted:

I've had more than one TA that I've chatted with talk to me about pursuing a Master's. I basically politely laugh in their face every single time.

That's because they are miserable pursuing their PhDs and wish they had dropped out with a Master's instead. Or maybe they (I) are (am) just projecting.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
What's even the point of a CS master's or PHD unless you're really into research? You're going to learn most of the practical stuff you need as a programmer out in the field. Postgrad CS work seems to be the exclusive domain of people who genuinely enjoy endless theorizing and paper writing. I imagine it's a perfect fit for some people, but it would be completely miserable if you don't like spending a semester researching some microoptimization to dead code analysis in optimizing compilers or whatever.

Although the (totally great) student lecturer from my compilers course said his grad project was demonstrating the vulnerability of drones to grids of consumer-grade laser pointers, which is pretty fun. They got to reserve a gym and then crash a bunch of drones into poo poo by disrupting their landmark selection algorithms with huge grids of laser pointers that they waved around.

JawnV6
Jul 4, 2004

So hot ...

LeftistMuslimObama posted:

This is the same guy who bragged he hadn't bothered to learn x86 assembly until this year, and only did it because he had to to teach this course.
That's pretty reasonable. Astronomers/telescopes and whatnot.

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

shodanjr_gr posted:

That's because they are miserable pursuing their PhDs and wish they had dropped out with a Master's instead. Or maybe they (I) are (am) just projecting.

You aren't the only one. I know a couple that moved their wedding date up more or less as an excuse for the wife to drop out of a PhD program with 'only' a master's without burning bridges with her advisor.

ExcessBLarg!
Sep 1, 2001

LeftistMuslimObama posted:

What's even the point of a CS master's or PHD unless you're really into research?
A Masters' isn't bad. It gets your feet wet with academia and research to see if that's a path you really want to go down. Plus it's a chance to publish something in your name which, even if you were solving similar problems in industry, you may not be able to publish. Masters' theses are also entirely reasonable in scope, so if it turns out you don't really like academia, you spend enough time in it to figure that out and no longer.

Recently though, a few things have happened. First, old-style research-based Masters programs, which were kind of like PhD-lites in that you got a stipend and all, have given away to two-year course-work based programs with high tuition costs. Basically they've turned into a fifth year of undergrad. Second, if you actually want to do research, in some programs now you have to join the Doctoral program straight out of undergrad, instead of doing a research Masters first to see if you're into it. The problem here is, if it turns out you're not fit for academia, you still have to push all the way through to finish, or drop out and burn bridges with your advisor, basically giving up any opportunity to seek a PhD later even in other programs. This change is pretty obviously intended to "encourage" more students to finish their PhDs instead of walking away with just a Masters. I think it also encourages more drop-outs and stress on both students and faculty though.

As for the point? Honestly there might not be one. But when you're a fresh-faced 22 year old at the top of your undergraduate class and your professors are selling you the Doctoral program as your best career move and your parents and everyone else is encouraging you to do it, it's easy to end up there.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
That's unfortunate, especially when places like my employer would pay those fresh-faced top-of-the-class 22-year-olds 100k to start and spend like 6 months giving them real-world training before dropping them into the stresses of software development.

There's something really sick happening to universities in general and I'm not really sure how to fix it. The problem you describe extends well beyond CS postgrad stuff. It's even worse in some fields where you're not considered even equipped to be entry-level until you've got your first doctorate.

ExcessBLarg!
Sep 1, 2001
There's a lot of parallels between academia and MLM schemes. Professorship is a total rat race itself, but in particular, aspiring professors need Doctoral students to conduct research underneath them, yet at the same time, they're ultimately competing against each other for relatively few jobs. It's not total servitude though, because students do make a stipend (even if it's barely livable) and they are publishing in their own name.

The thing is, in some fields academic research is the only way to be able to work on interesting problems that the rest of the world would otherwise not care about. That's definitely not the case in CS though.

VikingofRock
Aug 24, 2008




LeftistMuslimObama posted:

There's something really sick happening to universities in general and I'm not really sure how to fix it. The problem you describe extends well beyond CS postgrad stuff. It's even worse in some fields where you're not considered even equipped to be entry-level until you've got your first doctorate.

ExcessBLarg! posted:

The thing is, in some fields academic research is the only way to be able to work on interesting problems that the rest of the world would otherwise not care about. That's definitely not the case in CS though.

This is definitely how it is in physics and it sucks. I just want to help discover some cool poo poo; why do I have to go through so much bullshit to do so?

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

VikingofRock posted:

This is definitely how it is in physics and it sucks. I just want to help discover some cool poo poo; why do I have to go through so much bullshit to do so?

Because you can't sell a greater understanding of the universe, but if I make your porn download 1.5x faster I will be a millionaire.

ChickenWing
Jul 22, 2010

:v:

LeftistMuslimObama posted:

Because you can't sell a greater understanding of the universe, but if I make your porn download 1.5x faster I will be a millionaire.

Downloading porn in TYOOL 2015

Adbot
ADBOT LOVES YOU

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

ChickenWing posted:

Downloading porn in TYOOL 2015

I have a very intricate metadata and cataloging system for my porn, OK?
:goonsay:

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