7 Replies - 1475 Views - Last Post: 14 May 2014 - 04:57 AM

#1 leibniz76  Icon User is offline

  • New D.I.C Head

Reputation: -11
  • View blog
  • Posts: 27
  • Joined: 02-May 14

Do you computers really do the same thing every time?

Posted 11 May 2014 - 11:05 AM

The real question is do computers really do the same thing every time they're in the same state? What is your opinion? I have seen mysterious cases of computers doing different things in the same state but I admit that it is difficult to know if the computer is in the same state. Pedantically speaking a computer is in a different state with each passing moment because it is at least counting time and I imagine they are doing other things that I do not know about. But what we have to keep in mind is the programmer designs the computer do the same thing when part of the computer is in the same state and 'same' is giving a definition in terms of 1's and 0's. My hunch is that computers probably do do the same thing when they are in the same state but today's computers are so complex that what appears to be the same state really isn't the same state.

Is This A Good Question/Topic? 0
  • +

Replies To: Do you computers really do the same thing every time?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: Do you computers really do the same thing every time?

Posted 11 May 2014 - 12:05 PM

Are you talking about an application or the computer as a whole? As you pointed out the computer - as a whole - is changing states as processes spin up, updates, paging, moving things into memory, hardware decaying, etc. Granted you are not shown this on face, but it is happening. Applications tend to compartmentalize the states that affect itself, and at the end of the day there is a pragmatic reasonableness standard that can apply to a given app (or machine) is working in a 'same state'.
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5540
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Do you computers really do the same thing every time?

Posted 11 May 2014 - 12:46 PM

Silly fraking question. It sounds like you're asking if computers choose to do things how they see fit. Don't worry, they aren't alive and they aren't Terminators coming after you. They are machines. They don't think (yet). Yes, they do the same thing the same way under the same conditions each and every time. Period.

As you said, deep down there may be some condition that changes - and that can affect the final behavior. And that's it. A bad memory chip, a dropped network connection, a failing hard drive... Can all effect how a computer runs. If a program is not designed to handle such things it can hang and just wait for a failed drive to respond, or it can crash when the network sudden drops mid-transmission. Sometimes you can get unexpected results due to poor handling of unexpected conditions. If only half the data is received but the program continues on anyway, it might fail, crash, miscalculate, or display gibberish.

But that is entirely expected under those conditions. If you can precisely replicate the conditions you will get the exact same results.

Put down the Colorado and don't be so worried about the computers rising up.
Was This Post Helpful? 2
  • +
  • -

#4 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7807
  • View blog
  • Posts: 13,203
  • Joined: 19-March 11

Re: Do you computers really do the same thing every time?

Posted 11 May 2014 - 10:04 PM

This question seems like an exercise in misplaced pedantry, on the order of worrying about whether your car is "really the same car" if you replace a tire, or whether you yourself are "really the same person" tomorrow as you were yesterday.

The practical answer is this: there is a class of bugs known as "phase of the moon bugs", where odd behavior is triggered by seemingly unrelated changes of state in the machine. This is sometimes the result of trying to be a Mel, without having sufficiently mad skillz. More often it is simple, unadorned incompetence.

The underlying purpose of programming methodologies such as functional programming and object-oriented programming is to reduce local complexity and thereby kill phase-of-the-moon bugs. Whether you compose well-crafted objects enforcing good access controls on data, or you write functions that pass around immutable states, you're limiting the number of ways your state can change, and this limits the ways in which the state of the machine can affect the state of your program. A well-made program is a program whose state is sufficiently constrained that you can talk sensibly about what the program will do for any particular input, and more importantly, that you can be correct in your predictions on that score.

So while enough marijuana can make it seem interesting that the machine is never in the same state twice - congratulations, Heraclitus, nobody's ever thought of that before! - if this matters to your program, it only means that You're Doing It Wrong.
Was This Post Helpful? 2
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: Do you computers really do the same thing every time?

Posted 12 May 2014 - 06:31 AM

Quote

- if this matters to your program, it only means that You're Doing It Wrong.

There's absolutely nothing wrong with surprise features!
Was This Post Helpful? 0
  • +
  • -

#6 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7807
  • View blog
  • Posts: 13,203
  • Joined: 19-March 11

Re: Do you computers really do the same thing every time?

Posted 12 May 2014 - 06:58 AM

They're like Easter eggs... only Easter can come any old time.
Was This Post Helpful? 0
  • +
  • -

#7 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2021
  • View blog
  • Posts: 4,194
  • Joined: 11-December 07

Re: Do you computers really do the same thing every time?

Posted 14 May 2014 - 04:41 AM

It's not a silly question. It's something that many development teams struggle with.

A common cause of computers behaving seemingly irrationally is in multithreaded code. Such applications can happily go about their business for a long time and suddenly freeze, exit, produce an erroneous result or set the fan to 100% while appearing to do nothing (livelock). In software testing, you often hear people talk about the probability or frequency of these bugs. Do they happen every minute, hour, month? If it's a case of restarting a server at midnight at the weekend to try and avoid the about monthly bug from cropping up, some businesses may decide that's better than fixing the actual problem.

Of course, it's not really a probabilistic thing, If the precise internal state of the machine could be recreated you could reproduce those bugs every time. However, you can't recreate that internal state easily. Test teams are reduced to writing long-running tests and adding delays to different parts of the code to try and coax out buggy behaviour.

And you are all correct. It's down to crappy programming. People either don't know or don't care about the rules for writing bug-free concurrent code.
Was This Post Helpful? 0
  • +
  • -

#8 depricated  Icon User is online

  • Derpicorn

Reputation: 752
  • View blog
  • Posts: 2,502
  • Joined: 13-September 08

Re: Do you computers really do the same thing every time?

Posted 14 May 2014 - 04:57 AM

One I ran in to recently was stored proc that was eating up 90% of the CPU power on the SQL server when given a file over its size limit
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1