HOW TO PROGRAM - Getting Started!

HOW TO PROGRAM - Getting Started!

If you want to learn how to program but don't know where to start this, video should help point you in the right direction. The mother programming can be a large and confusing place, but let's try and break it down. I find that lots of people who have never tried to program before think of it as one skill being a programmer means how to do one thing. However, the truth is pretty far from that. There are many different programming languages and ways to program.

So this brings us to the first decision. An aspiring programmer has to make what language do I start with, and the answer is well, it depends there are a lot of languages to choose from and each have their own strengths and weaknesses. But, most importantly, what language is right for you is going to completely depend on what you want to make for this series. I'Ve chosen to go with c-sharp, no, not that c-sharp this c-sharp. Now some of you might know that I'm a bit biased here. After all, our entire YouTube channel is built around game development and the most public game into today. Unity uses c-sharp as its programming language, but I do believe that c-sharp is a great starting point for most developers. This is not because it does everything perfectly. No language does, but because of its diversity you see, c-sharp is a widely used programming language. It can be used to develop for mobile, PC, Mac and even the web, and if you want to get into game development, you can get started with unity right away.

It'S also based on C, which makes it really similar to other popular languages like C C and Java. So if you ladie want to pick up another programming, language chances are that the transition won't be too difficult. So in this short series, you will learn how to get started programming in c-sharp and make your first programs the videos are going to focus on the absolute basics. So, whether you want to make video games or web apps, you should be able to apply everything right away, but before we get coding, this video is sponsored by Jason Wyman. Sometimes, when learning new skills like coding, it can be hard to find the motivation to learn by yourself. In this case, joining a course alongside other students and with live help from a teacher can be a better choice. Jason has made an awesome course on game architecture which will teach you how to write clean and proper game code.

You'Ll have access to live, help from Jason himself and a discord channel where you can chat with your fellow students. This will also give you access to the game. Dev mastery course which will teach you how to a variety of game types in unity, so make your first game by signing up now simply click the link in the description now, once we've chosen the language we want to write in, we need to pick a code. Editor many modern code editors will not only allow us to write code but also help with debugging and building our program. You'Ll see some of these referred to as an IDE or integrated development environment, but don't let that scary title throw you off.

Of course, there are a lot of code editors to choose from and most of the time, it's a matter of personal preference in this series we're going to be using Visual Studio code. Vs code is Microsoft's lightweight code editor, it's great because it can be used to program in almost any language. It'S multi-platform open source and it's 100 % free. Now, in this series, we're going to be creating a console application. If you don't know what that is, here's one, I agree with you that it does not look very appealing, but it's great for learning how to program, since it allows us to focus on the language itself without too many distractions, but creating any kind of software completely From scratch is a huge challenge; instead, we normally use what is called a framework for now. You can think of a framework like a toolbox with a bunch of tools inside that will help you accomplish your job better and faster. It'S kind of the foundation that we build our program on top of we're going to use the dotnet framework. This is also created by Microsoft and it can be used to create pretty much any kind of application.

So don't worry, You don't need to understand exactly what a framework is just know that we need one for now and with that explanation in mind, let's get dotnet and vyas code set up and run our first program get it. I ran a program, so the first thing that we want to do is install the.net core I'll, of course, have a link to this in the description simply follow that link, select your platform and hit install then simply follow the installation instructions that you see on this Screen it should be pretty straightforward once you're done, we can simply hit close and next up, we want to install Visual Studio code again now, of course, have a link for this in the description simply download and follow the installation screen, and once it's done, we can Go ahead and open up visual studio code now this code by default is really lightweight and it doesn't have the necessary tools for us to start writing in c-sharp.

Instead, we need to install this as an extension. So let's go to the bottom icon. In the left, hand, side and hearing go ahead and search for a c-sharp, let's like the first one as weensy c-sharp by microsoft, and that's emily go ahead and hit install and once it's finished, we are ready to start writing c-sharp. However, there are actually a lot of really cool extensions available here, one that I personally like is the vs code icons. So I'm going to search for icons here and select the vs code icons and install it. It then prompts me to select it as an icon theme here, which I'm gon na. Do you can also hit this button right here and all this does is just add some nice user friendly icons to all of our files, and with that we can go ahead and close down this page and go to the top icon here, and we are now Ready to create our first project so to do that, let's go to our desktop here and let's create a folder that is going to store our project.

I'M gon na call it my awesome program and right now. This is, of course, completely empty. Let'S go ahead and fill this up with a project. To do that, we go inside of this code. We hit open folder. We navigate to the my awesome program, folder and hit select and, as we can see, it's now opened up in BS code.

But of course it's still completely empty, so let's create a new project in here to do that, we go to terminal at the top here and create a new terminal. This is a command line interface that allows us to call certain commands and, as you can see here, we're currently inside of the my awesome program folder on my desktop, so we can go ahead and call a command in here called dotnet space new in order to Create a new project here and we're then going to type console in order to use the simple console template. That'S it enter and, as you can see, this creates some files in our project. The most important one is the program dot CS file. This is the meed of our program and it's why we're going to write our first lines of code now for some of you, the font size might be very small by default, so to change this, we can go up to view and open up the command palette. You can also press control shift P, and what this allows us to do is search through all kinds of commands.

In our case, we want to change some user settings, so, let's simply search for user settings and indeed here we can open the Preferences and go under user settings and right here we can change the font size. Now, I'm just gon na set this to something. Like 24 - and I'm also going to search at the top here for code lens and here where it says edit their code lens, I'm going to disable that what this does is it overlays some extra information on top of your code - and I find that's a bit Confusing for a beginner, so I recommend just turning this off and that's it for a setup.

Now we're not going to get into the code itself in this video instead I'll just quickly show you how to run your program as you're going to be doing that a lot now. If we look at our code here, we can see that by default. That'S a bit in here, and this might look really scary, but for now we can ignore everything, except this line right here. This line writes out the words hello world in our console. So if we run our program now, it should simply display hello world to run our program. We can go to our terminal and type dotnet space run and hit enter, and indeed it says hello world, but typing in this command. Every time we want to run our code is a bit annoying. Instead, we can tell V s code: how to run our program.

Let'S again, press ctrl shift P to open up the command palette. Let'S search for generate and select, dotnet generate assets for build and debug and, as you can see, this creates two new files in our program: folder, launch and tasks. These files tell V s code. How to run our code while we're working on the program by default? These are set up correctly, except that we want a program to open in a new window when we run it instead of just having it down here in the internal console.

So to change this, we go into a launch, dot, JSON file and look for a property called console and we're simply going to change this from internal console to external terminal, with a non capital e and a capital T.. Now, if we save this and go to our program, we can actually run our code by simply going run, start debugging and what you'll see here is a bunch of things happening. You will see some things flashing on your screen. You will see things printed in the debug console and you might even see a window quickly open and then close immediately.

And the reason for this is not that our program didn't run. It did actually start, but it also closed as soon as the program was finished and right now it's finished as it said hello world. So we didn't even really get a chance to see it. So, to fix this, let's add a line underneath here, So I'm gon na add a new line here, and this line here is going to tell our program to wait for some input. Before closing. For now we can just write after me, I'm going to type console dot, read key and remember. Your capitalization is important here, Open and close parenthesis and a semicolon. So this line is simply going to say: hey we're going to wait for any kind of input from our keyboard and this way, if we save this and go run our program so we'll go to run, start debugging or you Can simply press f5. We can indeed see that it opens up. It displays hello world and when we then press a key, I'm just going to press the spacebar here.

The program is finished and it closes automatically awesome. So that's our first program and that's pretty much it for this video if you enjoyed it, make sure to subscribe and ring that notification bell. So dome is the next one in the next video we're going to start. Writing some code Also don't forget to check out Jason's course on game architecture, learn how to write clean game code by simply clicking the link in the description and get the game dev mastery course included for free and that thanks for watching - and I will see you In the next Video, thanks of the awesome, patreon supporters who donated in April and a special thanks to blank lost, violin stuff forever free Samara,