Sponsored by Travelzoo
Take Advantage of Ridiculously Low Holiday Airfares view!
travelzoo.com - Flights $52 and up for Thanksgiving, Christmas & New Year. But move on it now.
65 Comments
- tazamore, on 10/12/2007, -0/+23That's interesting. As a programmer I tend to approach each problem as progressive a series of obscenities. This may start with a small subset of common vulgar words uttered under my breath but as the number of compiler errors grows so does my vocalization of obscene words both in descriptiveness and amplitude. By the time the application has reached beta testing the string of obscenities has evolved into complete sentences, mostly in the form of a question such as "What the f*ck is wrong with this f*cking piece of f*cking sh*t?!!!" The application is ready for release when the lead programmer shrugs and says "Ah f*ck it."
- jcook793, on 10/12/2007, -0/+4Hey maybe I can teach a mathematician how to add like a programmer. Next up in this series: "How to Drive Like a Tree", "We Think Fish Should Bark" and "Mountain Climbing: Limbs Not Required".
- oepapel, on 10/12/2007, -0/+4" If the programmer is the only user, why bother bloating it up with such things? If you know your code intimately, you needn't bother making it idiot-proof because no idiots are going to be using it."
... Except one. (::joke).
Seriously, proper programming technique is not "bloat"; rather it is an approach to problem solving. Even when you are the only user, adding "sanity checks" allow you to track down the inevitable problems that arise when a program grows over time from a small program to a not-so-small program.
Also, nobody has perfect memory and what you wrote last week, last year, or last decade may have been clear at the time but is gibberish to you now. You COULD take the time to figure out what you were thinking when you wrote it the first time or, more likely, you'll start from scratch wasting the previous effort.
With any skill or talent, there is proper technique in it's application that frustrates novices but professionals swear by. This is no different. - tazamore, on 10/12/2007, -0/+3After reading the blog comments I get it now. As one commenter Steve says:
Suppose you need the sum of all integers from 1 to 100. You'll probably do this:
sum=0;
n = 100;
for(i=1; i <= n; i++)
sum += i;
That loop executes around 500 CPU instructions. Suppose this were a real time application and we can't afford 500 cycles. Can we do better? Yes, if we know enough about math we know that the sum of a series of numbers can be expressed in "closed form":
//some pseudo-language
n=100;
sum_n = ((n + 1) * (n)) / 2
That's 4 CPU instructions instead of 500. That's an elegant hack.
Other cases where programming and knowing math helps: cyptography, statistics, game physics, game logic (probability and cominations), 3D rendering, graphics... math pops up everywhere. - mgrasso, on 10/12/2007, -0/+3Ok, I need you to solve a math problem. We're not really sure what the problem is yet, but we want the solution to look like this solution for this other problem that was done for somebody else. We're still working out the details, so why don't you just get started and we'll adjust course along the way. Oh, and make sure the icon is cornflower blue.
- Pihkal, on 10/12/2007, -0/+3Coming from the other direction, I'm a former programmer working in a neuroscience lab for a math-heavy professor as a prelude to grad school, and I feel that mathematicians need to learn to program better. Between the wasteland that is Matlab, and mathematicians that don't know how to design programs (e.g., everyone writing SPM), there's a lot of atrocious, fragile, idiosyncratic code out there. So, if you fall in this category, you are probably not even *aware* of how much your code could improve. Buy a copy of Fowler's Refactoring, and start from there. Basic things like clear/consistent variable names, checking inputs, etc are left by the wayside by too many of the mathematician "programmers" I've seen.
- olegk, on 10/12/2007, -0/+3The best programmers I know do (1) know math extremely well. (2) know algorithms very well. Knowledge of particular languages does mean NOTHING. A real programmer can learn a new language in less than a week.
- surfing, on 10/12/2007, -0/+2Ok! Ok! I must have, I must have put a decimal point in the wrong place
or something. *****. I always do that. I always mess up some mundane
detail. - Darkmoth, on 10/12/2007, -0/+2I have three thoughts on that article:
1) Someone should tell him that we've already figured out what Finite State Machines are.
2) Enjoy debugging a function that depends on the result of all previous calls to that function.
3) You're not done with #2 yet. Sorry. - Vladek, on 10/12/2007, -0/+2@oepapel
Digg opepapel's comment. In my own experience and from code I've seen from both camps, the skill correlation between professional programmers and professional Mathematicians is slight at best. Now there is definately a greater correlation between CS work and Mathematics works. But CS is not programming.
There is a reason why a certain segment of the population who find programming "enjoyable" usually eschew mathematics. - trigonalmayhem, on 10/12/2007, -0/+2Also, I just want to say this:
For mathematicians programs are a means to an end, but for programmers the program is the end itself. - inactive, on 10/12/2007, -0/+1@tazamore: nice one ;)...
wait i suck at maths, does that make me a bad programmer ? :/ - MellerTime, on 10/12/2007, -0/+1I think that's my liquified brain drooling out of my ears...
- tont0r, on 10/12/2007, -0/+1maybe its because CS majors have to do calc 1-3, diff eq, and linear algebra
- carlheinz, on 10/12/2007, -0/+1and me!
- puggy, on 10/12/2007, -0/+1tazamore, I think we went to the same school. :)
- oepapel, on 10/12/2007, -0/+1"Do programmers think like mathematicians?"
Well, since my computer science degree is a Bachelor of Mathematics, i would say yes. But I don't think analytical skills necessary for programming are the exclusive purview of the math geeks. I've also met many many mathematicians with absolutely no programming skills to speak of.
You might as well as ask "Do glass blowers make good accountants?" There's no real correlation in either question. - n00854180t, on 10/12/2007, -0/+1"That's interesting. As a programmer I tend to approach each problem as progressive a series of obscenities. This may start with a small subset of common vulgar words uttered under my breath but as the number of compiler errors grows so does my vocalization of obscene words both in descriptiveness and amplitude. By the time the application has reached beta testing the string of obscenities has evolved into complete sentences, mostly in the form of a question such as "What the f*ck is wrong with this f*cking piece of f*cking sh*t?!!!" The application is ready for release when the lead programmer shrugs and says "Ah f*ck it.""
Yep, that's about the gist of it. In all seriousness though, I think that most (good) programmers abstract their problems quite a bit more than do mathmaticians. - rm999, on 10/12/2007, -0/+1Can someone please explain the fibanacci example to me? What is the end message to a programmer? I understand up to the fact that a mathemetician looks for a closed form of the equation, but what does this have to do with programmers?
- n00854180t, on 10/12/2007, -0/+1Oh, one thing that annoys me about maths, however, is the relative disorganization of syntax. Depending on the particular type of math being used, you might have many different definitions for a given syntax. Mildly irritating.
- cppawnz, on 10/12/2007, -0/+1"The best programmers I know do (1) know math extremely well. (2) know algorithms very well. Knowledge of particular languages does mean NOTHING. A real programmer can learn a new language in less than a week."
I agree 100% with you...
----------------------------
"You might as well as ask "Do glass blowers make good accountants?" There's no real correlation in either question."
I disagree 100% with you. Programming is like 90% math. /* except if you write Hello World or something like that, i don't care what other think but you need to know math very good to be a good programmer */
-------------------------------------------
"I've also met many many mathematicians with absolutely no programming skills to speak of."
I agree 50% with you. If you are a good mathematician you don't need to know programming. Well some of great mathematicians suck at coding. BUT if you are a GOOD coder you have to know GOOD math.
------------------------------------------
BTW if someone thinks hes a geek and he doesn't like maths than he isn't a geek, that just doesn't makes sense. - BridgeBum, on 10/12/2007, -0/+1rm999:
The comp sci equivalent of looking for the closed form of a recurrence relation such as Fibonacci is converting a recursive function to an iterative one. - drosdin, on 10/12/2007, -0/+1>>>>Can someone please explain the fibanacci example to me?
This time through the function depends on the results of the last two times it ran. You are going to add the results of the last two times you ran your function together. So, if you got 3 the last time you ran the function and 2 the time before it your result this time would be 5. Next time you run it your answer would be 8 because you got 5 last time and 3 the time before. The time after that would be 13 because you got 8 last time and 5 the time before. etc.
>>>>>>What is the end message to a programmer? I understand up to the fact that a mathemetician looks for a closed form of the equation, but what does this have to do with programmers?
In this example the closure they talk about is a way of figuring out what your result would be on any given time through (20th, 30th, millionth time) the loop without having to run it that many times to get the results.
Lesson = math could save you time and cpu cycles. - swaxhog, on 10/12/2007, -0/+1I took a double major in Mathematics and Computer Science at University and I say mathematicians should think like Computer Science people. Time complexity algorithms was my most useful course I ever took.
- BrainiakZ, on 10/12/2007, -0/+1@tazamore: NICEEEE.
- oepapel, on 10/12/2007, -0/+1"It would probably be better to do it the way you suggest, but for now I find that it's easier to find problems with simple but well-documented code rather than hunting down the relevant parts of code amongst a bunch of error-checking code. When/if I have to scale things up, I agree that it may be best to impliment these sorts of things, but mathematicians tend to have different needs than most programmers in other fields."
I look at it like typing skills. Some people hunt-peck and swear that they can do it faster and better than they ever could touch-typing. And if they can get by with it, then I say good luck and god bless.
Those that have gone through the effort of learning touch typing usually hate it while they are learning but, once mastered, they are more efficent than they ever could have been otherwise.
It is human nature to take the path of least resistance but that doesn't make it the best path. I think there is enough bad code out there without feeling the need to add to the pile. - nugget, on 10/12/2007, -0/+1I consider myself a geek, and I do not like math anymore. I used to like it until college introduced me to calcuas. Then I went CS who cares I am changing to network admistraion and software development.
- oepapel, on 10/12/2007, -0/+1""Ok, I need you to solve a math problem. We're no..."
WTF?"
Sadly, the example given is rather typical. At the start of project, the requirements document usually has more holes than swiss cheese or is littered with "to be determined". If you are lucky, you can fill in the pieces yourself based on experience or with subsequent requirements interviews. And then you need to deal with requirements changing constantly throughout the implementation.
His point is that CS problems with the high degree of uncertainty make poorly defined math problems and therefore a purely math-oriented approach is an inefficent approach. - trigonalmayhem, on 10/12/2007, -0/+1"Seriously, proper programming technique is not "bloat"; rather it is an approach to problem solving. Even when you are the only user, adding "sanity checks" allow you to track down the inevitable problems that arise when a program grows over time from a small program to a not-so-small program.
Also, nobody has perfect memory and what you wrote last week, last year, or last decade may have been clear at the time but is gibberish to you now. You COULD take the time to figure out what you were thinking when you wrote it the first time or, more likely, you'll start from scratch wasting the previous effort."
You do make a very valid point, although some programs are never destined to grow like that. Often times when I'm doing things I only need a simple function or two that I probably won't even use down the road (or if I will, I tend to modify the code when I integrate it into something else anyway).
As for the rest of it, my solution for now is just documentation. It would probably be better to do it the way you suggest, but for now I find that it's easier to find problems with simple but well-documented code rather than hunting down the relevant parts of code amongst a bunch of error-checking code. When/if I have to scale things up, I agree that it may be best to impliment these sorts of things, but mathematicians tend to have different needs than most programmers in other fields.
Also, I want to mention that matlab has an awesome debugger that also vastly simplifies hunting down problems. - cppawnz, on 10/12/2007, -0/+1"Ok, I need you to solve a math problem. We're no..."
WTF? - trigonalmayhem, on 10/12/2007, -0/+1Hey now, I can touch-type!
( ; - trigonalmayhem, on 10/12/2007, -0/+1"Oh, one thing that annoys me about maths, however, is the relative disorganization of syntax. Depending on the particular type of math being used, you might have many different definitions for a given syntax. Mildly irritating."
one could say the same thing about various programming languages - oepapel, on 10/12/2007, -0/+1"No, math comes handy even when your writing non-math programs, not all of them though...But sometimes math makes your code so beautiful."
No, that's what software design does. Unless the white space in you code follows a fractal pattern, math doesn't make code prettier. Code optimization can also make code more elegant but it can also make it less elegant so it is a net zero effect on the large scale.
I really think this is your lack of experience and naivety showing here. - treemonk, on 10/12/2007, -0/+1I am a programmer, and I like math. It's like peanuts and nougat.
- oepapel, on 10/12/2007, -0/+1"Suppose you need the sum of all integers from 1 to 100. You'll probably do this:
..snip...
Yes, if we know enough about math we know that the sum of a series of numbers can be expressed in "closed form":
...snip... "
So, you are saying that, when solving a purely mathematical problem on a computer, knowing some math can help? Wow.
This example has nothing to do with programming. It IS a classical closed form math example but a computer brings nothing to the table. The same example was shown to me on a chalkboard 25 years ago. Computers are MUCH MUCH MORE than sophisticated calculators. I have been programming for decades and have never needed the sum of the numbers between 1 and 100 in the course of doing my job.
Btw, the same argument can "prove" that physics is necessary to programming when solving physics problems, chemistry is necessary to programming when solving chem problems, etc, etc. - oepapel, on 10/12/2007, -0/+1"I disagree 100% with you. Programming is like 90% math. /* except if you write Hello World or something like that, i don't care what other think but you need to know math very good to be a good programmer */ "
You need math skills (that's why most CS degrees require several math courses) but you also need many other skills like creativity (do we really need another version of notepad?) , communication skills (so that you can explain exactly what the program does and does not), empathy (so you can put yourself in the mindset of the user), humility (so that you aren't so arrogant that you take criticism and suggestions from others), inspiration (you can find solutions in completely unexpected places), the soul of a poet (so that you can appreciate and strive towards elegance in your solutions), visual design (so that the program is not so ugly that it actually gets used), optimism ( so that you realize that the program may survive you and needs to stand on it's design and documentation for others to continue without excruciating effort) and many many more skills.
Missing any one of these skills can be a critical flaw in a programmer. Math is almost irrelevant by comparison. - FlipSpiceland, on 10/12/2007, -0/+1I like this article, even though the digg title is a bit misleading. I took a great combinatorics class that linked programming and mathematics and even showed how to derive the nth term of many recursive functions, such as the Fibonacci sequence. If you're a college student interested in this stuff, look into some sort of applied combinatorics class.
- IGetNoSpam, on 10/12/2007, -0/+1My CS degree was math intensive.We had a built in math minor.
- oepapel, on 10/12/2007, -0/+0"I agree with you that math isn't only thing that is important to be a good programmer. But it sure doesn't hurt. So why are we fighting? "
By that same logic, knowing how to flyfish doesn't hurt either and if you are writing software that involves flyfishing then it helps, therefore all programmers should learn the flyfishing approach to programming.
How about YOU admit that math is math, programming is programming, and one does not imply anything about the other. - cppawnz, on 10/12/2007, -0/+0"Your a ***** lmao!" this was maybe to rough for you.
I agree with you that math isn't only thing that is important to be a good programmer. But it sure doesn't hurt. So why are we fighting?
"I think you are "sucky" at english."
You're right I've only been speaking it for 1 year or so.
"Maybe one day you'll learn that you don't know *****." of course I know *****. I'm just a kid, but my interest in computers, programming and science is huge so in couple of years I will know much more that I know now.
I am not trying to win a fight here so please, if you have any more of your rude comment on your mind go ahead. - cppawnz, on 10/12/2007, -0/+0No, math comes handy even when your writing non-math programs, not all of them though...But sometimes math makes your code so beautiful.
thnx for nice explanation of Sum(n) = (n/2) * (n+1) formula.
oh and i would add simplicity to your list - cppawnz, on 10/12/2007, -0/+0my job is done here
- oepapel, on 10/12/2007, -0/+0" Lol I'm not couse i at least inderstand this:"
n=100;
sum_n = ((n + 1) * (n)) / 2;
and you dont :)"
Ok, smartguy, here's a derivation of the formula:
Deriving a non-recursive formula for Sum(n):
When n is even:
Generate standard expansion to be simplified
Sum(n) = 1+2+3+....+(n/2)+(n/2+1)+....+(n-3)+(n-2)+(n-1)+n
Rearrange in pairs (first + last, second + second-last, etc.)
Sum(n) = (1+n) + (2+(n-1)) + (3+(n-2)) +........+ (n/2+(n/2+1))
Simplify each grouping (for n items, there are n/2 groupings)
Sum(n) = (n+1) + (n+1) + (n+1) + .... + (n+1)
Sum(n) = (n/2) * (n+1)
When n is odd:
The sum can be expressed as an odd value added to an even sum
Sum(n) = n + Sum(n-1) ( where n-1 is even, so we can use our previous results)
Sum(n) = n + ((n-1)/2)*n
Convert to a common base, expand the terms and add together
Sum(n) = (2n + n*(n-1)) / 2
Sum(n) = (2n + (n^2 - n)) / 2
Sum(n) = (n^2 + n) / 2
Rearrange to match the previous results when n was even
Sum(n) = (n * (n+1)) / 2
Sum(n) = (n/2) * (n+1)
Therefore the same formula works when n is even or odd.
Math is easy. - cranium, on 10/12/2007, -0/+0Where do they get the nerve?
80% of programmers aren't really great at programming. Mathematicians are at best "armchair" programmers. Any math major looking for a programming job from me would have a *lot* of persuading to do. It's not so much about implementing simple algorithms as it is about factoring requirements into subsystems and components that make sense.
Math is about hindsight, programming is about insight. - cppawnz, on 10/12/2007, -0/+0Your a ***** lmao!
- cppawnz, on 10/12/2007, -0/+0The "soul of a poet" refers to elegance in design. In Ma..."
And that proves you arent even a crappy mathematician, lol i could argue with you all year....I just luv math and loving math just doesnt hurt doesnt it?
When i said "Good programmer has to know good math." I realy wanted to say:
"Great programmer has to know good math." And here i dont say great math. Except if you are making programs that use that math =). And i don't suck at programming, I'm programming since i was 12.
From other point of view. You yourself (or who was it) said that computers are doing nothing but calculating numbers and comparing them. So isnt that what a programmer does? Telling computer what to calculate? Me myself, I always try to solve a problem first from mathematical view. Which is ALWAYS faster, ALWAYS. Nice talking to you oepapel! - oepapel, on 10/12/2007, -0/+0"And that proves you arent even a crappy mathematician, lol i could argue with you all year....I just luv math and loving math just doesnt hurt doesnt it?"
You are right. I am not a crappy mathematician. I'm actually a pretty good one and have used my math skills in some (a relative minority) of projects. "Luv" math all you want.
"From other point of view. You yourself (or who was it) said that computers are doing nothing but calculating numbers and comparing them. So isnt that what a programmer does? Telling computer what to calculate? Me myself, I always try to solve a problem first from mathematical view. Which is ALWAYS faster, ALWAYS. Nice talking to you oepapel!"
Ok, you seem to believe that professional programmers sit around all day doing nothing but writing programs that calculate, for example, fibonnacci series or number summing. I wish my job was so simple that I could do it equally well on the back of an envelope as on the latest computer.
The basic truth that you don't seem to grasp is that MOST programmers don't need to solve a mathematical problem. The math component of their project might consist of accessing a bunch of databases and consolidating the results. The math is SUM(data). Maybe even CalculateTax(Value).
The real programming problem is how to access the data in the first place. It may be on a high latency connection or a slow connection and the "solution" in this case is to write some TSQL that presums the data to relieve network traffic. Or the problem is that the connection is shared and the programmer has to write code that trickles that data slowly from across the country and has to deal with lost packets while still providing coherent data at all times. Or maybe the problem is a web service based order entry system that synchronizes with inventory, suppliers, warehouse, fulfillment, and accounting so that the company can use a just in time inventory system.
All these problems have one thing in common: there's no equations to simplify or derive a closed form for. In fact, most programmers will never need to do this. Need to do 3D graphics? Use a library like DirectX or OpenGL that just takes a list of points and renders them for you. Want more? Developing a video game? Guess what. There are complete game SDK's out there and even professional game houses base their games on them. They just concentrate on the gameplay and let artists design the characters and surfaces in 2D/3D drawing apps that require no formulas of any kind to use.
In fact, anything that requires anything like realtime access can be done faster in hardware (via SSE or via Pixel Shaders) and the math that governs their use is very simple. In fact, your closed form of the fibonnacci cannot be calculated in a pixel shader at all since many shaders don't have access to transcendental functions like sqrt. So your solution becomes useless.
So, in summary, good math skills are handy to have but they are NOT critical to being a great programmer. And I DO have a math background and I still believe this. A programmers job relies on so many other skills and there are so many computer problems that have little to no math component that you can be, for example, a web guru, and never need to dust off that copy of "partial differential equations and you". A database programmer may never need anything besides SUM(data) and a game developer might just need to brush up on his photoshop skills before he brushes up on non-linear algebra.
Is there an overwhelming demand for matlab programmers? - oepapel, on 10/12/2007, -0/+0"Your a ***** lmao!"
Good comeback. loser. - cppawnz, on 10/12/2007, -0/+0"Good comeback." I know. Lol why would i be a loser? Do you think i'm sucky programmer or what? Lol I'm not couse i at least inderstand this:
n=100;
sum_n = ((n + 1) * (n)) / 2;
and you dont :)
And by the way I do have creativity and inspiration...And don't think I'm saying that I'm an excellent programmer, no I'm not I'm still in fase of learning (as if I'll ever stop :) - oepapel, on 10/12/2007, -0/+0"Good comeback." I know. Lol why would i be a loser? Do you think i'm sucky programmer or what? "
I think you are "sucky" at english. Learn a language before you try and debate in it.
" Lol I'm not couse i at least inderstand this:"
n=100;
sum_n = ((n + 1) * (n)) / 2;
and you dont :)"
Congratulations! You understand a formula that an 8 year old could derive! bravo! You should patent before someone finds out your secret! Oh, wait, it's been around for over 2000 years. Too bad.
Since you don't understand english all that well, I'll tell you that my comment was sarcasm. Look it up if you are having trouble with the concept.
"And by the way I do have creativity and inspiration...And don't think I'm saying that I'm an excellent programmer, no I'm not I'm still in fase of learning (as if I'll ever stop :)"
Keep learning buddy. Maybe one day you'll learn that you don't know *****. Come talk to me when you grow some big boy hair. -
Show 51 - 65 of 65 discussions



What is Digg?