text
stringlengths
0
1.62k
[2586.16 --> 2590.32] the compiler is currently implemented one one actually sort of a general observation about
[2590.32 --> 2596.96] compiler writing these days which is there's sort of the way that the universities will teach you
[2596.96 --> 2602.56] how to write compilers and then there's the way that that you have to write a compiler today for it
[2602.56 --> 2606.64] to be relevant and they're they're actually a little bit divergent right right now because
[2607.52 --> 2612.56] universities tend to still teach you the classic way of writing a compiler with you know you have
[2612.56 --> 2618.96] a scanner and a parser and you probably use some lalr generator you know to generate your parser and
[2618.96 --> 2624.96] then you have your code generator and it's then there's this thing called speed and performance that
[2624.96 --> 2633.36] you you don't get to um but but even more importantly there's this thing called incrementalness
[2633.36 --> 2641.28] that is an absolute must for a compiler that you can build into an ide in an ide when you're sitting
[2641.28 --> 2646.48] there typing code let's say you're in a 15 000 line javascript file that's part of a 50 000 line
[2646.48 --> 2652.96] project which so happens to be how say our compiler works right and i type food dot i want to see
[2652.96 --> 2659.60] immediately what could i type here and and i'm not if it takes more than 100 milliseconds i'm going to get
[2659.60 --> 2667.36] annoyed now delivering meaningful semantically correct answers in 100 milliseconds is simply impossible
[2667.36 --> 2672.08] with the way schools teach you how to write compilers you got to go about it completely differently
[2672.08 --> 2677.36] you got to be much more incremental in your data structures you got to think about different problems
[2678.32 --> 2685.76] your type system has to be implemented in a very very lazy manner that produces just the right amount
[2685.76 --> 2692.88] of information on demand as opposed to binding everything up front and then knowing the answer to everything
[2692.88 --> 2699.20] even though i actually only need the answer to this over here right now so that that's that's interesting
[2699.20 --> 2706.80] and there's a lot of learnings there that i that i think uh are are interesting um with a with an editor
[2706.80 --> 2714.32] too um and this is kind of obvious once i say it but as you're typing most of your program is isn't correct
[2714.32 --> 2719.28] while you're typing right so your your language service has to be resilient to the fact that
[2719.28 --> 2724.16] thing you're having errors left and right because everything's in transition and then you stop
[2724.80 --> 2730.64] you've hit a stopping right literally a single character typed at the right place in your editor
[2730.64 --> 2736.88] can profoundly and completely change the meaning of your program right now most characters don't
[2738.24 --> 2742.40] but sometimes they do you know like you start a comment here and the rest of your file becomes a
[2742.40 --> 2748.16] comment or this identifier becomes another name and now all of a sudden it doesn't shadow another
[2748.16 --> 2753.92] identifier and 10 000 references bind to a different symbol do you know what i mean or just like all
[2753.92 --> 2761.92] these subtle things and and it turns out that doing that incrementally it's a challenging problem and and
[2761.92 --> 2769.12] you can very quickly go astray in oh well i'm going to keep all these tables that backlink to this and
[2769.12 --> 2772.64] then i'm going to try to incrementally update them and then before you know it
[2772.64 --> 2779.28] you're generating so much information that that is so subtle in the way that it interacts you know
[2779.28 --> 2786.40] that you you die a quick death right and and you really have to be pretty you you have to you have
[2786.40 --> 2791.20] to think about this problem hard you know to get it to be fast uh especially in javascript
[2793.60 --> 2797.20] i never really thought about it like that that's that sounds like a really hard problem
[2797.20 --> 2802.88] no i've never had a song it's a fun problem it's a it's a fun problem i and and and uh and i think
[2802.88 --> 2807.76] we we we i mean i'm not going to say that we've solved all but we're we do we're doing pretty well
[2808.32 --> 2812.72] in in our compiler right now one of the one of the things that andrews was talking about before
[2812.72 --> 2816.96] addition to the compiler we have this language service that's open source and and people can play
[2816.96 --> 2822.32] with and we put out we put that out a couple years ago and and people started doing things like
[2822.32 --> 2829.76] adding support to eclipse um more recently there's been a plugin for adam the typescript team has
[2829.76 --> 2835.36] written one for sublime and it's it's kind of neat that this thing is kind of proving itself out in a
[2835.36 --> 2841.20] way right we're sticking it in all these text editors and ides and and getting a nice rich experience yeah
[2842.32 --> 2848.72] but so some some of the stuff we do in the compiler is is um we've actually learned a lot um over the
[2848.72 --> 2854.16] the years from from say functional programming if if you look at how our compiler is is is built
[2854.16 --> 2860.08] internally it it very much relies on immutable data structures and incremental updating of immutable data
[2860.08 --> 2868.88] structures we also strangely in the compiler itself we we generally don't use classes uh the compiler is
[2868.88 --> 2876.40] just written as a whole bunch of nested functions and interface declarations so in that sense it it sort of
[2876.40 --> 2882.00] uses the the other way of coding in javascript you know where you you write functions and then
[2882.00 --> 2888.96] functions return objects that contain function pointers and you make closure over over local
[2888.96 --> 2896.88] state and and so forth so our entire type checker is a single function and that function just returns out
[2896.88 --> 2901.52] a callback interface that you can ask questions on and then it'll lazily go about its work but
[2901.52 --> 2906.48] but but it's and one single function closure and if you want to have three type checkers that's fine
[2906.48 --> 2910.72] you call the function three times now you have three separate type checkers that are maintaining
[2910.72 --> 2918.16] their own separate state internally and um so it's uh yeah so so it's it's it's interesting in in uh
[2919.44 --> 2924.88] in that sense but but i will say too that that is you know like like when we talk about javascript
[2924.88 --> 2931.20] the good parts that is one of the very good parts about javascript is that that brendan got uh he got it right
[2931.20 --> 2938.32] when it came to uh functions and and and uh and closures and sort of the functional aspects of the
[2938.32 --> 2942.96] language then there are other things that are that are not so great but that is a super great thing
[2943.52 --> 2949.36] and it really does work very very well and now with with the vms that that that have gotten good at
[2949.36 --> 2955.84] optimizing that as well it is it is a remarkably productive way to code uh i i'm really enjoying it yeah
[2955.84 --> 2960.96] i'm sitting here listening to to your knowledge here and i'm going to get a little bit upstream
[2960.96 --> 2966.80] perhaps a little bit meta because i'm thinking about uh our universities and the things that we're
[2966.80 --> 2973.20] taught how to write a compiler in university right and how there are very few people who have the
[2973.20 --> 2978.40] skill set and experience to you know retool a compiler in their free time and have a 5x speed improvement
[2978.40 --> 2983.68] um and no doubt and there's that was like based on years of your experience of writing compilers
[2984.32 --> 2989.60] how do we institutionalize some of this knowledge that that few people have how do we pass it down
[2989.60 --> 2995.28] to the next group of people who um need to be writing compilers 10 years from now 15 years from now
[2996.00 --> 3001.44] um have you put thought into that is it just too hard of a problem or no i i something else we can be doing
[3001.44 --> 3008.24] well i think that the the best thing that we possibly could do is open source right i mean and that's what
[3008.24 --> 3013.28] we're doing yeah good point source code for this compiler you get hey you can have it right now just
[3013.28 --> 3019.52] go clone the git repository and there it is and it's not very i mean it's it's 50 000 lines that's not
[3020.48 --> 3025.04] i mean it's it's a lot of lines but it's not that many lines i mean you you can you can find your way
[3025.04 --> 3031.20] around in it you can see how it's done exactly i was i was just going to say the same thing i reading
[3031.20 --> 3038.00] code and talking through code with people that are knowledgeable we can't you can't get away
[3038.00 --> 3043.68] from that and and because it's open source and you have these communities maybe we supplement the
[3043.68 --> 3048.80] the formal education with go work on this open source project and contribute to it yeah i think
[3048.80 --> 3054.40] that's a very meaningful way to do it yeah because that will force you to actually understand how it
[3054.40 --> 3059.36] works such that you can contribute right well not only the the not only the technical side of that too
[3059.36 --> 3063.04] but also the community side of that like you said earlier it's a culture you know you said there's
[3063.04 --> 3067.52] open source there's the real open source way you know yeah i think part of institutionalizing that
[3067.52 --> 3073.52] jared is as you're talking about in contributing to open source is not only getting the code right but
[3073.52 --> 3078.72] also interacting with the community of what the community needs from the from what you're producing
[3079.76 --> 3084.96] yeah yeah well said well said well let's pause here for our sponsor break we get back we're going to
[3084.96 --> 3090.72] get back to adoption and why we've had you know all of these large projects adopted and then we'll talk
[3090.72 --> 3095.52] about in the small like how could i adopt it what are the steps i gotta take so we'll pause here
[3095.52 --> 3102.48] and i'll be right back good news our friends at digital ocean are opening up a brand new european
[3102.48 --> 3110.40] region in frankfurt germany the first in germany fra1 is now open the new region features their latest
[3110.40 --> 3117.52] cloud spec and the full range of digital ocean features including metadata core os and ip version 6
[3117.52 --> 3123.20] something else that's cool is due to its placement on the german commercial internet exchange which is
[3123.20 --> 3128.80] the largest internet exchange point worldwide by peak performance this region will serve germany and
[3128.80 --> 3134.56] its neighboring countries with unparalleled connectivity and speed the story of the german startup community
[3134.56 --> 3140.08] is tremendous and digital ocean is hoping by launching this new region they can play a part in supporting the
[3140.08 --> 3146.32] innovation and awesomeness that's happening in germany so definitely check out fra1 for those
[3146.32 --> 3152.00] subscribing to digital ocean for the first time use our promo code changelog april or changelog may
[3152.00 --> 3157.68] to get a 10 hosting credit when you sign up head to digitalocean.com to get started and now back to the show
[3159.60 --> 3165.76] all right we are back talking typescript there has been a few large projects that have announced
[3166.40 --> 3173.52] that they will be typescript in their next major releases the biggest one being angular which will be
[3173.52 --> 3180.48] angular 2 will be written in typescript and then also dojo 2 will be written in typescript if you
[3180.48 --> 3186.80] guys had to guess or if you had some insight into why now and maybe even some insights into if you were
[3186.80 --> 3191.68] involved at all in the angular decision or if that was completely on their end i'm interested to hear