About this episodeThis show covers Dart, a client-side browser alternative to javascript. Dart currently only runs in Chrome, but dart code can be compiled…
This show covers Dart, a client-side browser alternative to javascript. Dart currently only runs in Chrome, but dart code can be compiled to javascript and then run in any browser. News: Raspberry Pi, California allows autonomous cars, Stanford online courses. The tools of the biweek are Disk Usage Programs (WinDirStat, Disk usage Analyzer, and Disk Inventory X), and Spelunky.
★ Support this podcast on Patreon ★Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Dart
Oh, a tear. But yeah, so babies have sort of been like a recurring thing, you know? Like, it's like one person has a baby. And a lot of our friends are having, like my wife and I, a lot of our mutual friends are having babies now. And so it made me think about kids. And one of the things that I think a lot about kids is I think about the, you know, how they relate to the internet and to tech and things like that. You should think about diapers. Yeah, well, I just many diapers. I told, you know, Lindsay that, like, we could just adopt a 12-year-old and get to, like, the cool part, you know, where they're into tech and computers. Have you met many 12-year-olds? No. Okay. Yeah, maybe that's not such a good idea. But yeah. So, you know, I was thinking, like, when we were kids, we, you know, our parents—well, maybe your parents are more savvy than mine. But my parents didn't understand anything about computers or the internet. You know, my dad, he thought the computer was like an extension of the sewing machine, you know, using the mouse with his foot and everything. It didn't make any sense. That is awesome. So, we sort of had complete freedom on the internet. Like, and, you know, you could argue that maybe it made us more responsible. Maybe it made us like more adventurous, you know. The internet was kind of like the Wild West, and we could, you know, have access to anything. And now, you know, the internet's become so big and there's so much content on there. And also, there's—it's so more accessible that you have to wonder, like, for kids who are growing up nowadays, like, should you censor their internet or should you sort of give them the same free rein we had?
Yeah, it is interesting. We actually had some friends of ours who have a one-year-old over, and the one-year-old was able to get on the phone and bring up YouTube and find Sesame Street videos and watch them on YouTube. And I looked at the parents and said, 'You realize there's other stuff on YouTube as well, right?' So, and I guess that's only a relatively dangerous place to go on the internet. But, I mean, yeah, it is an interesting question. So, a lot of people do try to install these nanny software or filter software and block certain sites. And the issue I have with those is that they don't really work. And then when the kids get older and if they haven't learned what's acceptable and what's not, they just figure out ways around it. And so, it is not particularly effective. What I think is effective, I think, is educating yourself. So, we have an advantage of, you know, we already kind of know about computers. So, we understand these things. And, you know, tell your kid that, 'Look, I need to be able to have access to your accounts.' Now, you don't ever use that. And hopefully, you never have to. But you need to share with them that, like, 'Look, this is important. I need to be able to know what you're doing,' and it's for their safety. Just like you wouldn't allow them to go with people you didn't know to the park or whatever. And I think it's important for them to trust you to not constantly be reading everything, but they need to know that you can if something happens. And that they need to know that—that's the kind of thing that they need to be thinking about.
No, no, no. That would be hard. But, you know, so that you're watching them and helping teach them good habits, you know. Just like the state requires you to have a parent or some adult who's hopefully responsible around when you're learning to drive. You know, same kind of thing. As they're learning, they need to have somebody responsible around so they can learn good habits and, you know, what's the right way to do things. And then even as they continue to grow up and gain independence, still to have it somewhere where they know somebody will, you know, be around and pay attention to what they're doing. And that, you know, show an interest in caring about what they post online and, you know, sharing with them the danger about. I think it's even different than when we were growing up because when we were growing up, it was still mostly consumer oriented. So, you would go on the internet and consume things. You know, you would read things. You would, you know, go to stuff. And that was a concern is you would view something that was damaging to you or that your parents didn't want you to view versus the relatively controlled media of like a TV or CDs or DVDs or whatever that they would kind of know about. But I think the extra danger that faces children today that is newer is this ability for phones and computers and everything to take video and then post that online or pictures as well. And I see that a lot. That's very dangerous because then the problem isn't you get damaged, you know, and then nobody kind of knows about it except you and maybe your parents or whatever. But that you could actually post something that's damaging to you and your family, you know, for everybody to see. And then the way the internet works, that's really hard to remove references to that, you know.
it's even possible. And so I think that is a far more dangerous thing is people having YouTube accounts where they allow children to upload to YouTube or, you know, even having a Facebook account, reading other people's Facebook statuses can be damaging enough. But allowing your children to post pictures and stuff to Facebook for others to view, that's, I mean, that's a very hard thing to control. I would struggle with not what I allow my kids to watch or view or read, but what I allow them to post.
Yeah, that's a good point. I mean, I think you're totally right on the nanny software. I have a coworker who's in sort of this arms race with his kids where, you know, he blocks YouTube and then they had some other website, which is basically a mirror of YouTube. And they just use that to get around it. And then he blocks that. And they did this whole back and forth. And it really doesn't get the message across, which is that you want ultimately what you want is for your kids to be responsible. And, you know, setting up a block and getting your kids to like spend a lot of their time figuring out how to break the system. So I'm like, I don't know, it might make your kid a great white hat hacker or something like that, but it's not really getting the message. But I think that you're totally right that you should try to, you know, in the beginning, walk your kids through the Internet and sort of, you know, hold their hand, you know, as they get through it. And then later on sort of, I always feel like maybe what I would do is kind of spot check, you know, like if things are going OK and if there hasn't been anything weird or if I jump into my kids' emails and, you know, there's nothing like weird or anything like that, then, you know, you just give them the freedom to do whatever they want. But then if they start getting into things which could be damaging, because ultimately you're responsible. I mean, if they are part of some group that, you know, that hacks into, I don't know, some kind of like power plant or something like that, like as a parent, you'll be responsible for that.
And I think it's a judge when you're checking to say, is this something minor or is this something major? You know, because it's something minor, you know, and it's like it's like the kid who's playing a little rough and, you know, your parents were like fussed when you and your siblings were playing. Like, hey, somebody's going to get hurt. Somebody's going to get hurt. They didn't always stop you. Then somebody would get hurt and they were right and you learned your lesson, you know, and that's kind of the way it worked. Versus if you're doing like, you know, juggling torches, you know, they probably would have stopped you. Like, hey, don't juggle torches. You're going to massively burn yourself. So, I mean, I think that's the thing, too, is like noticing them doing something that's a little bad versus like something that could cause, you know, major harm. Yeah, yeah, definitely. It's got to be a
case by case basis. So I know growing up, I was pretty responsible on the Internet, like pretty well responsible. So my parents kind of let me have free reign even, you know, as technology grew and understood more about the Internet. They never really had a problem with that. But then like conversely, it's really bad about doing chores, especially like leaving the laundry. I'd leave the laundry in the washing machine, like just just sitting like wet laundry in the washing machine for like a day. And then those clothes are like virtually ruined. Like you have to rewash them. First, you have to like let them air dry. Then you have to rewash them. And so so my parents are always on top of me like all of
It's been a while, but we'll try to keep news to relatively new news. So there's this thing you keep seeing around the Internet. First, I thought it was a dessert raspberry pie. And I realized 'pie' was spelled like the Greek letter. And it turns out it's an embedded computer device that looks pretty cool. So a group of people got together and said, you know, that they want to make an embedded computer that's going to be thirty-five dollars that runs Linux and see what people do. And it's similar to what we talked about on the show before, the Arduino and other such devices. And I heard you had found this already independently. Right? You had been looking at these and you even have your name on the wait list.
Yeah. Yeah, definitely. I'm on the wait list to grab a Raspberry Pi. It's relatively small. It's embedded. So for people who aren't too familiar with embedded devices, basically what that means is it's an entire computer on a single wafer. So on a single like sheet board. Yeah, single board. So I'm trying to pull up the specs on how big it is. I think it's like about twice the size of a credit card. So like two credit cards, you can imagine, like squarish, like stacked square-wise. And so it has many different things on it. So it has, you know, obviously a processor, has an SD card so you can pop an SD card, even a thirty-two gig SD card for storage. There's a twenty-five—there's a thirty-five dollar, which is ten dollars more than the base $25 model that has an Ethernet port on it. But other than that, it still has USB, has HDMI out. I think it even has RCA out and stereo out. So you can imagine you're plugging one of these here into your television. You could—it has a GPIO for people who aren't familiar with that. That's basically a way to general
Yeah, that's right. It's basically a way to talk to different things. If you have—excuse me, if you have little motors. So you want to make, say, a robot car or something like that, you could totally use a GPIO interface to talk to those stepper motors or talk to those brushless motors if you're making an airplane or whatever. So you can do all sorts of really fun stuff with it. Do you have any ideas of what you would do if you got one?
These are so there's so many cool things. And actually with the baby, you know, you start thinking of, you know, you see stuff in the store and I can make something that does the same thing. You know, feeding the baby takes a long time, you know, so like if you give the baby a bottle or whatever and they drink, but it takes a long time. They're not good at holding it themselves. I think I really should design something to hold this so that, you know, I can go do other stuff and basically try to be as lazy as possible. But yeah, so constantly I'm thinking of things like that. But I think that having HDMI is really useful. That's something that is traditionally very, you know, and also RCA video. But just having video output built in and so cheap has a lot of things because we've talked about before. It's very rewarding to program something and see it in video and pictures. And that's why I think part of what game programming is. So such a thing that people get introduced to programming through. And the thing that this board being so cheap and having that video capability is very intriguing. And what can you display onto a TV? Because everybody has TVs, and it's understandable. And your friends, you know, if you show a little motor that spins around, it's like, 'OK.' Or, well, look, I blinked this LED in Morse code. 'OK,' like nobody cares. But if you like put something up on the TV and like people like, 'Wow, this is awesome. Like, how did you do this?' So that's really intriguing to me.
Yeah, that's right. That's right. So I get a bunch of those stuff on it. But I think long term, what I'd really want to do with it is either some kind of like social kind of like communication thing. So maybe a bunch of people at a party or something. You could have this as like a centerpiece and talk to it from your phones or something like that. That'd be cool. Yeah. Yeah. And there's definitely make a robot that can fit you drinks from the refrigerator or something like that. You
It takes power. I don't know if it doesn't have a battery per se, but I'm sure people will add a module for that. It also, it doesn't have any type of Wi-Fi like Bluetooth or, you know, or wireless. But it does have a USB port and already some people are mass producing like really tiny little Wi-Fi nubs that plug into the USB port and add a little bit to the profile. But it gives you Wi-Fi and Bluetooth ones as well, similarly small. That's right. And I think they're looking at making a new version, like a Model C or something, which will have Wi-Fi. So look out for that in the future.
It could be cool. Something to keep your eye on. And so the article that brought this up for the news is not only is this cool, but they've had issues again. We never really talked about it here, but a lot of hardware manufacturers have this. It's very difficult to actually build something; unlike software, which you just kind of release it. And it's still very hard to get rid of all the bugs. But with hardware, not only do you have the issue with the bugs, but sourcing the parts, getting the parts installed correctly, making sure you have the right parts. Somebody could send you a batch. You know, I was reading the other day about somebody was trying to make a hardware kit and they got wrong LEDs. And it happened they were counterfeit LEDs. Oh, man. And it causes all sorts of implications. They were going through some troubles with having wrong Ethernet port parts.
done a lot of this kind of stuff before. I've used Gumsticks. Patrick's done a lot with Arduino. And, you know, a lot of these embedded operating systems, they don't support a wide range of hardware. So you might go to Best Buy, let's say, and buy USB Wi-Fi, and it just won't work. And it's because so much on the software level just hasn't been implemented for this OS. Well,
Yeah. So keep in mind that embedded devices run what's called ARM. Most of them run ARM. And long story short is ARM is just a different type of processor than what you have on your desktop. So the instructions are different. For example, like if you want to move data from one register to another, just a way to describe that action in ARM is different. And the set of instructions is different. So because of that, you know, even if you have some USB, you know, Wi-Fi adapter that works in Ubuntu, you know, on your desktop, doesn't necessarily mean that it'll work on these embedded systems for that reason.
Yeah. And it's definitely a useful skill talking about, you know, people interested in skills that transfer to the real world. I mean, there are many, many, many, many, many companies out there doing stuff with embedded computing platforms, systems, and learning how to program in a limited resource environment—that the systems represent is a very transferable skill. Yeah, definitely. So talking about making a robot.
Yeah. So we're going to talk now about California being the second state to allow autonomous cars. So what was the first one? The first state was Nevada. Okay. Yeah. They passed the bill a few months ago. It wasn't that long ago. Up until then, people had been sort of testing autonomous cars in very controlled environments. Then Nevada passed the law not too long ago saying that as long as somebody is in the car, you can have a machine or have a computer driving the car, but there had to be a person there to sort of supervise and take control.
The other week we drove to L.A., which is—people don't know—the drive from Northern California to L.A. is about what, six hours, seven hours, something like that. So it's a long drive. And the whole time I was thinking, God, if I had an autonomous car, like all four of the seats could just face the middle and we could be playing Agricola or Power Grid right now—board games. Yeah. We could totally be board gaming for seven hours. This is like, this is time that is so valuable. Last time. Yeah.
So I think about this, I just, it's going to be one of those things that I think is going to, even once the technology enables it, it's still not going to be here. And it's just going to be one of those things that's kind of because it's going to be so hard. Who do you blame when an accident happens? You know, the officer shows up and who does he write the ticket to? You know, what do the insurance companies do? You know, how do they price that in to insure cars that are autonomous? You know, all these situations or even the—I know there was one case where an autonomous car was driving and got rear-ended. Well, I don't think the autonomy was on at the time, but even if it did, like what happens if it's not even the fault of the autonomous car? The first thing that's going to happen is despite how much does engineers, it doesn't make sense. The first time somebody rear-ends a car that's autonomous and it was 100% their fault, but they have a really good lawyer. That lawyer is going to bring a lawsuit against the other person saying that they want all the source code for the autonomous car. They want it reviewed. They think it's his fault that it applied the brakes too suddenly, faster than what a human could have or any of these things. And basically in a fight to try to get overturned. And then it's going to get caught up in a legal quagmire for the foreseeable future.
Yeah, the thing I'm worried about too is, or just interested—I guess more is a better word—is are people going to be able to game the autonomous car? So let's say half the cars on the road are autonomous and you need to get to work and you're really in a hurry. Like you're late for work. If you turn off the autonomous mode, can you like somehow game the AI that's driving the other cars?
Well, I think early the, you know, like high occupancy lanes and stuff like this will be enabled for autonomous cars because they can drive so much closer. And so they'll be able to say like this is an autonomous car and they'll have special designated lanes for them or share them so that it's different. Because that is going to be the most difficult time. If we switch completely to an infrastructure that supported autonomous cars and there were only autonomous cars on the road, it would be very simple actually. Or when you get onto a freeway, it's required that you have autonomy enabled and you're not allowed to disable it while you're on the freeway. It would be very easy. Yeah, definitely. But between now and then, what do you do? Like you're going to have in the beginning, you know, very few cars which are autonomous, then slowly more and more and more. And through each of these phases, autonomous cars have to behave differently. Yep. Yeah, definitely.
I just, I think that, you know, in some senses though, I think that, I just wonder if people will be more or less stressed. Because, you know, they'll be stressed because they could go faster if they were driving it themselves. Part of the whole thing about the autonomous car is that it'll probably do close to the speed limit. I mean, I'm sure the autonomous AI won't. Well, but that
So, I mean, in the state of California, for those of you who don't know, they actually have a thing. So, if you want to get your car basically, you know, registered to drive, they inspect it and they look for, you know, modifications that aren't approved that make it emit too much pollution. They test it to see how much pollution it emits, all these kind of things. There will be a check, you know, checksum on your, you know, autonomous software. And if the checksum for your software doesn't check out, they know you modified it and they're going to, you know, write you a ticket. Yep.
And if you want to learn how to write an autonomous car, I have another news link for you. Stanford is just starting to roll out some new online courses. So, last semester, quarter, you know, I guess last year at some point, Stanford did the first of these, which was Machine Learning. And I think they had another one as well. And it's by a really reputable, I'm going to mess up the name, Andrew Ning? Andrew Ning. Ning, okay.
It's Andrew Ng. Yeah. And he is a professor at Stanford, and he taught this machine learning class to the internet for free. And it's structured very much like a class that you would take out of college, you know, with exams and everything. But it's all automated and tests and a schedule for you to go through and forums for you to talk on.
Oh, okay. So, I started in it, and then I got busy and didn't end up finishing it. And so, I actually thought about it. But this year, they're rolling out a lot more of those courses. So, I'm here on the list, and some of them include the Machine Learning one again, Software as a Service. This is a buzzword starting to lose some of its shine, but still important. Natural Language Processing, so getting computers to work with, you know, the spoken and the written word. Cryptography, Design and Analysis of Algorithms, Computer Vision. I mean, these are the kinds of things nerds really like. I mean, sorry, we really like. And then they have a few more which are getting ready to come out that, you know, are going to be out this year: Probabilistic Graphical Models. So, this is how Xbox's true skill works on a system similar to this. Game Theory, Human-Computer Interaction, Computer Science 101. Maybe we should have all the parents who allow their kids on the internet to take Computer Science 101.
Computer Security and Making Green Buildings. Really? So, they're starting to branch out, but most of these are still applicable to computer people. And so, I would recommend if you are not a person who's enrolled in college or graduated with a Computer Science degree or not already a programmer and you want to start learning some of those things and getting involved, this is an excellent, completely free resource for you to use. And I think, so, we've had discussions about this at work, about, you know, having a child and what is the university system going to be like when our children, you know, become college age? Will colleges as they stand today exist? Will it be completely online? Will it be a hybrid? What will happen? It's getting so expensive to go to college now. Yeah. I don't think it's sustainable that something is going to change. Something will break. And what's it going to be like? And what does that mean for putting away money? So, it's so big today because college is so expensive for parents to put away money for their kids to go to college. And if college is going to be completely different in, you know, 18 years, what does that mean? How do you plan for that? What should you teach your children now about learning online so that they can be prepared to be in classrooms where there's no physical teacher?
Yeah, definitely. I mean, I know it took several of my courses on—I think UCF called it Feeds, but I'm sure there's something similar at UF where you take the course online and there's essentially a camera set up in the classroom and things like that. But then you showed up for the exams. So, that was starting to approach, you know, totally online. But now I know several courses at many universities are done completely online.
It's a different skill set, though, because there's no—when you have class, there's some—even if you go—depending on your college and what class and your major and your professor's niceness or not, you know, there's some amount of peer pressure and obligation to show up to class and listen to them talk when they're talking. And that keeps you on schedule. If it's on video, you can always just watch it tomorrow. But if you keep just—I'm going to watch it tomorrow, you never watch it. And then what happens when you have to show up and take the test? And, you know, there's a level of self-motivation that you have to enforce on yourself there. Yeah, definitely. Our online courses at university, I remember, even though they were online and the videos were available, people still would go watch the recording of the video. Go watch the teacher be recorded doing it because that was the only way they could make sure that they would learn the material and do well on the test.
Yeah, definitely. I can say from experience that the Machine Learning course is awesome. I mean, I took it kind of as a refresher with some of my coworkers and it was extremely useful. And the cool thing especially about this particular course is that it covers a lot of, like, applied machine learning. So, you know, the guy doesn't go into a whole lot of theory. I mean, there's some of it, you know, what you'd expect from an academic course. But it's a lot of sort of hands-on, very specific examples. And they actually talk about how to, like, image search, for example, is one of the things they cover in the course. And so they do, like, I think they do Google News. So Andrew Ng actually works for Google. And so he brings up a lot of examples from things that he's done in his career. So if you ever wonder how some of those things work, you know, behind the scenes, you can take this course and get it straight from the horse's mouth.
So that would be interesting. So speaking of tools, do you have—oh, wait—tools of the bye week? Although it's not really been bye week any longer. I can't really say that. It's a tool of the bye month, tool of the semi halfway through the year. So what is your tool recommendation for this recording?
Yeah, so this is a problem that almost everybody has, you know, is disk space, right? Whenever I buy a computer, I always buy, you know, the lowest processor to let me buy and the lowest memory. And it just doesn't seem to make sense ever to spend twice as much for a better processor when you know it's going to be out of date. But I always buy the most hard drive space I can, you know, especially, you know, with a laptop. But even with desktops, I fill it full of hard disks. And I always invariably seem to run out of space. So this is interesting.
Yeah, so basically, these are a set of three tools, depending on which OS you use: Windows, Linux, or OSX. Which will tell you, you know, in each directory what disks you're using. So, and more specifically, what it does is it gives you these really cool visualizations. For example, you could say, 'Oh, your programming directory is like 70% of your hard drive.' But then you can drill down, and it'll sort everything for you. So, you can say, 'Like, what in my programming directory is so big?' And then you see, 'Oh, my programming/art directory is huge. It has all these art assets.' And then drill down there and say, 'Oh, you know, half of these art assets are for things I don't use anymore. Let me put these—like, let me zip these and put them on a DVD so I don't have to keep them on my hard drive, right?' So, for Windows, it's called WinDirStat. And if you take a look at that, it gives you—it's pretty cool when you run it. It has like these little Pac-Mans. So, it starts off with just one Pac-Man. And it has like C:, right? Or maybe it has a Pac-Man for every hard drive. But then it says, 'Oh, C: has these four directories in it. It has Windows, programming, whatever, you know, users, whatever it has.' And it will create like four Pac-Mans that go and scan those directories. Next thing you know, there's like hundreds of these little Pac-Man symbols. It's kind of cool.
Yeah, that's right. So, the idea here is, you know, you kick this thing off. And this is true for all three of the programs. You kick it off. You come back like the next day or the morning, you know. And then it gives you all these cool visualizations. Then you go through and start deleting stuff. And it's smart about, you know, if I delete a folder, it goes back and refigures out all the percents and redoes the graph without spending a lot of time there. So, WinDirStat. Yeah, WinDirStat. Look
Yeah, yeah. It's all one word. It's kind of weird. But the show notes has a link. And that's Windows. Yeah, that's right. On Linux, it's Disk Usage Analyzer. And there's no link for this because it comes built in with Ubuntu. But pretty sure if you run, you know, Slackware or Debian or any of these, you know, distributions, that you'll have some type of disk usage analyzer variant on there. Then for OSX, I use Disk Inventory X. And so this one's a little bit different. It gives you this, like, sort of, like, weird quadtree kind of thing where everything's split into cells. But the visualization's not as good as WinDirStat, but it does a similar thing. Awesome. Very
getting work done, my tool of this week is a game. A free game. Not open source, but free: Spelunky. And Spelunky is interesting. And I've only played it a little bit. And Jason got so excited when he saw this that this was going to be my thing. I think he is more excited about this being a tool of the week than I am. This game is amazing. So, he's actually played this more. So, the idea is you are a—we're going to get in trouble for saying this—Indiana Jones-like character. Yeah. So, a cave adventure, Spelunky, referencing spelunking, the act of going down into caves, I assume. Such a clever play on words, these nerds are.
The later ones maybe it can change. But so, even though there's the goal of getting to this randomly generated level, you don't just play on forever. They actually establish a metagame outside of the individual level that you play. And the goal there is that you can continue to accomplish things in each level. And then you can move on through this metagame. And it actually does have a conclusion, Jason, inform me of spoiler alert.
Yeah. So, Spelunky is kind of fun. It's an evolution of, like, NetHack and Rogue and all these games which had, you know, and Diablo, in a sense, which had randomly generated levels. But, the cool thing that Spelunky adds is this mechanic where, you know, it's really hard to go through the whole game without dying. Because you have one life and you only have, what, two or three hits. I think it's two hits. And then you die. So, imagine, like, Mario but with one life, right? So, it's very hard to make it all the way to, like, Bowser's Castle, right, in one shot. So, but what the game does to sort of keep you into it is it takes all the points that you've accumulated, you know, in your very short lifespan. And it puts it away. It puts it, like, in a vault. And you just, these points are accumulated, you know, every time you play. It's just cumulative. So, eventually, you get enough points where it says, 'Okay, Patrick, you don't have to play level one anymore. Like, we're going to start you off at level two.' Success! Yeah. So, it's like you have, like, the short-term game of let's see how far I can get. You know, because if you're super amazing, you could beat the game in one shot. There's nothing stopping you from going right through all 16 levels. But there's also this meta game of, you know, get as many points you can each time you play. And then, eventually, you'll start off, you know, meeting the boss right away.
That's right. That's right. So, it's being worked at by Google engineers, and it has a sort of interesting, you know, genesis. So, you know, Dart is a... Let's talk a little bit about Dart. It's a client browser-based—it's meant to be run in a browser, right? Okay. Similar to JavaScript. So, basically, Dart tries to kind of get around a lot of the drawbacks, a lot of the weaknesses of JavaScript from an enterprise or a big iron sort of view. Wait, JavaScript has weakness? I know. Shocking. Oh, I'm bored. I
Nice. But yeah, so one of the biggest things about JavaScript is that you know, you can get errors at runtime. It's not statically typed. And it doesn't have a lot of the things that many other, like languages like Java and C++, languages which have been used in huge applications. It doesn't have a lot of those features, which make it easy for, like, collaborative development and things like that. So, Google actually made a product called Google Web Toolkit, or GWT for short. And Google Web Toolkit, the idea was you would write code in Java. And then this Google Web Toolkit would turn all of your Java code into JavaScript. And this worked out pretty well. But it has some major issues, and we won't really get into that in too much detail. But basically, it doesn't really serve the full use case. And it doesn't have a lot of traction. So, Dart is an attempt to sort of create a brand new language that can give you kind of like the flexibility and the rapid prototyping that you need to, you know, make things quick and make web apps quick. You know, web developers are all about, you know, keeping up to date with the latest UI, making something sleek, making it look really nice, making it interact with the HTML, you know, and make it very interactive. And so, they don't want to be constrained with all the statically typing. But then, on the other hand, you want to write huge programs that run in the browser. And so, Dart is a way to sort of balance both of these.
This is an interesting point, that when you make a language, everybody thinks they have the right way to make a language. But it's very, very difficult to do everything well. And so, oftentimes, you make sacrifices by saying, this is what we're going to do well. And if you don't like that, then find another tool. Write your own. And so, I guess this is Google stepping up to a plate and saying there were some things they didn't like about JavaScript. And so, they're going to write their own.
Yep. Yeah. And so, Google Web Toolkit was just too much of a departure from the things that made JavaScript great. And so, Dart is an attempt to sort of bring those closer together. So, as we mentioned, it runs in the browser. Right now, there's only—so let's talk a little bit about virtual machines, right? Okay. Yeah.
Right. Surprise! Yeah. Ding, ding, ding, ding. So, it's not—you know, there's no Dart VM for Firefox or Internet Explorer or any of those. So, you might think, oh, if I write my code in Dart, no one else, you know, who uses—you know, no one outside of Chrome can use it. That's not true. They wrote a compiler called Frog. And so, what Frog does is it takes your Dart code and turns it into JavaScript. So, you could think of Frog is to Dart what the Google Web Toolkit is to Java. So, it's sort of a way to translate your code into JavaScript. Okay. But, at the same time, if you don't want to use Frog or if you're using Dart, you can actually detect the person's browser and say, oh, this guy's running Chrome. We can give him native Dart code. Or this person's running Internet Explorer. We'll use Frog and give them JavaScript.
Yeah. So, Dart and Java are extremely similar. They're both class-based. They both have classes, interfaces, this whole thing. They have inheritance. And I believe we covered Java, right? Yeah. Yeah, we definitely covered Java in a previous episode. So, definitely go back to that one. But almost everything in Java, as far as like the architecture, the language, and the semantics, you'll also find in Dart. One nice thing about Dart is that it also sort of gives you some of the features of JavaScript if you want. So, for example, in Dart, you can say `int x = 3`. And now x has that 3 in it. If you later say `x = Patrick`, it'll say an error. It'll say x is an int. And you try to set it to Patrick, that's not going to fly. And so, these are the kind of things that you want as a developer. You know, you want it to give you an error up front. You don't want to have to deploy this code and then your customers run it. And then at runtime, they get some weird error because you tried to add Patrick and 10. You know? And at runtime, everything blows up after you've deployed it, right? So, Dart has that advantage of you can specify the type. You can say, look, this is a number, and it'll always be a number. And if it's ever, you know, if ever something comes in that's a string and I set the number to a string, just tell me right away that something bad is happening. Yeah, don't let this compile. So, but also you can use `var`. So, if you say `var x = 3`, then you're telling Dart, I want x to be anything. So, you can turn it off. You can
Yep. And so, this lets you be very flexible. So, if you really want to hack something up quickly and you want to get out the door, or if you want to be flexible—maybe there really is a variable that could be anything and you want to be able to support that—maybe some kind of user-generated content or something like that. You know, so Dart will handle that as well. Very nice. Yeah. Interesting. Okay. So, another cool feature of Dart that JavaScript does not have is multi-threading. And Dart actually has two kinds of multi-threading because one wasn't enough. Yeah, that's right. If you'll notice, the big thing about Dart, and maybe we'll talk about this later in the strengths, is that Dart seems to try to do everything. You know, it has statically typed, but it can do dynamically typed, and it has many different types of multi-threading. Actually, Dart has all of the Java containers in it, which is something that's really useful. So, yeah. In the case of JavaScript, right, everything is a Map. So, everything is—if you want to say like `day = 3`, or if you want to do, you know, `day = Monday`—if you want to have some kind of enum, everything has to be structured in a Map. But in the case of Dart, you can have lists, you can have sets, you can have Maps, all the things that you're used to in Java. Someone's gone in and written those things in Dart. So, it really comes batteries included, as we talked about earlier.
Maybe, how about I'll go over coroutines, and you go over multi-processing. Okay? All right. So, coroutines are having multiple threads in a single process. So, you might say to yourself, like, why would I want to do this, right? And the answer is, let's say you were waiting for someone to type a key on the keyboard, but at the same time, you were constantly updating your GUI. Maybe there's some graphic animation going on in the background, but at the same time, you want someone to be able to type in, or you want someone to click a button to stop the animation, right? So, you need to be able to do both of these things at the same time. You don't want to have just one loop that says, you know, run a little bit of the animation, and then check to see if Patrick pressed the key, and then run a little bit, and go back and forth. Because this makes the code really confusing. What you really want is to have two different things running at the same time: one that's waiting for an input, and the other that's running the animation. So, you could do this in multi-processing, where you have, you know, two different threads on your operating system that are both doing different things. But this causes a lot of overhead. Anytime you create another process, you have to go to the operating system and say, 'Hey, operating system, I need, you know, I need another space to run some executor, to execute some code.' And it has to go and fetch that for you. And that's a little time-consuming. Also, as we mentioned, Dart can be compiled to JavaScript. And JavaScript doesn't support multi-processing. So, you know, there's no way to do that in JavaScript. So, Dart has this idea of what Dart calls a light isolate. And this allows you to do coroutines, where you have many different threads, but they're all sharing a slice of the same process. So, the process basically will do sort of what I was describing earlier, where it'll play a little bit of the animation and then listen for a keystroke. But from a code perspective, you're writing code as if you have two things going at the same time. And the multi-threaded is simulated. So, this is different than multi-processing, which...
Yeah, so multi-processing, you know, Jason talked about threads sharing a process. And the process is kind of what the operating system deals in. And the operating system schedules processes for the processors to run. And there's overhead there, such as things that include like the stack. And when you make a thread inside a process, you kind of have to emulate that or eliminate it. And there are all sorts of ways of handling that based on what you're trying to accomplish. But multi-processing, in theory, allows you, if you have a whole process and you have multiple processors, the operating system can schedule one process to run on one and one process to run on the other and give yourself true multiple things running at the same time versus the CPU just slicing very finely, alternating between two different threads. So, as a programmer, if the things you're doing aren't particularly intensive, like drawing some animation, checking the keyboard, drawing some animation, checking the keyboard. If neither of those turn out to be intensive or, in this case, checking the keyboard most of the time—you're just doing nothing—then you can share one process on one processor and it's not a big deal. But if you want to render the graphics and also compute a path for some entity, if you're doing like game programming and you want to have AI, those two things are very meaty, intensive things. And if you put them in two threads inside of a single process, it makes it harder for the operating system to know what to do. If you put them in two separate processes, the operating system can say, 'Oh, I'll put one on one processor and one on the other.' And then they can run at the same time and, in theory, make your stuff go twice as fast. There are lots of issues with that simplification, but that's what it means at a low level. But sometimes you don't need that. And there's overhead that's incurred from the processor standpoint—switching the process, having all this extra information that the operating system stores about it, and moving those in and out of the processor, depending on what's running, is something that you want to avoid if you don't need it. But sometimes you need it, and it's worth it if it means you can get scheduled on two different processors at the same time.
Yeah, totally. So the only other thing I guess I can mention on that is that the heavy isolates, you don't share any data, which, as Patrick mentioned, because they're on two different processes. They can run on two different processes. So you have to basically pass messages from one isolate or from the main thread to the isolates versus the light isolates; they can actually share data because they know that they're not. They have to
different languages. And that's something that today is becoming more applicable than ever before because those processors stop getting faster and start getting more cores. This is something that we have to start worrying about: how do we schedule efficiently 32 cores to do something on the computer? And it's not always straightforward most of the time, is it?
Yeah, so I think one of the biggest strengths of Dart is that it gives you the sort of, what's a good way of describing it? It gives you the sort of structure that you're used to that people have been developing with for years. It's not very often that you see a 200,000-line JavaScript program, and many JavaScript developers will say that's a good thing. It's because we can get it done in 20 lines or something. But the reality is if you have 30 people working on a project, you really want things to be encapsulated. Maybe that's the best word I'm really looking for. So you want to be able to say, 'Look, this is my GraphicsHandler class for my part of this game.' And the way you interact with me is you can say like add sprite, remove sprite. So I'm going to give you an interface with some functions, and you can code to this interface. But internally, you know, I'm going to be doing all the handling of the drawing the pixels and things like that. And I'm just going to expose sort of an API. That's the way a lot of these big languages work. Like C++, you have the header file. And you can give somebody the header file without the source file, and they should be able to interact with your code, even though they don't know what's happening under the hood. In the case of Java, you know, they typically use Javadoc, right? So you can see a Javadoc with the API, and you can code to this API, even if you don't know what the code is doing, because it's very structured. You know, in the case of JavaScript, this doesn't really exist, right? It's JavaScript; everything is an object, and it's very hard. You know, you can define an API, but you're doing a lot of the heavy lifting yourself. Dart sort of takes a step back and says, 'Let's give us more of a Java or C++ feel to browser-based, to client-side browser computing.' And that's something that, especially if you go to working with large teams of people, is something that is really beneficial.
It also seems nice that it has the option for static typing or dynamic typing. So if you really want dynamic typing and you're in Dart, great, use it. But if you have that static typing to enable those compile-time checks and make sure you didn't just try to put a string in an integer or vice versa, or try to add three to a string, which doesn't make a lot of sense or is ambiguous, then it's really nice to be able to have that because it enables, again, if Jason wrote one piece of line of code and I wrote another, and I thought he was using a string, in reality he was using an integer, then, you know, it could be a problem. And so it's nice to be able to kind of have those enforcements and checks there if you want them.
Yeah. I mean, just to put an example, I mean, let's say, you know, I was writing this graphics engine and Patrick was using it as part of his game. You know, in the case of JavaScript, I just create a set of functions, but I don't really say, 'Oh, you have to pass in two integers and a string or something like that.' And in fact, in JavaScript, I believe you can pass the wrong number of arguments and it'll just put in nines, you know, for the other ones. So if I go in and change my API, Patrick might not know. He definitely won't know at compile time because there's no compiler. JavaScript is completely interpreted, right? But even at runtime, it could be just really like the code can just do really strange things that you're not sure of if someone, you know, changes an implementation of something. But with Dart, it sort of allows you to, you know, to create these modules. And so it allows two people to sort of work together in parallel without having to constantly stay in sync.
So we already talked about a little, but some of the weaknesses is that the Dart compiler isn't an efficient generator of JavaScript code. You could do better by hand, you know, writing your own JavaScript. Now it tends to be, with any transition, tends to be the first thing that happens is people go, 'Oh, I could write this better myself.' And it's like, well, yeah, but
That's not the point. Yeah, I think at some point someone was telling me, 'I think when I was in like middle school or something, like, oh, we could do this so much better in Assembly,' you know? I mean, it's always true, but at the end it comes down to, are you going to pay the price in your, you know, how much time you have to invest or in how fast it's going to run?'
And so, oh, we failed to do a little bit of research, but that's okay. And so it's still pretty experimental. And, you know, nobody kind of really knows what Google's intentions are per se with Dart and where they're trying to go with it. And so people are playing around with it. We'll see, you know, what kind of happens. But, you know, maybe we do this, this is a little bit earlier in the life cycle of a language than we've done before. But it's something interesting. But, Jason, you did find one kind of cool use, one app that was using Dart.
Yeah, so for everybody out there who has de-soldered their Nintendo cartridges that they purchased with their hard-earned money and put the ROMs on their computer, they could do that. Otherwise, it runs a little Nintendo test suite, which by itself is kind of interesting. You can see how the Nintendo self-tests.
our landing pad. I don't know what the right word is, but now that we're not traveling all over the place, so it's kind of nice to be back doing this. Awesome. Well, until next time... Yeah, have fun hacking with your Raspberry Pi or Arduino or whatever. If you can manage to buy one. Yeah, yeah, if you can get on the waiting list quick enough. So, all
See you later. The intro music is Axo by Binar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 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.
