How to Learn Programming Languages in 1 Day (using Google)

How to Learn Programming Languages in 1 Day (using Google)

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI

Оглавление (3 сегментов)

Segment 1 (00:00 - 05:00)

Have you ever asked the question: hey, how many programming languages do you know? I used to ask this question a lot because I thought that knowing more languages meant you're a better programmer. Now, think about this. How long does it take to learn a new language? Maybe three months? One month? A week? What about one day. Seriously. Some programmers can join a new team, learn a new language, and start contributing code, in just one day. How do they learn so fast? They can do this because they're very good with a particular tool called google. Today we're going to take a look at how to learn new programming languages in one day, using google. To set this up, I'm going to do a project I've never done before, using a language I've never used before, and I'm just going to rely on google to figure things out, and I'll show exactly what I searched and why. I'm going to build the game 2048 using a programming language called go. 2048 is a game where you slide these tiles around, and if two tiles have the same number they combine into a bigger tile. And you're trying to get the number 2048. And go is a programming language created by google in 2007. It's pretty popular for back-end programming, but I've personally never used it before. So I start off with a basic go program, and the first thing I search is "go arrays" Why do I search this? A programming language can only do simple things, such as display some text, create a variable, create a function, etc Let's call these "simple language features". What you're supposed to do is to take a problem, and break it down into smaller problems, and then keep breaking it down until you can solve it with simple language features. Let's take the game 2048. How could we break this down? Well first we need a way to display the game, and then let the player make a move, which in this case is sliding up, down, left, or right. And then we need to figure out how to slide the tiles around, and combine tiles. So we broke it down into three smaller problems, and I'm going to start with how to display the game, because that's the easiest one to start with. I'm going to save the game in a variable, as a list of numbers, and then I'm going to display it as text. So now you can see that I've broken down this smaller problem, into just simple language features and that's what I use google for. Now I know from other languages like Javascript, I can save a list of numbers in something called an array, and that's why I search "go arrays" I want to find the go version of an array. Notice I'm using javascript as a reference point. Having a reference point is really important when you're googling, because you can take a language you already know, and try to do the same features just in a different language. And this is how programmers can learn new languages in a day, they already know how to break down a problem and solve it using simple language features, they just need to google the syntax for the new language. If you're just starting out you might not have a reference point, so start off with doing a few tutorials, and get familiar with your first language. And then use that as a reference point going forward. Alright let's get back into our project, and the first result I get back is from golang. org so this is the official website of go. Now when you see a result like this, you're not supposed to understand everything here, you're just supposed to take the things that look the most relevant based on what you know from other languages. I'm just going to take this line here, and I'm going to play around with the array. I'm going to set some values just to get an understanding of how it works. And the next thing I search is go arrays in arrays. So the game is played on a 4x4 grid, and the way to represent this in javascript is to use an array containing four other arrays, each that represents an individual row. So I'm going to try to do the same thing in go. Generally I read a little bit of the result to see if it's what I'm looking for. This result says "how to define an array in go. " This is not really what I want because I want to define an array inside another array. Arrays in go with an example. This looks like the same thing, how to define a simple array. The next result says arrays, slices, and strings. I don't really understand what slices mean, so this might not be what I'm looking for. And the fourth result here says multi-dimensional array. So this is exactly what I'm looking for. Now I don't have to understand all of this stuff, I'm just looking for a specific line of code that seems relevant. So this is the line that seems the most relevant, I'm going to copy it into my code, and then play around with it, and make it fit into what I'm trying to do. So this is what it looks like when I print my grid as text, and I actually want it to look something like this, something similar to the actual game board. And I want the zeros to represent empty spaces, and if there's a number it represents there's a tile there. Just like before, I first break this down into simple language features, I'm going to loop through the grid. If the number is a 0, I'm going to print an empty space. Otherwise the number. And we'll print some vertical and horizontal lines in between. Basically I need to google loops, if statements, and we already know how to print some

Segment 2 (05:00 - 10:00)

