 Hi, everyone. So I'll be talking about how to build a website that will eventually work on Mars. Before we begin, Bruce already did a great introduction, but let me tell you something about me. So I'm Slobodan Stojanovic, and I'm working with Bolshoi Theater, as you heard. I'm kidding. I'm city of Cloud Horizon. That's a small digital agency. Small digital agency, we're doing different applications for different startups. Part of it is in Montreal, and other part is in Belgrade. And beside that, I'm organizing JavaScript meetups in Belgrade, Serbia. You can follow me on Twitter, and there's a few different things on GitHub. I'm working a lot now with chatbots and things like that. And before we continue, I would like to know something about you. So I have a few questions. The first one is, did any one of you ever visit Mars? No? OK. Is there Elon Musk in the audience? No? Cool. OK, I guess then I am an expert today. OK, so before we continue, I just want to tell you a few things about my talk. The goal of this talk is to explore some different technologies. Some are new, some are not that new anymore. And I just want to put those technologies in a bit unexpected environment. So I'm completely aware that some of those things will not work on Mars, at least not in the way I will describe them, because there's a lot of other things that will just affect that. And this is not a deeply technical talk, because first I need to give you a context why would anyone build anything for Mars. So that will take some time. And the topic of this conference is problems for today and ideas from the future. So this talk will be a bit different. We'll solve problems from the future with ideas from today. OK, let's start. First, I guess you have really important, let's answer the most important question you have. And not that one. Why Mars? Why would anyone build anything for Mars? Let's see what do we know about Mars? It's a planet. That's a bit obvious. So approximately, Mars have the same landmass as Earth. It's quite smaller. It's just 15% of landmass of Earth. But since we have 70% of our planet covered by water, so landmass is almost the same. So that's nice. Second great thing is that day on Mars is almost the same as the day on Earth. So for example, our plants will really love that. We don't need to create a completely different environment for the plants and all other things. So again, that sounds great. Third thing is a year on Mars is twice longer than year on Earth. And that's, again, not a big problem. So if you're Santa Claus, you just rest a bit more than on Earth. Temperature on Mars, it can be 20 degrees. So it's not nice as Barcelona, but it's not too hot. So that can work really well too. And the gravity, that's important too. So on Mars, there's just 37% of Earth's gravity. What that means is that we can jump much more, or I don't know. You don't need a elevator to come from second floor or something like that. You can just jump out the window and everything will be OK. And there's also signs of liquid water on Mars. There's a lot of ice. We know that. But there is some signs of liquid water. So that's great too, because we need water for the living. And that's not all. There's a lot of other cool things for Mars. For example, the biggest mountain in the solar system is on Mars. So it's much, much bigger than Mount Everest. And they have two moons. So just imagine the sky in the night. That needs to be really great. But of course, there's but. There are some problems with Mars. First one is that just 18 of 40 or even more emissions on Mars were successful. Most of other failed. That's a problem. But at some point, we'll probably solve that problem, because our technology is better and better all the time. The second problem is that temperature can be minus 153 degrees. And that's not that nice. So just imagine something colder than Antarctic that looks like Sahara Desert or something like that. So definitely not the place where we would like to live. Yeah, but that's not the biggest problem. There's a big dust storms on Mars. And it can last for a few months. And it can cover almost the whole planet. That's not nice, too. But again, that's not the biggest problem that we have on Mars. There's radiation, because Mars don't have the atmosphere like we do. So there's much, much more radiation. And again, that's not the problem, because we don't have an atmosphere. So that's the first thing. We're not able to breathe anything. So we'll probably not survive long enough for radiation to kill us. So why would anyone go to Mars? Earth seems like a perfect place for a living, right? We have, I don't know, we have air. That's great. Temperature is quite nice. Then I don't know, there's a lot of water and everything. So everything seems really perfect. And it is. But it's not that perfect if you ask dinosaurs. So in Earth's history, there was a lot of mass extinction events. There's five of the biggest one on that chart. And in each of those events, we lost more than 50% of all species. And one of them, we lost 19% to 96%. Almost everything live on Earth. And that's not so great, right? So we are software engineers. At some point, if we want to survive as human beings, we just need to make some kind of backup copy or something like that in different data center. And why Mars? Why not something else? First, let's go back to this. Sorry. Those events are not that often. So we are safe for probably the next few thousand years or even more. But if you don't start exploring those things right now, we never know when the next one will happen and how it will affect us. And what's our options? First option is Venus. Oh, sorry, Mercury. It's not a really great place for a living because it doesn't have an atmosphere at all. And it's too close to the sun. So during the day, it's very, very hot, extremely hot. And during the night, it's very, very cold because there's no atmosphere that can keep the temperature and everything. And again, there's Venus after that. It's even worse. You have an atmosphere, but very thick one. And we wouldn't survive pressure or temperature or anything else. There's actually a place in Venus where it could be really nice for humans, but it's 50 kilometers above the ground. And we're not that great with building floating cities or something like that. So that's not an option. The next one is Mars, of course, with not so perfect options. But again, we can make it work somehow. And after that, all other planets in our solar system are too far away. And they're gas giants, so we are not able to live in them. OK, now, because we are talking about how to build a website on Mars, I want you to imagine that you have a website, some kind of website that will be useful to people. Any kind will not get into the details because we don't have enough time. And let's just forget about that for now. Let's go back to Mars. So at the moment, Mars is the only planet inhabited by robots only. At least only that we know about. There can be some other planets, of course, but we don't know about that. And yeah, there's that crazy small creature that we don't know maybe exists on Mars. Until one day in the next 10, 15 years, that's not that far away. Some people start sending other humans to Mars. That will be a slow process, but they're planning to send first humans on Mars in, I don't know, next 10 to 15 years. You're not able to send humans on Mars any time you want because you need to wait for planets to be aligned because you don't want to travel for very long distance. And the plan is that in, I don't know, next 100 years or even more, Elon Musk have a plan to send 1 million people to Mars. Why million? Because he thinks that that's enough population to build self-sustaining, I don't know, colony on Mars that doesn't depend on Earth. We'll see how that will work. So in the beginning, people, of course, need some things. You probably know what this is. And when we get to Mars, first we need to find something to build some kind of colony where we can breathe and where we have some food, water, and things like that. Then we'll continue building a society as on Earth or probably a bit different, but we'll fulfill all those things that we really need. And after that, there will be something else that we really need. It's Wi-Fi. So at some point, we'll definitely have an internet on Mars. And how that can work at all? Let's see. So imagine one day you have that website. You remember that for a few minutes ago. From a few minutes ago, sorry. And one day you receive some message like this. And you just ask, OK, can you tell me a browser and a bit more context about that, and then you receive something like this. And so what's the problem? Why it's not working? OK, you start reading a lot of different things to find the problem. And the first thing that you see is the distance between the planet. So in perfect alignment, there's at least three minutes between for light needs at least three minutes to travel from Earth to Mars. So if you're sending information at the same speed, round trip from Earth to Mars will be six to 44 minutes. That's not working with TCP IP protocol and anything else. The first thing that you can think about is just, I don't know, deploying your website on some data center on Mars. And that will probably work. But in the beginning, AWS was just building their data center. So we need to wait for them to finish it. OK, what else can we do? We have large delay. It's not just a small latency or something like that. It's really huge latency. So no Netflix video or audio calls or anything like that. And I know he's not happy about that. But OK, so what can we do when we don't have enough servers? Maybe go serverless? I actually really like serverless, but it will not work with this. So let's see how do we communicate on Mars. At the moment, we're using just radio waves. So each spacecraft sends radio waves, the same radio waves that you are receiving in your car or something like that, to Earth. And then NASA has the very big receivers that just try to receive those things, those waves. And then it tries to respond with the same waves. And most of the time, they're really big because we're building our spacecrafts to save the energy and everything. And they need to be really precise because they need to travel very far. And they need to deliver some information. And then you need, of course, to parse that information and to do something with it. There's interplanetary internet, too. This thing is not new at all. They're working on that for, I don't know, 20 years or more. And how it works. So for example, on this GIF, you see how much time light needs to travel from Earth to Moon. Just imagine how. So in perfect environment, we would have interplanetary internet that will be fast as light. And let's just assume that. But let's see how it works. There is delay and disruption-tolerant networks. And they're a bit different than networks that we know today. Networks that we know today work something like this. It just sends packages and wait for them to return. And if something just stops working, they will just retry. But you need to send package from end to end. That's a bit problematic with Mars because we have 22 minutes. And you're not able to communicate if the sun is between the planets or if Mars rotates and the satellites are on the wrong side of the planet or something like that. So what we can do. This is a delay-tolerant network. And how it works, it's just some kind of store and forward method. So it stores all the packages. And it tried to forward them to the next node. If something breaks, you'll see it now. It will just try to resend it from the last node. Our nodes are, I don't know, satellites and old satellites and any other device that we can use as a node. So interplanetary internet is basically just the network of internet with that protocol in the between that can communicate a bit differently. But I don't know much about the network. So let's go back to web development because we already know much more about that than the networks and everything. First thing that we can do on Mars is, of course, to go offline. When we first load our website, so how do we load our website? I guess they will need to update something on some servers on Mars because we will have some servers. But most will not have big infrastructure. So we'll not be able to deploy everything to Mars, at least not in the beginning. And, of course, NASA will use a lot of those things. NASA or whoever else will use a lot of the resources to send more useful information than, I don't know, YouTube videos or something like that. So the first thing we can really do is just to make our website work to allow our website to work offline. And you already heard before this talk about service workers, so I will not go that deep into the details. But service workers are just like some proxy between a browser, your application, and network. So we can cache all the files. We can, I don't know, intercept network requests and just the requests that really need to go to the server. If we have network, if we don't have network, we can get something from our local cache or something like that. And we can allow push notifications. And we can do a background sync and things like that. So I will not show much code today, but some basic example of service worker will be something like this. So first, you need to check if browser has the support for service workers. You need to do that because some browsers, unfortunately, don't have support for that yet. And we don't know when they will support it. And after that, you just need to register files that you want to cache locally. And that's basically it. You can do much, much more with service workers. You saw that in the previous talk. Then you want to send. You don't want to send a lot of API requests to the server because if anything goes to Earth, you need to wait a lot for that. If it's on Mars, again, you don't want to make, I don't know, much pressure on that server because it's, I don't know, all the other people are using the same server, so we don't have infrastructure again. So the thing you can use is GraphQL or something like that. We heard more about that yesterday, but instead of sending API calls with the classic REST API and things like that, we can just use GraphQL to request everything that we really need for that view and store that somewhere. Beside that, it's good to have some local copy of the data and everything. So for that, we can use index DB. It's not working perfectly in all browsers, of course, but it can be useful at the moment that when we move to Mars, it will probably be a bit better. Maybe so far, we'll fix the bugs and everything. So what's an index DB? It's just a low-level API for client-side storage. And there's a few concepts that index DB is using. First one, it just stores key value pairs. It's a transactional database model, so everything you do is some kind of transaction. It's mostly asynchronous. Then it uses DOM events to notify you when some things are available, so you have some kind of success and there are events and things like that. It's not using SQL, so it's basically no SQL database and you need to be on the same origin to be able to use it. So that works nice. I will not show the code because the API for index DB is not quite nice, but there's other things that you can use. For example, there's PouchDB. That's basically just the implementation of CouchDB in the browser and it syncs really well and it works really well offline. So basically, you can synchronize with some database, CouchDB on the server and get just the data that you want and store it on your browser. And when you make some changes and things like that, whenever you're online, it will try to sync again with the real server and to send your information to the server. So it's great for offline experience and things like that. You can use it with nod or with many other things. It works with index DB, with web SQL, with local storage and things like that. And here's some basic example. It's really simple to use. You just need to create a new database to put some data into it and to connect to the other resource that you want to sync with. We are talking about background sync and things like that. So for example, when you try to send some data to the server, what if server is not available at that moment for any reason? What can you do? Basically, you can send the, I don't know, API requests and things in the background. So you can just, if you don't have connection, browser can, some browsers can, but many others will be able to do that in the future. But you can just basically save that somewhere. So even if you close the browser, system will try to send those requests when you have, I don't know, an internet access again. So that works really nice. And for example, it would be great to do some kind of periodic things or something like that. So for example, if you're reading your news at 10 in the morning, it can sync with the server at, I don't know, 7.30 or something like that. Beside that, the other thing that we can do is just upload and download big resources with service workers. It's not working right now, it's just a proposition, but the idea is to enable background caching of multiple resources. So for example, you have some big files or something like that, and you just close the browser. It will continue to do that in the background because operating system will continue to downloading and uploading everything, and it will just let you know when something is ready for you to use or when something is uploaded. And of course, it will allow you to react somehow on if something fails to upload or download. You can read more about that on this link. And that's it for service workers, but that doesn't solve all of our problems. So if we don't have a server, how can we communicate at all? So there's peer-to-peer connection with WebRTC. We still need server in the beginning just to connect with other people on the same network, but after that, we can send files and everything just by peer-to-peer connection. WebRTC is a free open source project that provides real-time communication for, it provides simple API for real-time communication and it works in the browsers. There's a few APIs that it implements. First one is media stream. So for example, if you want to do voice calls or video calls or things like that, you can use that. There's RTC peer connection that's just for managing all the connections and things like that. And the third thing is RTC data channel. So you can send the data, not just media, not just video or audio or something like that. Here's some example how to do that. WebRTC allowed us to build implementation of WebTorrent inside the browser. So what that means is that you're basically able to load and upload Torrents from your browser directly. Why something like that is important for Mars? It's important because for example, if I want to watch some movie and some of you have that movie, I don't need to download the movie from Earth or from server or whatever. I can just stream it from some other people in the same network. If it works for movies, it works the same for images or things like that. So it can solve our problem with media and with loading resources and things like that. So as you can see on their website, just imagine peer-to-peer YouTube. So you don't have servers, you just load everything from other people. That works great for us. And it's quite simple to use it for some basic use cases. You just need to do something like that. You need magnet link, of course, but everything else is quite simple. But if you can load images and I don't know videos and things like that for peer-to-peer connection, why wouldn't you be able to load, I don't know, HTML, CSS and JavaScript? That seems like it's just a file. So if you can load one type of file, you should be able to load some other types of files. So there's a thing called Hyperdrive and it's a file sharing network based on, it's basically something that allows you to make peer-to-peer Dropbox really easily. So you can share files and you can, I don't know, load files from other peers. And as you can see, that is using that as a main protocol. That can allow us to build something really cool. We can build, for example, I don't know, just imagine a distributed app store that doesn't have a server or something like that. So for example, if you have some application, I will be able to load that application from you via peer-to-peer network. And we don't really need servers so we can ship whole applications or updates or things like that. We are just simple peer-to-peer connections. Of course, we heard more about this a few days ago but instead of, I don't know, instead of Hyperdrive and things like that, we can use interplanetary file system that will work too because they can transfer a large amount of data from one machine to another. We appear to peer in other protocols. Okay, but those are the things that we can do from, I don't know, with the technology that we have today but that doesn't solve all of our problems. It just solve part of the problems. What are the other problems that we have? So for example, things like timestamps are a bit problematic. As you can remember, the day on Mars is a bit longer than day on Earth. It's 40 minutes longer, that's not much, but again, it's enough to cause some problems. So we probably need a better way to manage timestamps and things like that. Beside that, how do we do login and things like that? So for example, you want to access Facebook. How do you do that from Mars? Because you're not able to connect with Facebook all the time to check if token and everything else is valid. So that's another problem. Then security and privacy, how do you, I don't know, how do you stay secure on Mars? Because we don't have all the system that we have on Earth and if majority of our infrastructure is on Earth, how do we just check if, I don't know, right person want the right file or something like that. Of course in the beginning, we can just assume that no one else will do that because we'll have a small population, but at some point that will be, I don't know, very big problem probably. The other problem is how do we test anything that we want to deploy to Mars? Because it's a completely extreme situation. So how do you simulate that on Earth at all? So that's some of the problems that we are not able to solve on front end only. We need to, I don't know, to use back end of course and we need to find a better way to, I don't know, to handle those things. So what's the message of this talk? Is the message that we now know how to build an Instagram for Mars or something like that. No, it's not. It's not important still because we still have a lot of time until we send people to Mars and until we have problems like this. But the main problem we have today is that most of the things that we are building today are not working for everyone on this planet. So most of the time we just don't care about, we just assume a lot of things. And for example, if you live in, I don't know, Southeast Asia or Australia or something like that, you have a huge latency because majority of servers are in North America or Europe or something like that. And there's a lot of people with poor connections and they're not able to, okay, we are building faster web applications and things like that, but it's really hard to use all those things in some places without stable internet and things like that. So for example, how do people on, I don't know, South Pole or something like that check their emails because they don't have secure connection. They have huge latency and things like that. And we need to try to improve application that we are building on Earth because at some point we'll need to build applications that we need to deploy to more other planets on or who knows what and we're even not able right now to build applications that will work on this planet, on all parts of the planet without the problem. And basically, that's all from me. If you have any questions, you can ask them with that hashtag. Thank you, Slobodan, that was really cool. I really like the way you ended there because I was talking recently to some people who travel around African villages vaccinating their children and they're offline for days and days and they're using pouch DB and service workers. So it's a real problem as well as a fun trip to Mars. Actually, they tested interplanetary internet on some villages far north and things like that because they don't have stable connection and you can have big latencies and excellence. A few questions from the audience. Is there a limit to the amount of stuff that you can store in the service worker cache? Do you know? Yeah, there's a limit and it depends from a browser to browser but that thing will evolve so we'll probably be able to store more things. And presumably it depends upon the memory available on the device. Of course, but you can ask for more memory and things like that. So for now, that's not the big concern. Excellent. And the same question I put to Andrew because you mentioned Safari a couple of times. Is Safari the new IE6? I don't know. It's just Safari. We'll see. It will introduce problem. Actually, we already have some issues with Safari. It works differently than other browsers but we'll see how it will evolve. Thank you. Well, ladies and gentlemen, give it up for Sloboda, please. Bye.