ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Learning Programming - The Basics

Updated on June 27, 2016

What is programming?

First and foremost, to learn programming you must know what programming is. Programming is pretty much the process of taking an algorithm and rewriting it using symbols and a style of writing called a syntax in order to make a computer understand the instruction. Simply put, programming is just the process of helping a computer understand what you want it to do.

In order to do that though you must learn at least one programming language. A programming language is what you would rewrite the algorithm into so that the computer understands what you want it to do. Every program is written in a programming language. Everything you do on a computer was written in some sort of programming language. Once you begin to understand how a programming language works, you will be able to write your own programs!

Programming Languages

There are quite a lot of different programming languages. Some of the examples that we will demonstrate later will be written in a programming language called Java. Simple because it is some what on the easy side to learn. Some other good beginner programming languages are Python, Ruby, and C++. Listed below will be some pros and cons of each of those languages, along with some popular uses for those languages.

Programming Language Comparison

Language
Major Uses
Java
Mostly mobile/web applications.
C++
Can be used everywhere.
Python
Can be used everywhere.
Ruby
Can be used everywhere.
PHP
Mostly used for web/servers.
HTML
Used to design websites.
CSS
Used to build layouts.
Perl
Used for servers.
SQL
Used for servers.

Easiest Language To Learn

5 stars for Python

Programming Language Basic Concepts

There are 5 basic topics you need to understand that have to deal with any programming language. That is:

  1. Variables
  2. Control Structures
  3. Data Structures
  4. Syntax
  5. Tools

After understanding these 5 basic subjects you will be well on your way to creating that ideal project you have had in your mind that brought you to this blog post!

Variables are just like Bucky said in the video, they are placeholders. Variables are essentially the backbone to every program ever created, also the backbone to any programming language. Variables are pretty much storage boxes that you gave a name and a type. Inside of that storage box you put the data or the value of it. So for example, if we wanted to store a users name to our website, we would set up a variable called userName and insert the user's name into that variable so we can call it later. As I said above, you would assign it a type as well. So in some languages such as C++ or Java you will have to define the variables type along with it's name. In python you simply just have to assign a name to the variable as you saw in the video above.

Here is an example of what defining some variables would look like:

- Java example:

string userName = "Brian"
int userAge = 27
string userGender = "Male"
double awesomenessLevel = 99.9

- Python example:

userName = "Brian"
userAge = 27
userGender = "Male"
awesomenessLevel = 99.9

As you can see, in Java you are required to define the variable type and name before giving it a value. In Python you would simply use the variable name, the language will do the rest for you. There are a lot of types when it comes to data types though, string, integer, and double, are the most popularly used types. So cool, we have these variables, now what can we do with them!? Well lets take a look at control structures and try to make some sense of all of this.

Control Structures

Programs run in a sequence structure. From top to bottom line after line. So it runs the first line of code then goes directly to the next. Control structures change that based on criteria or conditional criteria. So control structures are all about the flow control of the program. There are a few different types:

  • If-Then Statements
  • If-Then-Else Statements
  • While Loops
  • Do-While Loops
  • For Loops

Don't worry, these are quite simple to understand. For "if-then statements", if the variable is true, then do this task. An example:

x = 10
if x = 10:
	x += 1

As you can see the if statement checks to see if the variable equals 10 and then if it does it adds one to it.

For "If-Then-Else" statements, if the variable is true, then do this task, else do this. For example:

x = 10
if x < 9:
	x += 1
else:
	x -= 1

For the "if-then-else" statement you can see that x = 10 but it is checking to see if x is less than 9, since it is not less than 9 it runs the code after the "else:" line, which subtracts one from the variable.

For "while loops", while the variable is true, do this or these tasks. For example:

x = 0
while x < 10:
	x += 1

As you can see above, while x is less than 10 it adds one to x, once x is equal to 10 the code will break out of the loop and continue moving forward.