text. It's the same kind of searches that we just did, so instead of doing it again I'm just going to fast forward through this video, and next we're going to take a look at how to use google to search for errors. Here I get an error that I don't really understand. It looks like this is a type mismatch, so I'm just looking for something in google that explains to me how types work in go. I'm just going to copy this entire error into google to see if I can get any insight as to what's causing it. This one is talking about a variadic function I'm not really sure what that means, I'm not sure what the dot dot means, so this is probably not what I'm looking for. So for this result, there's a lot of new terminology, that I've never seen before. I'm not sure what this code means, or this code means. I'm not sure what a struct is, so this is probably not what i'm looking for. And the next result also has a lot of syntax that I don't understand, so I'm going to skip this one as well. So the next result is actually in java, so I'm not making any progress here. I go back into my google search, and I'm going to reword this as go function type multi-dimensional array. I want to learn how to correctly give the type in a function for a multi-dimensional array, that's what I suspect the error is coming from. But looking at these results, it doesn't seem like I'm going to get the answer I'm looking for so I just go back into my code and just make sure that the types match, and then I'm just going to go with that. I'm going to give up on this search. Maybe at a later date I'll come back to it and learn some more about go. And then all of a sudden, I see this black and white percent sign. I'm not really sure what's causing this, I don't have an error message so I'm just gonna try to describe it as best that I can in google. The first thing I search is go print percent and this is not actually a good search, because there's many meanings for print percent. It might also mean how do you print a percentage sign in go, and that's exactly what the first result shows us. If you ever run into this situation, try to make your search queries more specific, so that there's no confusion. So now I'm going to search "go print percent sign at end of" I'm not really sure what I'm searching here, I just want to emphasize at end, because I'm seeing a percentage sign at the end so I don't want google to be confusing it with other meanings. And "at the end of" I'm not really sure what to describe this as. At the end of the output? command line? I just leave it as blank to see if google can autofill it for me. And after making my search more specific I see exactly what I'm looking for. There is a percent sign with an inverted background color, and this means that there is no new line character at the end. So all I have to do is just add a new line character at the end and it should go away. Alright, so that's mostly what I wanted to show you about using google, remember it's okay if you don't understand everything in the search results, sometimes you do have to reword your searches to make them more specific. I hope that makes sense let me know in the comments how you guys learn new languages, and what other tools you guys use besides google. For the rest of this video I'm just going to finish this game, there's actually not a lot of other google skills I can show you. I'm basically just doing the same kind of searches, which is searching for language features and errors. And I guess I'll show you how I broke down the other parts of this game, to give you more examples of how to break problems down into simple language features. After about 10 minutes this is the code I made for displaying the game like this. You can see it's a combination of loops, if statements, and displaying text, which is all simple language features. There's three more problems that I did for this project. The first one is how to create new tiles on the board. So after every slide, you can see that a new tile is generated at a random spot. And here's how I broke this problem down. I made a list of all the empty positions in the grid, I picked a random position from this list, and then at that position I set it to a two or a four. The second and third steps are simple language features, but the first step can be broken down even more. We'll create a new array, we'll loop through the grid, and if a position is empty, we'll add the row number and column number to our new array. And now we've broken down all three steps into simple language features, the only thing I googled here is how to add things to an array, and how to generate a random number. The second of three problems I did was how to slide tiles around and combine them if they were the same number. I had to sit down and think about this for 20 minutes, but basically we just have to figure out what happens to each row or each column. So let's say that we're sliding to the left, we'll loop through each row. If there's one tile, I just need to move it to the left. So I just need to change the numbers around. If there's two tiles, if they're the same number we'll combine them, and then move them to the left. Otherwise we just move both of them to the left. And the logic is pretty similar for rows with three tiles and four tiles. For this problem, I'm just using loops, if statements, and setting values in a grid

Segment 3 (10:00 - 11:00)

which I already learned how to do from earlier. So I actually didn't have to google anything here. And the final problem I did was how to let the player slide the tiles. I let the user type in some text, this is another thing you can do in other languages. Then I'll use WASD to represent the four directions the user can take. If they entered a "w", I'll slide up. If an "a", I'll select left, and so on. And I'll put this all in a loop until the game is over. Now these are all simple language features, and I only had to google "how to wait for command line input in go" And that's pretty much it for this project, I know there's features that are missing, such as how to check if the user is blocked, or game is over, but this is the core functionality of the game. It took me two and a half hours, which is not bad considering I'm using a new programming language, and just relying on google. Thank you for watching, my name is Simon from supersimple. dev I want to make a tech career possible for anyone. If you have any questions or comments, please leave them down below. As always you can contact me at supersimple. dev/feedback I'll see you in the next one.

Другие видео автора — SuperSimpleDev

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник