Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 15 Aug 2018, 08:42
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
The Coming Software Apocalypse
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [22 Posts]   Goto page: 1, 2 Next
Author Message
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 12936
Location: Arizona USA

PostPosted: Tue 10 Oct 2017, 12:09    Post subject:  The Coming Software Apocalypse  

The Coming Software Apocalypse

A pretty good article about programming, from The Atlantic magazine, of all people.
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Tue 10 Oct 2017, 19:51    Post subject:  

The results of using the lowest bidder. Same as it ever was ..
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1009
Location: Oslo, Norway

PostPosted: Wed 11 Oct 2017, 00:15    Post subject:  

A very interesting reflection on the programming 'industry'. Thank you, Flash.

tallboy

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
6502coder


Joined: 23 Mar 2009
Posts: 469
Location: Western United States

PostPosted: Wed 11 Oct 2017, 17:56    Post subject:  

When I was programming on UNIX way back in the early '80s, I remember pointing out to my colleagues how amazingly primitive it was that we were still creating programs by laboriously typing characters into text files. Even then, I can hardly have been the first to make that observation.

I am skeptical of any suggestion that a breakthrough is anywhere in sight. Fundamentally, a correct program is a logical construct, a collection of (mostly implicit) assertions that since THIS is true, then THAT is true, and so on. The problem is that the logic is often necessarily convoluted, so it is easy to make subtle errors in reasoning. Writing a non-trivial bug-free program is at least as hard, if not much harder, than writing a law that is free of unintended consequences.

Back in '70s and '80s the computer scientist Ole-Johan Dahl (Turing Award winner in 2001) did some really interesting work on the question of how one proves that a program is correct, using the notion of "weakest precondition." On the one hand, it was great to see how one could, for example, prove that a for-loop terminated with the correct result. On the other hand, it was very sobering that so much of the apparatus of formal logic was required just to prove that a simple for-loop was correct, much less an entire non-trivial program.

Graphical aids like the ones described in the article are nice, but can only do so much. As long as programs continue to have to manipulate complex abstractions that have no simple visual rendering, programming will be hard work.
Back to top
View user's profile Send private message 
WIckedWitch

Joined: 29 Mar 2018
Posts: 198
Location: West Wales bandit country

PostPosted: Fri 20 Apr 2018, 19:24    Post subject:  

A subject dear to my heart. Many years ago, I was taught mathematics at a school that had, at the time, probably the best school mathematics department in the UK. Its maths course for UK A-levels went far beyond the written syllabus and covered a large part of what was then first year undergraduate mathematics. In fact, at one point, we were trained for UK A-level exams by being given Cambridge University Master's papers to attempt (which most of us found not unduly difficult).

Most important of all, we were taught that mathematics is not about numbers and algebra but about patterns and structure; and further that mathematics is the finest problem-solving tool that human intellect has yet devised.

Although circumstances and illness prevented my completing an undergraduate course (pure maths, applied maths, statistics and computing), I nevertheless brought a well-trained mathematical mindset to programming - and was immediately considered an utter freak by my colleagues.

Back in 1977, I was a founder member of the British Computer Society Specialist Group in Formal Aspects of Computing Science. By the time I retire, I thought, everyone will be using mathematics to get programs right. How wrong I was.

Largely because of an early excellent mathematical education, it is second nature to me to solve problems in mathematics before getting anywhere near writing code. For the past 25 years, I have worked on nothing but critical systems - and the mathematical incompetence of most software engineers leaves me, frankly, terrified.

Only yesterday, I received from a colleague an email about the desirability of strenuous testing of compilers for code in autonomous vehicles. It's a good idea - but the biggest risks in such vehicles arise from technical over-reach by gung-ho AI developers, some of whom, IMHO, shouldn't be trusted with so much as an abacus.

The software industry is riddled with ignorance about how to get software correct and dependable. I see very little impetus towards the thoroughgoing culture change that will be needed to ensure that self-driving cars stop killing people any time soon.

(end of self-righteous, opinionated rant)

