Why is so hard to find anything useful?

Started by
66 comments, last by Coz 18 years, 9 months ago
Programming is as much about code as car racing is about petrol. You need petrol to race a car, and you need code to do programming, but there is a lot more to it than just that. I can't buy a can of diesel from the filling station and be a Formula 1 driver, and I can't just write magical words and symbols into a computer to be a programmer.

Many good, knowledgeable programmers will answer questions with theory, rather than code. This is for a few reasons. First of all, it is vital that a programmer know how to take a theory and implement it in code. Without this skill you will always have to rely on other people's samples to finish your projects, and chances are your final code will be a mess.

Second, as has been said, just having code does not tell you how the theory works.

__freon_inline extern float fracNoise(Vertex_S point){	float sum = 0, jl = 1;	sum = perlinNoise(point);	point.x *= 0.05f;	point.y *= 0.05f;	point.z *= 0.05f;	for(unsigned long i=1; i<=5; i++)	{		point.x *= 7.1784f;		point.y *= 7.1784f;		point.z *= 7.1784f;		sum += perlinNoise(point) * jl;		jl *= 0.77f;	}	return sum;}


That doesn't teach you a lot about iterative noise functions, does it? It's an example of an iterative noise function, but you could stare at that code for days and never understand why it is doing what it does. Unless you are extremely experienced with writing noise functions, you won't be able to visualize the results, either - and if you are that experienced, you didn't need my code sample [wink] Now, if you manage to take that code and use it in a project, that's great - but what will you do when you have to change the way the function works? Will you just change the numbers in the function and guess, and maybe hope it looks right? Unless you know the theory, you cannot truly use the code - all you can do is copy and paste it.

Third, if you don't understand the theory behind things, they can seem like "magic." Magic is when things work but you can't explain how. Magic is extremely evil - if you write code that relies on magic, you are writing bad code. I'm not saying you have to know how quantum tunneling works in the transistors of a CPU to write &#106avascript on a web page, but if you just copy and use code without understanding it, you are not writing code as well as you could be. The difference between a beginner and a master is that beginners have to do this - that's how we learn new things. A master never has to do it, because he has the knowledge and tools - the theory - to get things done in any situation.

A good programmer who gives you code to solve your problem is not doing you a favor. He is doing your work, whether it seems like it or not, and he is actually hurting you by making you rely on magic. A programmer who teaches you the theory of what you want to do, and maybe how to take some theory and make code with it - he has given you much more useful things. Give a man a fish, and he eats for a day; teach a man to fish and he eats for a lifetime. Give a man some code, and he has a cool program for a day; teach a man to code for himself and he can become a master.

Finally, as I started the post saying, programming is not about writing code. Writing code is what you do after your mind has finished programming and is ready to tell it to the computer. If you aren't thinking about and understanding the theory of the things you do in a program, you aren't programming - you're writing magic spells that make the computer do things.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Advertisement
To add onto the above post, this is especially true for artifical intelligence. A lot of AI is about coming up with justifications for what you have done, through theory that often has very little to do with how things are implemented and through carefully thought out experiments. The theory is important too, becuase it's somewhat true that it's easy to "fake" the experiment part; that is, it's easy to find some experiment that makes your algorithm look good, so theory is needed to argue that the experiment wasn't a set up or a fluke. To throw in another analogy, artificial intelligence is to writing code as chemistry is to mixing chemicals.
this is a sample of code

Point CreateSphere(double radius,unsigned int st,unsigned int sl)
{
...

for(unsigned int a = 0; a <= st; a++)
{
for(unsigned int b = 0; b <= sl; b++)
{
vertex[a].x = sinevector(radius,angle*st);
vertex[a].y = cosinevector(sinevector(radius,angle*sl),angle*st);
vertex[a].z = sinevector(cosinevector(radius,angle*sl),angle*st);
}
}

...
}


Well, it's a code I use to create a sphere in OpenGL using raytracing. Its translate the formula 4*PI*radius^2, The theory and code.

