Return to Video

How To: Beginner Programming: Part 1 - Hello World

  • 0:06 - 0:08
    Hello, and welcome to How To: Beginner Programming,
  • 0:08 - 0:11
    a multi-part guide to your first steps in the world of programming
  • 0:11 - 0:13
    In these following episodes, I'll be demonstrating
  • 0:13 - 0:15
    the basic principles of programming,
  • 0:15 - 0:17
    from creating your first application,
  • 0:17 - 0:19
    to developing your own objects.
  • 0:19 - 0:23
    Now, don't worry yet if you have no idea what any of those are,
  • 0:23 - 0:24
    we'll get to that.
  • 0:24 - 0:27
    In the first episode, I'll demonstrate how to set up your
  • 0:27 - 0:29
    programming environment, or "workbench",
  • 0:29 - 0:31
    and run a simple 'hello world' command,
  • 0:31 - 0:33
    commenting on each step throughout
  • 0:33 - 0:34
    so you guys know what's going on.
  • 0:34 - 0:35
    First things first:
  • 0:35 - 0:38
    You'll need an environment to work in, as well as a language to use.
  • 0:38 - 0:41
    Now, this is entirely up to preference,
  • 0:41 - 0:44
    but I'll be using Visual Studio Express, which is available for free.
  • 0:44 - 0:52
    I'll leave a link in the description.
  • 0:52 - 0:55
    It's available from the website for free,
  • 0:55 - 0:57
    and I'll be using C# (pronounced "see sharp") to program.
  • 0:57 - 1:00
    I suggest those of you who have no idea what you're doing,
  • 1:00 - 1:02
    or are first-time learners,
  • 1:02 - 1:03
    also follow along in C#.
  • 1:03 - 1:07
    Otherwise it might get confusing with syntax.
  • 1:07 - 1:10
    Once you've got it downloaded and installed,
  • 1:10 - 1:15
    open it up and start a new project.
  • 1:15 - 1:20
    Now, this will display three basic programming languages.
  • 1:20 - 1:22
    Visual Basic, which I would not recommend,
  • 1:22 - 1:28
    is good for beginners, but it's a bit too simplistic,
  • 1:28 - 1:30
    and not pretty to use, either.
  • 1:30 - 1:36
    Visual C++, which I would not recommend for beginners,
  • 1:36 - 1:38
    because you have to worry about so much [more than C#].
  • 1:38 - 1:41
    For a simple 'hello world' program, C++ is simple enough,
  • 1:41 - 1:44
    but when you get to more stuff it gets a bit more complicated,
  • 1:44 - 1:45
    especially with arrays.
  • 1:45 - 1:47
    Again, we'll get to that in due time,
  • 1:47 - 1:50
    but for now we'll be using C#.
  • 1:50 - 1:52
    Start a console application.
  • 1:52 - 1:55
    Now this is just a basic "black box window" that pops up,
  • 1:55 - 2:00
    and you can input and output text to it.
  • 2:00 - 2:03
    I'll be calling it "HelloWorld"
  • 2:03 - 2:05
    because that's what we're going to be doing with it:
  • 2:05 - 2:07
    outputting "hello world" to the screen...
  • 2:07 - 2:09
    exciting stuff!
  • 2:09 - 2:13
    This has created the project, as well as a "main" method.
  • 2:13 - 2:16
    This is where all of the code we're going to write
  • 2:16 - 2:20
    will be ran from.
  • 2:20 - 2:22
    Every application has one of these ["main" methods].
  • 2:22 - 2:23
    Whenever you run an application,
  • 2:23 - 2:27
    it will look for the "main" method and run whatever is inside.
  • 2:27 - 2:30
    It will continue throughout until it reaches the endpoint.
  • 2:30 - 2:32
    For the purpose of the first video,
  • 2:32 - 2:35
    we're just outputting a message to the console window.
  • 2:35 - 2:36
    To do this, we write
  • 2:36 - 2:41
    "Console.WriteLine()"
  • 2:41 - 2:46
    and then whatever message you want inside here.
  • 2:46 - 2:48
    For the purpose of this, again,
  • 2:48 - 2:50
    "Hello World!"
  • 2:50 - 2:53
    Whenever you're starting a new language,
  • 2:53 - 2:58
    you can usually find a "Hello world" example,
  • 2:58 - 2:59
    to show you the syntax [of the language].
  • 2:59 - 3:07
    So this is accessing the "Console".
  • 3:07 - 3:12
    And using the method, "WriteLine".
  • 3:12 - 3:15
    And passing the value, "Hello World!".
  • 3:15 - 3:22
    Now, every line you write, in most languages,
  • 3:22 - 3:24
    you have to put a semicolon at the end
  • 3:24 - 3:28
    as if to say, "That's the end of the line. No more on this line."
  • 3:28 - 3:32
    Otherwise, (showing an example)...
  • 3:32 - 3:43
    the program won't know what to do.
  • 3:43 - 3:46
    Once we've written this, we need a
  • 3:46 - 3:49
    "Console.ReadLine()"
  • 3:49 - 3:51
    which stops the program from closing,
  • 3:51 - 3:55
    so the user has time to actually read the message, "Hello World!"
  • 3:55 - 3:59
    If we ran the program without "Console.ReadLine()"...
  • 3:59 - 4:08
    it will just open up and instantly close!
  • 4:08 - 4:14
    So we use "Console.ReadLine()", or "Console.Read()"
  • 4:14 - 4:18
    to stop it from closing so we have time to read it.
  • 4:18 - 4:22
    All "Console.ReadLine()" does is it waits for the user
  • 4:22 - 4:24
    to input any text and then press enter.
  • 4:24 - 4:29
    When enter is pressed, the value is passed into the "Console.ReadLine()",
  • 4:29 - 4:35
    and if we had something here, like (example)...
  • 4:35 - 4:41
    The variable will be assigned the value of the user's input.
  • 4:41 - 4:42
    For now, don't worry about that;
  • 4:42 - 4:45
    we're just displaying "Hello World!" to the screen, like this...
  • 4:45 - 4:53
    Press enter when you're done.
  • 4:53 - 4:58
    That's it for a "Hello world"!
  • 4:58 - 5:00
    That's part one of, "How To: Beginner Programming".
  • 5:00 - 5:02
    Further parts will be released shortly,
  • 5:02 - 5:06
    but I'll leave a gap between videos to allow you to ask questions,
  • 5:06 - 5:08
    and I'll answer them at the start of the following part.
  • 5:08 - 5:13
    The gap between the first and second episodes won't be too long.
  • 5:13 - 5:20
    Maybe do a bit of research before the next episode,
  • 5:20 - 5:26
    so you're a bit ahead of everything,
  • 5:26 - 5:30
    and any assumptions I accidentally make will make sense to you.
  • 5:30 - 5:34
    Thanks for watching, and leave any questions in the comment section below,
  • 5:34 - 5:37
    and I'll try to answer them at the start of the next episode.
  • 5:40 - 5:41
    Thanks for watching!
  • 5:43 - 5:44
Title:
How To: Beginner Programming: Part 1 - Hello World
Description:

more » « less
Video Language:
English, British
Duration:
05:49

English subtitles

Revisions