_________________
Sometimes I post mindfully, sometimes not mindfully, and sometimes both mindfully and not mindfully. It all depends on whether and when my mind goes walkies while I'm posting Confused
Back to top
View user's profile Send private message 
tallboy


Joined: 21 Sep 2010
Posts: 1009
Location: Oslo, Norway

PostPosted: Fri 20 Apr 2018, 20:13    Post subject:  

There is a strong focus on Computational Mathematics today, for example at the UiO, Ole-Johan Dahl's old workplace. (uni in Oslo) Unfortunately, they now often use a language like Python to implement mathematical formulas to problems, instead of doing the opposite, like WickedWitch describes. Okay, you save chalk on 3 blackboard full of formulas, and can show nice 3-D curves and colored stress models of the result from the calculations, but I feel that the whole concept start off in the wrong end.
But then again, my own mathematical 'achievements' are not exactly worth mentioning at all... Laughing

_________________
True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send private message 
WIckedWitch

Joined: 29 Mar 2018
Posts: 198
Location: West Wales bandit country

PostPosted: Sat 21 Apr 2018, 19:41    Post subject:  

tallboy wrote:

But then again, my own mathematical 'achievements' are not exactly worth mentioning at all... Laughing


I don't think mathematical achievement is too important. It's the mathematical way of thinking that's the key thing. My own mathematical achievements are as near to zero as makes no difference but ever since I can remember being aware of my own cognitive style, it has been second nature to me to use mathematics as a way to describe and solve problems. It really annoys me when people who have studied mathematics at university try as hard as they can to run away from it when working as engineers. In my experience, software engineers are the worst offenders of this kind.

_________________
Sometimes I post mindfully, sometimes not mindfully, and sometimes both mindfully and not mindfully. It all depends on whether and when my mind goes walkies while I'm posting Confused
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Tue 24 Apr 2018, 13:58    Post subject:  

WIckedWitch wrote:
tallboy wrote:

But then again, my own mathematical 'achievements' are not exactly worth mentioning at all... Laughing


I don't think mathematical achievement is too important. It's the mathematical way of thinking that's the key thing. My own mathematical achievements are as near to zero as makes no difference but ever since I can remember being aware of my own cognitive style, it has been second nature to me to use mathematics as a way to describe and solve problems. It really annoys me when people who have studied mathematics at university try as hard as they can to run away from it when working as engineers. In my experience, software engineers are the worst offenders of this kind.


(a -= (b = (a += b) - b))

Wink
Back to top
View user's profile Send private message 
WIckedWitch

Joined: 29 Mar 2018
Posts: 198
Location: West Wales bandit country

PostPosted: Wed 25 Apr 2018, 12:00    Post subject:  

jafadmin wrote:
WIckedWitch wrote:
tallboy wrote:

But then again, my own mathematical 'achievements' are not exactly worth mentioning at all... Laughing


I don't think mathematical achievement is too important. It's the mathematical way of thinking that's the key thing. My own mathematical achievements are as near to zero as makes no difference but ever since I can remember being aware of my own cognitive style, it has been second nature to me to use mathematics as a way to describe and solve problems. It really annoys me when people who have studied mathematics at university try as hard as they can to run away from it when working as engineers. In my experience, software engineers are the worst offenders of this kind.


(a -= (b = (a += b) - b))

Wink


Assuming this is intended to be read as a fragment of C, I should first tell you that I am the original author of the MISRA C rules and was the first person in the UK (and quiet possibly the world) to configure a static analysis tool (QAC) to enforce them.

The result of evaluating the above expression is not defined by the ISO C standard. Among the reasons for this are:

1. In all contexts where expressions appear, they are preceded by and followed by sequence points. Between sequence points the order of evaluation of operators is not defined, hence, in the above expression, the net result of side-effects is not defined.

2. Only for certain logical operators does C define the order of evaluation of the operands of operators.

3. This is quite apart from any implicit conversions that may occur if a and b are not of assignment-compatible types, or even of mixed floating and integral types.

4. Not only are the relevant orders of evaluation not defined but the C standard imposes no requirement that they be done in the same order in the same expression.