Give the fish so is not the point, show a rod to a man and he learns as himself how to do one. Better, Worst, don't matter. What matter is he does it.

If one reads it, and don't know trigonometry, can use the code above in a simple copy and paste, until see that the sinevector/cosinevector function are not provided by any engine/set of libraries, because I create it. Only theory are the key to solve this part of code, where all find that a arc sine/cosine is
equivalent to Pi/180*angle*radius.

If you give to one a piece of code and say to him "it's maybe can solve your problem", he/she will search first to understand the code before use it, or surely the program just crash or will be full of bugs. Theory and code are smashed togheter in brain, and itself returns to you a full useable new code, associating each line of theory with each line of code.

It's not subestimating anyone, all are potential genius since the brain have same structure to all people. Contact with things are the special diferences with a full genius and a full amoeba.

IMPROVEMENT is the key. What I do with code above, since I was not interested in noisy? Maybe if it's useable to me, but I will discover it by research, right? The point is, understand theory, understand code, use code, modify code with need, re-write code, and finally this code desapear with magic as a final result. Understand? It's not a contest, it's life. But life is contest also. If you aren't the fittest, you are extinct.

Theory, especially with artificial intelligence, are not mathemathic, are psychology. Hard to do, inexact, full of possibilities. To me, trigonometry is to draw circles and squares. Now, understand how fear, rage, and other N-factors ages over a single question that you do for other people and the responses that it can result is to let any other crazy. When you begin to walk, the fear on your mind make you calculate each step. With time and pratice, you walk automatically and as a wrong step you fall. It's the dinamic.

Really six months are not sufficient to learn all C++ stuff. Because this I need samples, to understand things that I don't know.

I really happy with range of replies that this topic goes. Forums are this. If you are a opinion about this, post it. If you can help, post it. I and others really thanks for it. Beginners will thanks especially.

Quote:Original post by DarkThrone
Theory, especially with artificial intelligence, are not mathemathic, are psychology. Hard to do, inexact, full of possibilities.


I completely disagree with this. Although some artificial intelligence methods are inspired by psychology, the theory behind artificial intelligence is very mathematical. Training a neural network with backpropagation, for example, is just performing gradient descent on a error function. The update rule for neural network weights is just an application of the chain rule from calculus. A lot of the new machine learning research is based on probability and statistics. For example, markov chains, bayesian networks, monte carlo methods--these are all things that mathematicians knew about long before AI researchers. Outside of machine learning, a lot of natural language processing and good ol fashioned AI is based on theory from formal grammars and formal logic that have a basis in discrete math.

I think with more complicated algorithms and models it gets much harder to figure out the theory from the code. Here's some of my code from an AI related project; this implements a well known algorithm:


int stateCount = process.getStateCount();
int actionCount = process.getActionCount();
double[] values = new double[stateCount];
boolean valuesChanged = false;
do {
valuesChanged = false;
for (int i = 0; i TOLERANCE) {
valuesChanged = true;
}
values = val;
}
} while (valuesChanged);
int changed = 0;
for (int i = 0; i maxActionVal) {
maxActionVal = actionVal;
maxAction = a;
}
}
if (policy.getAction(i) != maxAction) {
changed++;
}
policy.setAction(i, maxAction);
}
return changed;

