Blrd

Anime, Comic Books, Super Heroes, it all goes down here!

Stats

Category
Entertainment
Total members
4
Total events
0
Total discussions
774
Total views
167K

Learn To Code Today

TheHarmattan

*nix Master
Tither
Messages
2,248
Reputation
1,266
Location
Wakanda
zBucks
0
Sex
Male
Race
Black
Origin
USA
10,000 foot view of programming


Programming is about controlling a machine. It's not a secret art or magic.

To control a machine, you need to understand how that machine takes instructions and how it returns the answer to you.

So, naturally, we are going to need to focus on a language. There are many languages out there that a person could use to "speak" to a machine. I don't believe that there is a single "best" language to use. So, whatever language you choose, it should do the trick. I'll address languages when we finish preliminary points on programming.

Algorithms

College courses, in my opinion, do not spend enough time on teaching algorithms. An algorithm is basically the "flow" of your program. So, the first step in a proper algorithm is to establish what your program wants to do. After you decide the solution your program will give the user, you should be breaking down the "problem" into manageable pieces. It's good practice to break down your "problem" as small as you logically can.

I will use a cake as an example to explain:

Gather: eggs, flour, milk, sugar, shortening, spice, extracts, mixing bowl, spoon, oil, baking pan, stove, electricity and a timer.

Think of the things that you just gathered as "objects". Objects are the actual data that you will use in your program. You will hear that term quite often.

Trust me this is going somewhere.

Break down your objects further:
Gather: Chicken eggs, wheat flour, cow's milk, cane sugar, canola oil, etc.

As you can see, in programming, you need to be precise as possible.

Continuing, you have all the ingredients to make a cake but you need to do something with the ingredients. In programming, actions are called functions or subroutines. You can use those phrases interchangeably. So your actions (functions) should tell the computer what to do and in what order:
1: mix in a bowl
2: crack eggs throw away shell
3: add spice
...

It's up to you to create the flow of your program so others using your program can be successful.

Review:
Algorithms are the flow of your program. You need to create one before you even write a single line of code. Objects are the data that you will use in your program. Functions are the actions that the computer must perform in order to solve a problem. Please practice algorithms because they are very useful for design and upgrading your code to extend it if you should want to in the future.

Next: Language Types
 

TheHarmattan

*nix Master
Tither
Messages
2,248
Reputation
1,266
Location
Wakanda
zBucks
0
Sex
Male
Race
Black
Origin
USA
Language types

Generally, there are three types of languages with their own set of strengths and weaknesses.

Compiled languages are more robust and historically faster than the other two types. Examples of compiled languages:

C - The grandaddy of many languages' inspiration. It is flexible and allows the programmer to get real close to the actual "circuits". Windows, Mac, Linux, BSD and Minnix are primarily written in C.

C++- This language is a superset of C. It was known as "C with classes" in the earlier days of its adoption. C++ is even more flexible than C, and the native code is a very good primer on object oriented programming. There's that word "object" again.

D - This language is the new kid on the block. The creators thought that C++ could use a little beautification and some more modern features. Very good language in my opinion.

There are tons more to name so I'll end this section with a short list: Assembler, BASIC, Fotran, COBOL
 

TheHarmattan

*nix Master
Tither
Messages
2,248
Reputation
1,266
Location
Wakanda
zBucks
0
Sex
Male
Race
Black
Origin
USA
Interpreted Languages

An interpreted language is a language that is written for an executable program usually called a interpreter. These languages do not need to be compiled before they are run. The instructions are typed out and made into a script. The interpreter reads the script and it executes the script at the interpreter level. Interpreted Languages are very flexible and convenient but they lack in speed.

Examples of interpreted Languages:

Python: This language is the rockstar of all the interpreted languages and it's in high demand. It is object oriented and provides a general purpose language for automation compiled programs or it can be used to extend a program's functionality.

Perl: Over the years Perl has gained a cult following for its specialization in dealing with strings. If you are working with a lot of words, this language is a no-brainer.


Ruby: Ruby has been called the ugliest language in the word but its properties are solid. It's a general purpose language that does what other interpreted languages can do. It's extension: Ruby on Rails turned out to be great for developers wanting to extend and add functionality on the web.

PHP: Speaking of the web, this is the one of the big languages that works on the web and add functionality to your web pages. Over the years it has suffered security issues but it's now on track to continue to be a top language on the web.
 

