 What programming language should I learn? It's a question that's asked by people who want to learn how to program but don't have any experience. Where should I start? There's all these programming languages. Which one should I learn? Which one should I learn first? Should I learn more than one? The answer is, it doesn't really matter. It does, but it doesn't. There are people who are very argumentative, they think one programming language is better than another, and some are more suited than others for certain tasks. But for the most part, if you learn one programming language, you can at least understand and quickly pick up most other programming languages, unless you go really low level like assembly, which is very different. But anywhere from C up to Java, Python, Bash, you learn these and they're kind of interchangeable in many ways. I don't want to say interchangeable, that's probably not the best. Usually I equate it to this. My father doesn't speak Italian, but he claims he can understand Italian pretty good because he grew up around it. And since he also understands Italian pretty well, he also can understand Spanish pretty well, just by hearing it, even though he may not speak it well. You learn one programming language, you may not be able to sit down and write something in another language, but you could look at the code and understand what's going on. So what I'm going to do today is I looked up an example code. I wanted to start with C. C is a lower level language, not quite as low as assembly, but it's definitely lower than Bash or JavaScript. Well, I looked up some example codes and I just picked one at random, modified it a little bit and basically you give it a list of years, you loop through those years and it returns whether that year is a leap year or not. So it does a little bit of math, have different functions, arrays and loops. So I took that code, modified it a little bit, compiled it. Then I took that same code and with a few modifications, I converted it to JavaScript because JavaScript and C actually are very, very similar. Last time when I've written stuff in C and then I've gone to write the same thing in Java or JavaScript, did I say Java before? JavaScript, two different things. If you write something in JavaScript and you go to C or the other way around, lots of times it's very, very similar or almost identical code. Then I also wrote it a third time in Bash, which I'm actually a lot more fluent with and with Bash the way I wrote it, I could actually shorthand it a lot and make it a lot shorter. I'm going to show you that how similar they are. So let's go ahead and look at them on a computer. I'm going to run each one and then we'll compare this code side by side. I have... I don't want to say it in the video, but as always in the description of this video I have C code which I've compiled to a C binary here. I have a JavaScript of the same code and Bash the same code. So let's run each one. Let's run the C code first. There you go. It looped from the year 2000 to 2004 telling you which years are leap year. Then I'm going to say let's do the JavaScript one. The output is exactly the same and then we'll run the Bash one and again we have the same output. So now let's go ahead and compare the code together. We'll start with... Not the C, but the C code and then over here we will look at... We'll start with the JavaScript. Okay. So we have some comments at the top here and they're commented the same. And with JavaScript I had to say this is a script used the Java interpreter, the Node.js interpreter. With C we had to include some libraries. Okay. Beyond that the code is going to be almost identical. So let's go ahead and move up here and we'll line this up. So we have some functions here. So here I declared a function. I called it year check and we passed a variable called year. Here we're doing the same thing but we're saying that it's a Boolean meaning it's going to return true or false. So we're checking year. And we're passing at a variable here. We're declaring it's int so a whole number basically. With JavaScript you don't have to declare that it's going to recognize it. So that's a little bit of a difference but clearly the same. The rest of this function, so this function is exactly what I copied from the example site and I did not have to change it at all from C to JavaScript. It is exactly the same. Comments and everything. Okay. So let's look at the main function down here. So we have a main function. And here we're going to say int so it's going to return something. Over here with JavaScript we're just going to say function. It's a function. Okay. And we're calling the main. And here we're going to create a variable. I'm sorry an array which is a type of variable. And we're going to give it an array of numbers which is very, very similar. Here we're saying int because they're numbers. Here we're saying let other than that we have curly braces here and over here we have brackets. Other than that it's the same. And again if you know this you're going to look at this and go, okay clearly this is an array. Right? Next over here I'm getting the length of the array which is this line here. With the JavaScript you can shorten that just to give it an array and ask for the length. That's kind of a built in function there. So it's shorter so I was able to put it right in the for loop here. So it saves us the line. I could have put this down in here but it's so long I broke it up into two lines. So now we have a for loop. We're saying okay we're creating a variable called i saying it to zero. We're going to say while it's shorter than the length of the array loop and add one to it each time. We're saying the same thing here. Create a variable i equals zero as long as it's shorter than the length of our array add one. Right? So we got, I don't have them lined up exactly the same but almost identical lines there. And then the rest we're passing it to the function. We're saying here's the year. Same thing here. And then if it returns true here we're printing f which will print it to the screen and here we're saying console log. Again they're written slightly different but if you know one you can look at that and you go okay you might not know oh I have to do percent u and then put the variable over here where here you just kind of put it in the line with curly braces and a dollar sign. So you may not know how to write it and see but looking at it after knowing this you understand what this is doing. And then if it returns false we're going to print that it's not a leap year and print the year. The only other difference is C is automatically going to run your main function where in JavaScript we have to call the main function so that's what this is doing at the bottom here. And actually this could have gone at the top because JavaScript doesn't isn't doesn't matter the order of things you can have functions below where you call them or above. Okay so we have that let's go ahead and load up the bash version of it. Okay we'll go up in our C code here and again we don't have to import any libraries for the bash code here but again we're creating a function called year check same as over here we don't put the variable of the year in here we're going to pass it and the first variable is going to be dollar sign one and we're saying that equal to year and saying let means that it's an integer. Okay so so far a little bit of difference there but again if you if you see here you're like oh year equals what I'm passing it if you know that you come over here and you go okay it's we're looking for a variable year that's giving past next now there's a lot of different ways you can write out math problems in bash and I chose this example here but there actually are ways that I could have made it look more like this one over here but we're doing the same thing we're taking the year that's past we're dividing it by 400 and getting the remainder that's what the percent does it's and it's kind of universally you can see in JavaScript we did it in C we did it in bash we did it we're saying percent 400 that's not getting the percent of something that's dividing the year by 400 and getting the remainder if the remainder is zero we mean it's evenly divisible by 400 we're returning true and in C I think I could put zero here bash I'm pretty sure you want to be zero you can't put true here I think anyway but when you're in programming you know that zero equals true and one equals false that's kind of universal so again I return true here but I'm pretty sure I could have gone in here and put zero so again it's written kind of different and I could have written this with an if statement here I could have done if then return about trying to do it in the same number of lines so I shorthanded it a little bit and again with bash I'm more familiar with it I could have written this whole function in probably one line it might have been a little bit long of a line but I could have shorthanded it to one one liner but I was trying to line it up so they look similar so we're gonna say if it's divisible wind by 100 and you get zero remainders well then it's not a leap you're returning false same thing over here we're doing the math we're returning one which is false here we're checking okay is it divisible by four evenly divisible by four returning zero well then if that's true then we're going to return zero which means true and then if we get past all those my indentations messed up a little bit here that's more of just how it ended up getting indented when I wrote it we're gonna return one okay now let's look at our main function so we'll come over here and again it's going to be very similar we have our function called main which here we do have to call because it's not gonna call that by default and bash is you know the order is important so we had to call main after we declared it again with JavaScript we could have put this at the top even though the function was down here anyway here we're declaring a year so you know looking at this that this is going to be an array if you're if you do any programming in any language you're gonna say okay this is an array so you're like okay we're declared this is how you declare an array even if you didn't know that even if you're looking at most languages where you do something more like this it's clear that this is an array once you get used to programming again we're gonna start a for loop here in bash this is how you get the length of an array and there's actually a way where we could just loop through the array without getting the number but again I'm trying to do it similarly but we got the the length here and then we're gonna loop through it we're going to run that function and pass it the year here we're gonna run this function and pass it the year and again instead of printf I'm doing echo although in bash you can do a printf which is very similar to this I probably should have wrote that over it might be exact I might be able to copy and paste this code over here I'm not sure why I changed that but again in most languages you're going to have print or echo are going to be for or printf to print to a screen java script it's console log but yeah again very very similar and then at the end we're going to return zero which isn't even really necessary here with C if you didn't do that especially if you don't put void there it might throw an error but which still work so I hope you can see those are three very common languages but very different languages but the code was very very similar so again if you learn one programming language and you get efficient at it you're going to be able to understand many other languages again if you get really really low level like like assembly it's it's gonna be very different and even with see see you can write simple stuff like this but you can also get into memory pointers and having to collect garbage and free up garbage and stuff like that you can get real complex with see where the higher level languages take care of that for you but yeah it doesn't really matter you know look at what should I do java script if I was to pick a language I probably recommend most people learn java script even though there's a lot of people out there who hate and again people will argue this language is horrible that language is horrible I like java script because every device already supports it because every modern device whether you're running linux mac os windows i ios android they're all gonna have web browsers built in and if you write something in java script you can run it in someone's web browser it's already there where if you write something and see you got to compile it for different operating systems and processor types bash is pretty portable but most other interpretive languages you have to like bash or python those run natively on most devices but you have to install the interpreters java script is just real easy to get your feet wet and get it out there and as I showed you it's very very similar to see the way it's written at least for you know the basic structure of things but don't let anybody tell you don't learn this language and now I'm gonna tell you don't learn this language my only suggestion is with most things avoid proprietary stuff most programming languages you're not gonna have an issue but I would say avoid things like visual basic you know through windows or anything that contains proprietary libraries and interpreters or compilers you write a program you want it to be your program you don't want a couple years from now for them to lose support and then all send the code you wrote isn't isn't supported anymore and they and you're just thrown aside you want control over your own code so to avoid things like that basically anything made by microsoft I'm sure Apple I think they have some sort of scripting language for their desktop machines laptop machines but again you learn bash you learn basic shell scripting that's especially with windows now has windows subsystem or Linux subsystem for windows but even if you go back to windows XP you can install bash as a single binary or even busybox which is gonna be similar enough that has all your tools there so yeah that's my only suggestion when it comes to programming languages is make sure you don't pick one that is based on proprietary software just like anything else you do computer wise avoid the proprietary stuff right so yeah other than that look at what you're gonna do for it on your you know on a computer if you're writing code for doing daily tasks on your system or server it's fairly common to do that with something with some sort of shell script like bash but you could write it in C right there's no reason you could write it in JavaScript or Python there's nothing against that it's just usually system stuff is done with a shell script but there's nothing to prevent you from using other languages so I hope that is confusing enough that you have no clue I'm talking about but just don't worry too much about what language just pick up a language and start learning and practice every day until you understand the concepts once you understand the concepts and basic structures you can then move to another language and it doesn't hurt to learn multiple languages for different things I use very little PHP but on servers I use PHP to interact with databases because that's the one of the easiest ways to do it but other than that I don't really use PHP so learn programming because you don't control your machine unless you control the code thanks for watching filmsbychris.com that's Chris with a K and I hope that you have a great day I don't think I said in the video but as always in the description of this video will be linked to all the example code from the video so you can try them yourselves have a great day