Teaching C++ WTF.



  • @antred said:

    @Cat said:

    2. Variable initialization -- I'm kind of iffy on this.  Sometimes it's nice to make sure that you have some default value, but I don't do it every time.  I always do it for pointers, though, because that can lead to incredibly hard-to-find errors otherwise.

    Declaring variables without initializing them is silly. Instead of 

     

    int a;

    // ...

    a = someFunction();

    Why not do it the right way and just go 

    int a = someFunction();

     




  • Someone else may have nailed this, but I couldn't be fucked to finish reading the entire thread when I saw herpius derpius like the following:

     @Heron said:

    Of course, I haven't even mentioned the economic disaster you two seem intent on creating. Hint: there's a reason economies flourish when people are allowed to specialize. Go take Econ 101 at your local college. There is absolutely nothing wrong with ensuring that people who specialize in a field aren't going to do more harm than good.

    Are you completely and utterly retarded? Apparently you haven't followed your own advice and taken Econ 101 at your local college. Specialization emerges naturally in economies because sometimes people figure out that they're better at making a particular type of instrument, say ink, than they are at making a pen and ink set. The cool thing is that nobody gives a shit whether or not their ink sucks - if it does, and there's an alternative, people just don't buy it. That's a result of a market. Similarly, if an influx of ultra-shitty programmers showed up and produced a bunch of garbage tomorrow, you wouldn't have to worry, because nobody would care about their trash (unless you're a scrub yourself?...). Again, that's something you'd learn in Econ 101.

    When people specialize and are relied upon for important shit, like health care, it's nice to have some entity like the government make sure people know what they're doing. In fact, some liberatarians purists would argue that even that's not necessary, and that eventually the people who don't get well/die would drive the market to avoid those particular health care providers. But that's pretty ridiculous, and developing computer software is definitely not on that level, unless you're doing some nuclear power plant automation or something (food for thought: most appropriate language for nuclear power plant automation?) Anyway, it would hardly be an "economic disaster" if programming was easier for lay persons (unless you're worried because you're a no-talent asshole, of course). Let me give you an example.

    Suppose I'm a social scientist who is interested in how people express their sentiment towards others through social media. Since you don't have any imagination/creativity at all, the next part might be hard, but bear with me. Suppose I had a hypothesis/an idea (!) that I could create a list of "positive" and "negative" words, look at all the posts on a particular person's social media page (like Facebook wall posts), and somehow infer the sentiment towards that person in someone's comment based on the counts of positive and negative words. Obviously this idea is not very useful - for example, sarcasm might have a lot of positive words, people use emoticons, etc. - but this is an example for example's sake. Unfortunately, since I'm a social scientist, I don't have a lot of training in computer programming - perhaps I've only done some scripting here and there. So, as a researcher, how can I leverage machines to help me with my research?

    Now I'm sure you're furiously scouring Google for some Facebook API implemented in C# that automatically writes to an SQL Server Express instance or some bullshit. Maybe there's already a library that does the entire shebang for you. But see, you've already lost the game - you're thinking like a programmer who has been assigned some task. I'm sure you would assert something like, "boy, this is so easy to set up, I just need to open VS2010, create a Windows service, add this .dll to my project, throw up a timer or two, generate a simple DB schema, hit up LINQ2SQL, and bam, I'm all finished!! Anyone who can't do this is dumb!!" Or maybe you'd rather do it in C++ or Python or whatever else. The bottom line is that in order to accomplish his goal, the social scientist needs to wade through a ton of shit that isn't his speciality. This is not efficient and hinders science's progress.

    Now, a particularly resolute social scientist may realize that this might all benefit him in the future and learn it all on his own. And I can guarantee you that his first working version would be a steaming pile of complete and utter shit that would break the record # of comments for a front page story if it were posted here, especially if it used PHP, VB, Oracle, Perl, or some combination thereof. But the beauty is that it doesn't matter at all as long as he gets his data and can investigate his hypotheses. I don't see why this bugs you, to be honest. Alternatively, he could ask his computer science colleague to ask his graduate student to write something like this. Or, he could hire a professional. But in any event, we're not really talking about a mission critical system here, so the "quality of code" means nothing, IMO anyway. The stuff probably won't see a home outside of his own rig. The worst outcome would be if he just gave up altogether, and didn't investigate his idea due to the technological hurdle that exists in getting his idea from his brain into the computer. Then not only does science lose, but society potentially loses on an idea that could have significant impact.

    Unfortunately this happens all of the time with "lay people", who have brilliant ideas all of the time despite a lack of degree and/or technical training. Think about a dance teacher who wants to document all her knowledge on a Wikipedia-type site for her students to use and other instructors to contribute to/correct. Or, think of the two guys kicking back brewskis, discussing how they could leverage the massive amount of data created and recorded in a baseball game in order to predict which statistics are meaningful, and which aren't. Bottom line is, if we could just leverage more brains in society, we'd make a shit ton of more progress in every part of society, even if the people don't have any technical training at all. An important step in that direction would be making it easier for anyone to generate a computer program that investigates what they're curious about, or helps them investigate it themselves. And despite all of that, there'd probably be some weird place interested in C++ developers, so don't trip about your job.

     



  • @Someone You Know said:

    @antred said:

    @Cat said:

    2. Variable initialization -- I'm kind of iffy on this.  Sometimes it's nice to make sure that you have some default value, but I don't do it every time.  I always do it for pointers, though, because that can lead to incredibly hard-to-find errors otherwise.

    Declaring variables without initializing them is silly. Instead of 

    int a;

    // ...

    a = someFunction();

    Why not do it the right way and just go 

    int a = someFunction();

     


    Since this thread got necroed I might as well point out:

    for(int index = 0; index < length; ++index)

    {

       int a = someFunction();

    }

    vs

    int a;

    for(int index = 0; index < length; ++index)

    {

       a = someFunction();

    }

    In C#, it's not going to matter, but if a compiler doesn't optimize the allocation out of the loop...


Log in to reply