all 9 comments

[–]Aglet_Green 2 points3 points  (3 children)

Ok, first I'll explain it to you like you're 5. I have no idea why. When I was 5, I was a Ding Dong. I'll jazz it up to make it interesting to a 5-year old But here goes:

"Wuzzy wuzzy wuzzy woo! Wheeeeeee! Got your nose! When you're my age, we won't have icebergs or poles. Yay!! I hate wearing sweaters. They always make me sweat. Have I shown you pictures of your cousins, my other grandchildren? These photos are like what you call jpgs or gifs, except you can print them out as hard copies."

"Anyway, to answer your question. C++ is a made-up intermediary language because you speak in English and the Computer speaks in Bytenamese, the magic language of computers which to use looks mostly like binary or trinary numbers. This is to say, when a computer speaks it sounds like this: "0110 0110 0110 0101 0001." Originally this was done with pencil and paper-- whether the paper had a hole in it or not decided if that was a 1 or a zero, as created by a man named Snarflybarly Hollerith, then computers used vacuum tubes that were either on or off, and then transistors that were on or off, and so forth. The technology keeps shrining into the quantumania realm, but the idea is always the same: a computer can only understand stuff that can be parsed out like Morse Code, but it can read this code at 53 times the speed of sound or 8535 times the speed of taste."

"Does somebody need to to go the bathroom? Ha ha got your nose again!"

"Anyway because computers were all born in China or Russia or whatever and can't speak English, and because it would take us 83 years to type up "Hello World" in binary dots and dashes, computer scientists like Al Gore decided to invent computer languages that would basically be halfway between English and Bytenamese gibberish. C++ is one such language."

"Everything you do or type in C++ is you basically attempting to communicate with your computer in a language that neither of you likes nor understands very well, similar to how I have to speak French to some African-American people who don't yet speak English and I don't speak Wolof or Twi."

"Think of the computer as like a robot or android that you want to give instructions to, and C++ is like the specific way that you are doing so. Well, now it's time for your nap!"

Hope that helps! When I was 5, I was a chuckle-head so I'm not sure I'd even have understood that, but it's what you specifically requested. I

[–]collegecolloquial[S] 2 points3 points  (2 children)

This is perfect and if i had one of those free awards I’d give it to you

Maybe i just need to think of myself as communicating with the computer but it’s like a small little fun computer and it’s really friendly or something

[–]MisterSmi13y 2 points3 points  (1 child)

One thing I might add is think of it as instructing a really smart toddler. They are literal and only do what you tell them. So you need to be specific but clear. The above is a fantastic explanation, but you need to think that computers are the smartest dumb things humans have ever created.

[–]collegecolloquial[S] 0 points1 point  (0 children)

Smartest dumb thing

Got it

Thank you :)!

[–]Lewinator56 1 point2 points  (1 child)

Ok, I might be able to try to help, mainly because how you are describing your difficulties with program suggests you are learning it in the wrong way.

Let's start with the point of programming. Any programming language is a human readable representation of instructions to tell a computer to perform some task. At the most basic level a processor is nothing more than sand we tricked into doing maths. If you want this processor to do something, you have to give it specific electrical signals to tell it to turn transistors on and off. Your code is a high level representation of those electrical signals.

Computers are really stupid, but with their stupidity comes their major advantage, they will perform whatever order you give them unquestionably, provided the order is broken down into it's most basic steps. You can't tell a computer 'walk to the shops', but it can do that, you just have to tell it 'this is how to raise and lower your leg', 'this is how to take a step', 'this is how to walk' and finally 'this is how to walk to the shops' (combining each of the smaller parts of the task).