Even though I've named the variables nicely and written things as clearly as I can, without the corresponding theory I would have an extremely difficult time figuring out what is going on here. More importantly, I would have an extremely difficult time figuring out why this code works and when I should use it over some other code that implements a competing algorithm (which there are many in this case).
I've somehow mangled the code, here is a second try:
        int stateCount = process.getStateCount();        int actionCount = process.getActionCount();        double[] values = new double[stateCount];        boolean valuesChanged = false;        do {            valuesChanged = false;            for (int i = 0; i < stateCount; i++) {                int action = policy.getAction(i);                double actionVal = 0;                for (int j = 0; j < stateCount; j++) {                    actionVal += process.transitionProbability(i, j, action)                            * values[j];                }                double val = process.reward(i, action) + gamma * actionVal;                if (Math.abs(values - val) > TOLERANCE) {                    valuesChanged = true;                }                values = val;            }        } while (valuesChanged);        int changed = 0;        for (int i = 0; i < stateCount; i++) {            double maxActionVal = 0;            int maxAction = 0;            for (int a = 0; a < actionCount; a++) {                double actionVal = 0;                for (int j = 0; j < stateCount; j ++) {                    actionVal += process.transitionProbability(i, j, a)                            * values[j];                }                actionVal = process.reward(i, a) + gamma * actionVal;                if (actionVal > maxActionVal) {                    maxActionVal = actionVal;                    maxAction = a;                }            }            if (policy.getAction(i) != maxAction) {                changed++;            }            policy.setAction(i, maxAction);        }        return changed;

The plus plus's seem to be disappearing, but you get the idea.
If IA is mathemathical, give me the magical formula of a dream. Or to be more simple, give me the formula that calculates the sensation when you awakes and acidentally smash the finger of your foot in the edge of the door.

About Theory and Code, I was not being as explicit in my posts, I think so. I say that "Theory Was Important TOO.". Just code was be a shit if you don't know what it does ( I have THOUSAND of this stuff, nothing useable to me. ) as the case of noisy simulation. But code is so important to you understand MORE FAST the theory. Teach anyone to resolve a serie of problems jsut explaining how do in a techinical language and you give a 70/30 fails until he/she really understand it. Teach anyone to resolve a serie of problems giving the proper result in the first and as magic, he/she inherit it as water, giving you 0/100 fails with sure.

The code given was so interesting. I was figuring that "process" is a class, right? policy is also a class, and both are used to make the function. Really, before this point, I don't know what I use with this. But the dinamyc of the code is simple. policy is a object, process the iteration. to each transition for process, a new result is compared and calculated using policy and so well.

The question is ( now above the theory, even I say and repeat, if a understandable one ): Policy is needed? It haves really the full needed methods?
Uses efficiently this? Understand? it's code without theory.

At other hand, some theory are just needed with a full mathemathical PhD. 20 years after, the work of your life is shit close to a enterprise 10000 employers similar project. It's theory without code.

Life is mathemathical, dear friend. But mathemathical formulas don't are the key to IA. Dreams are ramdom pieces of foms, sounds, color and facts, that are just recorded in your mind, even if you don't know. You can dream with a woman that you can swear and take off your eyes that you never seen, but You see her, maybe at glance, when you take a bus to go home. Brain is so powerful, the power isn't know why Ideology is not strong at level of control it. You can't for yourself, but your brain can. Understand it? First, to build a dream, you need material. If you create a interative world that your object have contact with others, ALL iterations have to be recorded. But not all are useable, so the brain solve this in a single "acelerate your most useable thinks". So if you understand how the brain record this, analysis this, give priority to pieces of this above others, mathemathical is just a cicle of "ifs" and "fors" at end of code.

To complete, programming is hard, but if you don't like it. I can't explain, but to me programming is so easy because I do this the way to follow. I just love it, as a son. I was sad with fails, glad with sucess. Each key pressed is hope, and this is the heart of programmer. If you spend time on programming, jump out. If you dedicate time to programming, you will be a master, don't matter how. This is the SURVIVE-OF-FITTEST, a natural law that moves the world.


[Edited by - DarkThrone on June 13, 2005 9:40:29 PM]
Quote:If IA is mathemathical, give me the magical formula of a dream.


X = 7;

No really.

If this answer isn't the one you are looking for, you have not sufficiently well defined the word "dream".

Quote:Original post by DarkThrone
If IA is mathemathical, give me the magical formula of a dream. Or to be more simple, give me the formula that calculates the sensation when you awakes and acidentally smash the finger of your foot in the edge of the door.


