kikz
26/7/07 12:21:17 PM
Immortal

|
http://warpedjavaguy.wordpress.com/2007/06/20/natural-born-programmers/ This guy hypothesises that smart people aren't meant to be programmers because they apply their human shortcuts to the their programming. Smart person code based on heuristics for determining even/odd in real world.
// know what is even and what is odd // (humans store this in memory) Boolean even = Boolean.TRUE; Boolean odd = Boolean.FALSE; // initialise results for numbers 0..9 // (humans store this in memory) Map results = new HashMap(); results.put(new Integer(0), even); results.put(new Integer(1), odd); results.put(new Integer(2), even); results.put(new Integer(3), odd); results.put(new Integer(4), even); results.put(new Integer(5), odd); results.put(new Integer(6), even); results.put(new Integer(7), odd); results.put(new Integer(8), even); results.put(new Integer(9), odd); // get the last digit of the given number // (humans look at the last digit) int lastDigit = Math.abs(givenNumber % 10); // lookup the result // (humans recall the result from memory) Boolean isEven = (Boolean)results.get(new Integer(lastDigit));
dumb person code:
// perform divide by two test and get result boolean isEven = givenNumber % 2 == 0;
The supposedly less intelligent persons code is clearly the more efficient. Warpedjavaguy is definitely simplying his example for the sake of his argument. I don't consider myself stupid and as I was reading through the blog I thought of the code that everyone uses to programmatically determine odd/even (the second example). In the realworld I realise that integer numbers are always even if their last digit is even, but I can't recall ever coding the first example. Maybe I'm not as smart as I credit myself to be :p ----- http://www.atomicf1.com
|
boyter
26/7/07 12:46:36 PM
Guru

|
But smart people tend to be lazy as well. I know which one I would go for based on the amount of effort involved. -----
|
QuadLex
26/7/07 01:15:12 PM
Guru

|
I think his argument is flawed. For starters, humans do % 2 to check if numbers are odd or even, when we first start learning them. Afterwards we simply remember the result of our initial calculation, much like a derived field in a database. Perhaps the issue comes from his definition of a smart programmer. I think smart means "smart at producing efficent, elegant code", not "thinks like a human". Human reasoning is not suitable for computers, which is what his argument really shows. Now, I'm going to disclose my bias and say that I think good engineering solutions to any problems are some of the most beautiful things humans can produce. They're a testament to human thought and creativity. The roundabout solves a tricky problem with a static device that requires no maintenance. I think good engineering solutions are what "Smart" means. So I think his argument is flawed. I know plenty of people who use "tricky" maths, entirely because they're not as bright as some, so they need shortcuts. It doesn't really cost them anything and it saves them from (say) having to learn and remember trig (Builders) or figure out how much they need to multiply and measure to make that cake again (Cooks, using ratios). It's not smart, it's just easier. The advantage of the smart solutions is that generally, they're provable. The odd/even example is an encoding of the rule for odd/even numbers. The program can say: "By definition, this is an odd number" instead of inferring it is odd based on some rules that, on the surface, don't prove anything. ----- RIP Simba, 19 May 2007.
|
nickeax
26/7/07 01:37:35 PM
Banned

|
Then you have people like me, below dumb. Programming is very difficult for me, and I do things in odd ways. I keep trying though, because it's fun and satisfying mentally. I disagree with the examples too. A smart person uses tools and does things the easy way. A smart person will seek out a ready made solution to a given problem before wasting their time coming up with a duplicate solution. Well, I assume this, anyway! ----- http://www.bandofgreen.com/SellYourself2.5/ OMFG!!!
|
zephyr
26/7/07 11:09:45 PM
Hero Titan

|
heuristics have their place, but come on, you're not going to use them as a shortcut when there's an even shorter one on offer. Faced with a problem like that, and not knowing the modulo operator existed, I'm sure most "smart" programmers would figure out how to do it in far fewer lines of code than you need for the heuristic. Or put it another way... humans use heuristics because they're not good at doing those sort of calculations in their head in a timely way. But computers are, so why would you bother doing it using the rule of thumb when you can do it with a simple, precise calculation. And if you think I'm still talking about figuring out odd numbers from the evens, you're wrong :-) A good example is spam recognition - given a few samples of spam emails, a good bayesian filter can classify incoming spam faster than a human could, with a fair degree of accuracy... we have our own heuristics that give us clues that an email is spam, but that doesn't mean doing a frequency count and analysing the statistical probability of those words appearing at certain frequencies isn't a valid way of determing that it's spam. ----- "It is better to be silent, and be thought a fool, than to speak and remove all doubt." (Confuscius)
|
bedhouin
30/7/07 02:19:24 AM
Serf

|
I'll remember to mention that to John Carmack next time I bump into him. ----- My bookmarks: http://www.hyperigo.com/bedhouin/
|
slimdog360
30/7/07 10:28:53 AM
Initiate

|
Quote by boyter But smart people tend to be lazy as well. that must make me a bloody genius then ----- bloodninja: Rhinoceroses don't play games. They f*cking charge your ass.
|
bolt_krank
30/7/07 05:07:38 PM
Champion

|
Honestly - I can't see how the first option is a smart answer. Seems to me like someone going out of their way to make more work for themselves. The smarter option would be the more elegent 2nd option. The used memory and compiled code would be a lot less/ smaller. ----- I wrote my friend a letter using a highlighting pen but he could not read it; he thought I was just trying to show him certain parts of a piece of paper.
|
NearZero
30/7/07 08:43:23 PM
Master
|
First example looks like the work of a consultant! -----
|
Blitz[VFF]
30/7/07 10:49:10 PM
Titan

|
Quote by NearZero First example looks like the work of a consultant! Which means it's worthy of a dailywtf. :P ----- Quote by Jeff Spicoli Ever been on auto-pilot? I just found a box of tissues in my fridge.
|
stadl
31/7/07 08:41:56 AM
SuperHero Titan

|
I would never have thought anyone would use the first one for any reason. What I would have expected from an overly creative developer was
boolean isEven = givenNumber & 0x01 == 0; And given the context - analysing even numbers even if the & operation is more efficient on some CPUs, unless this is low spec embedded stuff, I'd prefer modulus operator to be used as its easier extract the requirement (although the name isEven is pretty definitive). ----- ...so brilliant in fact, that by simply harnessing the power of one live frog, it.. it.. uhh.<poke> <poke> World domination has encountered a momentary setback. Talk amongst yourselves. Waffles, Lots of Waffles... And Chips...
|