I think he's more interested in the software level than the hardware level...
I don't know that much about computers. I have had a programming class on C++, but really I didn't understand too much stuff in there. I am hoping to get a bachelor degree in computer science and really learn how these things work.
I remember hearing that once we could describe if then statements that was when computers took off.
If X Then Y. If not X Then Not Y.
So I don't know how computers do logic, anyone care to explain?
Well, the simplest type of program is just a basic linear program.
Linear programs just do a bunch of stuff in order.
for a basic program, the programming file is just a text file with a bunch of programming commands, that are executed in order. The programming commands are defined by whoever wrote your programming language or whoever wrote your third party function librarires to go with your programming language.
So you'll have a list of stuff for your program to do, from top to bottom, selected from your personal collection of functions and commands written by other people. So you're building on whatever they wrote, but you get to choose the order to execute it in. ( unless you want to build your program out of whole cloth, this is the way to go ).
You'll have various logic statements such as if statements, and loops. You also have variables. Generally you'll have an "If" statment, which checks the value of some variable. If the variable is equal to the value it's checking against, it will execute a block of code associated with the "If" statement. Included in the block of code can be other statements which can changes the values of whatever other variables you want to change.
here's an example of an IF statement
// note, in code anything behind a "//" is a comment for
// the reader and not actual executed code.
// at least in c style languages...
Code:
If ( 50 == x )
{
DoSomething();
}
NextStatement();
...
The command "DoSomething()" ( inside the {} ) will only be executed if the value of the variable "x" is 50. If it isn't 50, then nothing will be done. and it will move on to the next statement.
Then you have loop statements, which are blocks of code that continuously execute again and again, until the loop breaks. the loop breaks on a condition, usually by checking a variable.
For example, a loop ( in pseudocode ):
Code:
int x = 0; // sets the starting value of x to zero.
Loop
{
// Code goes here to execute a bunch of stuff
x = x + 1 // this line increases the value of the variable "x" by 1. )
if ( x == 10 ) break; // the loop exits once x is 10, so it loops 10 times.
}
So this code will loop through everything between the { } 10 times. Because after
...
Later, past simple programs, you'll get to "event based" programs, with multiple threads.
Here, you have one ( or more ) page which describes what your user interface looks like. ( an example of this type of page is HTML code for a web site, or instructions for a windows-form application )
Then you have a bunch of buttons on your form or web application. Each button will cause an "event" ( defined in a separate code file ) which will run a linear program. So you have a bunch of little programs inbedded in a user interface, and clicking a button fires an "event" which creates a new thread and produces a particular action, which is defined in your event handler which is associated with that button/action.
You also have data storage... the simplest type of datastorage is just writing stuff to a notepad file, and then reading it later in the program or reading it by some other program. Or just storing it.
More complicated data storage can involve 3rd party database software ( such as microsoft SQL server ), designed to organize your data for use in your programs.
You also have Methods ( also called functions ), which are blocks of code that can be run anytime the function is called.
So, in the middle of your code, you'll put a line that says:
DoSomething();
and then later down at the bottom of your code, you define what "DoSomething();" does.
so you'll have a definition:
Code:
void DoSomething()
{
// Put code in here to define what DoSomething() does.
}
So if you have this definition at the bottom, then anywhere else in your code where you write "DoSomething()" it will execute the above block of code.
Also, all the code you write, will either be simple arithmatic, loops, or if logic, with variables you create, while calling functions.
Many functions are pre-made by some third party or someone else in your office, you don't write them yourself, they're written either by whoever created the programming language you are writing with, or they're created by some third-party vendor, or some guy downstairs... You build on what other people have written... for example, someone may have written a graphics program, which is designed to do graphics and design forms, text editors and all kinds of stuff. You don't really do anything with the manual pixels you simply call functions they've already made.
You use premade stuff so you don't have to reinvent the wheel by manually changing pixels everytime you want your program to display some image.
To call other people's functions, you need to associate your program with the various precompiled
.dll files that you will obtain from third party sources. Note, that other people don't usually let you see their programming code, they simply give you the compiled version stored in the .dll file. ( actually .dll stuff is specific to microsoft stuff, but other types programers have different ways of doing this. some video game programmers make everything from scratch... you'll have one guy designing hte gameplay, scenarios, etc, another guy builds a graphical user interface from scratch... the lower level guy will design the graphics engine ( which consists of functions used by the higher level guys to draw cool 3d things ), also there be a game engine for each game, which will idealy be flexable and reusable in later games. )
Basically all programming is made up of premade functions and operators coded by other people, until you get to the very bottom 0s and 1s. So there's "lower level stuff" and "higher level stuff", layered on top of eachother... a windows application would be a higher level program... below that you have "windows forms" which is a premade library and interface used to make windows applications, written by microsoft...
...
next up parameters:
since i was talking about functions, You can also pass "parameters" to these functions, which are variables, and functions can return values. So, for example, you could have a function called "multiply", with two parameters, being the two values you multiply. When you called the function, it would multiply the values together, and "return" the result.
so the code might look like this:
Code:
x = Multiply(5,10); // this sets the variable x to 50, which is 5 * 10
Print(x); // this displays 50 for the user.
// ... and then the definition for "Multiply" ...
int multiply(int a, int b)
{
return a * b; // this "returns a times b.
}
The above is pointlessly simple, but you get the idea... ( do you ? )
...
also, later you'll get into stuff called "Object oriented programming" where you have all of the above, except wrapped in "classes" and "objects" to organize it all better, or to make it all pointlessly complicated. But that's more advanced stuff, best to learn the above first.
If you want to get started programming, you'll probably want to download an IDE. You can get a free one from microsoft, google "Microsoft Visual Studios Express Edition" for info on that. Also there will be all kinds of training and instructional stuff that you can find for visual studios. ( and you can pick your programming language... i do most of my stuff in C#, but people use all kinds of languages ). It's a good idea to start learning how to use IDE's, cause half the job of programming is knowing how to make full use of the tools in these kinds of applications that help you write code.
Also there are a bunch of programming languages but they're basically all mostly the same, just different syntax. Once you learn one language you can learn the rest pretty easily.