6 ms·
The computer will always do exactly what you tell it to. With the obligatory footnote: "Unless you get into multithreading - then all bets are off." ;-)
by petercooper 16y ago
The computer will always do exactly what you tell it to.
With the obligatory footnote: "Unless you get into multithreading - then all bets are off." ;-)
- j_baker 16y agoEven if you multithread, it will still do exactly what you tell it to. It's just that it becomes even easier to tell it the wrong thing. ;-)
- KeithMajhor 16y agoMultithreading sacrifices determinism. So, regardless of what you tell it you can't make any claims of exactness about what it's doing.
- dhume 16y agoThe programmer is still allowed to specify operations to perform as well as restrictions on the order in which the operations are performed. Not fully specifying what to do just gives the computer more options to pick from -- it will still pick one of those options.
- AgentConundrum 16y agoit will still pick one of those options which is the part that gets rid of the "does what you tell it" bit, since now it's doing what it thinks it should, which might not be very consistent or easily determinable because minor variations during a race can produce wildly differing results.
- dhume 16y agoIf I tell someone, "bring me a sandwich or a bowl of chili," and the person brings me a bowl of chili, that person has done exactly what I told them to do.
- regularfry 16y agoWhat if they get bored waiting at the counter in the cafe and come back empty-handed? 'Cos that's what can happen as soon as IO is allowed into the picture; particularly so with network IO.
- deleted 16y ago[deleted]
- sambe 16y agoIn that case you probably said "get me a bowl of chili if you can get served in a minute, otherwise don't bother". Or at least it was implicit.
- regularfry 16y agoThe problem is that combining this with multithreading makes for a combinatorial explosion of possible states that you might have to deal with. It's just not feasible to exhaustively specify everything., and leaving things implicit means that you're expecting the computer to do things you haven't told it to do.
- sambe 16y agoSure, there is complexity. It's easy to make assumptions or forget real-world details too. But you DID tell it to time-out, because that's how the I/O library is specified.
- regularfry 16y agoThe more pernicious problem is when they don't come back at all, having deadlocked.
- extension 16y agoThe computer is still deterministic, but somebody lower in the technology stack doesn't want to completely define its behavior.
- KeithMajhor 16y agoYou're right. However, from the perspective of the programmer it is non-deterministic. It only becomes deterministic when it is coupled with a particular scheduler and dispatcher. Most programmers strive to write cross platform code.
- gnaritas 16y ago> Most programmers strive to write cross platform code. On what planet? Surely not this one, as most programs are very tightly coupled to particular operating systems.
- KeithMajhor 16y agoRude, but whatever... you might be right. Regardless, a future version of any single platform could include changes to the scheduler and/or dispatcher.
- gnaritas 16y agoHm, sorry, didn't mean to be.
- nikster 16y agoIf it's non-deterministic, you're not doing it right.
- KeithMajhor 16y agoThat's false. If you're doing it "right" then it will produce the same functional output for all of the possible execution paths. That doesn't make it deterministic.
- hasenj 16y agoIt's still deterministic; just not by you: by the kernel.
- philwelch 16y agoPhilosophically, it's deterministic. In engineering terms, it's non-deterministic from the perspective of the application programmer.
- Locke1689 16y agoPhilisophically, you can't say either way. For example, consider the case where the kernel scheduler uses random numbers from a hardware random number generator which uses quantum uncertainty. Since physics doesn't know whether or not quantum mechanics is deterministic, we can't say whether or not this system is deterministic.
- philwelch 16y agoI was assuming a deterministic scheduler, but sure. I wasn't aware that hardware RNG's were commonly used by kernel schedulers.
- Dylan16807 16y agoIf the cores aren't at the same speed it can probably happen.
- hasenj 16y ago> Since physics doesn't know whether or not quantum mechanics is deterministic Just because we don't know the laws that govern quantum mechanics doesn't mean they're not there.
- Natsu 16y agoKnowing the laws wouldn't necessarily make the system deterministic, though. You'd need hidden variables (and non-local ones, to boot). As best we can tell, sometimes certain information doesn't exist so you may very well get something truly random that averages out to something that looks like what we think of as deterministic, classical behavior.
- jules 16y agoIf you're using threads you told it to be non deterministic. So it's still doing what you told it to.
- j_baker 16y agoTrue, but my point is still valid. When you start a thread, you're saying "do this these tasks in whatever order is most convenient for you". And the computer does just that.
- a-priori 16y agoAll the more reason why I hope that history remembers multithreaded programming as an experiment gone horribly wrong.
- InclinedPlane 16y agoThis is a bit of a silly statement, as it's grossly misleading. Firstly, in the very strictest sense it isn't true, given that defects in operating systems and processors and single event upsets due to cosmic rays can introduce some degree of randomness into computer processing. Secondly though, even ignoring all of that, it's not helpful. It's a bit like telling a chemist "remember, the chemicals will always do exactly what you tell them to." Well, sure, that's true in the abstract, but the full complexity of the entire process is greater than any human mind can cope with, so it's necessary to use models and techniques that bring that complexity down to human scale. The same goes for the full breadth of the complexity of programming significant pieces of software today. The computer will do exactly what you tell it to, but your brain is not capable of determining exactly what the computer will do (it'll process billions of instructions a second, if you tried to fully map out the operations of a computer in complete detail you wouldn't get even a fraction of a second done in your lifetime). Which is why we have to use abstractions, models, and various techniques to render that complexity manageable by human minds.
- olalonde 16y agoDown voted for lacking a sense of humour. Seriously, why did you feel the need to explain at large that computers are deterministic when OP was clearly making a joke. (I know I'm probably going to get down voted myself but I had to vent off)
- petercooper 16y agoHaving read the post you voted down, I don't think he/she was actually responding to my joke but to the concept I was quoting. He/she seems to be arguing against computers being entirely deterministic at all. I wish there were a better/more formal way to quote things on HN as it can lead to confusion with attribution. Purely italic text doesn't quite cut it, but nor does the "source code" quoting feature.
- benkant 16y agoComputers don't make mistakes, people do.
- njharman 16y agoPeople make computers.