News for hackers. Stuff that matters.
Re:Do I Really Need a Programming Language? by wildgift on Sunday December 29, 2013 @05:56AM (#6979189)
Here's the code in either C or C#:

return ( (price > 100) ? 10 : 5);

Computer languages are for people. It should really be more like this:

    #
    # Description of what this does.
    #
    PRICE-THRESHOLD = 100
    LOWER-PRICE = 5
    UPPER-PRICE = 10

    IF PRICE > PRICE-THRESHOLD RETURN UPPER-PRICE
    ELSE RETURN LOWER-PRICE
Alternatively, use Excel:

    =IF( (price > 100), 10, 5 )
Excel is cryptic, but a lot of finance people understand it.
Re:Do I Really Need a Programming Language? by J_Darnley on Sunday December 29, 2013 @07:26AM (#6979368)
With C it can be more like what you want. Stop using ?: if you don't like it.

    if (price > 100)
        return 10;
    else
        return 5;
Replace with more named variables if you want.
Re:Do I Really Need a Programming Language? by the_af on Sunday December 29, 2013 @11:54AM (#6980160)
I'm going to guess wildgift was being sarcastic. COBOL syntax is so needlessly verbose it interferes with the understanding of the actual formula. I contend that

    return price > 100 ? 10 : 5; 
is way more readable.
Re:Do I Really Need a Programming Language? by nkoren on Sunday December 29, 2013 @08:14AM (#6979446)
That code works in C, C#, and JavaScript.
Re:Do I Really Need a Programming Language? by weatherlight on Sunday December 29, 2013 @12:24PM (#6980300)
ruby too!