Programming Throwdown - Javascript

Episode Date: August 29, 2011

This show covers Javascript, the only client-side scripting language built into most modern browsers. The episode talks about Patrick's move to Silicon Valley, Codecademy, The HP Touchpad Fir...e sale, and Minecraft's Notch challenging Bethesda to Quake 3. The tools of the biweek are Low-Level Virtual Machine (LLVM), an open source virtual machine and suite of compilers that compile and run code from many languages. and Hamachi, a free virtual private networking solution. ★ Support this podcast on Patreon ★

Transcript
Discussion (0)
Starting point is 00:00:00 Hosting provided by HostTornado. They offer website hosting packages, dedicated servers, and VPS solutions. HostT.net. Programming Throwdown, episode number 10. JavaScript. Take it away, Jason. So, welcome to the valley, Patrick. Yeah. script take it away jason so welcome to the valley patrick yeah uh part of the delay for this episode has been i've been moving yeah so moved out here so for dedication out of dedication
Starting point is 00:00:34 for the podcast patrick has decided there's you know it was a hard for us to do the podcast in different time zones you know patrick would have to stay up really late or i'd have to leave work early um and so out of dedication to you guys that's right and for no other reason Patrick decided to move took one for the team that's right 2600 miles to uh Silicon Valley so and this is the big 10 the big one zero congratulations that's right if I had had a streamer, I would blow it. So there goes our clean rating. So, yeah, not too much. Been actually learning a ton of JavaScript and HTML and the whole works.
Starting point is 00:01:22 How apropos. Yeah, that's right. So feel pretty prepared to come in and nail this podcast uh so what about you so do you have all your stuff yet or no uh no i still don't have all my stuff yet although i did want to make a corollary to your statement from our previous podcast about moving being like defragging okay your hard drive i feel like uh moving is like reformatting your hard drive because i feel like i am getting rid of a ton of stuff that i just decided i don't need anymore like whoa i didn't even know i still had this and you kind of get excited and you're like wait if i went you know x number of years in my case like four years without knowing
Starting point is 00:01:58 that i had the thing and never used it in four years i could probably do without it yeah i had this like weird almost like buddhist like revelation because i moved and my stuff was uh in storage for a while i want to say like a month or so and and my wife and i realized we really don't need that much stuff and when our stuff did appear i mean of course you know we needed like a bed and things like that like a lot of this stuff we just you know gave to salvation army or something because it was like we just realized you don't need that much to you know be content yeah yeah yeah i don't know that we're you know getting rid of it just to to get down in
Starting point is 00:02:36 size but definitely you know a place we're moving into is smaller so we got to get rid of some stuff but it's always hard because there's some amount of things. It's like this has value to me, but it doesn't necessarily have value to other people. Yeah. And so like you hate just getting rid of it. But so you like I'm giving stuff to my friends and family, you know, you could like sell it to them. But ultimately, you know, it only the value is really what it has to you to give it to somebody else. Like, you know, trophies from high school. It's like, oh, oh these are nice these represent something but i i don't need a hundred of them you want to hear a funny story we uh uh we went to a garage sale my family and i one time this is when i was really young and this person was selling all of their trophies and they actually had a family of like it was like
Starting point is 00:03:19 wife and husband and they had a family like seven kids that all just graduated or they weren't they didn't all graduate high school but they were all around that age and so they all had a just a ton of they literally had boxes full of trophies and we we bought all of them for like i think you know two dollars or something and then anytime we did anything we got a trophy so we put duct tape over all of them so like one time uh i think like my cousin he was really young he's a baby and he had just like got potty trained and he gave him like a basketball trophy it was totally awesome so every time you made a made a free throw on your ymca team yay here's a trophy yeah that's right your first shot. Your first made shot. Yeah, and nothing would ever match.
Starting point is 00:04:05 I won a spelling bee in fourth grade, and they didn't give us any trophies or anything, but my mom gave me a bowling trophy. Nice. It was pretty epic. But yeah, you realize... But it was even more epic because bowling was the word that won the spelling bee. Oh, that's right.
Starting point is 00:04:25 You realize that there are things like that where it's like it has some sentimental value. And then there's almost like you don't want to throw it away, but not really because you care, like because that's sentimental value, but just you don't want to lose something. I don't know what it is, but... Yeah, you can't ever get it back.
Starting point is 00:04:42 Yeah, that's right. That's right. And plus it's like you just like the thing you were doing so like i got a trophy for uh playing soccer i got like a participation award because as you might imagine you know patrick and i have very little athletic ability and so for yourself except for your weightlifting olympics i forgot about that that's right that's right but uh but yeah so so my participation awards, you know, it's just, like, I like doing that and playing sports as a little kid and stuff. So I hate to give that stuff up. Yeah.
Starting point is 00:05:15 Yeah. And it's hard for me, too. I have, like, a bunch of cool, like, RC, remote control airplane type things. Oh, that's right. And it's, like, because we're moving into a smaller place and not going to have lot of space you know like i'm in debates about what to do with it you know and if you're gonna have to throw them away you should at least crash them epically no that stuff you can typically find people who will you know buy it off of you or whatever yeah that's true it's true so all right well anyways news. Yeah. So the first thing I saw, which is kind of a news slash tip thing that I found, this website, CodeAcademy.com, opened up recently.
Starting point is 00:05:55 And I went and checked it out. I saw some news stories about it. We'll have to do it in one of our podcasts, some of the places we go for our news. That might be interesting. Yeah, definitely. do in one of our podcasts the some of the places we go for our news that might be interesting yeah definitely anyways so i saw on a couple of those this codeacademy.com and they have um actually relevant to today uh some lessons about javascript i forget how many about 10 maybe um you know different lessons kind of walking you through very beginning programming very interactive kind of see what you're doing and very well done web 2.0 e you know very nice oh nice um and then
Starting point is 00:06:25 i saw an article on tech crunch that said that 200 000 people uh used it and did some number 2.1 million lessons on it in just three days which is crazy because this is very niche and not only is it niche that it's a programming site but the fact that it's for like very beginners like you know for you and i is going to be like snooze fest i i don't mean that we're expert programmers sort of like beyond the beginning stage kind of like if someone just told you to bench 200 or something after you did your olympics it would be like somebody telling you to bench 15 and yeah that's right okay anyway sorry so so um i i encourage you guys to check that out code academy.com and that's also
Starting point is 00:07:12 cool that somebody you know is teaching others to do programming and apparently i assume it's some sort of you know startup or there's some money motivation they're advertising i'm not sure what or if it's just non-for-profit um i don't know but that's kind of encouraging that this guy got that much traction and people signing up and using it or eric could be a lady i don't know but um yeah that's that's pretty awesome and you know i was thinking about that that there's got to be a pretty big market not only to learning programming yourself and making yourself more marketable because that's a growing industry and i can't see any reason why it wouldn't grow even more in the coming years but also if you uh want to teach others who want
Starting point is 00:07:50 to get in the field of computer science programming that kind of stuff um there could be some it's a win-win right you're getting money to do something that you like teaching others and helping people learn programming kind of like you know something we're doing with this podcast although we're not getting money but if you'd like to donate let us know that's right um and uh or just pay us you know yeah we take checks cash money order credit cards i think that you know one of the things that i've always kind of believed is that everyone should learn how to program like programming should be something that's taught at a fundamental level like every high schooler should know how to program because i feel like any job could be made easier if with knowledge of programming you know and i i won't go
Starting point is 00:08:31 so far as to say any job but yeah a lot of jobs even if you're just using excel yeah and i mean i'm not even talking about computer programming but the idea of sort of coming up with yeah algorithms are coming up with like a recipe it's sort of like i want to do these things you know there was a game uh at epcot in uh in walt disney world in florida where um i remember when i was really young we went to this uh i i can't remember what it was called but it was an area of epcot where they had like machines from the future which was like you know a 486 dx or something but um they had a game on there where you had a position and there was sort of a grid. And so you're walking around on this grid.
Starting point is 00:09:14 Oh, yeah. Or you have to program a robot how to move to get to a goal. So you put like 2L, 2D, 2R. And that would go two spaces to the left, two down to the right. And so you have to put this really complicated sequence to get you to the goal. And, you know, along the way there's little pitfalls and it would tell you oops, and you'd change your sequence and eventually you'd get it right. And so I'm just talking about programming at that level,
Starting point is 00:09:36 like being able to understand like a sequence of commands and sort of what's going to happen at the end or iteration. And I just feel like any job could benefit you know from knowing something like this yeah the the algorithmic the codifying of a set of things and boiling down and unambiguity yeah i agree yeah i mean like let's say you said for that let's say i mean there's nothing against janitors janitors are awesome people but a lot of people wouldn't consider janitors programmers but let's say you uh excel at being a janitor, and all of a sudden you're a manager, and you're managing a team of janitors to clean an office complex or something. So there's a lot of programming there.
Starting point is 00:10:14 You have to sort of arrange the schedules. You have to worry about the overlaps. And people, if it takes them— How frequently should you clean? Yeah, and if it takes them 45 minutes to do one area and two hours to do this other area, how can you keep them busy for the whole eight hours? I mean, there's a lot of math, a lot of programming there. And the fact that we don't really teach any programming, it's not compulsory.
Starting point is 00:10:39 It's just, I don't know, I think it's a little crazy. Huh. Interesting. Yeah. So definitely a space i mean i think it would be a benefit if people have ideas or things they want to do there to to teach others would be good yeah for sure so there's all this craziness about the hp touchpads going to 99 dollars and the other day well the craziness is that the hp touchpad is being discontinued yeah well and hp is in a lot
Starting point is 00:11:03 of financial hp is is in a ton of trouble. But that isn't necessarily. I mean, people have known that for a while. But I mean, I've never seen anything like this. Like, I mean, when is the last time where some company was in trouble and just ran like a fire sale on all their hardware? Like, even like, you know, when Circuit City closed. I don't know if it's because of regulations or what, but nothing was really discounted very heavily. And in fact, I believe Apple didn't.
Starting point is 00:11:30 You could buy it cheaper online than it was in the store. Yeah, even with the store closing sale. So to see something that's marked at $500 go to $100 is pretty rare, and it causes massive explosion in purchases. So did you yourself want a hundred dollars for a pretty decent tablet seems like a good deal yeah so it runs web os which of course is run by hp so that's pretty much gone and i didn't get one kind of dead end yeah i didn't get one because i thought oh the operating system is not to be kept up to date but this news article uh hp touchpads linux slash android ports on the way shows that you know there's actually going to
Starting point is 00:12:06 be a path forward for these touchpads i'm kind of kicking myself yeah so a couple notes on this since i made the the show notes here that even now there's been some edits some people have offered a bounty so i think it's up to a couple thousand dollars now to the first person who can get android on the web os nice um and then some other people which I I haven't seen if it's a fake or not yet I they were saying it's true, but some people bought touch pads that had Android on them Oh Wow out of the box shrink-wrapped and they boot to like some Qualcomm screen Oh weird, so it's like a Qualcomm Research Center So they don't there's a lot of speculation about what happened and that they might be a really elaborate fraud.
Starting point is 00:12:46 But I watched a video. It seemed pretty convincing, these people turning on Android devices or turning on touchpads and having it boot to Android. And they claim they got them out of the box that way. Yeah, it's awesome. The thing about the iPad, and maybe you own an iPad, right? Or I guess I should say the thing about the tablet. I can never seem to find a use case for the tablet. Like, that's why, you know, I have some, like, oh, I could put recipes on it.
Starting point is 00:13:11 But, I mean, I don't really have a $400 use case. I mean, what do you use your tablet for? $400, it is hard. It is hard. But I use mine definitely when I travel. It's awesome. So, like, I don't have to take my laptop anymore if I'm only traveling only traveling over like a weekend or, you know, a few days for business or something. For business, I have my business laptop.
Starting point is 00:13:31 But for personal stuff, I just bring my iPad. It's more than enough to check my email, read my webpages, you know, see the news. It's very, very nice. Also use it like if I wake up in the morning early and i'm not ready to get up and get at it yet i'll take on ipad and use it there or at night before going to bed you know because it's a much more portable so that's nice i read it read comics on it use it to play games i have books on there i would like to claim that i read them but to be honest it's really distracting to have it do so much else you find yourself really easily distracted and uh it
Starting point is 00:14:05 has awesome battery life so i mean it lasts you could use it probably for six seven hours doing stuff on it and before the battery runs out oh that's pretty awesome which a laptop won't do without power yeah i guess i guess it's a smartphone situation all over again i never thought i would use a smartphone and now i'm kind of addicted to it yeah it's hard you really got to personalize it to your taste and have your stuff on it and you know check twitter on it you know whatever it it's you got to have one i used other people's always like i don't get it like this is silly but when it's yours and you have it with you you know it it doesn't make a difference do you have a keyboard or how does that work no they have an on-screen keyboard you can get a bluetooth keyboard for it my some my brother has one okay he uses with it
Starting point is 00:14:49 i don't tend to create content on it so that makes sense it's not really a big deal for me but he says it works really well it connects wirelessly oh nice that's pretty awesome so um so talking about the twitter uh something I saw on Twitter that was pretty interesting was the guy who started or first created Minecraft, the head guy, he goes by his handle Notch. His real name is – it's slipping away now. Oh, I'll look it up. Do you know? Okay. But Notch, and I follow him on Twitter, and he posts stuff about working on Minecraft, which is now a company Mojang.
Starting point is 00:15:25 His name is Marcus Person. Marcus Person. Okay. I always want to say Mark Pincus, but that's the guy who runs Zynga. Yeah. So their names are kind of close. Anyways, they're both in the games. So, yeah, Marcus, so Notch, you know, has his Twitter feed,
Starting point is 00:15:41 talks about all this stuff. It's pretty cool. You can follow him. He does pretty interesting stuff um and he would have been you know had the story that he was coming out with a game or had an idea for a game called scrolls and um there is a company in in america i guess it's it's worldwide uh bethesda that is um so they're the people who made Fallout 3, Oblivion Yeah, so they make Elder Scrolls, which is, Oblivion was
Starting point is 00:16:10 one of the Elder Scrolls series I think, yeah And they're coming out with a new one, even Skyrim I think it's called Yeah, I'm not into those style of RPGs But they have this Elder Scrolls with these different titles in this series, and so
Starting point is 00:16:26 they found out he was making a game called scrolls and they decided to sue him yeah i mean he has millions of dollars might as well right i i have no logic behind it i don't think a lot of people get confused between scrolls and elder scrolls um and the games are not similar in any way from their description. So he's been kind of, he was griping about it. And then one day he gets on and basically says he's going to challenge them that instead of making the lawyers rich on both sides, why don't they just
Starting point is 00:16:56 settle this? And he agreed that, you know, he claims he's serious about it, that they'll have, you know, and he set up the rules. Basically, they'll play Quake 3, a couple of the guys from his team and him, versus a team that they can pick, you know, and he set up the rules. Basically, they'll play Quake 3, a couple of the guys from his team and him, versus a team that they can pick on their end. They'll play several rounds of Deathmatch of Quake 3. And then whoever wins, if he wins, he gets to call his game Scrolls.
Starting point is 00:17:14 And he's saying either way, he always will plan to, if it would make it any better, that he'll say that, you know, that they're not associated with, you know, Elder Scrolls. That this is its own thing, no way affiliated with Bethesda. And so he says that if he wins, he'll still do that, but he gets to call his name Scrolls. And if he loses, he'll call it something else. Yeah, I think that's awesome. I think good for him for sort of making it,
Starting point is 00:17:40 bringing more publicity to him and his team, because that's really what's the only thing that he can gain out of it. So he sort of took a rotten thing that was offered. He took lemons and made lemonade. In some way, yeah. He got a lot of publicity out of it. I think it's pretty awesome. I'm sure a lot of people saw that
Starting point is 00:17:59 and really kind of said kudos to him. Yeah, but it does bring up how silly some of this stuff has gotten that you know or even the the android phones the droid i see at the bottom whenever there was a droid commercial it says you know basically some note to lucas films ltd so george lucas's company because droid is a trademark of the star wars series yeah i mean really the lawsuits are just have gotten more and more out of hand um you know apple's suing hcc i believe and like several other droid they're all suing each other at this point i mean basically you know the it's sort of like
Starting point is 00:18:36 the cold war except it except we've reached uh what was that called is it deaf mutually assured destruction yeah but mutually what's the word for that i keep wanting to say defcon i think it is defcon defcon is that's like when you're under threat well defcon's a hacking conference but defcon's also the um state so there's a defcon level this is back from the cold war yeah and so if you're at defcon level like one then that means basically everyone's launching nukes at each other and so we're at defcon level one right now when it comes to patents and and patent litigation it seems that way and it doesn't it doesn't help nobody's like innovating because of this or doing more work just lawyers are making more money yeah
Starting point is 00:19:22 and the worst part is the people who get hit because you know huge companies like HTC and and Apple and things like that they basically shrug these lawsuits off or they you know so so the people who really get hit hard are the small companies like somebody Lodsis was suing Angry Birds we talked about yeah all the Apple they were suing Roxio the company that makes Angry Birds and it's about this. All the Apple. They were suing Roxio, the company that makes Angry Birds. And it's like a company like that is probably just five guys in their basement, right? I mean, they can't afford. Oh, Rovio.
Starting point is 00:19:52 Oh, it's Rovio. They can't afford to take a lawsuit from a huge company. Well, actually, the Angry Birds developers probably can. Really? Maybe. By now, yeah. I mean, Angry Birds is big, but I don't think it's like HTC big. You know what I mean?
Starting point is 00:20:06 No, yeah, I don't know. But I mean, regardless, yeah, a lot of little developers are just getting beat up over these patents. It's just ridiculous. So while we're on games, I guess you were supposed to do this story. That's okay. No worries. So the new Deus Ex has just come out. Yeah, Deus Ex Human Revolution come out yeah Deus Ex Human Revolution
Starting point is 00:20:25 actually Deus Ex have you played it? well no but Deus Ex Deus Ex 1 is goes down in history it was one of my favorite games of all time
Starting point is 00:20:33 really? I mean I played it before but I didn't ever play it for very long yeah so there's a number of things that make it awesome one is
Starting point is 00:20:41 this whole like philosophical you know discussion of consciousness and you know you're they're sort of walking the boundary between what's conscious and not there's like this whole philosophical undertone and you know behind the game and actually depending on your opinion you know of like how conscious a robot is a humanoid robot and things like that you can actually change the ending so you know actually i went back and played it and i
Starting point is 00:21:06 always try and like answer truthfully you know unless i've played the game you know over again but this time i went through answer truthfully and i've my opinions as far as you know consciousness robotics and things have changed since i since i was like 13 or wherever it came out no i don't know maybe like 16 and so um i actually had a different ending, you know, and it was just, that was like fascinating. And it also has a lot of sort of gamey elements. Like you have different skills. So if you focus on the stealthy skills, then you could do like really cool missions where like you don't even like kill anybody. You just use stealth and avoid everyone.
Starting point is 00:21:43 If you focus on like the military skills, then you can shoot rockets and just blow people up so it really kind of has something for everybody um so i'm really excited to play the new one the third one but yeah i haven't done it yet so it's coming out and there's this other company which is i have not tried it have you tried it yet on live no i've heard of it i i've actually i didn't believe it but i've heard really good things about it from people i trust yeah yeah so i'm've actually i didn't believe it but i've heard really good things about it from people i trust yeah yeah so i'm thinking i'm gonna have to check it out so basically on live has and correct me if if this is wrong but the way i understand is they have servers that basically run games for you so you've got a very high-end game that takes a lot of processing power
Starting point is 00:22:21 expensive graphics cards these kinds of things so like deus ex or crisis 2 or you know any other game that is is really you know high-end graphics that kind of stuff and they run it on their server and then they basically you know most are kind of like a remote it amounts to kind of like a remote desktop thing where your controls get fed into the server the game runs and then they stream the video back to you the video and audio and so you end up not running very much processing on your computer and it's just network activity and they even sell now i think a little box that handles the you know just taking the inputs and displaying the output so you know equivalent of like a roku box or a boxy box
Starting point is 00:23:01 or a google tv box or you uh you know size of like maybe a i don't know really small thing you can play games on your tv or on a computer screen and i've heard it works really well and the nice thing is it's it's fairly expensive you it's like buying the game at full price and i don't think it's any uh ongoing expenses but then they host the game and you can play it whenever you want yeah i mean it's pretty awesome you don't have to shell out 400 for the latest console um yeah or a new computer yeah um and so they were putting codes the way i understand it is at least in the beginning shipments they were putting codes for a free license on on live for this deus ex if you bought
Starting point is 00:23:43 the deus ex in a box store um so that's a really great you know thing like if you buy it and you'll have it but gamestop is very threatened by online delivery you know things like steam and on live and others that are not people don't have to go to the store and buy a box they just go online and buy it and they trust it and there's all sorts of drm issues we could get into about why that might not be the best thing that industry is moving that way. But this is the way it's moving. And so GameStop is very threatened by this. And they're trying to get into digital distribution to counter it.
Starting point is 00:24:14 And so all of that swirled up. Basically, they instructed their managers to open the shrink wrap copies of Deus Ex and take out the coupon that had the on live code printed on it that's ridiculous so i guess they had to like re-shrink wrap it then at the store right yeah i i think so but they sell used games so i think they have the you know plastic and the heat gun to do it yeah so that's pretty crazy i i don't know how i feel about that i mean yeah it's pretty it's pretty wild i mean i get the impression that things like this happen all the time but we just found out about this one you know oh maybe and it seems like if i were gamestop like i don't have a problem with gamestop being
Starting point is 00:24:54 opposed to it but they should have worked with i don't know who makes deus ex but they should have worked with that company and said look we really want the ones that come to us to not have the coupon in it and then they could have just done that for them. And then I wouldn't have had a problem with it. I just don't like the fact that they, like, opened it up and removed it. Yeah, they probably didn't know until it was too late or something. But, yeah, I mean, it's pretty shady, I mean, to tamper with the device before giving it to the customers, you know. I mean, the worst part is if if you know people are going to
Starting point is 00:25:27 know that oh the game comes with this thing and so if they buy and it doesn't come with it you know they're going to get upset like the customers yeah and you're going to drive away your customers because here is like a reason to actually go to a box store and buy it and not just download it from you know steam or wherever and now you go and it's like oh i'm getting the same treatment well forget that i'm not doing that anymore yeah i think that it's only a matter of time before steam kind of takes over it's like you know with portal 3 or sorry portal 2 i think it's oh you heard it here first yeah that's right secrets out i think that like if I remember correctly...
Starting point is 00:26:05 Oh, no, it was backwards. If you bought the PlayStation copy of Portal 2, you also got the Steam copy. But really, that would have been nice to go the other way, where if you bought it on Steam, you also got to download it for the PS3. If they had done that, I think that would have been the beginning of the end
Starting point is 00:26:22 for GameSpot, you know, GameStop. Yeah, it could have been. It's hard to say i mean like i said with the drm i actually don't necessarily like the steam thing because well steam you don't pay a subscription for so it's not as bad but i mean if they one day run out of money and stop having it and if they just turn off the license servers for all of your games six months later you're not gonna be able to play games anymore yeah all the games you bought yeah definitely and i still have games i was when i was packing i saw games that i had from you know before 2000 1995 1999 you know all these awesome old school games playing the x-com thing no i don't have them that far okay but you know like uh maybe they're like the original starcraft i don't have them that far. Oh, okay. But, you know, like maybe the original StarCraft.
Starting point is 00:27:05 I don't even know what year that was. Maybe that was in the 2000s. But I have my copies of that. The Diablo 2, which that's a little bit newer. But, you know, games like that, which I still have and I can install them. If those were on some distribution service that had gone away between then and now, I wouldn't be able to get them anymore. Yeah, that's true.
Starting point is 00:27:23 It's definitely true. And, I mean, not only do you have to worry about the distribution surface going away but um you know a lot of older games you can like emulate them with dos box for example but it's like they might you know the drm might make it hard to like emulate these games and you know preserve them yeah i guess you should point out it's not the fact that you couldn't download the game anymore because you could always back that up yourself if you're worried about it but that the games now actively or some of the steam ones actively go out and ping the steam servers and make sure you're still an authentic user and this and that and if it
Starting point is 00:27:58 doesn't detect after a certain amount of time it'll basically lock you out yeah i was playing uh thief 3 on steam and uh i guess while i was playing my internet went out and uh at some point just kicked me out of the game it was really frustrating it's not even a multiplayer game hmm yeah that's the part that's kind of disconcerting anyway so i'm not sure that moving to that model is the best yeah good point so uh oh well yeah time for that that part of the show tools of the bi-week tool of the bi-week so why don't you go first since mine is kind of ham-fisted it's pretty heavy uh-oh oh that's that's kind of scary oh i'm i'm worried now um so mine is uh talking about notch and minecraft i've been using this tool to play now that i've
Starting point is 00:28:47 moved well even before i moved i used it but to play minecraft with my family and yes we're nerd and uh the tool is hamachi and um it used to be a separate service but now it's part of log me in which is a company that offers a variety of remote login type products. And it's not open source, but it works really nice, really well. It's really easy to use. So I kind of, sticking with my sequence of not using open source tools, why Jason uses only open source tools. Hamachi allows you to run a program on your computer which creates basically a second network device like your normal Wi-Fi or your Ethernet.
Starting point is 00:29:29 But the difference is this one, when you connect to it, tunnels your traffic over your other connection. And it allows, for instance, if Jason runs a version of Hamachi and I run one, and we create a virtual network, name it, have a login and password if we want. And then him and I are on the same, what appears to be local network, because Hamachi bridges those together. And so if you point a game at an IP address that is serviced by the Hamachi adapter, that's kind of a virtual adapter, then it'll talk to it, and it'll see, hey, Patrick, jason's over there you want to play with him and you know i can say yeah and we can just play um like we're on a land even though we're
Starting point is 00:30:12 very far apart yeah so let's let's talk a little bit about like we can go in a little bit more detail on hamachi just what so maybe you could explain what are the like things that hamachi solves like why couldn't you just connect to, say, your brother's computer directly? Yeah, so the idea is that, first, if you're going to go onto the internet and connect to something, you have to open up all of your ports for somebody to be able to get to you. And normally, since that's a bad thing that people can just connect to a server running on your computer and maybe do whatever they want, a lot of people's routers their isps whatever it will will block ports block traffic that's incoming so you can't really host
Starting point is 00:30:52 servers a lot of things that go against you being able to do that just on your local box and so if my brother tried to connect to the server running on my computer he wouldn't even be able to see it and even if i opened up all that stuff and allowed him to see it on a certain ip address my ip address might move so then i have to solve that problem so you've got this you know kind of issue after issue after issue yeah like like the way to explain it is uh you know you have you live in what's like a what's called a address space and so you could think of this address space as literally being an address like an envelope but the problem is that it's recursive so what that means is for someone to get to you they have to send an envelope to your router and that envelope your router
Starting point is 00:31:35 opens it it's addressed to your router so it goes through the internet to there they see it they have to open it up and then there has to be another envelope inside that one that says hey send this one to Patrick, send this one to, you know, if you're living with your parents, send this one to Patrick's dad or send this one to whoever else is in the same, on the same router.
Starting point is 00:31:55 So the problem is that the person from the outside doesn't know that he has to package all these envelopes inside of each other because all he sees is your router. So he'll just send you an envelope with your router's address, and the router opens it and says, what is this? I'm a router. I don't play Minecraft, and just throws it away. So what Hamachi does is that you connect to Hamachi, and then the other guy connects to Hamachi, and then Hamachi does all of this negotiation so that when Patrick's brother tries to connect to his machine, he knows to send these send these envelopes inside of each other. Yeah. And Hamachi handles the setting up of the connection. But then you connect directly to the other person. Right. So it doesn't like all your traffic doesn't have to flow through Hamachi.
Starting point is 00:32:42 It flows just directly between me and my brother. But it handles the setting up of that tunnel, as it were. And VPN does the same thing, a virtual private network. There's a lot of tools to do that. But they require a lot of configuration. And because Hamachi has a server in the cloud that handles the arrangements, so we can each connect to the server in the cloud, and then the server in the cloud connects us together,
Starting point is 00:33:06 versus in a normal VPN, you have to run the server somewhere that somebody can get to in order to be able to set up this other connection, which adds just, you got to have a computer on all the time, or you configure it, it just becomes kind of a mess. Yep, yeah, exactly. So this tool's pretty nice if you're trying to solve that problem.
Starting point is 00:33:24 It has some other features too, like when a person joins, you can see who's on there, you can message them, and it's completely free if you're using it non-commercially. There may be some limit on the number of computers or that kind of thing, but they're reasonably high, so I've never run into a problem where I needed to pay for it, and I don't use it commercially, so it's exactly what I need, and it saves me spending
Starting point is 00:33:45 hours and hours uh trying to get it set up just so i can play my game yeah definitely hamachi's awesome um so yeah that's a that's a really nice tool that's one that we probably should have mentioned earlier it's fantastic so my tool all right now that you've said such nice things about my tool, my tool of the bi-week is low-level virtual machine, LLVM. And so this tool is pretty amazing. But let me sort of set the stage here. You know, we talked about C++. Actually, we talked about C. And we talked about Java.
Starting point is 00:34:21 About C. And we talked about the difference between these two. I mean, With C, you're talking directly to the hardware, directly to the memory. If you have an array in C of length 10 and you try and access element 11,
Starting point is 00:34:36 now you're reading something off your operating system or you're reading a part of someone else's program. It's at such a low level. In the end, all this stuff turns into electricity. So the idea of getting an error and things like that, when it comes down to electricity, it doesn't matter.
Starting point is 00:34:55 You're just going to get something back. And so that's sort of an oversimplification. But basically, C will let you do just about anything. Java, on the other hand will throw an exception which just just add a caveat we haven't actually talked about that yet uh as one of our episodes we haven't talked about what java yet we haven't done java no i'm almost sure we it's okay i just checked really oh we've done a language of the virtual machine though right maybe yes we've done python matlab okay let's go with python then i just didn't want people to be confused like oh no
Starting point is 00:35:29 i missed an episode wow we'll definitely have to do java that that's exciting because i really like java um so yeah so python if you have an array um of length 10 and you're trying to access element 11 python's running in a virtual machine a fake fake machine. You think of it as like, you know, the memory's fake, the electricity's fake, everything in the machine's emulated. And so it knows that, you know, element 11, it doesn't exist, that there's only 10 elements. And if you tried to go beyond that, now you're in some no man's land. And so the virtual machine can sort of analyze itself and say, oh, this isn't going to work. And so it can throw an error, which is much, much better than just giving you some random data, right?
Starting point is 00:36:16 You would rather have an error and be able to go in and fix it than you just get some random data and maybe you don't realize that there's a problem until it's too late so what would be but again the reason why people use c as we talked about in the c episode is that it's extremely fast really really fast so what you'd like the ideal thing is if you could compile c like in different ways so if you had the regular way where you compile the C straight to the machine code and you have this super fast program, but then another way where you could compile C to a virtual machine and check for errors. So maybe you run it on the virtual machine for a while and then once you trust it enough there, then you run it on the machine. So low-level virtual machine this is part of what LLVM does is you can compile C code actually you can compile from C,
Starting point is 00:37:11 Java, Python, a bunch of languages. It's basically just a definition of a virtual machine. Yeah it's sort of like a super virtual machine. So you can compile from many languages to this LLVM and you can run in this controlled environment and so you can run your app you know for like a month under this controlled environment it might run slower but you're fine with that maybe you don't have a lot of users yet or you you know spend extra money for some extra hardware in the cloud or something and then once you trust that your programs working then you can run it on the machine code so another
Starting point is 00:37:50 awesome thing about llvm is that people have written uh i guess would you call it a compiler or a decompiler but people have written programs which go from LLVM to another language. So you can actually go from LLVM to C or you can go from LLVM to Java or LLVM to JavaScript, which is what we'll be talking about later today. So, for example, let's say you have a lot of Python code and you also have like a bunch of C code. And you want them all to sort of play nice together you could combine you can compile both of them to LLVM and the LLVM will handle sort of the communication and things like that there's part of like an LLVM library you can use and then you can decompile that or I guess recompile that to C yeah I would say recompile yeah and now you have a C program.
Starting point is 00:38:48 Also, JavaScript is the only language that works in the web browser, but you might not want to use JavaScript for reasons that we'll talk about later in the show. So you write your code in, say, Java or Python, compile your code to LLVM, and then go from LLVM to JavaScript. And now your Python code runs in the web browser. So there's a bunch of awesome things you can do. I just kind of scratched the surface. But definitely you should check out LLVM. The other big thing, the nice advantage that LLVM has, which maybe we'll have to talk about it in a show one time because there's a lot here,
Starting point is 00:39:22 but since there's so many kind of front ends, languages that can be compiled to LLVM, and then it's a common base that once you're in LLVM, people have done a lot of research in academia and for companies. They've written a lot of optimizers for LLVM that say once something's been compiled to that, here's how we optimize it. We don't care where it came from. But once it's in this language, we'll write all these really awesome optimizers,
Starting point is 00:39:50 analysis programs. We'll transform it, make it more optimal in some way, but keep the functionality. And then you can compile that to assembly, to run natively, or to another language or whatever. And you get the benefit that because it's common across all of these languages on the front end you get the same optimization as opposed to just having that for a single language yeah i mean one thing that i um sort
Starting point is 00:40:16 of alluded to but didn't mention completely is you can go from say c to llvm and then to machine code and that might sound worse because you have this extra step, but because of the reasons Patrick mentioned, it's been shown that it's actually the code that's generated is better. So going from C to LLVM to machine code, actually, again, your mileage may vary, but often produces better machine, faster machine code than if you went straight from C to machine code. Well, even big C compiler, C++ compiler, GCC, use an intermediate format. They just don't typically, it's not, other people don't really output it.
Starting point is 00:40:58 It just GCC outputs it. Right. So GCC outputs this intermediate language that's easier to do optimizations on. Kind of like they do a first, it's not really just one pass, but they do some passes and output this language. Then they use the optimizer on that, and then they put that out to assembly. And so this is kind of the same idea,
Starting point is 00:41:16 but just making it more open and encouraging more people to output that intermediate format. Right, because the guys who work on GCC, making things run fast is their whole life. I mean, if you could make your code run faster, think about all the things that are built on C. Like we've talked about how Python is written in C. The operating system. That's right.
Starting point is 00:41:35 So, so many things are written in C. If you can get even a 1% improvement in C, I mean, you'd probably save millions of dollars in electricity and processing power. So, the guys who are writing GCC are really into performance. Meanwhile, the guys who are writing Python, they're more into, you know, engineer, I guess, saving time. Productivity. Right, exactly. They're more into productivity. So, they don't really spend the kind of time that the GCC guys spend on optimization. They want to make something that's flexible and that allows you to develop fast. So by creating LLVM, we're sort of combining the best of both worlds. It's like the language guys can focus on the language,
Starting point is 00:42:18 and the compiler guys can focus on LLVM, which helps every language. Good tool. Yeah, awesome. So now let's jump into some JavaScript. JavaScript. So somebody... All right, so first question I got to ask. All right.
Starting point is 00:42:35 How does JavaScript relate to Java? Okay. So JavaScript does not in any way relate to Java. What? And this is just... I feel ripped off. I think what it is, I think people in Silicon Valley are just obsessed with coffee. But yeah, JavaScript has nothing to do with Java. So when we do the Java show, which maybe we'll do.
Starting point is 00:43:00 Well, we'll leave a couple of shows in between just because of the name issue. Just because we don't want people to think that there's any relation but yeah between javascript and java i thought there was for the longest time i thought there was a relation between the two yeah me too i mean i never knew what it was but i always thought there was something but yeah there is actually nothing um to do between those two so so the story goes i guess and and maybe people don't know completely for sure but um netscape was developing a language to add interactivity to their very early browser i think netscape 2 version 2 kind of time range i don't remember the the years but
Starting point is 00:43:38 they were calling it live script and LiveScript was their name. But Java was really big and had a lot of kind, or not big at the time, but was new and was gaining popularity. People were really excited about it. And Netscape went to, at that time, Sun, who was developing Java, and said, hey, we would like to be able to use the name JavaScript.
Starting point is 00:44:04 I assume that's what happened. This is the most plausible explanation I've heard. And that they wanted to name it JavaScript because they wanted to be associated with all the popularity of Java. And Sun was willing to do that because they wanted Netscape to have Java applets be able to be run in their browser.
Starting point is 00:44:22 And so it was kind of a, what do you call that? A horse trade? Yeah. That JavaScript could become javascript which supposedly i guess sounds better and they would have the rights to name it that and then java would be able to have their um java run in the netscape browser and so i guess it was a win-win and then netscape was big on the idea of being able to be the only ones to be able to call it JavaScript so it could be theirs. And because they got an exclusive license from Sun to do that, they knew nobody else would be able to call their specific thing JavaScript.
Starting point is 00:44:55 Oh, what a mess. I guess. That's what I've heard. But then it kind of got weird because then Netscape wanted to, I guess it was still them at this point, they wanted to get it standardized. And so they took it, tried to find somebody who would standardize, you know, ISO, who are the other people, the various committees. Oh, W3C, right? Or WC3.
Starting point is 00:45:20 Yeah, that's another one. These kind of people to, you know, standard, I give them a standard for JavaScript, and they couldn't get anybody to do it. So the European, the ECMA, decided they would do it, and so they produced their standardized version of JavaScript. But they couldn't call it JavaScript because that was only Netscape-specific, and so they called that ECMA script.
Starting point is 00:45:43 So we don't really have live script around anymore but you do hear the names javascript and ecma script and they kind of do mean the same thing but in reality we probably should have named the the show ecma script because it's what you know is the thing that everybody runs but everybody just calls it javascript yeah it's hard once you know you have so much inertia buying a name, it's hard to change it. Yes. Yeah, so yeah, JavaScript has a pretty muddy history. Yes. But it has several really important uses. It does. Okay, before we move on real quick, most of that came from a lecture I was watching that's pretty interesting because of the the history and also teaches javascript um by a guy named douglas crockford oh nice who i assume works at yahoo um but i we put we'll put the link in the show notes but it's uh crockford on javascript and he it's like very like each
Starting point is 00:46:36 episode's like an hour hour and a half and i think there's like four or five of them wow that's pretty cool it's definitely a lot of material and he goes over all the history and talks a lot about what javascript is so for a much more in-depth uh description you can go there but sorry yes So it's definitely a lot of material. And he goes over all the history and talks a lot about what JavaScript is. So for a much more in-depth description, you can go there. But sorry, yes, the uses of JavaScript. Did you watch any of these? These look pretty awesome. I watched the first one and kind of skipped around
Starting point is 00:46:56 because I knew a lot of what he was saying and then started watching the second one. It's just long format. Somebody told me that JavaScript was based on Scheme, like way back. It's a descendant of Scheme. Is that true or is that made up? He did talk about that in there, that it was influenced by some of the... Well, we'll talk about it.
Starting point is 00:47:15 But JavaScript does have a lot of functional programming language to it. And so, yeah, it was influenced in some ways by that, yes. Cool, awesome. So, yeah, what are some of the uses of JavaScript? Why is it so popular? Well, we already talked a little bit about the, you know, kind of main one. It's kind of the language for web browsers. Yep.
Starting point is 00:47:35 Client-side. Sorry, go ahead. I was going to say client-side web browsers. Yeah. Yeah, so it's the thing that people put in their web browser to, I guess, add interactivity? Yep. Yeah, definitely. So as we talked about in the HTML episode, the HTML code, we'll say, is called the DOM, the Document Object Model. And so this is if you write raw HTML, this is your, you know, you type the body tag and
Starting point is 00:48:07 then the, you know, the P tag for a paragraph and all that stuff. So it's really just a sheet of XML. And that sheet of XML can be thought of as this tree. So the body is actually the HTML tag is the root of the tree. And you have, you know, head and body as the two children. And, of course, head has, like, scripts, can have script tags. So you can think of this as, like, flowing down like a tree. And so you might want to do programmatic things.
Starting point is 00:48:37 Like, you want to scan through this tree. You know, again, you know, HTML is often generated by another language so you might want to scan through this tree and count up how many how many tags you have inside of a particular table you might want to do some sort of logic or some sort of programming on the Dom on the on the HTML that's been rendered and so JavaScript is one way to do that so So for example, you might have a block of HTML that contains records, and you might want to have a little pull-down menu that filters the records. Give me all the records that start with J.
Starting point is 00:49:15 Now give me all the records that start with K. So you don't want to have the server generate a new page each time because the client has all those records there. You just want to alter the DOM. You just want to make some of those records invisible. So that's something that you could do in JavaScript. So JavaScript can loop through all the elements in this tree and set some of the parameters on them. Set one to visible, set one to invisible, to hidden, etc. Also, a lot of HTML5, even though it's called HTML5,
Starting point is 00:49:48 the vast majority of it is JavaScript. So, for example, one of the things HTML5 adds is typed arrays. So if you want an array of data, as we talked about in the C episode, in JavaScript you can't really do that. You can have sort of an array of objects, in the C episode. In JavaScript, you can't really do that. You can have sort of an array of objects, but it's not really like a chunk of memory like it is in C. But now with HTML5 and typed arrays,
Starting point is 00:50:17 you can actually ask for a block of memory, and that's important for many different tasks. Yeah, that's kind of interesting because that's kind of a divergence. JavaScript's thing has been that there's just one kind of number. Right. There's just one kind of interesting because that's kind of a divergence. JavaScript's thing has been that, you know, there's just one kind of number. Right. There's just one kind of, you know, it was just very, you know, straightforward. Just every number is a double. Yep.
Starting point is 00:50:33 Double floating point precision. Oh, no, actually, so in Python, every number is a double. But in JavaScript, every number is a float. I believe, yeah. But, yeah, you're right. I mean, in JavaScript, there's basically, there's float, there's object, there's array. This is pre-HTML5. And there's a couple others. I think there's like none or null. I think it's called nothing. And so that's about it. I mean, everything's either an object, which is a hash table about it i mean everything's either you know an object which is
Starting point is 00:51:05 a hash table in javascript so everything's either a hash table an array a floating point number or nothing so you know it's very it's very simple in that respect yeah and i guess that's a strength but also it can be limiting right i mean if you need to do some number crunching or something like that, you need just like a block of memory. You know, the compiler, you know, at the lower level, the compiler and the machine, what they're looking for is for you to, you know, again, we're talking about electricity and, you know, memory at a really low level. You want to just access things in order. And so what JavaScript will do is, if it has an array but it isn't typed, it doesn't know that each element is going to be a number.
Starting point is 00:51:52 Maybe the first element of the array is an object, the second element is a hash table, and the third element is a number. So JavaScript can't just take one chunk of memory and say, here's your array, because it doesn't really know what to expect. But HTML5 sort of adds a lot of that because performance for JavaScript has become more important. And it's been previously the fact that we talked about that on the, and we referenced it a little bit earlier
Starting point is 00:52:20 when we were talking about Hamachi, but on the client side, so the client being the person running the web browser, sitting at their home wherever they're the client and then they're connecting to a server to get the html the html5 the javascript all those things get transferred over to the client and then the client has to render and their browser has to draw the what you know ultimately ends up being the image the thing you interact with that's the web page and that's what the client side does and the javascript is the language that is the program that continues to run even once the page is loaded and the html kind of
Starting point is 00:52:58 is what gets loaded describes how to load it and then the javascript goes in and says you know here's how to continue running and that's on the client side but on the server the part that's you know either the static html you know just stays as like a text file that's html they get served up or that we talked about programs generate javascript that generate html so those are often other languages like PHP or Ruby on Rails or one of the Python web frameworks or it could be even C or C++. And those run on the server and serve up the HTML and JavaScript and change parts of the JavaScript, parts of the HTML to do something based on, for instance, the time of day or what the newest news story is or what user you've logged in as. Yeah, I mean, you know, a very simple example is if you look at Gmail, you can get new emails
Starting point is 00:53:55 on Gmail without the whole page refreshing. And so we'll talk about this a little more later on, but that's JavaScript stepping in and, you know, asking Google, hey, are there any new emails? Are there any new emails? Are there any new emails? And so JavaScript gives you the ability to sort of continue processing even after you've loaded the page.
Starting point is 00:54:15 But I wouldn't guess that on Google's side that that's JavaScript running on their server because almost always that's something else running on that end. Right. But then there's this new tool that's gained else running on that end right but then there's this new tool that's gained a lot of popularity actually it's it's kind of interesting called node.js and node.js is it's takes google's chrome's javascript engine so to get web pages to run really fast which chrome has tried to make one of their selling points well selling points there is i guess they give it away but one of the reasons to download chrome google always says is because it's really fast and as part of that they have
Starting point is 00:54:56 to figure out the way to make the interpreter that runs the javascript engine really really fast yeah i mean i remember when uh you know when gmail first came out um it took like on the order of minutes for it to load and it actually loaded this like weird javascript blob thing that then like expanded or something and then you know after it loaded the first time then it was fast but i mean it took literally over a minute to load gmail for the first time on a machine and now when you go to gmail even for the first time it's instant yeah and a lot of that's because of the effort that they've put in and others and then also kind of they've encouraged others and challenged others to put in more work to making this javascript engine really really fast right so they open sourced that engine they they called it, I think, V8.
Starting point is 00:55:47 Yeah, that's right. Reference to an engine, I assume, a fast engine, V8. And they open sourced it. So this person took that engine, runs it on the server, and then adds in hooks so that from JavaScript, you can create the server side that serves up web pages and handles people visiting a web page, people logging in, people doing actions, and in JavaScript on the server side.
Starting point is 00:56:16 And that's something that's pretty new. It was kind of very interesting, and it's catching on. Because it unifies the client- side scripting that people are writing programs to run in the browser in javascript and now they can also write code on the server that runs in javascript and it does it does all this asynchronously um and so instead of waiting for stuff it does you know you register an event to happen and then you get a callback. And it is a new and novel way of doing it, but it allows for a lot of parallelism, allows you to run more clients from a given server
Starting point is 00:56:53 so you don't have to have another server to handle all the traffic. And it's catching on. It's pretty cool. I don't know that it's the first time that JavaScript's been used on the server side, but it's definitely become probably the most popular way to run JavaScript on the server side. Yeah, for sure. That's pretty awesome. So what are some of the features of JavaScript?
Starting point is 00:57:12 What are some of the things that differentiate as a language? Yeah, so JavaScript is, you know, compared to the languages that we have talked about, it's more like Python and less like C. So it's dynamically typed, similar to Python. It's got lambda functions, which means you can, you know, a function is basically an object, and you can create functions whenever you want versus.
Starting point is 00:57:37 And you don't have to give them names. That's right. So you can pass in, and the functions are first-class citizens, which we've never talked about. But, yeah, basically means a function can be an object. So you can pass functions as the argument to another function. Right. Like imagine if, I'm trying to think of a good example here.
Starting point is 00:57:56 But oh, so a callback is a good example. Yeah, yeah. So you want to have a callback. Say, hey, I want you to go get, read bytes from a network. And instead of waiting here, I want you to call get read bytes from a network and instead of waiting here I want you to call this other function when you're done right and the other function is just going to you know do something gonna blink up make a blinking thing on your web browser let's say so a lambda function says instead of calling back this named function I'm gonna just give you the
Starting point is 00:58:22 code not give it a name just here's the code just run this code when you finish yep and that's an anonymous function that you pass to it yeah exactly it doesn't have a name yeah so um yes the javascript has a lambda function which is super useful um and it but one thing you know so javascript, as you mentioned, there's a V8, which is an interpreter for JavaScript. Internet Explorer has their own interpreter. Firefox has their own. I think it's called SpiderMonkey. So each browser has built in their own interpreter, their own JavaScript interpreter.
Starting point is 00:59:01 And each one has its own sort of nuance. Some have different instructions. I know, for example, if you want to find out, you click the mouse, and you're writing some JavaScript program that just needs to know where you clicked on the screen. Well, in Chrome and in Firefox, you would call this function or this parameter called event.which. Actually, sorry, event.
Starting point is 00:59:31 Yeah, event.which tells you which keystroke or mouse button. So if you clicked the left mouse button, event.which would return zero. If you click the right mouse button, it would return one, et cetera. In IE, it's not event.which. It's something else. I don't even remember. So you have to write all these if IE, then do event.whatever it is, target or something. Otherwise, event.which, right? And so the language is full of these nuances because there's so many different interpreters.
Starting point is 00:59:58 You remember, like, Python only has the CPython. Well, it has a couple others, but CPython completely dominates, right? You know, but in this case, you have many browsers, and each has a large market share. You know, I think Internet Explorer has, like, 50% of the users are on that, and the other 50% are spread across Chrome, Firefox, et cetera. Well, it's almost like the analogy is that it's different hardware platforms. Yeah, that is a good analogy.
Starting point is 01:00:25 So if you had to run on like an Intel processor, and in this case, AMD happens to comply with the same standard as Intel. But IBM used to make, I guess they still make Power PCs, all free scale now, Power PC chips. Sony has the Cell processor. You know, these are all very different processors. And you need to be able to run on all of them because everybody on the Internet has essentially a different machine, a different operating system that they're using. Yep.
Starting point is 01:00:51 And so there are several libraries, JavaScript libraries, that are designed to sort of save you the trouble of having to do all these if IE this, if Mozilla that, if Firefox that. So the most popular one is jQuery there's another one called MooTools there's no one called prototype I've used a jQuery a lot I've had a really good success with it I can't really say much about the other two but I've heard they're they're both very good as well but what they basically do is save you from having to care about what each browser does one thing to note and we'll talk about this more in the
Starting point is 01:01:29 weaknesses section but these tools are good but they're not great I mean you know you'll still have issues your code still will run a little bit differently in IE and so you definitely need to have an environment where you can test all the different browsers. Well, we should say the tools are great. The problem is just really hard. Oh yeah, maybe that's the best way of saying it, yeah. Because, I mean, these tools are trying really hard. There's a lot of work that goes into them. They give you a lot of help. They make your life a whole lot easier. They take an impossible task and just make it hard. Yeah,
Starting point is 01:02:11 and you know, another thing is that it changes constantly. Like from IE8 to IE9, they'll change a bunch of different function names and they won't be backwards compatible. And so, you know, these tools have to stay up to date, but then they also still have to backdate so that someone using IE6 or someone using IE9 or someone using Firefox, they can all see the same, get the same experience. And so that is, you know, a really, really hard problem. Yeah, definitely. So, you know, writing JavaScript, you know, can be painful. We'll talk about that a little more in the weaknesses too. But many people have written compilers which compile to JavaScript.
Starting point is 01:02:47 So you can write languages that are, I guess, a little bit more formal and then run this compiler and generate the JavaScript. So do you have a couple in mind? Yeah. I mean, one of the big ones that, you know, kind of, I guess, is one people think about is the Google Web Toolkit, which breaks what we said before that Java and JavaScript have nothing to do with each other. Yeah, I guess. Because this actually allows you to write kind of a certain style of a Java program and then compile that to JavaScript. And Google has actually open sourced that. Yeah, open sourced it and released that so
Starting point is 01:03:26 that others can use it. And you can write, they show you how to write it in Java. And then you run their program and out comes JavaScript that you can put on your page. And that allows you to build up bigger applications more quickly and not have to worry about the tediousness of writing all the JavaScript. And it also, built in, tries to handle about kind of the tediousness of writing all the JavaScript. And it also built in tries to handle a lot of the stuff like jQuery and others will do
Starting point is 01:03:48 as far as cross-browser problems. Yeah, I mean, you know, jQuery is sort of limited in the sense that, you know, you're writing JavaScript and you're calling their functions and they're trying to do whatever they can to sort of deal with these browser issues. But, you know, ideally what you'd love is to write something else and have it create separate, just completely separate JavaScript files. And just have something on top that says, if you're IE, run this JavaScript file, otherwise run that one.
Starting point is 01:04:19 And do it at that level where you really have the most control. Mm-hm. Yeah. So- What about, we talked about LLVM before. I have a feeling we're about to get another talk about that. Another one, compiler JavaScript is mscripten. What that does is it takes C++ code, compiles it to LLVM, and then compiles that to JavaScript.
Starting point is 01:04:43 This is pretty freaking wild. Imagine all the things that have JavaScript. That's crazy. And so this is pretty freaking wild, right? Because, I mean, imagine all the things that have been written in C++. Like, let me just give an example. Imagine if you worked at Microsoft. You could compile Microsoft Office to JavaScript. Like the entire thing. Oh, not quite. Yeah, no, actually, LLVM has support for translating different things.
Starting point is 01:05:06 So, in other words, the, what's the drawing thing? The Windows drawing library. Paint? No, no, no, I mean the C routines. GDX, I think. Is that what it's called? Oh, okay. So, anyways, the library, which, you know, actually handles, like, drawing the widgets on the screen and drawing the windows and the framework and all that stuff.
Starting point is 01:05:27 MFC, that's what I was thinking of. So they have different libraries. I don't know if they have MFC, but where they've sort of told LLVM sort of how to translate that to JavaScript. And so I wouldn't be surprised if you could actually do this. I wouldn't be surprised if you had to put in a fair amount of work and didn't just compile it. Wow, look, it works.
Starting point is 01:05:50 I've been able to compile some things. One thing that somebody compiled was there's a library called Bullet, which is a physics engine. And it came with OpenGL samples where you can move boxes around and throw boxes in this 3D environment. And he just ran it through this Emscripten. And it knows to turn the OpenGL calls into WebGL calls. And he had the Bullet physics engine running in browser. That's pretty cool. It's pretty wild.
Starting point is 01:06:20 You should definitely check out some of the demos. Yeah, I'll have to check that out. So since this is LLVM in the middle, does that mean that you can, in theory, use other languages as well? So like Java or Python or anything that can compile to LLVM? Yeah. As a front end? I mean, the Inscripten engine takes an LLVM file as a parameter. And I don't think it cares where that file came from so yeah you could definitely yeah i don't think anything that compiles the llvm now can run
Starting point is 01:06:51 natively in a browser which is pretty wild what if i want to write javascript right before going to bed i might i might be in my pajamas oh man yeah so so somebody had an awesome idea they said what if we basically took the google web toolkit and ported the entire thing to python and that's what they did and so pajamas is a python to javascript compiler and so they try and keep it relatively up to date with the latest google web toolkit it is spelled pyjamas yeah yeah with a y that's right pretty awesome so you can code pyjamas in your pajamas maybe we need to do that this needs to be a milestone i'm pretty sure you'd get an achievement for that oh that might be good uh Another one is reiterating your assertion that people in Silicon Valley are addicted to their coffee, is CoffeeScript. So it's a play on Java, which is,
Starting point is 01:07:56 you know, coffee to CoffeeScript. And so this is kind of an extension, a growth of JavaScript. It adds some of the features that are trying to come into Java, and it kind of makes even more brief syntax and some, I guess, what's called syntactic sugar. So things, different ways, different notation that you can use that allows you to be more shorthand and doing more powerful things with the language and it compiles it's another language that compiles to javascript
Starting point is 01:08:30 but it looks a lot like javascript so some of these other things it would be very hard to write kind of one part in hand-coded javascript and one part in a c++ to llvm to javascript you know that's kind of could get messy. Versus like the CoffeeScript, it's very easy to sit side by side with handcrafted JavaScript. Yeah, definitely. And so the last one we have is called Clojure Tools. Not to be confused with Clojure, which is a JavaScript extension. Clojure Tools with an S is, well, CLOS, closure tools, is it's a language that's very similar to JavaScript, but it adds some extra, I guess, like type safety and things like that.
Starting point is 01:09:15 It's a statically typed language as opposed to JavaScript, which is dynamically typed. And the idea here is if you're doing something, if you're running like a big project, you have like hundreds of developers and there's all sorts of stuff going on, you really dynamically type languages can become an issue, can become a problem. They create bugs that are hard to find. You know, people can accidentally pass a function into something that expects a variable and you don't really have any you know compile time errors
Starting point is 01:09:51 because the system doesn't really know there's it can't make any assumptions because there's everything could be any type so closure sort of you know puts more restrictions on JavaScript with the idea being that you're going to use this for sort of enterprise application that you know you can more restrictions on JavaScript with the idea being that you're going to use this for sort of an enterprise application that, you know, you can use the extra time to make something that's more robust and less likely to fail. And Clojure code compiles into JavaScript. Nice, nice. Yeah, so what are, oh, go ahead. We're going to have to say... Oh, what are some of the strengths of JavaScript? Yes. So we talked about the fact that all the different browsers have JavaScript,
Starting point is 01:10:36 and we complained that they were different between them all. But the nice thing is that if you write in JavaScript, you know that the browser is going to have some support for it. Yeah, I mean, just to explain this in more detail, just to put a contrast on this, if you write your code in C, it's going to compile down to machine code, which of course your machine can understand because every machine has a machine code interpreter that is the CPU. If you use something like Python, the person on the other end, so the person who's running your code, the customer, needs to have Python installed. Or you can do some crazy hacks to sort of inject
Starting point is 01:11:16 the Python virtual machine onto their computer without them installing it. But I mean, those are hacks. But the thing about JavaScript is that everybody has the JavaScript interpreter. You don't have to tell them to go out and download it. It's already on the machine. Nice. Or like Flash, which doesn't come by default on a lot of installs. Yep. So another strength is JavaScript.
Starting point is 01:11:41 Now, JavaScript has something called JavaScript Object Notation or JSON. And JSON is actually used, it's similar to XML. It's a file format that's used in many languages. But it's particularly amenable to JavaScript because JSON consists of the basic primitives that JavaScript consists of. I mentioned before something's either an array an object floating point number or nothing and JSON in JSON something is also one of those four things so you can seamlessly go between Objects in JavaScript and this JSON format so you can
Starting point is 01:12:23 Say take your HTML DOM, which is a JavaScript object, convert it to JSON, and then send it to somebody else. Then he can convert it from JSON to a JavaScript object and continue manipulating it. Nice. Yeah, so there's also the ability to, JavaScript helps you not have to refresh a whole page
Starting point is 01:12:46 like back in the day everybody used to do. Whenever you would click something, pull down a menu and select something, the whole page would refresh. And things couldn't update. Once they were there, they were there. You couldn't get new news stories or new tweets to just pop up into your web page.
Starting point is 01:13:02 You would have to reload to see them. If you want a new mail you had to click the refresh button yep um and so ajax asynchronous java and xml did i get it right yep um has added that ability which was for the javascript to keep running and like jason talked about earlier kind of pull the server and say hey do you got anything new for me hey you got anything new for me and then act on it when something new does arrive that's right yeah so you're going back to the gmail example um there's a javascript thread which is constantly running in the in the background and constantly querying google and saying hey do you have any new mail and uh that's and so how
Starting point is 01:13:43 it's doing that it's actually making a request so in other words there's a website that you can go to a real website in your browser and it would either return like just it'd either be blank or it would have a bunch of json in it which is like pretty unintelligible you know to humans but um python sorry javas JavaScript is constantly going to this website as if it was a real person typing in this URL. And whenever it gets something, whenever there's something to display, it's taking that data and saying, what is this? Oh, it's a new email, and then putting it on your screen. So JavaScript's able to pretend like it's a person and make additional requests and then put the results of those requests on the screen without refreshing the page
Starting point is 01:14:31 yep so uh yeah another oh go ahead no we keep doing this i know we're just you know ever since patrick moved to the valley we've just been on sync i think that's what it is i think you have to move back now we just shorten that delay between us that just enough that now we can interrupt each other fantastic so javascript you know the people who designed javascript they knew that well tabbed browsers weren't around but you know multiple browser windows were around and people knew that you would have more than one website open at a time. And so, and they also knew that websites had to be responsive and that was key to the user experience. I mean, if the server is busy doing something and your browser locks up, I mean,
Starting point is 01:15:17 that's a really bad user experience. You know, often, you know, if you're using Photoshop and you're doing some really complicated task and so you just get the bar that slowly goes across the screen, that's okay because you expect that doing some crazy Fourier transform or doing some magic eraser or something in Photoshop is going to take a while. And so you expect that. But on the Internet, the expectation is that things would be instant or as close to instant as possible. And so to sort of obfuscate all of the time that goes into making requests, waiting for the server, JavaScript is asynchronous, which we mentioned back in the Objective-C episode. It's designed for you to be able to say, hey, I need some data, but I don't want to wait for it. Whenever you have it, let me know. But in the meantime, I'm going to keep running.
Starting point is 01:16:06 And so JavaScript is designed from the ground up to be asynchronous. And that's one of its biggest strengths. That's one of the reasons why Node.js is so popular. The server could get a request from a client and say, hey, go process this. But I don't want to wait for that. I have more clients that I need to talk to. And so asynchronous languages actually make for great web servers. But they also make for really great anything.
Starting point is 01:16:36 So some of the issues, we already alluded to this one many, many times, but the fact that JavaScript doesn't have a standard implementation and exact definition across all the browsers so you got to handle that somehow either by doing kind of if statements in your code all over or using a library that tries to handle it from you or handle it for you and that's an issue that's hopefully will get better one day but i'm not going to hold my breath yeah i mean even today if you look at websites in internet explorer and you look at them in chrome or firefox you'll see different there's either a different visual style or you know there's some different functionality it's just it's it's close to impossible or at least it's extremely difficult
Starting point is 01:17:21 to get things to behave the same and that's why you end up with some really crazy hacks. Like I saw one hack where they got a rounded rectangle by creating a bunch of like really tiny like one pixel high rectangles. And they just by layering a bunch of these like a cake, they were able to create sort of like this rounded shape on the top and the bottom of the rectangle and so it's just you get these crazy hacks because people do crazy stuff like that though because it makes their website stand out different than everybody else's right and you know you think about the process of a website is you have an artist who's using something like photoshop where he can do whatever he wants with those pixels. And he comes up with a mock of like, this is how I want it to look.
Starting point is 01:18:09 This is my vision. And this is sort of the best user experience. And he kind of has the expectation that you can sort of make this a reality. And so often, you know, the programmer has the burden of sort of taking this image that someone made in Photoshop and creating a website that sort of conforms to this image. And so in trying to accomplish that, yeah, you end up with some really crazy stuff. Another thing is that it can be hard with some of this stuff that you're basically going to a website, downloading some code, and running it on
Starting point is 01:18:46 your computer yep but that's exactly what hackers want to be able to do yeah that's just have you download code and run it on your computer because in most of the time when that happens it's a win for the hacker they win that um once code is executed on your computer they can make that code be whatever they want and they win um but the javascript the challenge is you got to be able to do that but limit it and so you can't let it do which kind of will play into the our next point but that you can't let it do certain things because else people would make it do bad things so you have to very much limit what it has access to what it's allowed to do what it's not allowed to, what it's not allowed to do, how it can behave. Right. Like just to put it in perspective, HTML5 adds local files to JavaScript. So up until now,
Starting point is 01:19:34 you haven't been able to create a file on the client's computer. So think about that. I mean, you know, the very first thing you learn when you learn a language is reading and writing to a file. Like one of the very first things is, you know, you create a file, hello world.txt, and you read all the lines from it or something like that. But, you know, up until now, you haven't been able to create or delete files in JavaScript. And it's because of what Patrick's saying. You know, someone else is running code on your computer. And so if you go to some malicious website maybe they create a ton of files or they read your whole hard drive or something like that
Starting point is 01:20:10 so now with html5 there's i believe you know you can you first of all you can't access the hard drive you can only access like one folder on the drive and then in that folder i think you can only create five megabytes worth of files per session so you know they have all these restrictions now and browsers have become more sophisticated so that you can you know do things like that but but yeah you can't there's a lot of things that you can't do in javascript because of that reason yep so what are some of the things you can't do in javascript do you know any you have any in mind any things you can't do you can't access a microphone yeah i mean that's i think
Starting point is 01:20:53 that's huge right i mean look at um uh what was i thinking there's uh so for instance skype skype can't run in just a website they'd have have to use Flash. Yeah, like Google Hangouts. Google Hangouts is sort of a thing where you can chat with different people online. But to do that, you have to download and install and use somebody's graphics processor, which you can't use it directly. But in theory, somebody else could detect what you're doing and decide to run that code on the GPU if they wanted. Right. So there is, and to be completely fair, there's WebGL, which doesn't let you write code to access access the GPU but does let you you know draw triangles and things like that using the GPU so you know HTML5 has unlimited GPU accessibility but yeah and the browser also will do things like use
Starting point is 01:21:58 the GPU to help rescale pictures and things like that but that's sort of outside of control that you have as a JavaScript programmer. You don't know whether or not that's going to happen. Yeah, exactly. So yeah, I mean, really, if you have some kind of custom hardware, if it's a webcam, a microphone, pretty much anything.
Starting point is 01:22:15 I mean, the volume on your speakers. I don't know, I'm just looking around. You have pretty much no hardware. My TV. Yeah, my USB-powered robot that cleans the floor. An airplane. Yeah, your RC plane. JavaScript can't control any of these,
Starting point is 01:22:31 and this is because you don't want to go to some website like crazyjoe.com, and then all of a sudden your printer starts printing, right? Well, it depends on what it's printing. If it's printing something awesome maybe I do if it's a coupon to Crazy Joe's yeah
Starting point is 01:22:48 maybe I'd want that alright alright man well I think that was good that was good good talk about JavaScript
Starting point is 01:22:54 congratulations making it through 10 episodes man pat yourself on the back yeah you too man definitely this is a this is a milestone
Starting point is 01:23:02 I think that every episode has been really has been really awesome and i hope that the people out there uh feel the same way we do that we've really been able to sort of deliver a lot of content with some good flavor yeah i've definitely enjoyed doing all of these and hearing from you guys out there and saying that you know you enjoy the show as well and that's definitely encouraging definitely encouraging and keeps us doing this and excited about doing it. We have a lot of friends now on our Google Plus account of Programming Throwdown. I see every so often, I keep seeing people in there doing stuff.
Starting point is 01:23:39 We're getting a couple more iTunes reviews we've gotten. So that's pretty awesome. Keep doing that. Keep up that work. Help us increase our ranking on iTunes. Yeah, so just so everybody knows, we have a blog, programmingthrowdown.blogspot.com. We also have an email address, programmingthrowdown at gmail.com.
Starting point is 01:24:02 So you can email us any suggestions for new languages that you want to see or particular topics or just give us comments and feedback. We're also on iTunes. You can rate us on iTunes. And we're now on G+. So add us to your circles. Yeah, that's cool.
Starting point is 01:24:22 Also, we should mention that oh I completely just lost my train of thought oh we need to make sure we are on android marketplace as well or whatever the android download too we need to do that somebody mentioned that to me one of our fans oh I don't know what are you talking about android download there's a
Starting point is 01:24:40 they said there's an android podcast oh really like catcher oh I didn't know that yeah oh yeah we'll learn something new every day this person that one of the fans was telling me that that they tried to find us on their android phone and whatever app they were using they couldn't find us on it so oh yeah we'll have to check into that okay anyway sorry yeah well you'll find us on there too once we fix it all right well thanks for listening in and uh like always uh make sure to leave us some feedback yeah definitely have a good one guys and gals the intro music is axo
Starting point is 01:25:13 by biner pilot programming throwdown is distributed under a creative commons attribution share alike 2.0 license you're free to share copy distribute transmit the work to remix adapt the work but you must provide attribution to patrick and i and share alike in kind

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.