Cloud + Blockchain – Build Live with Mark Russinovich and Vitalik Buterin – BDL2024

hey thanks Christina my name is Marc Mercurio lead product pm4 blockchain engineering and welcome to build live like to introduce my two guests here we have batalik deuteron co-founder of the etherium blockchain hello we also have mark russinovich CTO of adder so thanks for everyone for joining us I know we just came from another session if you missed our vs code demo you can go to a kms is code you can see a demo of that going right now but we're gonna get some questions or waiting for folks to come in and as they came in I've got a couple questions to get started mark in that last session you showed confidential consortium framework yes huge right so you showed 60,000 transactions per second you so the team can get up to hundred fifty thousand you're the guy behind that you started that tsuki toes a little bit about how that got started and where that came from well so it's related to our work that we've been doing at Microsoft both Microsoft Research in the Nasher on something called confidential computing since back in 2014 this idea that we can create enclaves that are black boxes effectively protected by from heart protected by hardware software from outside tampering and I started to get interested in blockchain and cryptocurrency learned the basics of it and as I learn more about it saw things like the proof of work algorithms that consume a lot of energy and slow down transactions and even some of the other consensus algorithms that really don't provide the same latency and throughput as a centralized database on top of it it's complicated to get confidentiality in block chains you can do it with certain techniques like zero in lawless proofs but complicated to set up complicated to manage very kind of difficult to dynamically update permissions for access and so marrying confidence are competing with blockchain resulted in confidential consortium framework which was previously known as cocoa we launched as confidential or CCF framework it launched on github now and you it's integrated with quorum I demonstrated that in this session so what we can do with the blockchain like quorum is drive very high throughput on transactions per second with very low latency with flexible confidence and so you can take and integrate it with other different kinds of Ledger's and so that's kind of the result of about a year and a half now of engineering work between Azure and Microsoft Research and people can go and download that today right it's on github there's documentation there's technical paper that describes the protocols and the code that you can download build and run wherever Thanks so on the topic of scale metallic on the public chain you and I were talking to a young man he was actual high school student was filing patents he was working on his company that was actually using state channels and so I know there's some folks that are probably new to state channels that might be just getting access to solidity development for the first time working on a theory I'm you talk a little bit about state channels and what they do and how they can benefit today yeah so state channels are a layer to technology that sits on top of the blockchain but where the basic idea is that you have a channel between two parties and these two parties can send many transactions between each other but these transactions don't go on chain right they just mostly stay as messages between the two parties and there's only three cases in which you actually need to send anything to a blockchain one is when you're putting funds or putting assets or whatever into a state channel the second is when you're taking things out of a state channel and the third is when there's a dispute so when like one of the two party is like basically either and of maliciously tries to break break the thing or it gets hacked or like some other really exceptional thing happens so most of the time like you could have thousands of transactions happening you could imagine is being micro payments you could imagine them being like rebalancing a financial contract you could imagine being like all sorts of things and like most of the time that even though the interactions are all protected by the ability to put the state on the blockchain if you need to the most of the time you don't actually need to put any of those individual transactions on chains so scalability increases by a huge amount so one of the other technologies that people have talked a lot about recently is plasma talking about plasma and yeah so plasma is the other big category of the assembly r2 technology is that and if sit on top of watching and rely on the watch unit for security but don't actually put things on to a blockchain and unless there's disputes happening and the way plasma works is a bit differently basically the way that it works is that you have some plasma operator and the plasma operator and I've gathered up a lot of transactions into a block and only publishes a route hash of a block so just a 32 byte hash no matter how big the block is I'm on to the chain every time there's a block and there is a smart contract mechanism that basically ensures that if the plasma operator does something wrong or it disappears or anything happens then if you legitimately own some object inside of the plasma chain the the contract ensures that you have the ability to convert that into an object that's running on the underlying public chain so I think plasma is interesting because it allows you to get a lot of the benefits of decentralization fairly quickly with like a fairly few of the costs basically because you can run something that still looks like and works just a server and you could basically take any existing application that runs on a server and like potentially you got a plasma fly it and it gets you these higher security guarantees but otherwise it just keeps week into working the way it did before and the and if actual like incremental costs of running the thing or very low because the number of transactions you're pushing on to a public chain are very small so it sounds like whether it's a consortium network with DCF where the technology just talked about state channels and with plasma you know the concerns people may have had in the past about scalability for blockchain a really a thing of the past or quickly gonna be a thing of the past yeah I'm definitely very optimistic about scalability at this point so let's shift to a topic that comes up all the time I do executive briefings for our customers all the time and someone comes in with a really great idea and you're like that's a great idea but it's not a blockchain solution so a lot of times a database will do just fine so what I saw this what are the scenarios you've seen people say hey this sounds like a really good blockchain idea so hey you know that actually is better suited for for a database for more traditional style applications unblocked oh yeah so the principle that I think defines what is a good scenario for blockchain is you've got multiple parties you've got some transactions or workflows that they participate in with one another and there's no single entity that they trust or want to turn management of that the tracking of those transactions over to so if they did then that's where a centralized blockchain all right sir centralized database would be suitable but in the case where you've got a bunch of parties they're all effectively peers and they don't want at some middleman to operate the ledger they can operate it in decentralized way and do their transactions and get kind of visibility across them is that kind of case where blockchain could to play a role so one of the things that we were talking about here is is decentralized is versus centralized and so if we look at as much I think we'd all love everyone to run everything in Azure the reality is a decentralized solution if maybe with 30 different members of a consortium at least one of those may be running maybe on-premise or something like that so as you look at that networking and identity becomes super important especially federated identity networking can you talk a little bit about some of things we have in Azure and how people might be able to leverage those for those sorts of scenarios well so yeah if people want to leverage higher-level identities I mean obviously identity and blockchain is really represented with a cryptographic key but what we recommend customers do is they protect that cryptographic key and put it behind some other identity system that grants access to the use of that key so in the case of Microsoft technologies would be Azure Active Directory with the key stored in cryptographic HSM like as your key vault and so you can then give somebody access to or permissions to leverage the key that's stored in key vault to go sign transactions you can revoke their access at any time the keys never made available directly to them and so that would be a more secure Enterprise kind of approach to leveraging identities and key management so let's shift to a scenario for a second so one of the things it comes up a fair bit is media right and so people say hey I've got these I want to attest that this this media file has not been tampered with I want to go ahead and you were talking about that your last session with clinical trial details but you don't put media on a chain right so metallic and mark what are some of the sort of best practices you would recommend for people looking at that from from solutions Harrison media doesn't belong in the chain is it that's right yeah I mean like putting big hulking like PDF music or video files or whatever onto a chain is a terrible idea because the chains just not big enough to hold that stuff and like if you want to use the chain to authenticate files then generally the technique you would use is you would take a hash of the file and put it on the chain and then if you wants to verify it later you would just check the file you received against the hash and if it matches and that's the same file yeah one of the things I liked about the demo that you had mark is you hatched the file you actually metadata to the file so people didn't take the the file and then maybe say it was their own which that match if you're doing like photography things like that and then you also did OCR on the file and you hash the OCR data as well so it was the the image was the same the content the image is the same in the metadata was there and so regardless of what vector you're looking at you had that at two stations across the board exactly yeah so we talked about what not to put on the chain in terms of media let's talk about IOT and so devices can be so IOT plus watchin is an area that a lot of people are interested in you know one of the things that comes up a lot is we talk about provenance oh how did this good get from point A to point B but there's also what are the conditions so temperature and humidity and you demonstrated that in your session as well but should you put all you all the IOT data on there how should people think about when they should what IOT data they should be putting onto the chain well generally what we've seen is that the specific shipment for example would we were represented by an instantiation of a smart contract shipping smart contract that would have ownership and transfers and keep track of the state of the shipment like the humidity and temperature had been exposed to and whether it's in violation or not so the example that I showed and talked about which we've seen companies like 3m support is for asset tracking and for keeping track of the fact that the pharmaceuticals being shipped are within boundaries is have smart packaging that is got sensors on it and the IOT device that it's talking to has access to the smart contracting and fire events into the smart contract to say hey a humidity violation on this particular instance of a shipment and so that shows up in the blockchain everybody can see it everybody knows exactly where it happened when you hand it off you know that that it's that segment of the supply chain that where the issue happened not downstream and so this is really transforming the way that tracking down problems in a supply chain and making sure that goods and services arrive at a destination in a proved state a healthy state can be tracked and it's great consortium example because there's lots of different parties on the supply chain it's not– not just one entity especially if you've got a group like Starbucks working with the coffee suppliers and the different consumers of coffee of those coffee shipments from those suppliers so let's imagine Starbucks oh let's take a pivot on that a little bit one of the things I love about their scenario is they say hey you know what we want to help the farmers we would help the farmers at the first mile they may not know where their coffee is going they may not be getting a fair price it's hard for them to get credit and so there's whole topic in blocks one of things that I'm happiest about that I get to come up and work a block chain every day is there's a block chain for good like where people are leveraging blockchain to provide value to people and you guys travel around the world probably more than most people in this room and talk to me about blockchain all the time what are some of your favorite like watching for good scenarios that you might talk and I think one of the ones that's sane if somewhat underrated is just it's a really dumb one which is like I visited Africa about a week ago and there was a hackathon there and I actually asked the local I'm African community like what interesting things are happening with aetherium there um this the first answer that they gave is just people are using cryptocurrencies to work remotely for first world companies and like just be able to remit the money back to where they live and even just that like it just seems providing such a huge amount of value for them and aside from that I know there's projects there that are trying to replicate like in places like Africa and India they have these different different names for this and all their local languages but these financial or credit systems that are based on these kind of local community mechanisms so you have groups of people that all kind of put their money into some kind of pot and like there's rules for when people can take it out and when people are supposed to put it in and they try to replicate these kinds of things on watch hands um insurance is also interesting like I know there's project saying ether risk is doing like is and thus is doing some of them like there's one in uh Puerto Rico there's one in Sri Lanka they're providing things like insurance for floods hurricanes like droughts just things that are very easily verifiable because if you have something it's very easily verifiable it's sick and that there's a lot of Internet data feeds for you can just take that in turn into a smart contract that's like a few lines of code and I can boom you have an insurance system that so we had talked to some customers about that too and so for folks who are unaware you know a place like Africa you have small hold farmers they have like less than two acres of land and they might make 365 dollars a year so it's not economical for insurance company traditionally they give them insurance and so they'll just talk about you have access to data and so if you know that their farm is here and you have satellite data that says they can with a I you can say drought or no drought you can automatically cut them a claim for that and so you've got sort of this a testable process you've got a testable information and you can just remove this sort of heavy piece which is claims for them right now and then they could go for something that was Impractical to profitable I'm pretty quickly no mark what are some of the scenarios that you're seeing in your travels with customers well one of them is it's related to this all space and I think vitalik touched on it and that is businesses in Africa so doing transactions with other businesses outside of Africa and typically what they have to do is get credit loans from banks and actually the process to go and get a loan from a bank for if you're an entity in a country like that that might be in Africa is extremely onerous and so very few of them actually get approval to get loans from international banks that would allow them to do cross-border payments so that's where crypto currencies can come into play is to help them do transactions outside the country the other place which we're involved with in Microsoft is digital identity so with the un's ID ID 20/20 standing up digital identity and that is also aimed at serving some of these people that are in parts of the world where they don't have strong identities where they're don't have they've got skills but there's no record of the skills that they've got so when they go apply for jobs it's very difficult for them to prove that they've got their requisite skills so with digital IDs and the wallets that go along with them this is where they can carry around data stations of this is me and I've got these skills or I've got these certifications or I've got this history and experience and and then leverage that to go get employment and so that's a where the local infrastructure just does not support keeping track of those things or attesting to them well you put up together with Eid 2020 what was interesting to me and I would I'll admit I was ignorant of the fact but you know you have someone who's born in a refugee camp they could live their entire life there they don't have a nation they don't have an identity and so how do you build up the things you would do in sort of a traditional democracy there and so this was gonna be super helpful for them I think there's lots of things like that I've even heard I know consensus is here and they've done some work in Brooklyn for tokenizing energy from people that have solar panels and so I thought was really cool is like there was a woman shelter and after-school program you could actually donate your energy for them to do some interesting things so even weather as far away or even in our own backyard we're seeing some really interesting things come through so one of the things we have customers talk about a lot is um hey how secure is this and how and and we were talking about the dow earlier today and i think at the end of the day like bad code is bad code no matter what language you put it in and where you where you deploy it and the blockchain spaces is notion of code verification or contract verification you guys want to talk a little bit more about what that is and how that's helping people in these stories yeah so there is a few different kind of families of ideas here right so the underlying goal is basically to just try to ensure that contracts do what what we intuitively expect them to do and not just do things that are civic some crazy and unexpected like have a hole that lets attack or steal three and a half million a third from them so the simplest thing that you can do is just like manual audits and there's plenty of companies that are doing the annual audits going kind of a step above that like basically you can kind of just start adding more layers of automation right so aside from audits you can have testing you can have tools for things like automated test generation there's tools for static analysis and so first and static analysis just tries to go beyond just like running the contract with one specific input and it tries to say for any input or for any input within some range like what are some properties of this program that I can prove and then you can go and into higher and higher levels abstraction and then there's these formal verification tools that let you basically and have expressed claims about code any mathematical language so you might express a claim that says like if this number goes up by some email and then this other number goes down by the same amount and that could be used to report represents some kind of validity condition of a currency transfer system and you could express these conditions and then it would use like automated mathematical theorem provers to try to prove whether or not the code action we satisfies those claims and like this has been done for quite a few contracts and and it seems to be a pretty good way of like me of really cutting down the possibility and that they're serious issues in code so in last section we talked about this vs code extension we said we ship software every day you talked about debugging one of the other things we're gonna be adding this contract verification as well so really looking forward to to seeing how people leverage that well I would say also that aetherium has a great paper on guidance for writing secure smart contracts and safe smart contracts really I mean it's it's a pretty long document but it talks about all the pitfalls that have been seen out in the wild I think is a great resource as well you know I think that's github aetherium wiki we've got safety yeah yeah hosted on github so DevOps and so know a lot of folks in here as a developer running its DevOps not gonna be anything new to them but now we're doing DevOps in a consortium so historically I developed on my local machine I do my tests I would check in and go through a pipeline but now I'm in a consortium of 30 people and so I may have consortium a B I'm sorry a member a B C D and E and E is build an app on this and B is–nothing app on that so what sort of new tools do people need for that can they use the existing tools what about Azure DevOps smart yeah I mean as your DevOps is certainly part of it in fact we've got a white paper too that provides guidance for developers that are writing smart contracts and and want to ensure that they are go through a valid test process that there's gum that they follow the governance for the consortium on updating smart contracts versioning is a key consideration as well because like you said there might be a smart contract that needs to be upgraded and how do you keep preserve the existing smart contract addresses that our applications are built on top of so this is where registers come in for smart contracts where you conversion so all of these are kinds of considerations for creating enterprise-grade smart contracts so just on the enterprise grade for a moment so a lot of customers have processes exist already they're running dynamics they've got office they've got you know you get multi-billion dollar banking institutions using FTP of files you're getting an attachment on email I can see the enterprise is messy how does that work with the the blockchain do we need to go all in and move everything over right now is it a gradual process kind of like going a public cloud was or yeah so I actually showed some demos of some of the things that we've got to support integration because blockchains don't live in a vacuum it's not here's the blockchain and smart contracts are operating in isolation they're in a group they're interacting with outside systems inherently and so when you talk about enterprise and those outside systems could be a dynamics database it could be a sequel database over here it could be a workflow over in this other part of the business so with logic apps with flow the etherium logic ax connector the etherium connector for flow we it's really easy to integrate and we've got integrations for aetherium more coming for different Ledger's those external business systems with things that are happening on the blockchain so both directions actually of integration where the connectors based off of hey some file shows up in a SharePoint folder let's go fire in stage hit smart contract and and deploy that in the blockchain to blockchain transaction just occurred emitting some event we want to kick off some work flow based on that like the humidity out of bounds event for a device or a shipment kick off a workflow that says hey this is the mitigation process we're gonna follow for making sure that thing never arrives in in the hands of a consumer so those are the kinds of examples and really just a few minutes actually it's so powerful to use logic after flow to create these integrations so we're now integrating with existing systems so a question for both of you we talked about IOT data all of it doesn't belong in the blockchain media doesn't belong in the blockchain we got gdpr we've got you know a number we got PII what are some other things people should not be putting into the block any when it comes to data and how should they look at if they if they can't put it in the blockchain how do they make sure that it's a test well how can they leverage the blockchain in those centers you know I think like the the two biggest no-nose are probably private data and too much data so and you pretty much covered that other things the blockchain doesn't provide one big one is like extremely if like low latency this blocks just are going to take more time to confirm like we're in a Syrian right now it'd take about 15 seconds and the future will go down a bit but it's never gonna be as fast as one computer so like if you want a blockchain based thing that has very low latency and that's another actually a reason to use payment channels because what say which channels you can have the same security guarantees as a blockchain gives you like in may often but the way the guarantee comes a student to you as soon as you receive the message hmm so let's talk about scenarios again we've talked about blockchain for good talk a little about hey with the transaction speed you have financial services makes a lot of sense provenance is an area where Starbucks has talked about that in addition to we had Starbucks we had Naomi John Mayer yesterday are there other people you're seeing using using the blockchain for provenance type scenarios any interesting things we're seeing there this is the sort of area where I see you and have lots of proof of concept just constantly popping up popping up and I myself honestly haven't seen anything alive yet that I find super impressive but I'm sure there's things kind of weren't working in the in the shadows diligently as there always are yeah I mean if the if the Starbucks thing pans out that'll be really interesting so there's one that I saw actually saw a couple scenarios of this and the justice and public safety space we think about with evidence there's this chain of custody and you've got a mixture of media and other documents and things like that and so that was one where a bunch of companies came in at the same time asking us about that but going back to hey we want to make sure that it's decentralized we've got hashing on the chain this technology ipfs interplanetary file system you talk about that so for people want to have the storage distributed as well yeah so the IP FS is this half collection of Technology is and it's basically trying to create aims of decentralized way of looking up in accessing files so one of the core ideas of ipfs is that instead of addresses of files and being kind of server based so like something-something comm / something which is basically saying go go contact this server over there and tell him this magic number and he'll give you the file instead you were it's a content-based addressing so you just ask whoever like hey here's a hash of the file do you have a file that has this hash you don't really care who gives it to you so then then on top of that like then they're building the things like distributed hash tables and these mechanisms for searching for files and then you can have layers for actually storing the files so the ipfs definitely doesn't kind of solve every layer in its current form so like if you want to like store files to get about a yeah and get them backed up for a long time then that file point my deck might be the right choice for that or like swarm which is one of the a new aetherium sub projects might uh is also something that what we're working on for that but it's you know like the sort of thing that it's useful for is basically like if you just have a file and you wants to have and wants to have that file stored either for for kind of public consumption so there's a lot of users that would need to download it or for your own backup like you can again serve both use cases you know you can do that so we're talking about etherium but there's really sort of two of theirs right there's f1 and you're hard at work on on f2 yeah if you talked a little bit about f2 and sort of what some of the drivers are for that and sure so the two biggest parts of each – uh one is proof of stake so we have a proven state consensus algorithm called Casper so we were wheel off proof of stake because it's a much more energy efficient than proof of work much cheaper to run also potentially stronger security properties the other big part of it is sharding so this is massively increasing the base layer scalability of public chains by potentially a factor of about a thousand and the way it does this is basically by instead of requiring every node in the network to process every transaction you do you actually distribute the work so you would just assign some random subset of notes to verify each batch of transactions and by doing that like if you have more nodes in the network then your scalability goes up so let me shift gears for just a second it's something someone asked me yesterday mark we one of the things with the new tools we have they work with the public chain and not just because metallics here because you know we believe in the public chain they said hey your your tools connect to the public chain and the tools themselves are free you don't make any money when people demand for the public Jane I don't think why is Microsoft doing that could you speak to that a little bit yeah I mean if you take a look at a bunch of things Microsoft's doing we don't make money off of things like vs code and so it's in the same spirit of that when we go and talk to enterprise customers there's a larger business problem we want to make it possible for them to get going with that business problem and not have to worry on the low-level mechanics and so what this does is make it easier and faster for them to get up onto a solution and we figure if we're there working with them giving them technologies understanding their problems showing them how to integrate with higher level systems like we talked about that they could potentially be a Microsoft or as your customer deploy their nodes on Azure deploy their consortium on Azure or take advantage of the other things that we've got there but at the heart of it too is that enterprises are demanding open technologies that they can leverage wherever they want to and so CCF while that runs in Azure on our SGX servers you can take CCF the confidential consortium framework and run it on your own SGX servers now we hope that as a best place to do that and that the other benefits of that Microsoft and as you provide mean that customers will do that here but if we said some you know created something that's like you can only run it in Azure and you have to pay for it obviously that's gonna limit adoption especially in the blockchain space which is made up of consortiums where some customers might be as your customers other ones want their nodes to run in their own data centers on-premises so we're just wrapping up the session but there's a great question there so can you from one of our viewers know that's Tanya Janka could you please name a few security best practices for a block team yeah so there's different kinds of security on the blockchain so like there's different kinds of risks you want to guard against right so like for example if you the risk you want to guard against there's a risk of bugs in your smart contract code then there is that safety page that I mentioned and there is also all of these like different code verification tools and like audited auditing processes and things that you can go through so there is an entire and if code list of things that you can do if you want to secure assets then one thing to look into is that you don't really want to explore large quantities of assets in a single private key because a private key can easily get lost or I could get stolen like you wants to have some kind of smart contract multi-sig solution and like like the etherion foundation for example stores the bulk of its funds any four or seven multi-sig wallet and like most big projects do something like that so you can do you think do things like that also it's when you're building in application its importance to just kind of reason explicitly about like what security properties you're trying to provide so this is basically just a question of like why are you using a blockchain and I'm in the first place and actually makes are you getting the benefits that you claim to be getting excellent so I think that's a great note to finish up on Vitalik mark thanks for joining us today Thanks I think now we're gonna go ahead and check in with Christina hello Christina all right welcome back to build live we're on the wing the showcase area on the show floor and I'm actually at the JavaScript in typescript booth and then super excited because not only might here with my co-workers and fellow advocates Cassie and Jeremy but we're here with Anders who is the creator of typescript C sharp and lots of other amazing things and thank you for being here so cool I'm not even gonna lie like I'm just kind of nerding out right now I used to borrow a shirt and Kathy we're talking earlier you're saying like you are a c-sharp person yes right you're in this t-shirt you're not a JavaScript person but you might type script yes I love typescript because it makes it a lot easier to do full stack development because it streamlines how I do things from front end to back end very cool and you pull develop types of how long is it that it's we got started probably went public about seven years ago six or seven years ago yeah yeah we worked on it for a couple of years before that so it's popularity like it keeps just rising through those two numbers that we never would have found impossible ourselves yeah but it's wonderful I mean that it makes us really just energized as a team to see that that level of adoption and that level of support from the community yeah it's amazing that's amazing um Jerry when did you start using typescript I started using it actually the day after a conference presenting framework we use back bones back then they review and react and they came out and I said this is gonna be huge so I scrambled back and refactored my whole application to use type stroke and work that into the back so I showed it the normal JavaScript away I said but there's this new typescript thing coming out and look what it could do and I've been using it since then in fact one of the most impactful projects I was on was a massive enterprise project we spent two years rebuilding a bunch of different components to a web-based app and we started out using javascript and we were just having tons of issues velocity for some reason the customer wanted us to deliver it faster ahead of deadline and so we looked at options to accelerate it and we decided to go with typescript and just converting that existing application of the typescript we saw a velocity increase of four times Wow and we were measuring this and tracking this so I became a very firm believer after that exercising definitely okay so you're now going to show us a little bit of a demo why would Josh script people should be paying attention this yeah absolutely and cast contenders of course are going to chime in the kind of their comments as well as a little long so I mean you're kind of doing it in front of the type father so right that there's no pressure when someone comes up and say why should I use typescript and you start to answer and Anders walks around the corner I hope I'm getting this but what I would like to show people is I start with a very simple piece of JavaScript and I've got a function that just takes two parameters and what I'm logging back is I'm doing something very natural I'm saying their first variable calling second variable I happen to multiply that by two now javascript is a very flexible language that's why a lot of people like it so of course what I'm going to type is the answer to everything and past 21 yeah what's interesting is with JavaScript it's perfectly valid for me to do it the other way the answer to everything is and what I love about JavaScript is I feel like it's written with a sense of humor because if we run this application and we pass it it says of course 21 not a number that's not a number and we can multiply it not a number by two and it's still not a number that's why it's fine and so the first thing I tell people is what's interesting is typescript is used by Visual Studio code to give me intellisense inside of the code completion here so if I do food its inspected and figured out what it can that X is anything Y is anything so the first thing I can do the first step to take an advantage of typescript is I can do something like this with comments and annotate what I'm expecting so I'll tell it that first parameter is a string that second parameter is a number and when I do this and I come down here and I look at my function it's telling me string a number which is great but now I'm expecting people to read the documentation right and learn from it I mean and we know we should all should read the documentation but I mean right I like things to be automated so I don't have to keep asking did you read it did you follow it so if I just do this simple comment at the top and tell it to use typescript checking suddenly it throws an error for me and it tells me something bad just happened I'm expecting a string he then passed me a string the interesting thing here is that this is the typescript compiler checking it but what you're writing is JavaScript but we're just sucking the types out of comments so you don't even have to compile this to run it right you know it just runs the way it is and that's why I have a lot of people ask me we have a huge JavaScript code base how do I start taking advantage of typescript and the first thing I say is you can start using these comments and you already get those checks but the other thing I point out is that typescript is really just JavaScript so what I'm going to do is I'm going to take this and just gonna rename the file so that the extension is TS instead of j s and when i do that suddenly oh and i actually move my comments i want to keep them there that's okay i can throw them back let's pretend like we were right here with a Carmack's of string and a parm Y of number and we're doing that so basically it's starting to give me some hints it's saying okay we're in type script world but we have some hints what's nice is if i hover over this it's looking at those document types i click quick fix tell it to annotate and now it's using this typescript notation to tell us x must be a string y must be a number now at the end of the day when i have this piece of typescript i can come down and compile it i'm just going to call the typescript compiler tell it compile the typescript in my directory I get a J's file and if we look at this this file looks very much like the Java Script we started with so there's no surprises we're not taking a completely different language and translating it there's something different in fact the way I used to sort of bait people into trying typescript is I'd point out the JavaScript and generated if for whatever reason this experiment fails you can take the JavaScript that it generated and actually check that in the source control and continue on as if nothing happened now no one has ever done that because there's so many advantages but that's one of the powers of what it's doing takes the risk out of making the change ya know which is important right because you don't want to be okay sometimes I'm using this this what if I'm adding this and make some other change but in this case is right and the other big thing that's huge is there's support for different JavaScript versions right so I may have to maybe in one of those organizations where I have to support an older browser version or an old or node version so what is no I think be more prevalent at this point than the browser stuff right right I mean because and they're released even there LTS stuff that I mean they just had a you know something go end-of-life that if you want something you haven't updated that can be a problem well I never thought we'd see the day that JavaScript would get so many spec updates as quickly as it's getting yeah and so at the end of the day there's a few things I look at past present and future so right now I'm in the past because this index that is that it compiled it took a modern feature called string interpolation which will parse out variables from the string and it turned it into just simple string concatenation because that's what the older JavaScript supports all I have to do is come into my configuration file and I come up here and I tell it you know what I've done with those old browsers I want the freedom of being on the edge so let me go to Ahmed script six which a more modern I'm going to just recompile it and after that simple recompilation which is right there now suddenly it's just past the interpolation through now I said past present this is present but for futures what I've loved about typescript is as new features of the language are on the drawing board and not quite release typescript adopts those features and so I can start using things even if I'm on an older version of JavaScript using the conventions that are perfectly valid modern JavaScript and what happens is when I finally get to switch right and the future becomes the present then it's just passing through the code is done and I've already learned that syntax I think you've shown like so the two key value drivers of typescript one is the type checking and the great tooling that you get out of it or the other is the translation of your code that allows you to target different versions of JavaScript in older runtime environments yes and so it's sort of a combo book but you can actually use it just for one or just for the other where a lot of people use typescript in combination bable for example we're just using the tooling and the type tip and then they're using a different transpiler no transpiler at all amazing amazing Thank You Anders Thank You Jeremy thank you Cassie and we're going to go back to more content moves to you later on go live

You May Also Like