TheHarmattan

*nix Master
Tither
Messages
2,248
Reputation
1,266
Location
Wakanda
zBucks
0
Sex
Male
Race
Black
Origin
USA
Byte Code Interpreted Languages

These languages are compiled into bytecode and then executed inside of a virtual machine.
The logic to this type of language execution is mainly twofold: it is faster than interpreted languages and the code is portable between virtual machines on different operating systems. Java lead the charge back in 1995. In the early 2000's, Microsoft followed through with their rendition when they released the .Net Framework.

Bytecode Languages are:

Java - The granddaddy of bytecode Languages, is a staple in many development projects. It is still in high demand.

C# - This language was developed by Microsoft and it is a general purpose language and has been a rockstar for that platform. It was inspired by C, C++ and Java.

F# - This is one of the newer general purpose languages that emphasize functions over objects. It's still too new to see if it can break out of the pack.

As you can see, you have many language solutions for your projects. No one can tell you which on is right for you. So, naturally you will need to have a sense for experiment and try a few languages and pick one that is right for you and your project.

Next: Object Oriented Programming
 

TheHarmattan

*nix Master
Tither
Messages
2,248
Reputation
1,266
Location
Wakanda
zBucks
0
Sex
Male
Race
Black
Origin
USA
Object Oriented Programming

I cannot stress it enough that the programmer needs to think in terms of objects when learning a new programming language. I will use a back for my examples in this section.

A bank offers many services but most of them are in the form of accounts. Accounts are therefore tied to actual people. Accounts are usually currency.

So let's say you have a personal n that wants to open an account. The programmer needs to think about the type of account. The type of account opened has different properties applied to how your money is stored and spent.

For simplicity you could open up a savings or checking account. Think of those two as different objects that you need to program and define on your program. You have to tell the computer about the interest rate, minimum daily balance, etc.

Once again, for simplicity, the account holder is a separate object. Within the account holder's object, there needs to be something that differentiate one from another. Two people can have the same name and birthday. But no two people have the same SSN, for example.

There are whole books on object oriented programming. I suggest that you learn to think about objects as separate parts if an idea that needs to work inside of a program.

Next: Intro To C++ (With A Twist)

Since C++ is widely used and it is the forerunner to object oriented programming, we will start writing code in the next chapter.
 

Jay

