1 00:00:00,460 --> 00:00:02,930 A paradigm is a way of doing something, so 2 00:00:02,930 --> 00:00:05,780 a programming paradigm is a way of programming. 3 00:00:05,780 --> 00:00:11,010 A few common programming paradigms are procedural, functional, 4 00:00:11,010 --> 00:00:12,930 and object-oriented. 5 00:00:12,930 --> 00:00:17,240 Here at Treehouse, we primarily teach object-oriented programming. 6 00:00:17,240 --> 00:00:19,840 Let's take a brief tour of these practices and 7 00:00:19,840 --> 00:00:24,110 then look at the similarities between the languages we teach at TreeHouse. 8 00:00:24,110 --> 00:00:28,240 The procedural approach describes step by step the procedures that we 9 00:00:28,240 --> 00:00:30,740 should follow to solve a specific problem. 10 00:00:31,860 --> 00:00:34,720 C is a classic procedural language, [SOUND] and 11 00:00:34,720 --> 00:00:36,784 here's what C [SOUND] looks like. 12 00:00:36,784 --> 00:00:38,820 This code says to print Hello World! 13 00:00:38,820 --> 00:00:40,200 on the screen. 14 00:00:40,200 --> 00:00:43,860 Just like you learn the alphabet on the first day of kindergarten, 15 00:00:43,860 --> 00:00:47,410 the first thing you learn in code is to print the phrase, Hello World!, 16 00:00:47,410 --> 00:00:47,960 to the screen. 17 00:00:49,160 --> 00:00:52,790 It's obviously not the only way to get started, but it's a good, 18 00:00:52,790 --> 00:00:53,930 logical first step. 19 00:00:55,260 --> 00:00:59,640 But here at Treehouse, we always like to do things a little bit differently. 20 00:00:59,640 --> 00:01:02,414 So instead, what do you think this would print out? 21 00:01:02,414 --> 00:01:05,785 [SOUND] If you're thinking Hello Treehouse!,. 22 00:01:05,785 --> 00:01:07,257 you're correct. 23 00:01:07,257 --> 00:01:09,410 [SOUND] In functional programming, 24 00:01:09,410 --> 00:01:13,080 you look at program somewhat like mathematical functions. 25 00:01:13,080 --> 00:01:15,232 The function receives some input or 26 00:01:15,232 --> 00:01:19,331 information, and then uses that information to create an output. 27 00:01:19,331 --> 00:01:24,088 Lisp, Racket and Scheme are examples of functional programming languages. 28 00:01:24,088 --> 00:01:26,435 [SOUND] Now let's try printing [SOUND] Hello Treehouse! 29 00:01:26,435 --> 00:01:27,680 in Racket. 30 00:01:27,680 --> 00:01:30,195 Can you see where to put the words Hello Treehouse? 31 00:01:32,420 --> 00:01:36,396 That's right, it's in between the quotes, same as in the C language. 32 00:01:36,396 --> 00:01:40,993 Lots of programming languages use [SOUND] quote marks to show groups of characters, 33 00:01:40,993 --> 00:01:43,500 something that's usually called a string. 34 00:01:43,500 --> 00:01:47,534 [SOUND] Object-oriented programming is a very popular type of 35 00:01:47,534 --> 00:01:52,822 programming because it often uses code objects to mirror real-world objects. 36 00:01:52,822 --> 00:01:58,496 Each code object is usually made up of two things, attributes and methods. 37 00:01:58,496 --> 00:02:03,934 Attributes represent the data associated with that object, like a name, 38 00:02:03,934 --> 00:02:05,066 color or size. 39 00:02:05,066 --> 00:02:09,952 And the methods are actions you can perform with the object or its attributes. 40 00:02:09,952 --> 00:02:15,221 [SOUND] To give you a real-world example of this, say the object is a puppy. 41 00:02:15,221 --> 00:02:19,001 [SOUND] A puppy has attributes like gender, weight and 42 00:02:19,001 --> 00:02:23,797 hair color, [SOUND] and actions such as eat, sleep and go for a walk. 43 00:02:23,797 --> 00:02:28,681 If a puppy is the object, gender, weight and hair are data. 44 00:02:28,681 --> 00:02:32,330 And eating, sleeping and going on walks are actions. 45 00:02:32,330 --> 00:02:35,305 [SOUND] Here at Treehouse, we [SOUND] primarily teach 46 00:02:35,305 --> 00:02:39,182 object-oriented programming using languages [SOUND] like Java, 47 00:02:39,182 --> 00:02:42,860 JavaScript, Objective-C, PHP, Python, Ruby and Swift. 48 00:02:43,900 --> 00:02:47,316 Let's see if we can do the same exercise we did in C and 49 00:02:47,316 --> 00:02:50,823 Racket in some object-oriented languages as well. 50 00:02:50,823 --> 00:02:53,256 [SOUND] Can you see where to put Hello Treehouse! 51 00:02:53,256 --> 00:02:54,172 in Python? 52 00:02:54,172 --> 00:02:56,839 [BLANK_AUDIO] 53 00:02:56,839 --> 00:03:01,234 If you guessed between the double [SOUND] quotes, you'd be absolutely correct. 54 00:03:01,234 --> 00:03:04,008 Let's look at the [SOUND] same code in Ruby. 55 00:03:04,008 --> 00:03:05,928 Where do you think we should put Hello Treehouse! 56 00:03:05,928 --> 00:03:06,652 here? 57 00:03:06,652 --> 00:03:08,829 [BLANK_AUDIO] 58 00:03:08,829 --> 00:03:13,096 [SOUND] If you guessed in between the quotes again, you're right again. 59 00:03:13,096 --> 00:03:16,103 Let's look at that same code in [SOUND] PHP. 60 00:03:16,103 --> 00:03:18,706 This might be a little more cryptic. 61 00:03:18,706 --> 00:03:20,840 Where do you think our phrase goes this time? 62 00:03:20,840 --> 00:03:24,742 [BLANK_AUDIO] 63 00:03:24,742 --> 00:03:27,602 [SOUND] You're getting really good at this. 64 00:03:27,602 --> 00:03:30,610 So let's look at one more example in Objective-C. 65 00:03:30,610 --> 00:03:32,146 [SOUND] 66 00:03:32,146 --> 00:03:37,991 [BLANK_AUDIO] 67 00:03:37,991 --> 00:03:41,410 Can you sift through the code to see where to write Hello Treehouse! 68 00:03:41,410 --> 00:03:42,600 this time? 69 00:03:42,600 --> 00:03:45,108 That's right, it's [SOUND] in between the quotes. 70 00:03:45,108 --> 00:03:48,223 Those quotes are a bit of a giveaway, huh? 71 00:03:48,223 --> 00:03:51,231 [SOUND] There are a lot of similarities among the languages. 72 00:03:51,231 --> 00:03:55,380 And many programming languages are hybrids of several programming paradigms. 73 00:03:56,580 --> 00:04:01,470 Python, Java, and PHP, for example, are all object-oriented languages, but 74 00:04:01,470 --> 00:04:04,560 they also have functional and procedural aspects as well. 75 00:04:05,730 --> 00:04:08,470 Choosing a programming language can be hard. 76 00:04:08,470 --> 00:04:12,520 But know you can write a program using any of the programming languages you saw it in 77 00:04:12,520 --> 00:04:15,620 the examples, or even ones you didn't. 78 00:04:15,620 --> 00:04:19,030 The trick is that some languages make writing certain types of 79 00:04:19,030 --> 00:04:21,150 programs easier than others. 80 00:04:21,150 --> 00:04:22,690 To give you some more practice, 81 00:04:22,690 --> 00:04:26,750 see if you can print yourself a personal message in a few different languages. 82 00:04:26,750 --> 00:04:29,200 If you get stuck, look for the hints to help guide you