That's quite interesting. Have you seen or read the results of dream research? Well, the most promising results show that dreams are actually the results of random neuron firing, which is just a series of random images, color, or memory or whatever. The pieces of information used in a dream are both conscious and subconscious. The average person remembers more things than they consciously know. So, the people with photographic memories are just special in the sense that they know how to access the memories they've gained subconsciously. So, back to the point. They found that dreams are inherently random. However, since our brains aren't very good at dealing with pure randomness, the first instinct is to try to make sense of it. So, when we are dreaming, our brain is rapidly processing random information and trying to make sense of them, which sometimes is not possible. This result comes from the fact that experiments show that people who have just woken from a dream state are actually more competent at finding correlations between random things, than a person who has awoken from a deep sleep state or a fully awake person. So, that's why sometimes dreams tend to "jump" around. So, the process of finding a commonalities and trying to interpret random data is pretty much statistical regression. So, mathematically, the brain is performing multi-dimensional statistical regression to try and create order from the randomness that it is given.

SO, we can pretty much model a dream as a series of random information that gets thrown from anywhere in our memory into our cognitive processing unit, which then tries to run a multi-dimensional regression or ordering algorithm on the data to try and discover commonalities and trends in the data. Thus, our dreams then get pieces of story line as the random information gets merged with seemingly "related" information that the cognitive unit can call up at the time. Thus creating continuity. So, after performing regression, a multi-dimensional curve fitting interpolation is performed.

That, in result, gives you your dream.

As for waking up, its equivalent to all your senses being rewired and starting up at some random initial value. Usually when you wake up, your sensory sensitivity is higher than usual, so, and pain sensation is a little heightened. However, since there is still some internal chaos with the consciousness, the sensory input will be delayed, due to the processing of other tasks. Somewhat like sensory overload due to network congestion. Too much information, too little processing time, causing latency and flooding. So, I guess, mathematically, it becomes a probabilistic network congestion simulation model.

The thing is, as long as you can slap a numerical value onto something, you can pretty much explain it or map it to some mathematical model. Physicists will tell you that one of the beauties of nature is the fact the all phenomenon can be broken down to simplistic formulas. Whether or not the average Joe will understand the formula is a different thing.
x = 7 is so great. I use it and now my machine can think, dream and solve the problem for dominate the world. Thanks.

Without sarcasm, I'm not questioning the DYNAMIC of a thing. A car is based in physic, with VELOCITY, TORQUE, RPM values. But a engine is built by MECHANICS, not PHYSIC. Even Mechanics uses Physics, it's relative to Mechanics the Physic formula used.

The problem is the theory, in some parts, show you anything so complex that you need a full mathemathical course rather than code. So, you finally know that this damned formula is more simple than 1+1. If in same theory, a simple step-by-step by example will teach you by association what that means.

Seems that I and Weirdofu agree with dream dynamic, but that's not the point. Since the base is psychology, first we have to gave a full structure of storage and manipulation sufficient efficient to dynamic runs out of errors. If you don't, you will seek and modify the dynamic code ( the mathemathical part ) to try repair a error that don't be there. Even you can sucess, it's not perfect, and in a point or another it fails. If you build a clear base, dynamic adjustements just enhance the project instead. That's the concept. The machine knows nothing, just you can teach it. If you are a good teacher, if will be a good program.
Quote:Original post by DarkThrone
If IA is mathemathical, give me the magical formula of a dream. Or to be more simple, give me the formula that calculates the sensation when you awakes and acidentally smash the finger of your foot in the edge of the door.

Since such an AI does not exist, there are obviously no models for its creation. Maybe you meant "show me the math equations behind actual intelligence", and if that is the case everyone is looking. That is part of why everyone talks about theory, because AI is still very much a field of research. Like everyone has already said, for most purposes the code is the easy part.
Turring Machines are better than C++ any day ^_~

This topic is closed to new replies.

Advertisement