ElixirConf 2020 - José Valim

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone thanks for the intro i hope you had a great first day so today i'm actually with a very short presentation um with what is new in elixir it's more of a dramatic reading of the elixir change log as we'll see with some nice bits here and there so so yeah let's get this started so the next elixir version is going to be elixir 1.11 and we are hoping the release candidate is going to be out this month so we'll have the release at the end of this month or beginning of october as we we planned and some nice information we have crossed uh more than one thousand contributors to the language uh the whole ecosystem is nearing uh twelve thousand packages on hex and we are almost crossing uh two billion downloads which is quite impressive because if i remember correctly when we started the year we had not crossed or just crossed one billion so that's uh really nice so what are we going to talk about today so there are some topics i want to cover cover from alex 0.11 this is not a complete list it's more like the most exciting things in my opinion come in the next release and we're going to talk about erlang interrupt compile time checks compilation time improvements configurant time and some of the new apis so let's get started so airline interoperability so in elixir 1.10 uh we we started to require erlang 21 and one of the reasons for that is because we wanted to integrate directly with erlang's new logger and we we set up this basic integration and now we are continuing to improve on it so in elixir 1.11 we are going to get four new log levels notice critical alert and emergency so you are now mapping to all uh airline log levels which map to syslog log levels so uh so we are getting four new levels the one the one caveat here is that um if you use those levels with the old elixir back ends you're they're still they're going to translate to some of the existing levels so for example if you use critical it's actually going to come out as error if you have an old logger backhand because of backwards compatibility reasons but there will be ways for to extract this information if you want to um another area that that we are integrating better with erlang airlinks logger is that we now support structured log as well so you're not forced to log only strings you can log a map or a keyword list so another nice feature thanks to the erlang integration and another feature that is coming uh thanks darling integration is that we now get airlink docs in ix so you can type h if you type in previous releases if you type h and interlink module it would say hey this module was not compiled docs but now if you are using airlink otp 23 and it has been compiled with docs we are going to show the docs you can do like htgen server and it's going to show the docs for our jump server for our function and so on so this was uh easy work from our site because the have lifting was done by their angle tp team so a huge thank you to them and a huge thank you to the documentation working group of the airline ecosystem foundation for coordinating those affords so that's it about interrupt now let's talk about some things that are very specific to elixir so one of the things that i'm really excited about this release this is an area that we have been working on for a while and we are we are starting to see some continuous improvements and we hope that it will follow up in the next release as well is that we are adding more compile-time checks okay so one of those compile-time checks are related to binaries so let's take like five seconds and look at this code can you spot what is wrong here so what is wrong is about it's around here right so what is happening is that we have this variable called ping that it's a binary and we know that is a binary because we have a guard is binary that is checking it or we call the byte size function that expects a binary and this code it's wrong because when you are creating the a binary like that using the binary segments we expect all the arguments to be integers and here it is a binary so what so if we execute this code at runtime you're going to get an argument error and the fix is to write this instead so with elixir 1.11 uh you don't have to wait to get a runtime error the compiler is actually going to let you know that it's going to say here's the whole warning as you know at this point we have very long warnings because we want to be very specific and very clear about our uh error messages so you don't have if you can't see everything here it's fine but the idea here is that we you're going to get a warrant that says hey you know you have this thing that we know it's a binary because you called something like uh is binary on it and we have this expression we're trying to use it as an integer and that's not going to work out so you don't have to do anything we're just looking at existing code and say hey this is going to go wrong and they are going to let you know about it another compile check coming electron.11 is related to maps and structs so if you write this code today um so you pattern match and extract and then you access the extract field using the dot syntax and that field does not exist this code compiles just fine and there is no warnings right but when you run this code it's you're going to get a error message saying there is no such field right if you were pattern matching on this field then you would get a compilation time but not written like this good news is in alex 0.11 now we are going to track this destruct usage throughout the function life cycle so if you write this code now you're going to get a warning again you don't have to wait for runtime at compilation time i'm going to say hey you know this field is undefined it does not exist on this struct so that's another improvement another improvement that it's really nice is that we are going to check application boundaries right so let's look at this code what is wrong with this code right we are calling the crypto module and which exists we are calling this strong grand bytes function that exists and passing a valid argument right what is wrong with this code so this is a tricky question for us to answer what is wrong with this code we need to know if the crypto application is a dependency is our current project depending on crypto because the thing is crypto is part of their lane standard library okay so you can just call it at any moment right but the issue is if you call crypto but did not depend on the crypto application when you build a release the release is only going to keep the applications that you use so the release can remove the crypt application and now your code is going to fail later on so um so this code is correct if you are depending on crypto but it it's not correct if you're not independent if you're not depending on crypto so in alex 0.11 we are actually checking now we're actually checking the application boundary so when you call module you're going to say hey do i actually depend on the application that defines this module and if you don't you're going to get a warning with what went wrong and exactly what you need to do to fix it and uh and this is going to help us catch mistakes like that but this is also extremely helpful for umbrella applications because in umbrella applications we did not enforce the boundaries you could call a code from a sibling application that you did not depend on and now we are going to we are going to verify that and also going to help avoid cyclic dependencies between umbrella applications so it's a really nice change too um so let's move on to the next topic and i want to talk about compilation time improvements so we did not only make made the compiler smarter but we made it faster as well okay so and that's what we're going to talk about compilation time improvements and in order to talk about compilation time improvements we need to talk a little bit about how elixir track dependencies between files right because when you change a file elixir may need to recompile other files because of that change right so that's why sometimes when you change a single file in your project it says hey i'm compiling 20 files or in more extreme case it says we are compiling 90 files okay so the way in lx 0.10 the previous versions right how did it work so if i'm defining module a in a file that depends that's using module b that is defined in another file we have dependencies like this so if i'm calling b do something inside the module a body outside of a function but just in the body that's a compile-time dependency because i am calling b while i'm defining a and defining its functions similarly if i import b because the import needs to know which functions b defines and b defines and so on um they compile time dependency too however if i call b inside a function that's a runtime dependency okay and uh and and the thing is if a has a compile time dependency on b every time b changes i have to recompile a but if a has a runtime dependency on b if b changes i don't have to recompile a that's fine right so that's so that's why we have those two levels to track things elixir 1.11 makes one very small change to this which is now that imports there are no long compiled time dependencies we say that they are an export dependency and basically what it means is that we are only going to recompile a if b changes and it is changing its public definition or it's adding a function or it is removing a function or adding a struct field if you are simply changing the function implementation then we don't no longer need to recompile a at first this may look like a small change but the thing that we have to keep in mind is that those dependencies they are transitive so if a depends on b at runtime that depends on c at compile time a depends on c at compile time right and therefore when we convert when we converted import from compile time dependency to an export we are closing this transitive dependency we are making the graph of transitive compile time things much smaller so to see an actual example okay we can go to the hex project and in netflix 1.10 if i change the user file and compile the project it required 89 other files to recompile right and this because user you know it's a core part of our application there's a lot of things that are calling user okay but in elixir 1.11 so we just change the electric version you don't exchange anything else in the code base when we touch the same file it's going to compile only 15 other files exactly because of this change of how we are tracking stuff okay so this is going to be a really welcome improvement to large applications that are having um larger compilation cycles not only that not only we improved uh how we are tracking things we also improve the visibility that we are adding to the whole recommendation process and the completion process so now for example mix compile gets a profile time flag so you can see which modules are taking the longest to compile uh mix xref graph which is graphs which which shows you a graph of dependency between files and when it's recompiled it's getting a bunch of new options and flags exactly so it makes it much easier for you to pin down exactly what is happening so a very nice addition that is going to help uh maintainability of large projects another feature coming in 1.11 is configuring time so um at the beginning of time from lx01.0 we had this configuration file called config slash config and this was and is until today the main way of configuring elixir applications elixir applications so uh whatever you do here it's going to configure your mixed projects going to configure our releases however this configuration file has one big downside right is that it is compile time configuration this file is executed before we compile the project okay and this has brought some issues that we've learned with time as a community right so um and so for example the issue of compile time configuration is that there are some configurations or maybe most of configuration that you only know the value at runtime when you are deploying the thing in production and not when you are compiling it so to solve this when we introduced releases to elixir in version 1.9 we added a new file config slash releases right and this new file it works at runtime so it we read this file uh before your application boots but asteroid is compiled and it is available only for releases so the idea so this was really helpful and people really enjoyed this edition and gave the desired flexibility for releases but now we have this gap right where you know we have this compile time configuration that works for mix and then we have this runtime configuration that works for our releases but we have this gap in the middle and the goal of configuring time is exactly to close this gap right we hope that it's going to eventually phase config releases out right so now we're going to have two things we're going to have the config file which is compile time and works for mix and releases and are going to have config runtime that works for mix and releases but it's only at runtime right and the config runtime has many benefits right so one is that so today whenever you change the config file it you have to recompile the whole project right because you may have changed a compile time configuration but with configurant times since it's only about runtime when you change it you don't have to recompile anything we just start the project again right it can rely on application code because it is called after all applications have been compiled all dependencies have been compiled so now we can call application code so we can do that but there is we need to do that carefully right because the applications they have been compiled but they have not been started so you cannot call a process from that application and so on so you know there are it's a benefit but there is a important uh gotcha in there right you can only call modules it cannot depend on any of the services another thing is that because configuring time works both for releases and mix and when you are running a release there is no mix you can no longer do like mix.m to get the m beside such configuration file for this reason we have we have added config underscore m and configure the score target that works for all configs but that encapsulates this aspect nicely and we are no longer leaking mixed concerns throughout all of our configuration files and our hope is that it's going to become the main source of configuration in the long term right it's too early to say it has not even been launched yet but uh that's the hope uh it's it provides much saner default uh across across the board and finally to cross uh to to to finish uh this talk i want to briefly touch some of the new apis that are coming in elixir 0.11 so um for example we added uh easy struct and these exception guards we have also added an electron.11 support for calling map.field in guard so if you want to access a map field in award now it's going to be possible we introduced calendar strf time this was actually the first feature to to land for elixir 1.11 and what strf time does is that it does date time formatting so if you're using a dependency only because you need a daytime formatting with electron.11 that's no longer going to be necessary and it is called srf time it's a weird name right but aster f time is the name of a standard for string formatting uh that's usually um it's used by a lot of languages right so c ruby uh they use this format so that's what we're using and that's that's why it's named like that there are other standards uh but we're supporting srf time right now we have also continue continue with our usual improvements to the calendar modules so now we got beginning of month end of week we have got conversion from and through gregoire and seconds to many of our apis and so on and we have added a new task called mix test coverage and uh so in alex 0.10 we added support for partition tests so for example if your tests they cannot run concurrently for a reason or if you have a very long-running test to it and you want to spread it apart on ci so for example you run it on four machines we we added partition tests but the issue with partition tests is that if you partition the test then the coverage no longer correct right because you have you run it in four different places so with mixed test coverage you can actually now get all those coverage reports together from the partition tests and generate a final report with everything considered you can also use it for umbrella applications so in an umbrella application um if you want to get the report of the whole umbrella project instead of each individual app you can also do that with the mix test coverage task as well so that's it that's what i wanted to share uh for today and uh i am personally really excited about this release uh last year at alexa conf i said that you know we have no new plan features and some people and despite my best attempts to clarify that some people thought oh no like there is feature free alexa's future frozen right uh and that's not the point right our point is that we are not focusing on like very user-centric features but we want to focus on the infrastructure right we want to to focus on the compiler we want to focus on doing more checks on making the compiler more useful for you without you having to do anything and and sure we're still going to add small features like calendar staff time here and there but the focus is really on the foundation the infrastructure which i think is very important and i think this release showcases really well uh our that that's exactly what we plan to do and that's exactly what we are doing so so that's it unfortunately i believe i don't have time for questions but feel free to ask me in the app and i can reply online and feel free to let me know or the elixir team know as well which of those features you are most excited about thank you very much
Info
Channel: ElixirConf
Views: 4,858
Rating: 4.9807692 out of 5
Keywords:
Id: guc16D_0Imk
Channel Id: undefined
Length: 20min 18sec (1218 seconds)
Published: Sat Sep 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.