News for hackers. Stuff that matters.
Re:A Case Study of Toyota Unintended Acceleration and Softwa... by wyager on Saturday January 17, 2015 @08:25PM (#8906253)
>80+% of variables were declared as global

This is actually important for safety-critical programming. It lessens the likelihood of running out of stack space, and it's useful for eliminating dynamic allocation.

Some safety-critical software has 100% global variables, without even using a stack.

Re:A Case Study of Toyota Unintended Acceleration and Softwa... by ufo on Saturday January 17, 2015 @09:48PM (#8906402)
But even then, you want to declare those variables as static or otherwise find some way to reduce their scope. Most global variables in the Toyota code were visible and writable from the whole program.

This is not even counting all the variables declared with the wrong type or more than once, uninitialized variables, etc.

Re:A Case Study of Toyota Unintended Acceleration and Softwa... by jacquesm on Saturday January 17, 2015 @09:10PM (#8906351)
I think this is possibly one area where functional programming could shine if the garbage collection issue could be dealt with once and for all (and that's a hard one). It's for practical reasons impossible to test something with that much state exhaustively, but once broken up into functional units you just might get there. Something along the lines of Erlang for embedded systems.
Re:A Case Study of Toyota Unintended Acceleration and Softwa... by mattmcknight on Sunday January 18, 2015 @12:39AM (#8906772)
No. Functional programming does not magically free you from "state". The world has state, the unlimited number of real world inputs are the state of the program, merely expressed as function parameters. The CPU itself has registers, and stores a call stack.

The abstraction of functional programming does not alleviate all of these issues, and can introduce other ones.

Re:A Case Study of Toyota Unintended Acceleration and Softwa... by jacquesm on Sunday January 18, 2015 @01:03AM (#8906822)
Of course it doesn't free you from state. But it can help to put the state into a more manageable context. Just like side-effect free functions can help you with that.

I've done enough embedded programming (and repairs on embedded programming projects) to know just how bad the spaghetti can get and it really wouldn't hurt to borrow a few leaves from the functional world in those cases.