For "do-while loops" it does the task first, and then checks to the criteria. For example (this one looks different because this is a java do..while because python doesn't have one):

int x = 0;
do
{
 System.out.printIn("x is : " + x);
 x++;
}
while(x < 10);

Besides the confusing syntax, which you will read about shortly, you can see that the while check is done after the statements have been ran. You would use this when you want to be assured that the code that would be looped is at least ran once before the condition check.

The takeaway from all of this is that you can compare and check variables based on different criteria or control structures to make the program jump around your code to make it do different things.

Data Structures

Data structures are quite simple to understand. They are the way you store and organize data so that your program can be run more smoothly and efficiently. Simple, enough right? No. It sounds a lot easier than done for beginners especially.

The first time I wanted to create a bunch of contacts my code looked something like this:

contact1 = "Brian Peter"
contact2 = "James Bond"
contact3 = "Karate Kid"
contact4 = "Chelsea"
contact5 = "Dominic Lee"
contact6 = "Rocky Lee"
contact7 = "Lilly Anne"

Well, it looks right, and it is. It is one hundred percent correct, there are 7 contacts there with different string values. Though there is a much more efficient way to write that code. Instead of the program reading 7 lines of code, it can simply read one and have the same effect. (I know it doesn't sound like much but once your program is thousands of lines long, it begins to help.) Here is the one line example:

contacts = ["Brian Peter","James Bond","Karate Kid","Chelsea","Dominic Lee","Rocky Lee","Lilly Anne"]

So what we did was take those 7 variables and put them into one list. Much more efficient than reading 7 different lines of code. We restructured our data structure to make our program run more efficiently. As you begin to venture off into the language you wish to learn you will want to learn about data structure and what you can do to make your program more efficient. The other thing you are going to need to learn is the syntax.

Syntax

Syntax is something that is tricky at first but once you play with it for a while you will understand it quickly. It is the way your symbols are combined to correctly structure that programming language. Some languages require semi-colons at the end of every line of code and some require opening and closing brackets around blocks of code and some don't.

This is where it is super handy to pull out that programming languages documentation and study the syntax as you are coding to ensure you aren't getting a silly error over and over simply due to syntax errors.

Here is "Hello World!" in JAVA and Python:

// Java example:

System.out.printIn("Hello World!");
# Python Example:

print("Hello World!")

Notice that the difference between the two are quite huge. Some languages require a lot more than others. So make sure you double check and even triple check the syntax of the language that you are learning!

Tools

This is a hard section for me to cover because I don't know what specific language you are wanting to dive into. So the biggest take away from this section is to do research in what the best tools are for that particular language. I will list a few for a couple of languages but again, do your research here and see if they will help you before you swear by them!

Java

  • Java Development Kit (JDK) - Downloadable from the Oracle website.
  • Javadoc - This is a documentation generator

Python

  • PyCharm - jetbrains.com This is a notepad editor that helps with syntax!
  • Pydev with Eclipse - Another IDE of the free tier.
  • Pygame - if you want to make games!

Conclusion

That is it! That is it? Really? You can now program knowing those 5 basics. You will have your mind toolkit ready to rock and roll. Now just select a nice beginner language to begin with and dive right in. Just remember, don't forget the syntax! Commas and semi-colons tend to be the death of us!

Best of luck!

Why do you want to learn programming?

See results

Comments

    0 of 8192 characters used
    Post Comment

    • Brian Peter profile imageAUTHOR

      Brian Peter 

      2 years ago from California

      Linda,

      Thank you very much! I was nervous because this was my first time ever doing something like this. So far it seems to have been doing pretty well. Time to begin the next!

      Brian

    • Linda Robinson60 profile image

      Linda Robinson 

      2 years ago from Cicero, New York

      Hello Brian, so nice meeting you. And welcome to hubpages. Absolutely loved your hub, very informative and so well written and such in depth detail and interesting and easy to understand descriptions, awesome. You are an excellent writer and I look forward to following you and reading many more of your hubs. Linda

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)