Thursday, 2 January 2014

HOW TO: Programming: Episode 1 - Basics

Programming. Give it a go!

In this tech savvy world, it's hard not to encounter a computer in your daily lives, and indeed if you are reading this blog... Well, you are using a computer right now (obviously!). Many of us go about using 'applications' without even a thought to the work that goes into producing them for our enjoyment. Programming may seem like a daunting task, but really it's very fun and simple to get into!

If you've read this far then I'm going to assume that you'd like to know more about programming, maybe you might want to give it a go yourself? If you do, then you're in the right place because with the miracle of the internet you can give programming a try without even needing to download anything to your computer. 

http://ideone.com 

IDEOne is a wonderful website that allows you to program online without needing to download any software onto your computer's hard drive. It is an online 'Integrated Development Environment', all this means is that it's somewhere you can write code and it will produce an output from what you typed into it. 



Once the website has loaded you should see this on your screen. Immediately you will notice that there is some strange writing inside of the IDE box. This is JAVA, a very popular programming language, but I am not going to start you off with JAVA, I want to start you off with something called Visual Basic.NET. To change IDEone's environment to Visual Basic.NET you need to click on the button that says 'Java' underneath the programming window where the 5 buttons are. Clicking on this shall bring up a box with an array of programming languages to choose from, but we want to select VB.NET from the list, which is on the second column at the bottom:






Once this has been clicked on, the JAVA code that we witnessed earlier will have been replaced with sample code from the programming language 'Visual Basic.NET' commonly abbreviated to 'VB.NET'.



Let's break this code down:

Imports System - This is a short piece of code that will import a 'library' into the IDE. The 'System' part of this code is telling IDEone that you want to import the 'System' library, which is the core library of VB.NET. Libraries are sets of preset instructions that you can write which are then expanded ~behind the scenes so to speak~ into larger pieces of code. 

Public Class Test - Without getting into to much detail, VB.NET is an 'Object Oriented Programming Language', this means that it works with blocks of codes called objects. Objects contain two main components: The code and the data. A class is the top dog, defining the parameters, variables and events of an object. Once a class is defined, as many objects relating to that class as you want can be created. 'Public' means that the program in its entirety can access this class, and the 'Test' part is simply the classes name. 

Public Shared Sub Main() - 'Sub' unfortunately doesn't refer to the sandwich, but rather a shorthand way of saying 'subroutine'. This is where any code that you want executing should go, inside of a subroutine. Subroutines perform the operations that produce outputs but shouldn't be confused with 'functions' which actually produce the outputs. A subroutine can be as long or as short as you want, containing mathematical code or simply text for output. The parenthesis are there for something called 'arguments', but don't go writing swear words in the brackets, I will leave explaining arguments for another time. 

End Sub/End Class - 'End' statements are simply to mark the end of some code, simply book ends!

EXCITING PART! - Now to actually write some code of your own!

Imports System
Public Class MyFirstProgram
Public Shared Sub Main()
Console.Writeline("PUT ANYTHING YOU WANT HERE!")
End Sub
End Class

Once you have copied and pasted that, you may click on the 'RUN' button:

Or... You could personalize this code. Where I have written 'PUT ANYTHING YOU WANT HERE', change that text to anything you want, but leaving the 'Console.Writeline("") intact, only changing the text inside of the speech marks. Once you click run you should see the screen change and your text output!

Now you have written your first program and taken your first steps into the wonderful world of computer programming. Well done. I will do another lesson next time on doing simple maths within VB.NET.

Thank you for reading, 

Joseph Wright: SCOTech.

IDEONE suggested by Harrison Taylor. Thanks!


Welcome

Welcome!

Ah! Hello. Like many, you have probably got lost somewhere strange on the internet in bewilderment and have found my blog. I'd like to welcome you, welcome! My name is Joseph Wright and this is my blog: SCOTech. On my blog you will find me writing regular articles about technology and the world of computers, so if you happen to like those things then please stick around... Maybe even add me to your favorites so you can keep checking back? I don't bite. 

I love technology as much as the next person (unless you're a technophobe, don't worry though... I cater for you too!), so on my page you will find many stories about technology, new and old! Useful tips will be a'plenty also, with help finding your way around computers and mobile devices. 

I can be a rather opinionated person, so I will keep my opinions short and sweet, and preferably in a section away from 'How-To's' and the like. 

I hope you enjoy my sweet, tech saturated blog! 

Thank you for reading.

~Joseph Wright: SCOTech.