The First Sixer
HNIC
  • Messages
    9,579
    Reputation
    15,105
    Location
    California
    zBucks
    47,801
    Sex
    Male
    Race
    Black
    Origin
    USA
    10,000 foot view of programming


    Programming is about controlling a machine. It's not a secret art or magic.

    To control a machine, you need to understand how that machine takes instructions and how it returns the answer to you.

    So, naturally, we are going to need to focus on a language. There are many languages out there that a person could use to "speak" to a machine. I don't believe that there is a single "best" language to use. So, whatever language you choose, it should do the trick. I'll address languages when we finish preliminary points on programming.

    Algorithms

    College courses, in my opinion, do not spend enough time on teaching algorithms. An algorithm is basically the "flow" of your program. So, the first step in a proper algorithm is to establish what your program wants to do. After you decide the solution your program will give the user, you should be breaking down the "problem" into manageable pieces. It's good practice to break down your "problem" as small as you logically can.

    I will use a cake as an example to explain:

    Gather: eggs, flour, milk, sugar, shortening, spice, extracts, mixing bowl, spoon, oil, baking pan, stove, electricity and a timer.

    Think of the things that you just gathered as "objects". Objects are the actual data that you will use in your program. You will hear that term quite often.

    Trust me this is going somewhere.

    Break down your objects further:
    Gather: Chicken eggs, wheat flour, cow's milk, cane sugar, canola oil, etc.

    As you can see, in programming, you need to be precise as possible.

    Continuing, you have all the ingredients to make a cake but you need to do something with the ingredients. In programming, actions are called functions or subroutines. You can use those phrases interchangeably. So your actions (functions) should tell the computer what to do and in what order:
    1: mix in a bowl
    2: crack eggs throw away shell
    3: add spice
    ...

    It's up to you to create the flow of your program so others using your program can be successful.

    Review:
    Algorithms are the flow of your program. You need to create one before you even write a single line of code. Objects are the data that you will use in your program. Functions are the actions that the computer must perform in order to solve a problem. Please practice algorithms because they are very useful for design and upgrading your code to extend it if you should want to in the future.

    Next: Language Types
    As someone who used to write PHP this is such a great explanation. I like how you said “it’s just about controlling a machine” I used to tell people something similar when teaching markup. All you’re doing is telling the browser what to render but you need to learn the language that it understands. Once you learn that language it becomes easy to tell it what to do.
     

    TheHarmattan

    *nix Master
    Tither
    Messages
    2,248
    Reputation
    1,266
    Location
    Wakanda
    zBucks
    0
    Sex
    Male
    Race
    Black
    Origin
    USA
    As someone who used to write PHP this is such a great explanation. I like how you said “it’s just about controlling a machine” I used to tell people something similar when teaching markup. All you’re doing is telling the browser what to render but you need to learn the language that it understands. Once you learn that language it becomes easy to tell it what to do.
    Yes! I really want to demystify the field so people will be comfortable. Everyone makes mistakes and I bet the newbies to programming will make plenty of mistakes.
     

    TheHarmattan

    *nix Master
    Tither
    Messages
    2,248
    Reputation
    1,266
    Location
    Wakanda
    zBucks
    0
    Sex
    Male
    Race
    Black
    Origin
    USA
    C++ Variables


    In C++, there are primitive data types that all programs must have to store data. These days types are called primative because the C++ language provides them to the programmer and most importantly, their size are pre-determined to provide a foundation to build other objects that are more complex and offers more flexibility to your program.

    Keywords

    In order to create a primitive variable in your programs, you will need to use a reserved keyword. A keyword is a reserved word that you cannot use for any other purpose. The set words that you cannot use is defined by C++ and the list of keywords can grow as the language see fit. You can find the list here:
    C++ Keywords

    Integers
    An integer is a whole number. And it's keyword is int. To create a integer variable C++ requires that you use the assignment operator: =. Keep in mind that the assignment operator is NOT an equal sign. So, if you want to create an integer variable, you must first give you variable a unique name so you can distinguish one from another. So if you want to store someone's age you can type:

    int age = 25;

    This tells the compiler that you want '25' to be entered into the variable 'age'. The semicolon is a way to tell the compiler that you are finished with that single instruction. If you forget the semicolon, you program will NOT compile. So, you will see plenty of them in the future.

    Floats
    I could really go for a root beer float right now. LOL. A float is a way to store any number with a decimal. As we all know the real world does not operate on whole numbers: think about cash. If you need any number with a decimal, you must use a float or the compiler will "chop off" the numbers on the right side of the decimal and your math will not be correct. To create a float you should type:

    float accountBalance = 12.34;

    Char

    The char variable is very simple variable that stores a single character. As you can tell, a char (character) is a bisic building block of constructing words and eventually sentences. I told you that we are starting from the ground up. To create a char you need to type:

    char yes = 'y';

    As you can see that creating a char has single quotes. That is to differentiate a single char from a a series of chars, which we will talk about later.

    Long
    A long is a float but it is reserved for if you need large numbers. If you are calculating distances to stars then you may need exceptionally bug numbers.

    First Program

    Study the following piece of code:

    int main ()

    {

    int youngAge = 10;

    int oldAge = 70;

    return 0

    }

    This program does nothing useful for the moment. The object is to get your eyes used to looking and identifying the parts of a program. In later sections we will build upon this very basic program and you will see just how deep this rabbit hole goes.

    The very first thing to understand is that in C++, the execution of a program always start with the main function. There is no such thing as a program without a main program. The word 'main' is a reserved keyword so you cannot use that word in any part of your program, except to tell the compiler where your program begins.

    Since main is a function, curly braces must contain the program code. All this program does is to store two numbers into two variables and exits. The word 'retirn' is another keyword. It basically tells the operating system that it is finished and the operating system cleans everything up and closes the program properly.

    Nothing special. Just get used to this very basic program and we will start to build on it as we go

    In the next section we will expand this program into something useful.

    Next: Adding Some Spice
     

    Invincible1914

    Sixer
    Tither
    Down From Day 1
    Messages
    389
    Reputation
    286
    zBucks
    0
    Yo, I took a C++ class and was learning until figured out all of the test answers were online.

    All of our tests were timed and I failed the first one cause I wasted too much time checking things in Visual Studio, but I was learning though. I was like the hell with flunking... I made a 100 on everything after that and didn't learn nothing.
     
    Last edited: