26285 total geeks with 3498 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: May 31
May Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Facebook teens
FLASH THEIR
PRIVATES more than
ever before
Attention large
Linux workloads
HTC woes prompts
"leave now" Tweet
from former staffer
Japan uses big data
to map cultural
climate change
WW II U-boat
attacks prompt new
US response
Garden fertilised
by Twitter output
wins Gold at
Chelsea
Aurora attack tried
to pinch secret
list of Chinese
spies
Embedded systems
vendors careless
says Metasploit
author
40 Gbps wireless
designed to
complement fibre
rollouts
Anonymous threat
shutters Gitmo WiFi
Slashdot
Quadcopter Drone
Network Will
Transport Supplies
For Disaster Relief
Congressional
Report: US Power
Grid Highly
Vulnerable To
Cyberattack
Google Chrome 27 Is
Out: 5% Faster Page
Loads
Special Ops Takes
Its Manhunts Into
Space
Aurora Attackers
Were Looking For
Google"s
Surveillance
Database
Dart Is Not the
Language You Think
It Is
EPA Makes a Rad
Decision
Ask Slashdot: Can
Yahoo Actually
Stage a Comeback?
3-D Printable Food
Gets Funding From
NASA
Transporting a
15-Meter-Wide,
600-Ton Magnet
Cross Country
Article viewer

Why computers are stupid



Written by:MaxMouse
Published by:bb
Published on:2009-08-30 23:51:07
Topic:Miscellaneous
Search OSI about Miscellaneous.More articles by MaxMouse.
 viewed 12836 times send this article printer friendly

Digg this!
    Rate this article :
It may not look like it, but computers, behind all of their gloss and fancy glass effects are stupid. Lets discuss why.

Well, computers won't do anything unless told to do so, and they will only do what you tell them in the order that you tell them, they will do it blindly and without question. Lets take the example of dates:

Date 1: 21/01/09
Date 2: 22/01/09

Which date is later? Date two obviously by one day, you did this in your head without too much of a second thought, but have you considered the thought processes you went through to come up with that answer? Lets outline them.

  • The year of date 1 is the same as the year of date 2, look at the month
  • The month of date 1 is the same as date 2, look at the day
  • The day of date 2 is higher than the day of date 1, therefore date 2 is later.


That's quite a lot going on, but for a computer you have to outline EVERYTHING to get one of three possible end results:

  • 1: Date 1 is later than Date 2
  • 2: Date 1 is earlier than Date 2
  • 3: Date 1 and Date 2 are the same


What makes it more complex is that each section of the date is dependant on the rest, EG: if the month in date 1 is higher than the month in date 2 that doesn't make date 1 a later date, since the year of date 2 could be higher, a similar thing happens with the days only they depend on both the month and the year, now lets look at some code (without using any kind of in built date functions) to determine all of the above.

Public Function DateMatch(Date1 As String, Date2 As String, Optional Delimiter = "/") As String
Dim D1() As String
Dim D2() As String
Dim Result As String

D1 = Split(Date1, Delimiter)
D2 = Split(Date2, Delimiter)

If D2(2) > D1(2) Then
 Result = "Date 2 is later than Date 1"
ElseIf D2(2) < D1(2) Then
 Result = "Date 2 is earlier than Date 1"
ElseIf D2(2) = D1(2) Then
 If D2(1) > D1(1) Then
  Result = "Date 2 is later than Date 1"
 ElseIf D2(1) < D1(1) Then
  Result = "Date 2 is earlier than Date 1"
 ElseIf D2(1) = D1(1) Then
  If D2(0) > D1(0) Then
   Result = "Date 2 is later than Date 1"
  ElseIf D2(0) < D1(0) Then
   Result = "Date 2 is earlier than Date 1"
  ElseIf D2(0) = D1(0) Then
   Result = "Date 2 and Date 1 are on the same day"
  End If
 End If
End If

DateMatch = Result
End Function


In English (And the full extent of what goes on inside your head):
If the year of date 2 is higher than the year of date 1 then date 2 is later than date 1 else if the year of date 2 is lower than the year of date 1 then date 2 is earlier than date 1 else if the year of date 2 is the same as the year of date 1 then if the month of date 2 is higher than the month of date 1 then date 2 is later than date 1 else if the month of date 2 is lower than the month of date 1 then date 2 is lower than date 1 else if the month of date 2 is the same as the month of date 1 then if the day of date 2 is higher than the day of date 1 then date 2 is higher than date 1 else if the day of date 2 is lower than the day of date 1 then date 2 is lower than date 1 else if the day of date 2 is the same as the day of date 1 then the dates are the same. - Is your head spinning? mine is!

As you can see every possible eventuality must be catered for, three possibilities for each section (Day, Month, Year), should two sections match, you must check the preceding section. That's 3 nested If statements, imagine if you wanted to also include the time (Hours, Minutes, Seconds, Milliseconds?)

Computers.... total morons!

Did you like this article? There are hundreds more.

Comments:
MaxMouse
2009-08-30 23:52:05
Fun article, hope it's OK, lol!
Anonymous
2009-08-31 11:23:48
This is just silly. You write an article about a bad piece of code you've written. If all you want is to compare two dates, representing them as integers are sufficient and less error-prone. The following is not something I would write for a real program, but is just for demonstration.

int conv(int year, int month, int date)
{
    return (year * 100 + month) * 100 + date;
}

int compare(int y1, int m1, int d1, int y2, int m2, int d2)
{
    return conv(y1, m1, d1) - conv(y2, m2, d2);
}

void test()
{
    int res = compare(2009, 1, 31, 2009, 1, 21);
    if (res > 0)
        puts("Date #1 comes after date #2");
    else if (res < 0)
        puts("Date #1 comes before date #2");
    else
        puts("Date #1 and date #2 are equal");
}
Anonymous
2009-08-31 11:34:06
...and even simpler, you can represent dates as strings in the format "yyyy-mm-dd", which makes it possible to lexicographically determine the order.

void test()
{
    string s1 = "2009-01-31";
    string s2 = "2009-01-21";
    if (s1 > s2)
        puts("Date #1 comes after date #2");
    else if (s1 < s2)
        puts("Date #1 comes before date #2");
    else
        puts("Date #1 and date #2 are equal");
}


Conclusion: Don't blame the computer, blame the programmer.
Domuk
2009-08-31 18:22:33
I disagree, cyph1e, I think this is a good article. Okay, his code is a little verbose - for the very purpose of the article. He's writing in code exactly how he described his mental process. Your code, however, is also how the article describes, you're just delegating to the string library to handle the comparison. You seemed to have missed the point - not every article on this site that includes code is there to say 'this is how you should code'.

The point I took away from it is that computers compute - they can do exactly what we ask of them, and they can do it repeatedly, very quickly - and sometimes, what we take for granted we have to reflect on how we do it in order to instruct a computer.

If you don't like it though, you're always encouraged to add an article you think others would enjoy! And log in to post, otherwise it looks like you're trolling.
MaxMouse
2009-08-31 20:40:43
lol... I had a feeling something like this would happen.

I think Dom hit the nail on the head though. My target for this article is those that have little or no programming experience, to these people software "just does it" i wanted to show what happens in your head when asked the question "Which date is later" then coding it exactly as that.

It's a demonstration to those that assume computers/software have some level of intelligence, and shows you must hold their hand the entire way through.

Further more, this isn't a "bad piece of code i have written" as i said, it's a code representation of the logic any human would perform when comparing dates, and is meant to be just a bit of fun, no need to get critical.
Kriss
2009-08-31 21:54:37
OK, on topic, I disagree that computers are stupid. I think they are as stupid as us. A month ago my girlfriend worked with litel children, orphans, ~10 years old. In my country the government doesn't spend a lot of money for their proper rise. So she told me thay can't differentiate the colors. Why they can't ? Simply becouse no one taught them what is black and what is white. Maybe it sounds strange to you but it is true. Someone has to teach them like you have to "teach" the computer how to execute a task.