5. The C standard permits the compiler to omit any evaluation provided that it produces no needed side-effect. Unfortunately the standard omits to define what it means for a side-effect to qualify as needed.

Any decent static checker will flag this expression as exactly the kind of thing that you don't want to write in C or any C-derived language for that matter.The only worthwhile use for code like this is to test the implementation-defined, unspecified and undefined behaviour of the compiler.

*** Side challenge: write a program to determine whether the left-hand-side or right-hand-side of an assignment operator is the first to be evaluated and print out, using the letters L and R what the order is ****

Coincidentally I received today a message from a colleague that he received from the engineering manager of a medical instruments company that I once worked for. Their programmers complain that using a static checker (in this case QAC) creates a lot of hard work. (Believe me, they are some of the worst programmers I've ever come across). In certain areas of software engineering, cultural bias trumps any amount of sound technical understanding. I was fired from that company for reporting them to a safety regulator for falsifying test reports (nuff said).

At least in semi-retirement, I can now choose which parts of the software engineering madhouse I visit.

_________________
Sometimes I post mindfully, sometimes not mindfully, and sometimes both mindfully and not mindfully. It all depends on whether and when my mind goes walkies while I'm posting Confused
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Wed 25 Apr 2018, 13:32    Post subject:  

Back in the 80's I was a budding C programmer, and a member on a few dialup BBS's that had to do with ASM and C programming.

On one BBS in Palo Alto a user started a thread proposing a contest that primarily related to chip programming. At the time, the amount of space on a chip for data/variables was quite small and engineers were constantly looking for ways to stretch the chip's limited resources.

The thread challenged users to swap 2 variables without using a third variable in the fewest lines of code. There were dozens of entries, with the closest winner doing it in 3 lines (McAfee Swap) by the time I first saw the thread.

My math instincts told me that it should be possible in a single line using algebra, so I approached the problem from that angle, and the result was what you see above. It took me two hours to conceive then debug. Needless to say, my solution won, hands down.

It has several advantages. When implemented as a macro, it becomes type agnostic and doesn't need a call stack. It works on all properly cast data types.
Code:
/* Swap two values  -  cc Swap.c -o Swap

    Usage: ./Swap <First Number> <Second Number>

   - Jafadmin 1987
*/
#include <stdio.h>  // for printf()
#include <stdlib.h> // for atoi()

// This single-line macro swaps two variables of the
//    same type without using a third variable.
#define Swap(a, b) (a -= (b = (a += b) - b))

int main(int ac, char *av[])
{
    int Left  = atoi(av[1]);  // We convert args to int's for
    int Right = atoi(av[2]);  //  demo purposes

    printf("\n\tLeft = %d, Right = %d\n"  , Left, Right);

    Swap(Left, Right);   // Call the macro

    printf(  "\tLeft = %d, Right = %d\n\n", Left, Right);
}

It goes without saying that the sum of a&b cannot exceed the size of the type. Upcasting is highly recommended. Easy peasy pointer swapping ..

I have a personal header file called "Cool.h" that has many tricks like this that I have come up with over the years.
Back to top
View user's profile Send private message 
WIckedWitch

Joined: 29 Mar 2018
Posts: 198
Location: West Wales bandit country

PostPosted: Wed 25 Apr 2018, 16:23    Post subject:  

As a means of swapping two scalar variables, your code makes ingenious use of multiple side-effects. But the results it produces will also be dependent on the values of the variables in cases where a and b are reals that differ widely in value. Also it would be asking for trouble if a and b were pointers into arrays with different cell sizes.

Try writing out the compound assignment operators in full and then consider that the order of evaluation of the operands of arithmetic operators is unspecified in C.

Note also that while it does not explicitly use a third variable, a compiler might well generate code that does use a third variable. A propos of one-liners and other concise coding tricks, you might find the book "Hacker's Delight" by H. S Warren an eye-opening read.

My solution to the order-of-evaluation problem is below:

#include <stdio.h>

static char ordeval[2] = "RR";
static int i = 0;

int main(void)
{
// in next statement, if the = operator is evaluated L to R, i.e. the
// lvalue is computed first, then 'L' goes into ordeval[0], whereas if
// evaluated R to L, then 'L' goes into ordeval[1]

ordeval[i] = (++i, 'L');

return printf("Order of evaluation is %c%c\n", ordeval[0], ordeval[1]);

}

You might wish to consider whether this affects your confidence in your macro. What happens if, when evaluating the outermost -= operator, the compiler puts the value of a into a register before evaluating any other assignment in the expression? If you are relying on the innermost bracketted expression being evaluated first, this might not be a robust macro because the order of side effects is not defined by the C standard and different compilers may do it differently, or even the same compiler may do it differently under different compile-time options, or, albeit utterly perversely, the compiler might choose the order of side effects at random every time it compiles another expression. All of these possibilities are permitted by the ISO C standard. SPARK Ada gets round these problems by requiring all expressions to be such that they produce the same result under all possible orders of evaluation that the compiler permits.

(Sorry about scroodup indentation)

_________________
Sometimes I post mindfully, sometimes not mindfully, and sometimes both mindfully and not mindfully. It all depends on whether and when my mind goes walkies while I'm posting Confused

Last edited by WIckedWitch on Wed 25 Apr 2018, 18:58; edited 1 time in total
Back to top
View user's profile Send private message 
WIckedWitch

Joined: 29 Mar 2018
Posts: 198
Location: West Wales bandit country

PostPosted: Wed 25 Apr 2018, 18:40    Post subject:  

Here's another programming challenge - from a real safety-critical project that used C coding using X libraries to control air traffic control LED radar displays.

The main functional code was in SPARK Ada and machine-verified to be free from run-time undefinedness. A top-end static checker was used on the C code, which had to comply with MISRA C as far as possible.

To work properly, the static checker has to know, among other things, what macros are predefined by the compiler. These predefined macros must be identified to the static checker together with their defined values.

The challenge is to find means for automatically determining which macros are predefined, and what their values are, under given compiler options.

(Some eminent C experts told me this was impossible before I enlightened them.)

_________________
Sometimes I post mindfully, sometimes not mindfully, and sometimes both mindfully and not mindfully. It all depends on whether and when my mind goes walkies while I'm posting Confused
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Wed 25 Apr 2018, 20:48    Post subject:  

Keep in mind I was merely trying to win a friendly contest and provide proof of concept using an algebraic approach.

The original algorithm was done longhand and with more parenthesis forcing LtoR/RtoL evaluation. I distilled it intentionally to make it smaller and simpler for that viewing audience.

Once they got the gist of it, there were a dozen CS/SE's exploring all the real-time performance considerations and pitfalls, and providing peer review.

Also, chipset compilers do not create variables unless explicitly directed. Otherwise, the programmers would have no control over the provisioning of the code/data segments of the given chip. Also, one can check whether the compiler creates a third variable anyway by testing the output with 2 values that when combined, exceed the size of the type.

More robust: (a -= (b = ((a += b) - b)))

Rilly, rilly robust, in longhand: (a = (a - (b = ((a = (a + b)) - b))))

Thanks for the HD recommendation. Looks fun: http://hackersdelight.org/

.

Last edited by jafadmin on Wed 25 Apr 2018, 22:42; edited 9 times in total
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Wed 25 Apr 2018, 21:05    Post subject:  

WIckedWitch wrote:

The challenge is to find means for automatically determining which macros are predefined, and what their values are, under given compiler options.

(Some eminent C experts told me this was impossible before I enlightened them.)


Hmm ..
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 933
Location: not Bulgaria

PostPosted: Wed 25 Apr 2018, 21:45    Post subject:  

tallboy wrote:
There is a strong focus on Computational Mathematics today, for example at the UiO, Ole-Johan Dahl's old workplace. (uni in Oslo) n again, my own mathematical 'achieve


Ah... I have such fond memories of the ten months I spent at UofOslo - sharing flat with Norwegians at Sogn Studentby

I didn't learn much maths but some norske.

Wiak
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [22 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0665s ][ Queries: 11 (0.0060s) ][ GZIP on ]