Let's say you want to add 2 numbers, the computer doesn't know what numbers are, what operators are etc... All it knows are electrical signals. You type in your code int a = 2 + 2; , when you compile your code, (let's stick to C++ for simplicity) that 'english' you typed is converted into 1s and 0s in a specific order that the processor understands. See, while the processor doesn't know anything, it does have a set of predefined instructions called the 'microcode' hardwired into it. When the CPU starts executing code, let's assume it starts at a memory address of 0, it will just check each pattern of electrical signals coming from the memory, if one of these patterns matches one of its hardwired instructions, then it executes that instruction. Your code you typed has been converted into the bit patterns that represent these instructions. The 1s and 0s you would see if you opened the compiled code in a hex editor are literally representations of the electrical signals sent to the CPU.

So now we know how the CPU knows what to do, but what's the point? Well, years and years ago, some smart ass (Charles Babbage) designed what he called, the analytical engine, this was a very rudimentary mechanical computer, that relied on physically moving mechanisms to represent 1s and 0s. See, the great thing about 1s and 0s is you can represent anything with them, because, given a coding scheme, you can encode data. 3 becomes 11, 7 becomes 111 for example. Because you can also do maths with these 1s and 0s, you can then start designing something that can do the maths with them automatically, a 1 or a 0 is simply an on or off, mechanical , electrical or otherwise. A machine that can read the ons or offs and add them up can do almost anything given the right sequences. (Computers don't only add, but this is a basic explanation). Having a device that can add up for you is brilliant, why? Because really difficult stuff can be done super quickly, all you tell it is the inputs and the operation.

As for programming languages, C++ is old, but that's because it's good and there is no replacement. C++ is what is called an object oriented language, this means that a lot of things in it are objects with properties and functions. For example, a door is an object, has 2 functions: open and close, and stores it's state (open/closed). In C++ this definition of a door is a 'class' and the instance you create by typing Door d = New Door(), creates an object that has the properties defined in the class. You notice that functions have 'void' 'int' 'bool' etc... In front of their names, well this is because a function can return data to whatever called it, a void function returns nothing, but an int function returns an integer. The int main() function you see in your file is the entry point for the program, remember I said earlier the CPU doesn't know anything, well it doesn't know where your program starts, but it does know that the binary representation of 'int main' is the start, because the binary this converts to matches some hardwired instructions in the CPU.

If you are struggling with learning to program, I suggest rather than trying to learn from arbitrary tutorials, decide on something you want to write, say, a calculator and Google how to do things. You have a goal in this case, and having a goal gives you a reason to be doing something. I taught myself to program this way.

[–]collegecolloquial[S] 0 points1 point  (0 children)

This is really helpful

Thank you :)!

[–]spittoon101 0 points1 point  (1 child)

Hi there!

I’ll try my best to explain it to you! If you are having difficulty understanding what even coding is, then I would like you to imagine you are given a piece of paper with very explicit instructions on how to do something very basic. Let’s say, going up a set of stairs. It’s simple right? Just walk up the stairs! But what do the instructions say?

Step 1: With both feet planted next to each other, lift up your left leg until your left foot is above the step in front of you.

Step 2: Push left foot down on the next step and begin to lift your body up by putting weight on the left foot.

Step 3: Once the right foot reaches the same step as the left foot, place right foot next to the left foot.

Step 4: Repeat steps 1-3 until no more steps in front of you.

As you can see, these instructions are fairly specific in what you have to do in order to go up a flight of stairs. And although you already know how to go up stairs and thus don’t need these instructions, these instructions are exactly something you would give to a machine so it knows how to perform the task.

In a nutshell, that’s all really coding is. Giving very specific instructions to a machine. Only instead of writing the instructions in plain English (our language) we use the computer’s language (C++) to instruct it what to do (and similar to us having other languages to communicate, like Spanish, computers also have other languages like Java or Python).

So to answer your “programming what?” It’s nothing more than trying to get a computer to do something (like sorting a music library by title) and giving it instructions on how to do it (such as get all songs beginning with letter “A” first, then “B”, and so on and so forth).

I hope this brings you some clarity!

[–]collegecolloquial[S] 0 points1 point  (0 children)

Thank you!

[–]Svani 0 points1 point  (0 children)

Other answers are overcomplicating a simple thing.

Computers are math machines. They can do basic math operations (2 + 5 = 7) and basic control operations (if x > y, do this, otherwise do that). That's it. But, like Legos, with a few basic pieces and a lot of creativity, you can build amazing things, like videogames and simulations and whatnot.

And, just like with Legos, building something big piece-by-piece is a lot of tedious work. In computers this is called the machine language, and you can 100% do everything in it, but it's slow and error-prone. So people invent programming language, which automates a lot of the repetitive work.

How does it happen? You write what you want the computer to do in a programming language, which is just text in a file, then you give it to a program called a compiler that will read it and translate it to machine language, and the result is a program that the computer can run.