P.S. Didn't want to mention but some of them at that age can't even read.
MaxMouse
2009-08-31 22:21:18
You don't "teach" a computer anything, this is my point, it doesn't learn, if in one application it hashes HELLO WORLD, and you execute another application which does the same thing, it doesn't "remember" the hash, it has to do it all again. Some people attribute some form of intelligence to the machines we use, that they are intuitive, but they cannot learn, they are not intuitive and they are not clever. The code is. Computers are not only stupid, they have ZERO intelligence.

I think this is all getting a bit to much, my aim was to show the thought process for something humans consider easy we do things like this without really thinking about it, then demonstrate the steps you have to go through to duplicate that thought process in code.

This article came to fruition because of some code i was writing a while ago, someone asked me "Why doesn't the computer just know the pixel is black?" - That says a lot to me in terms of peoples expectations. It also adds credence to why most managers of software developers (who aren't developers themselves) have unrealistic expectations of their staff, they simply expect too much from the machines we use.
Anonymous
2009-08-31 22:44:56
Well, Domuk. In defense, my first code didn't rely on any library function and the second is just using char-by-char comparison, which is trivial. It was meant to point out the importance of how you represent data. Moreover, a programmer might need to think further about a problem than implementing straight-forward case-by-case work. In this case, making 3*n comparisons, where n is the number of fields in the date, and ending up with the conclusion "Computers.... total morons!" is to me not a good article.

Sure, if the article pointed out that doing what immediately comes to mind might end up being troublesome, it could have saved it. I don't see why you consider these types of posts as trolling. I might sound a bit negative though, I admit that. Why do you have the option to anonymous comment if you take (critical) anonymous posts as trolling?

I also understand that this wasn't meant to be anything more than it is, but I also think that some articles on this site doesn't really qualify.
Domuk
2009-08-31 22:58:56
I took it as trolling as at some point, you were a user who was active enough to register in my memory, who six months later comes back and anonymously criticises some code that clearly wasn't written as the best code to solve a problem. It wasn't the point of the article.

My point about the string library was that character-by-character comparison is essentially the algorithm proposed above - "check the year - is it higher? no, it's the same - check the month" - just on a more precise level. Exactly as we do - if we want to know which year is less, and we are given the dates 24/3/2009 and 21/4/1666 we (theoretically) see the '1' and immediately stop processing.

Your first example is basically the same, just multiplying numbers to a point where the years/months/days are distinct, to avoid using strings.

The fact that the code uses a lot of 'if' statements isn't why he comes to the conclusion 'computers are stupid'. Anyone who codes surely knows that - 'computers are stupid' is an idea that's been used a lot, talked about a lot, and I'd be really surprised if anyone who codes hadn't come across it.
Anonymous
2009-08-31 23:25:52
The whole article is built upon the example of comparing two dates by using the straight-forward logic we all use daily. He then implements it right off and spells it out in words to make it sound complicated. At least when I read it I found it focusing on how complicated it turned out when typing the code, not to show that the computer is essentially a calculator.

Obviously my code does essentially the same. One must compare dates in a certain way. I didn't think that needed clarification.
MaxMouse
2009-08-31 23:26:23
"Anyone who codes surely knows that - 'computers are stupid' is an idea that's been used a lot, talked about a lot, and I'd be really surprised if anyone who codes hadn't come across it." - I'm surprised at the reaction here... are people claiming computers are not stupid, that they are in fact intelligent? Maybe "computer's are stupid" is the wrong terminology, maybe "Computers have no intelligence what so ever and please stop thinking that they know what you want them to do" is a better title?
MaxMouse
2009-08-31 23:29:05
cyph1e, i don't "make it sound complicated" that is exactly what goes on in your head when you determine date matches, I'm all for negative criticism, but this is intended as a fun article, you're actually beginning to get insulting on the matter.
Anonymous
2009-08-31 23:40:36
Sorry MaxMouse, I didn't mean to offend you. I'm just used to write in a certain way.
MaxMouse
2009-08-31 23:44:59
This isn't intended to be "the right way" that's why my first comment is that its a "fun article" it did make you think about how you determine date differences, you even wrote some example code. So i guess even in a negative way, my article did hit home.
MaxMouse
2009-08-31 23:47:32
You aren't my target audience though lol...
Slav
2009-09-01 04:44:20
Hey MaxMouse disregard some comments above...
The purpose of your article should be quite obvious for everyone.
If someone does not like it, that is his choice but no one should not leave irrelevant and immaterial comments.
If you see a bug it the code or you think you can improve author’s approach to the problem or perhaps you can see other, alternative, way to grasp it, that’s different matter – this is constructive and more than welcome.
If you think you are smarter, prove it by writing you own article and have some respect for the people spending their own time trying put something to the community.
MaxMouse
2009-09-01 09:36:19
lol, controversial subject, the comments are larger than the article!
Anonymous
2009-09-09 11:28:43
* The day of date 2 is higher than date 1
* Compare month and year, the same
* Therefore date 2 is later than date 1

I dunno how you guys think, but I believe that was how I get it, because I read from left to the right, not right to the left. More human-like, no?

Saying smart or stupid is depend on how you define the word of "stupid" and "smart". When you define smart as able to do lots of mathematics given a very little time, of course computer is very smart.

Anyway, let's see what internet says:
Define: stupid
"lacking or marked by lack of intellectual acuity "
Define: intellect
"The faculty of knowing and reasoning"
Conclusion: Computer may know but may not reason -> Computer doesn't fulfill intellectual definition -> Computer is stupid

Nothing is absolute,
Vk21
Anonymous
2009-09-09 13:50:31
A computer is only as intelligent as the instructions it is given.
MaxMouse
2009-09-09 14:53:30
"A computer is only as intelligent as the instructions it is given." - My point exactly!

* The day of date 2 is higher than date 1
* Compare month and year, the same
* Therefore date 2 is later than date 1

That works for only one instance, you must cater for ALL instances, and ALL dates, if you read left to right, or right to left the logic is the same.

Try reading the article again.
MaxMouse
2009-09-09 14:55:09
When you define smart as able to do lots of mathematics given a very little time, of course computer is very smart - If you define smart as being able to fit a lot of marshmallows in your mouth at the same time, of course i am very smart...

The ability to calculate 1+1 or 9^10^100*4 is NOT smart.
MaxMouse
2009-09-09 14:59:44
Also... computers get math wrong... a lot...

http://www.codinghorror.com/blog/archives/001266.html

http://www.math.niu.edu/~rusin/known-math/99/calc_errors
Anonymous
2009-09-21 04:06:40
That article was retarded, especially coming from a programmer. Maybe its for people who are ignorant of computer science.

ps:I found this site from http://forums.maxconsole.net/showpost.php?p=1172389&postcount=54 where you were fighting down talk with abs(0)
MaxMouse
2009-09-21 09:17:10
Anonymous, it is for people who are not only ignorant of computer science, but mostly ignorant of how a computer's logic works. As for my conver.... flame-war.. with abs(0), yes, little stupid, I've been involved in a couple of flames there in recent months, i should stop it.
MaxMouse
2009-09-21 09:17:48
Also, if you find this article "retarded" why don't you write a better one?
Domuk
2009-09-22 22:49:36
That's brave, Anonymous - not only baselessly criticising an article but actually cyberstalking the author to criticise their contributions to other communities.

Go boil your head.
Ragz
2009-09-29 20:16:10
so one computer, with no code, assembly or lesser. if i just start typing at a keyboard is goin to figure out mathmatical equasions still. cause i don't see that happening, n though anon is apparently the absolute in programming today.. cannont wrap your head around this article still?
BabaNapster
2009-10-17 13:20:34
I agree with Max, computers are stupid, i mean geeks... they just can't do anything without an intsruction. And if they were smart they wouldn't provide a wrong output if someone have input wrong information.... they are stupid
sfabriz
2009-10-27 10:13:22
Can't wait for next article: "Hard disks can't swim"
MaxMouse
2009-10-29 14:21:29
lol.... wtf?! hard disks can't swim?
CodeX
2009-10-29 16:55:26
I suspect that was sfabriz's point, as its as its pretty much as true that computers are stupid
Anonymous
2009-12-17 21:52:59
what your talking about is the INTERNET not computers ! DAA! all your talking about is the interney! gosh doof!
bogdanp9
2010-03-16 07:26:05
I honestly don't think that we should talk about the intelligence of computers since they're just some kind of machine (a bit more complex than mechanical machines, since computers are programmable).
"A computer is only as intelligent as the instructions it is given. " - I agree with this line :), but "intelligent" should be swapped with "competent" or "capable" since intelligence is something much more abstract than the sum of your abilities to operate some data. Cheers
initpidzero
2010-03-16 13:07:35
they are neither intelligent nor dumb, they are just tools to achieve some purpose.
if computer becomes intelligent then HAL 9000 thing will happen
Anonymous
2011-01-04 00:44:08
Computers are stupid by itself. As an assembly programmer, I can tell you that the smartest thing a computer can do is cmp something, something else and set flags. A computer is as smart as its programmer.
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
Action
First one on Tue 12th Jan 10pm
Yaw, this is the first blog post, just to begin with something. Nice site here, cool features like OSIDrive, and so on. However, strange that an "OpenSource Institute" uses non-OpenSource softare to host its site (Windows and IIS). It's not correct... I t
bb
A Daily Profanity at dailyprofanity.com on Mon 21st Dec 11am
For anyone who likes viz, and roger mellies profanisaurus. There's a website called amusing daily profanity which dishes up a humorous profanity every day via rss, twitter email and a few other ways. Rather rude words, but very funny in my opinion,
hambone
Blog entry for Wed 25th Nov 7pm on Wed 25th Nov 7pm
wtf i can't do geek 12. I don't know what to do. i want to kill myself becuz of this
haziman
Blog entry for Mon 9th Nov 4am on Mon 9th Nov 4am
for all geekos out there...
echmil
fuck you all!!!!!!!! on Sat 7th Nov 11pm
jag har tjock med tyngate tråkigt-.-
goldie
Blog entry for Tue 5th May 6am on Tue 5th May 6am
import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import java.io.*; import java.util.Properties; public class SENDMAIL { public void sendMail(String mailServer, String from, String to,
bb
Bubble Graph on Wed 11th Mar 12pm
I love this graph bubble graph http://www.osix.net:80/modules/folder/in dex.php?tid=28125&action=vf
ketan404
My online resume! on Mon 9th Mar 8am
It is here http://www.listoffreelancers.com/profile s/ketankulkarni Simple and clean design. I like this website. Ketan
macrocat
Blog entry for Sun 8th Mar 3pm on Sun 8th Mar 3pm
Another site with some challenges. Basically, I'm linking this to get a measly five points ;O. Hellbound Hackers
Nightscript
Parapsychology - Fri 19th Dec 5am on Fri 19th Dec 5am
Yes i'm crazy but heres what ive been thinking about and it seems more reasonable that a lot of reality. Note that this ties into parapsychology/psychokinesis research. Mind is not over matter. Thats the wrong state of thinking for sure. Look, this


     
Your Ad Here
 
Copyright Open Source Institute, 2006