Slash Boxes

SoylentNews is people

posted by martyb on Thursday September 03 2015, @09:23AM   Printer-friendly
from the ignorance-is-bliss dept.

Olga Khazan writes in The Atlantic that learning to program involves a lot of Googling, logic, and trial-and-error—but almost nothing beyond fourth-grade arithmetic.

Victoria Fine explains how she taught herself how to code despite hating math. Her secret? Lots and lots of Googling. "Like any good Google query, a successful answer depended on asking the right question. “How do I make a website red” was not nearly as successful a question as “CSS color values HEX red” combined with “CSS background color.” I spent a lot of time learning to Google like a pro. I carefully learned the vocabulary of HTML so I knew what I was talking about when I asked the Internet for answers."

According to Khazan while it’s true that some types of code look a little like equations, you don’t really have to solve them, just know where they go and what they do. "In most cases you can see that the hard maths (the physical and geometry) is either done by a computer or has been done by someone else. While the calculations do happen and are essential to the successful running of the program, the programmer does not need to know how they are done."

Khazan says that in order to figure out what your program should say, you’re going to need some basic logic skills and you’ll need to be skilled at copying and pasting things from online repositories and tweaking them slightly. "But humanities majors, fresh off writing reams of term papers, are probably more talented at that than math majors are."

Original Submission

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by martyb on Thursday September 03 2015, @12:35PM

    by martyb (76) Subscriber Badge on Thursday September 03 2015, @12:35PM (#231693) Journal

    Mathematics is a very broad field which does include numerical calculation. But it is far more than just that! Boolean algebra. Set theory. Algebra. I regularly use all of these when I am programming.

    At its simplest, an algorithm is a mapping of inputs to outputs. Or, more specifically, a mapping of a domain to a range. Let's look at a simple program to calculate an average for a user's grades for a semester. Input is a string of blank-delimited grades. Output is the average. Simple and straightforward, right? This example is in AWK.

    # Tally an average for a student's grades:
    function compute_grades_average(grades_list,    grades_sum, grades_count, grades_index, grades_average) {
       grades_sum = 0;

       grades_count = split(grades_list, grades);
       for (grades_index=1; grades_index<=grades_count; grades_index++) {
          grades_sum += grades[grades_index];
       }  # for

       grades_average = grades_sum / grades_count;

       return grades_average;
    }  # function grades_average()

    # For each line of input, display the average of those grades:
       print compute_grades_average($0);

    Let's test it with a couple of samples of test data:

    echo 93 87 90 | awk -f foo.awk

    echo 75 90 85 70 80 | awk -f foo.awk

    Looks good... ship it!

    But, it fails.

    There is no input checking. It returns a non-integer in many cases. Non-numeric 'grades' are treated as having a value of zero. Worse still, the program crashes on a null-input with a divide-by-zero error.

    I would argue that one needs to know what the entire domain of possible inputs is and needs to be able to accurately parse that into non-intersecting subdomains that cover the entire of the input domain. Further, one then needs to be able, for each of those subdomains, perform the correct processing and generate the correct results.

    These are not difficult concepts. I learned set theory in 5th grade, algebra in 7th, and Boolean algebra as part of a programming course in 8th grade. But, I have had a successful career in software test and quality assurance because these simple concepts constantly fail to be fully implemented by developers!

    An aside. For those who know this already, it's no big deal. But until I learned these, conditional expressions were just a miasma of quirky symbolisms. Sadly, it seems, there are many professional programmers who are unaware of these!

    The Boolean operator 'AND ' is just multiplication on the domain of {0, 1}:

    (0 AND 0) == (0 * 0); (0 AND 1) == (0 * 1); (1 AND 0) = (1 * 0); (1 AND 1) == (1 * 1)

    Further, Boolean 'OR' is just addition on the same domain, where one defines 1 + 1 to have the value 1:

    (0 OR 0) == (0 + 0); (0 OR 1) == (0 + 1); (1 OR 0) == (1 + 0); (1 OR 1) == (1 + 1) == (1)

    Combine this with the rules of associativity, distribution, and commutation and even the most convoluted conditional expression can be evaluated. =)

    Wit is intellect, dancing.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 0) by Anonymous Coward on Thursday September 03 2015, @02:04PM

    by Anonymous Coward on Thursday September 03 2015, @02:04PM (#231741)

    tl;dr - Error checking and exception handling takes up a lot more time and code than the basic task at hand. This requires the programmer to understand the requirements rather than just the math, but some parts of the programmer's skill-set for checking/handling these issues can be compared to basic math learned in grade school.