# Yul - Intermediate language for Ethereum by Alex Beregszaszi (Devcon4)

- Speakers: [Alex Beregszaszi](https://streameth.org/speakers/alex-beregszaszi)
- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2019-10-09
- Duration: 09:41
- Topics: blockchain, smart contracts, distributed ledger, Science & Technology
- Watch: https://streameth.org/watch/yt-j6N9rdJXqN8
- YouTube: https://www.youtube.com/watch?v=j6N9rdJXqN8

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
https://archive.devcon.org/archive/watch/4/yul-intermediate-language-for-ethereum

This talk will give an introduction to Yul, the intermediate language developed by the Solidity team. We'll go through the motivation, design decisions and progress of implementation. Yul is designed to have multiple targets, EVM and ewasm, and support multiple languages as a frontend. We'll touch on languages using it (Flint, LLL) and what is ahead in order to support it in Solidity.

Speaker(s): Alex Beregszaszi
Skill level: Intermediate
Track: Developer Infrastructure
Keywords: yul, language

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 4 was held in Prague, Czech Republic on Oct 30 - Nov 2, 2018.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

hello again so it's actually not brand new in like blockchain terms because it's it's a year old so it's like really old at this point okay you'll which is it okay so some of you may have attended eff country and may have seen this at a talk called Yuliya which I had last year there's some overlap between that and this one but yeah after definitely we did learn that there's another language Julia and maybe we shouldn't go our language Julia's well so we decided to rename it to you so that's that's the real talk about okay the design goes for you the couple of these angles we had but first of all it has to be easy to read and write secondly it has to be a good base for transformations for more importantly optimizations on top of it and the third main point is that it should be a really good base for auditing so actually these three points play together by having it easy to audit the we're writing code as like single instructions in a function you know the smaller decoded the easier to audit and and as a result it's quite easy to read but it's not well optimized it uses a lot of gas so that's why we need a lot of good optimization steps on top of it and the last big point for the design goals is to support multiple target VMs and of course it supports EVM but it also supports even 1.5 and II wasn't okay some of the features we have in Yul itself it does look like in assembly language but it's heavily augmented from an assembly language first of all it has variables and it also has blocks and the blocks are the own scopes variables declared in blocks are not visible outside and you can nest blocks and then we also have two really high level constructs which are quite uncommon in assembly languages via for loop and we have a state switch statement but we do also have like this single condition if statement for those cases where a switch statement would be in a work you'll more importantly as mentioned we have functions and we function calls functions can be fee redefined and lastly we have types and that's kind of unheard of in assembly languages so that's why you'll is more like an intermediate language for compilers than an assembly language but it can be used in SM and s an assembly language to write manually contracts in okay just what it looks like an example of the switch construct this is a function there's a switch statement with three cases the case zero one and the default as you see there is no break statement in the textual blocks because it there's no fault true if it goes to k zero it wouldn't go to case one but this can be written as a for loop as well city is what it looks like writing it as a for loop now here you can identify that it is closer to assembling because we have those idiom like instructions LT for less than add and what is less or more so it is like an Augmented assembly okay you'll itself originates from the solid eight in lies assembly which you guys probably are familiar with because it can be used within solidity so this analysis time he was interest like two years ago it had instructions and jumps didn't really add anything else it did add like variables but didn't had all these nice features I explained these nice features we introduced probably a year ago we added the functions and foreign switch and they can be used for a year at this point now with zero five zero if you're making a big change and we're removing some of the features in an inline assembly we're removing jumps but you guys shouldn't be afraid because the foreign switch statements are very better to do the same things you were doing with jumps here I also must mention that even though in an item there was a single version of a line assembly presented to you guys but in the back end we had like three different versions of it and the solidi compiler can be used in assembler mode and all these three different versions can be accessed to the assembler mode so the first version is this inline assembly the bad one which has jumps the second version is the strict inline assembly which is you as I explained but the third version is district' inline assembly with types now with zero five zero we're not gonna have types yet but with zero six zero we are planning to have full complete you'll support now I must expand here what what the hell does it mean soon it here iam basically deploying a contract is a two-step process there's a constructor which we usually call the init code this is being sent to the network this constructor is executed it can change the state and it can also return a byte code which is stored in the state and that's the byte code for your contract currently there is no way to represent these two stages in you but we do have a plan to do that and that's what we call you'll object so that's like the next big part we have to do and then you will be fully capable to write contracts in and then lastly probably at zero seven zero we're gonna have types mandatory and we can have user-defined types but you say defined types here I actually mean a specific type for a memory pointer a specific type or storage key and storage value may be actually user-defined types later okay so when are we gonna have this in solidity it's gonna take a while but it's already in solidity partially it's being used in the ABI encoding v2 which is a complete rewrite of the API stuff are we gonna talk tomorrow at Great Lengths about all the changes in solidity so you guys should listen to that there are two blockers we have this in solidity have optimizations but the good news there's a lot of optimization work already being done so that should be covered soon enough but the other big blocker is rewriting this code generator so in solidity we take the source code we do the Perseid we do analysis etc and in one stage we generate EVM bytecode which probably is a bad idea so we need to rewrite this this one step into two steps to generate Yule and then use you to giant EVM but this only gonna start up to zero five zero but that's like the big plan for next year okay there other languages actually already involved with you apart from solidity there's this language called Flint which is a swift light language and it targets you it actually works I just tried it yesterday and okay it's not compliant with zero-five-zero but it works there's is a prototype lll to your compiler which is really small and there's also this other language called logic on which was a each Berlin project which also targets you hopefully I mean that's my personal hope but probably the entire sold it ensures that that you will going to be used and utilized by the entire ecosystem and hopefully we can convince the viper people to also use it and get all the benefits we have okay the tools regarding you obviously pretty much everything is the solid is in this solidity compiler which is C++ but there's also already a rust implementation of you and it interests implementation of this called you'll serve it is trust implementation you can create your code programmatically and you can print it out but you can also parse you'll code do transformations on it and printed out and this rust library is also integrated with so see to tap into the optimization steps and the compiler there's like one other use case I really like called why EVM so basically yvm is came from a need we have any wasn't so but he wasn't even a replace the VM entirely and we want to give you this webassembly only client but probably you still going to execute even bytecode and you can do that with ye VM so why a VM translates even byte code into your source code which can be also compared back to a VM and validated but it can be also compiled to II wasn't directly I think this really cool project and I hope that they're gonna be utter you know independent third-party you'll implementations and analyzers for so basically that that's what I wanted to tell you guys you should check the documentation so make sure you follow the link I have there which is latest don't go to the 0 for 24 or 25 version of it go to the latest also join our channel ask any questions interact with us and please contribute to user in yvm we need your help thank you guys [Applause] you
