Scala meetup dick wall
Recording: Scala meetup dick wall
[Music] okay so um yeah we've got we've got more content tonight so I'll try and keep this uh on track as much as possible but I do want to sort of share with you what my first impressions of Scala were back in the day I I was coming from a longtime programming Java uh Java okay language but the tooling for Java was pretty magnificent right uh idees like in elj would practically write the code for you as you started typing things you'd hit Dot and up would come a bunch of things and you'd be like oh I want that one and it would tell you exactly what to fill in so I got interested in skyar and I started trying to learn this new language and the first thing I realized was that I wasn't going to be able to lean on the tools in order to to learn it and that's not a bad thing you do learn a language differently if you learn it you know kind of the hard way but I really did miss having things you know simple things like code completion and stuff like that so I started looking around at the time there were a couple of different options uh and the main ones that were available were enzyme something called enzyme which was the enhanced Scarlet intelligence mode for emac uh which I got working after a weekend of struggling I got it working one time and I'm like this is great I can see I can see popups and I can see code completion and then something went wrong and I never got it working again after that I never did figure out what it was so then I tried start or started trying to use the uh the plug-in for uh eclipse at the time and that worked except I was on a plane one time and I was doing some scalar suddenly everything turned red and I mean everything like the whole file turned red and nothing would compile anymore so I thought right I'll quit um Eclipse I quit eclipse and that Eclipse never started again I kid you not I had to wipe it out take it down to empty yeah pretty it was pretty close down to the metal almost had to reinstall the operator system so it was rough and uh all I can say is you know this was a good long time ago now nearly 10 years uh long long time ago things have improved greatly uh and we're very lucky now we have a number of great tools Scala IDE uh which is the eclipse it's not really eclipse on its own anymore it's like a packaged IDE ready to go uh net beans I haven't checked in on beans for a while but net Beans really pushed during the early days really up the ante it was one of those ones that kind of nudged things forward there was I forget who it was but there was one guy on there he was absolutely trying to make a a really good environment and inell got on it and there their support became very good and in fact I'm going to say right now we do training in Scala and we still recommend everybody install intell for their training I don't want them learning the tool while they're trying to learn the language the tool should be a simp simple to use as possible get out the way that said I came back to enim uh probably about two and a half maybe three years ago and I remember it uh must have been about two years ago cuz I was actually had one of the first conversations while I was still working at at typ safe briefly and I was at skyar exchange and at the time I saw that um Sam Halliday and another guy Rory Graves had sort of kicked off and they're like hey anybody remember enzyme we're doing that again and I'm like very interesting because we've got this thing called activator and I was like I wonder if we can plug in uh enim in some way to to get activated to give code completion because that would be a great first experience for people anyway long story short had a nice hallway conversation with them got dragged in I think it went something along the lines of Rory said hey uh enzyme on Sublime doesn't work but I know you're a Sublime music if I can get it working will you Jo will you get involved with the project and I'm like sure he's never going to get it working and about 3 weeks later he comes back and he says hey it's working so I'm like great now I got to do this anyway TR truth is I've had had a blast doing it and uh really really still am uh very much enjoying it so enim is now no longer the inhal enhanced scalar intelligence mode for emac it's now the enhanced scalar intelligence mode for editors okay we actually have multiple editor support and there's a list of them uh choose your favorite here are the supported ones that we know of or that you know have some level of involvement right now so we've got emac of course emac is the granddaddy it has almost everything new features coming because uh well I'll get into the graph apocalypse uh a bit later on but um uh it has all of the features that are available up until this Point uh including Java editing support the others we've got atom any any atom users here yep I like atam too one of the main problems I've got is I'm I'm a died in the wall Linux user I won't I won't at this point I'm too stuck in my ways on lenux and uh High DPI support in atom doesn't really work quite right yet I get menus that come up with font sizes that have like they're so big they have three letters and how you get bigger rather than smaller from high DPI I don't know what's going on with that but they come out like these crazy big Duplo letters and you can't use the menus so that's killed that for me I was I'm a longtime Vim user I still reach for Vim a lot um but usually from the command by uh Visual Studio code I think it's called you guys know about this it's sort of um Microsoft released this I guess it's kind of a strip down version of Visual Studio it's actually quite interesting I I've tried it um Works nicely it has some support for enzyme and it's it's picking up script picking up speed Community Edition yes it's it's yeah it's a free it's a free Community Edition editor and then of course there's Sublime uh singled out in this list uh as the only proprietary offering uh but I love it and I use it and I find it very easy to uh to get along with uh the back end language is python which was actually the same as Vim which was my um previous favorite programming language back in the days when I was a Java developer and I was paid to be a Java developer I used to love working in Python and then I discovered scalar and I'm like oh this is nice I get a little bit of all of this stuff but uh still love Python and the fact that I can edit and work on it in Python is is a big draw for me so let's go through this uh this is my extremely professional slide deck uh that that I'll be working through actually I follow the venat sa branium uh mode of of uh presentation which is just list a bunch of stuff and say I've done that I've done that I've done that right getting started with it okay so you need an editor and you need a build tool what Nim is is a server that runs you you start it up it gets running in the background and then your client sends in requests over a few different PR protols right now it's probably time to get to dig into those there are two protocols that are kind of Legacy one of them is called Swank and that is based on S expressions in lisp remember it came from emac so they lisp um kind of very it's like a very compact Json with lots of colons and PN in it that's probably a good way to describe it um so that's that's Swank there's also jerk which is unfortunately named but that's the that's the Json protocol and now we have the new stuff that's coming in which isn't supported in many of the editors yet called Swanky and jerky and they're based on uh mostly the same protocol but using websockets to uh to get the to get the um communication back and forth converting Sublime over is going to be a big job for that so if anybody here and in particular my um python skills are about 10 years out of date because lo and behold that was about the time I discovered Scala and stopped doing so much python never really did a lot of Json in in uh python so we've got a big task ahead in taking the Swank protocol which is basically deprecated now 1.0 of enim just came out Swank is not going to be supported going forward so if I if we want the new features this is kind of the carrot and the stick that Sam's holding in over us right now we have to get it up to one of the new protocols in order to get the new stuff and so that's going to be a bit of work so I'm I'm fishing for volunteers here if anybody wants to get involved um in particular if you know uh python Json and any unit testing framework that you're happy to work in that's what we really need is we need a bunch of Json work and a bunch of unit test to make sure they work correctly it may be quite easy I'm cautiously optimistic that it's actually quite easy to take the the S Expressions just write a different serializer and drop it in and everything will magically work uh life is is rarely that that kind but um anyway yes so getting started you need an editor you need a build tool that that is supported the build tools are also uh everything's organized around enzyme enzyme uh.org build tools you've got your SBT which is what I use your CBT which I've only just recently started hearing about pants which is the the Twitter Tool uh Maven of course the Grand Daddy of them all lean I learn line another one I'm not really familiar with gradal and then you can actually edit the enzyme files manually if you want to the whole the way it works is from your project you get a enzyme file which is basically a bunch of settings that tell you all the class path and everything it needs to know to be able to fire up an Endtime server once it's running you communicate through one of the protocols from the client side and the support from the build tool is largely push this enzyme this enzyme file out there and uh uh manage the pro manage the server process coming up maybe do a few debugging things in the case of subblime um if I show you the the supported text editors you'll see that in the list spt integration is down the bottom here enim will command SBT for you and do all all the work in pretty much all the other editors there's an SBT plugin already and the two work so well that it's not really been uh together it's not really been a high priority to put that functionality into one basically as soon as I start enim I start SBT running server mode as well and the two are running alongside each other they don't they don't fight they get on pretty well they behave they behave well it is time to mention one thing about this though you may be under the impression that uh you know running enzyme in an editor is going to be this wonderfully lightweight experience by the time you're running the editor and enme and SBT in server mode uh it's about as heavy as running intelligy you don't actually Save A Lot on resources it gets it gets pretty gnarly in there uh but yeah that's not the reason uh that's not the reason to uh to come to it if you just want lightweight editing don't start IDE just use the text editor right so let's see uh getting help is the other thing that I need to mention um this has been become quite amusing in the uh G channels we have very active G channels we have a very nice team of people who occasionally get other people weighed in I want to set expectations here en's great I use it all the time it is my primary development tool at this point it is a long way from perfect and it breaks a fair amount um it hasn't eaten my code in a fair while but I'm not going to promise that it isn't going to do that keep your go your code nice and safe in GitHub okay usually command uh control Z will bring back anything disastrous that it does um but it's you know you need to be aware it's not going to be a super smooth experience if you want a super smooth experience at this point you're still better off going with an intellig or a scolar IDE however if you want something that you can actually really get involved with customize make better then and you're already well familiar with with Scala I think it would be a mistake as a beginner to come into this and try and learn Scala and enim at the same time that's a lot of cognitive load right there but if you're if you're comfortable with it then there are some real advantages one of the things we do get occasionally is people will be having a bad day they'll they'll Wade in to the get channel swing in they'll come in and they're like it's all broken nothing works everything went wrong uh to which Sam uh usually says have you read the troubleshooting guide and and everybody comes back and immediately says yes I've read the troubleshooting guide it became such a common common question we now have a bot that says as soon as error or compiler or any of these keywords come up it says have you read the troubleshooting guide and gives you a nice little link to it I I've actually started this new game of um uh of Bot Bingo as I call it which is trying to say something completely innocuous and unrelated to enim in anyway and still get it to go and tell me to read the troubleshooting guide it's uh it's some sometimes it's a nice distraction from work so yeah please do remember everyone's a volunteer everybody's got day jobs um and it's actually a good it's a good group of people uh things break uh quite a lot it's under it's got some good project velocity which means that there's a lot of changes coming in a lot of the time uh sometimes you just need to read what's what's changed if you go in uh I'm the worst offender at this being the I naturally go and say hey something's broken what happened and they say didn't you read the read me I'm like no I didn't read the read me I've got you guys to talk to and they say oh yeah we changed you know we changed the commands around or something like that um yeah so anyway what it is it's fast and usable integration of Scala into several editors perhaps the one you like the best and if it's not there's plenty of examples out there now in different languages so that you can add yours um if if you if you are so inclined many features can be explored on it it's not it's not feature Rich in the way that idea is feature Rich but the main ones are covered you got your in I'll show you I'll I'll run through them we'll we'll have a good explore of them it's very customizable I think that's the the main thing in my opinion is I can change this I don't like something I can just go straight in and change it Sublime this is one of the reasons I like Sublime is it's very configurable uh I find it hard to find a lot of the settings in idea cuz there are just so many of them uh trying to change things like the Whit space and stuff like that it's written by you if you want to change something you can it's really not that hard I mean the IGN plugin is a is maybe a couple of thousand lines of python code it's really quite small it's a very nice environment to work in because it's you know I I'm a scolar guy I like I like uh statically compiled language or statically typed languages but um sometimes it's nice when you're working on the editor to just hit save and it's immediately running in the editor there's no break I I CH I was working on in a cafe around the corner fixing the the Java do stuff on the way here and I was like try this save try and run it didn't work try this save try and run it works so there's the very quick cycle time I think the last one is probably the reason that a lot of a lot of um uh how do I put more seasoned scar developers are starting to get to it U this is a problem if you've used intellig with any kind of what I would call type Foolery you'll probably have seen this intellig doesn't really use the Scala compiler they have their own implementation that's mostly the same and they're tracking it well and they respond to you know they respond to um error reports quickly and stuff like that but you get deep enough in some in some monad [ __ ] with some for comprehensions and suddenly your for comprehension is going to turn red and it's going to turn red on valid code okay it happens quite a lot it it leads to the um the syndrome of you know people get tired of me saying it at work I'm like hit compile they're like what's wrong with this code hit compile and it compiles and they're like but it's all red and I'm like yeah life sucks so you get less of that uh I won't say it's perfect and in fact um enzyme does have its own quirks it it It suffers from Dirty builds occasionally but if you rebuild everything with SBT usually clears up clears up nicely uh and you get fewer of these false positives and negatives than you do in idea because it's using the presentation compiler so there we go that's all of those what it isn't it is not complete not even close find usages is probably my biggest um missing piece right now uh I can usually get around it I mean if you're if you know your editor well enough you you can figure out or find uh you know a search in uh the directory that will usually get you where you need to go or something like that but uh it's coming because of the graph apocalypse maybe it's time to talk about that Sam's been talking about this thing called the graph apocalypse for ages the the problem is that enzyme doesn't really maintain a connected graph of all of the calls in the system while it's running at least not not yet which means that you you can forward track easily enough that's that's a pretty solvable problem backtracking finding all of the places where something that's going to be refactored or used they don't work fully yet uh you can see this later on I'll show you the rename the rename sort of does half a job whatever's loaded in and it knows about it'll rename the other things it just doesn't rename and when you try and compile you're like oh I didn't rename that okay I'll have to go and do that myself the graph apocalypse is the an attempt to build up all of that information and get it to give that kind of functionality it's these these functions that are at the bottom here find usages show implementation advanced typ search passive suggestions and white box macros these are coming soon and that's because we got we got a Google summer of code intern to abuse and uh he he I think it is a he is hard at work on it so um that's that's very exciting these it'll be a while before these features are stable so don't dive in thinking you're going to be able to do find usages that quickly but they're coming and that's exciting to me all right so it's not complete it isn't totally reliable I'd say I probably restart enme two or three times a day um but I'm okay with that it's pretty quick to restart and I know as soon as it starts malfunctioning um I'd like it to be more reliable but actually it's got to the point now I was talking outside it's got to the point now where it's reliable enough that it probably ought to be less reliable because it would prompt me to do something more about it it's actually working well enough as a primary tool right now that a lot of the time unless I get time to mess with it I'm like oh it's just good enough let's just play through and and keep going I got to get my work done um it's not as full featured as idear I think I've mentioned that and it isn't I I mentioned this it's not necessarily lighter on resources as I say by the time you've had enzyme running for a few hours and you've had SBT running for a few hours you're going to be using that 16 gigs of RAM on your laptop and you probably want to think about investing in another 16 it's scala's a heavy language uh I quite happy to pay for a bit more memory to get the uh uh you know get the compiler doing what I want it to do so all right Sublime I'm not going to spend a whole bunch of time on it just happens to be my editor uh the one that I like to use how do you how do you get this then well let's take a look here this is this is Sublime running the first thing you'll do and this is true for you know most of these um editors have some kind of package Management in enim sorry in Sublime uh there's actually something called the package manager and the way you get it is it's kind of weird it really ought to come as part of the um as part of the editor install but what you actually have to do is bring up what's known as the console which is this guy you'll get used to seeing the console a lot if you actually start working in enzyme because it's where the logs it's where the it's where the trouble shows up so you keep that open a lot of the time you sneak it sneak a quick peek fortunately there's a very quick shortcut to get it up and up and down again and what you do is you paste a command in there that's off the web and it installs the the um the package manager for you once you got the package manager you can just simply hit control shift p which is the do everything in this editor uh key binding and you say install package on package control and it thinks about it down the bottom here uh and then it comes up and it says here's all the things that you can do and we can have a look in here and I think n sign won't be in the list right now because I've already got it installed but something like alignment aligner yeah there's all the different packages end time will be in the list you install it that's part one the next thing you need is you need the support in the build tool so you go to um supported build tools and you click on SBT and it shows you how to get set up using it the you add the SBT plugin which is the thing that builds your nign file for you uh probably put it globally because you don't want to keep adding it to every project as you go and here's your commands so at this point you've got the plugin installed for both the build tool and the editor you're actually ready to go the last thing you need is Project to work on and the project if you're using SBT it's going to have an SBT build file so what you do in there is you just say SBT and sign config let's do that so here's is my test project SBT enzyme config I'm going to close my editor down and we'll go through the whole thing so run the enme config takes a few seconds this is effectively what happens in intell when you import the project it goes through it figures out it didn't actually have to do a lot uh but it goes through and figures out all the dependencies it needs it downloads the sources and the and the Scala docs and the Java docs uh makes them available sticks them sticks together your class path all that sort of thing uh and if you want to have a look at it it's sort of semi-human readable this is what you get okay this is the endme and this is what we mean when we say manual you could produce that yourself if you wanted to uh it's probably easier to get somebody else to do it but yeah you could write that yourself and it's not beyond the Realms of uh of reality anyway so once you got that start the editor up Qui question it look like closure I think it's probably s Expressions actually remember this is an emac right yeah it is it's there's a there's The Telltale pen at the top uh it's it's lisp it's lispy there more PN it's actually very light on PN for for um uh for lisp that that's what threw you like the end of the file was not half of the end of the file was not closing ends that's what lisp usually looks like so all right so that's that's that um so we we've started it up you open up the project which I have open here just open up the folder and then you go in you usually start up the um the console when you start this just so you can see what's going on and then you say uh control shift p run all commands that it knows about enzyme start up okay and the first time you do this this particular operation takes longer than it does on on subsequent runs until you rebuild now if you change your dependencies or um there's various other reasons there's pretty extensive logging right now so one of the things that you'll find is the log files get very big and tend to slow things down uh so you know once every few days I just blow away my enzyme file and recreate it it's simple enough to do uh if you delete the enzyme file in the enzyme C and all of the other enzyme things you kind of do a reset I'll run through that before the end it's in the list of um turning off and on again kind of level of um getting things working properly okay now it's running so if we go back into here uh the next thing as I mentioned that I always do is just start SBT running at the same time pretty much enzy startup SBT startup these two things work together at some point I'll add the SBT or somebody if they get there before me we'll add the SBT support into enzymes so we won't have to run both of them it'll just be the one running but uh so that's running I've got a bunch of keyboard shortcuts set up so I'll compile this and let's see what n sign gives us so first thing you'll see is I can do things like this uh hold down alt and click on something and you get code you get a tool tip that tells you the type not only the type but in this case the call so here it says this is a person that's a person type here what it's actually telling me is the signature of the apply method uh for it and that takes a string and another string and an INT and returns a person I can then click on these they're they're hot linked I did this see this is this is why I love this stuff because I did this that takes you to the definition of string that's all right save your applause there's more there's much more impressive than that to come so anyway yeah that gives that that gives you something there if you go to something like uh down here I've got zip we can see one of the um one of the more scary scary ones and we can click through to can build from if we want to that sort of thing and I have to do that because I noticed earlier on Adrian I'm like hey Adrian's going to be there I'll I'll take the chance to embarrass him so um anyway that works that's why I usually right what else have we got let's go through let's follow my scripts I don't forget anything uh so that's toll tips tool tips are good all right alt click error highlighting let's go back over here and we'll do something bad let's say uh Zippy and save Tada error highlighting soon as I hit save it uh tells me hey you've got a problem there uh what I can do is click on that first of all watch down the bottom here this is a bit subtle until you're used to it the status bar is right down the bottom here uh but if I click on this it'll tell me um Zippy is not a member of list of int okay that's not all that helpful so there's fortunately another option here which is anim notes and this is for the what what I us do here is choose a layout that lets me have both of these at the same time move the notes down the bottom here this is what's wrong in the current file so right there it says zippies not that if I change reverse it to reversed it then we get two notes down the bottom here that tell you what's wrong with it so I can fix those go back and make it work make it right again save and some other nice things um and maybe we'll see this later it's not only errors warnings get highlighted um it's it's kind of interesting it has a different set of warnings and in many cases I like the warnings better than idea has but it's also missing some uh really good it would be lovely to have more of the kind of hints that uh intell has but this one picks up a bunch of things that intell doesn't as well so it's quite interesting working in a mixed project environment where other people say hey you should be using uh what's the one the other day that I for about you should use length on a raise rather than size because size causes a wrapping event to happen whereas length is just called on the underlying array and um intellig sorry is no I think length is length is the is the one on in in on arrays that exists there size is on collection so it has to do the wrapped array thing to get to size and um that's also true for Strings length string do length and intellig picked that up this doesn't so I'm thinking well that's going to be on my list of things yes abide actually abide support did I just hear you um volunteered to put a bite into enzy because that would be a lovely thing to have in enzyme uh a bide support anyway um so that it's it's quite nice it's got a lot of that stuff another thing that it shows is when a test fails when uh this is actually the SBT plugin when a test fails it highlights the line that failed which surprising a nice feature to have um makes it very quick to see exactly what happened right so that's that that feature uh we've got Auto Import God I can't tell you what it wasn't working when I first got to this it the feature was there but it just didn't work and it was the first feature that I dug into and fixed until you haven't had Auto Import you don't realize how freaking essential it is it is extremely it's an extremely length ly process to go and find every import you need because something's not compiling and enter it manually it's very tedious so yep so we can do that let's take let's add a um Val f equals future um of one okay that's now an error not found value future control I there it is Scala concurrent future and it adds it at the top lovely take some of that now however we need an implicit context um if I save this yeah we should get it this is a little bit rougher but it's still not too bad you can just go down here and uh did it put the import in I can't remember H yes it did comp yes compiler is very helpful and hooray we've got it working again so nice see it's this is what it's like not super slick but serviceable works well in practice the the features come together nicely all right so that's Auto Import import organization another one once you start importing a few of these things you can just hit Control Alt o and it reorganizes them it didn't do much here but that will also um remove the unnecessary Imports this is something that does better than Idea Idea will often show you um uh something is unused when you've imported implicit they are actually used you remove them and it won't compile anymore and some don't do that it's like nope that's actually in use or no that's really not in use work um likeor something from doesn't it it it does sort of half a job what it does there often is it sticks a dollar in the middle and you have to go back and change it to a DOT uh so it's yeah yeah so it it's sort of it's one of those things it's not super slick but it's workable so yeah that uh that's a good that's a good question all right so enzyme notes I've shown you code completion wouldn't be much of an edit of a um ID without code completion so let's choose something like a string hello Dot and control space and it didn't work let's start typing there we go um yeah no that's not right but reverse is there where did it where did it get return from okay let's do it click and see where it goes good plan yeah no that's not really good no uh but reverse is on there which is the one I wanted so I'm not quite sure where that uh where that happened now reverse is an implicit so it's not just uh methods that are available on the object it is picking up the implicits too I didn't even realize this until I was putting this talk together but enzyme has support for implicits that we don't have in Sublime right now but it will actually tell you all of the implicits and all of the details about them let you put a little blue underline under them or whatever you want to do and give contextual information like the class that that's being uh brought in from so once I saw that I'm like that's pretty much that's pretty much at the top of my wish list of features that I want to add next now that I know it's there uh no that that one's just for just for implicits just highlighting the implicits but basically what Sam and Rory said to me was if you get that if you can get that to work in Sublime and that's a big question I don't I'm not the sublime documentation isn't wonderful and I don't yet really know how to like um inject this stuff into the syntax coloring and change this the The Styling if I can do that then I've cracked the nut for semantic highlighting as well well because basically it's the same sort of thing it comes back with a bunch of contextual information and then you go through and it comes back with the contextual information and the start and stop points and so basically you just need to run through the editor View and change the Styles based on the semantics that are returned so that's going to be a that's going to be a weekend that I need to set aside and like I'm going to dig into this this weekend and try and figure out how the um how the Styles work and that sort of thing so that's code completion what else have we got I hear you say we've got control click navigation so if I'm in here and I say oh look a print writer control click and it takes me to the print writer very nice uh so that works pretty well and the other one I want to show you is um uh and I just actually got this working for this for the Java side in the cafe around the corner a few minutes ago so here's the skyar one um enzyme Brown scy do at Point okay go to my browser and it didn't happen did it happen in the other window nope oh lovely let's see what this said uh it went uh which one did I do no that's this one okay let's try again development Brown Scarlet locket Point okay that happened let's go back up here yes there we go I don't know if you saw that but it actually highlighted the zip for a moment there as well it's fancy So yeah thank you see I told you spontaneous applause was bound to happen eventually uh this also works for Java so uh if I come down here and say enzyme browse it says Scara do maybe I need to change that to Doc that point but this now takes you to it's not nearly as fancy but it takes you to the close method in the Java do as well so that didn't work until half an hour ago or an hour ago or something and it was a oneline change in Python it was a oneline change that took me about 10 different tries to get working but it was very quick yeah and it's hacky it's um it's a long story right all right so that's that refactorings we have a few uh all but one of them work really well so let's do one inline de first of all actually let's let's do it the other way around um let's take this constants in the code or you know string definitions in in the code that'll never wash for code reviews so let's do a extract local and we'll call this it's down the bottom here we just need to get used to that that's where that's where um Sublime puts its dialogue so it's asking me for the extracted Val name and I'll say file name and taada file name gets inserted and gets used here the same for the extension let's do that so extract local extension and it worked again hooray uh it does some funky selection afterwards I have to that's another one I have to track down why it ends up like selecting that after Woods seems very very random I think what I'll do is just remove all selections after something like that happens cuz it's less confusing than having something randomly selected uh and we can also inline these things so if I come back here and I then say anim in line local it totally did something different than I expected which is why contrl Z is a good thing I wonder if it's this one I have to do uh let's try that uh inline local no that didn't do anything at all all right I swear that was working the other other day so something's gotone funky there the previous yeah oh that well that's kind of what you want it to do but well what I really wanted it to do maybe I have to select this what I oh no no it just did it okay that was just that was just High latency in the server um I told them this was happening and Sam's like no no it's working fast and I'm like I don't know man it's taken like 20 seconds on some of these operations and he's no yeah now I think I have video proof so oh they love when I do that they're like yeah uh so anyway it did happen just very very slowly um so uh that works let's what's the other ones we've got oh um and we've got extract method so this oh this should be interesting let's try this one let's take this whole thing and do an extract method extract method and we'll call it uh write the file look at that it worked again it left a kind of I've got to figure out the um selection but it did it created the private Dev it does have a habit of fully qualifying path names which it really doesn't need to do in that case it doesn't need to be Java file I've got that imported at the top uh but otherwise did a pretty B up job and it did it nice and quick so that that replaced right the file there it even remembered to leave The Vow there um yeah is this using or from this is so what happens here is the request goes in with a position in the editor I'm glad you asked um uh it goes in with a position in the editor and often if you select like a word it it provides as much of that contextual information as possible it sends that through to enme enme figures out what needs to be done and sends back a patch file and the patch file is then applied to the file that's the way it works now the way out does it that's a good I don't know it's using whatever Scala ID is using what um I I should pay uh pay kudos to the Scala ID team because Endtime wouldn't be in the state it's in without a lot of the work that they've done as well so scal IDE has Been instrumental in The Rebirth of enzyme as well that's scor it is using scalar factoring okay so what what I can tell you is that what we get back is a is a patch file which is a big Improvement what it used to do was just go and overwrite the file which was terrifying because if things went wrong often it wouldn't undo afterwards and things as well which is why I say it doesn't it it hasn't eaten my code for quite a while now because the patches that's something that the editor does and it's a much better way of working so okay so that's good um let's see what else we've got uh wrong one um rename okay rename is the one that is I told you about will end up often doing just half the job so if I come in here and I say uh write the file and we'll change the file name to uh and I'm refactor um where is it refactor rename and I'll change it to uh file prefix so it works beautifully in a local file and it works reasonably well if you're if you've already opened a bunch of the files that you're working on and they it happens to have those in the cache at any given time anything that it hasn't cached it just won't do it and then you'll hit compile and like half the job will be done and half the job won't be done and that will improve with the um the graph apocalypse implementation it will actually know to to go and do that can inject some deviousness does it do does it do named arguments like what if you uh you know provide the name there of the write the file at the invation oh that's a great question I do not know let's find out shall we so let's change want get back in you for earlier so all right so this would be reversed equals reversed and this would be file name equals file name yeah let's let's give well let's see what it does right so let's do this one refactor rename and we'll change it to file prefix I expect Applause by the way if this does actually do what it's look at that wo i I really I really can't take any um any credit for that at all I didn't even know that worked or it didn't work until Adrian asked but somebody did it right cool that's very nice so yep rename uh but like I said use that one with caution uh and the last one is reformatting uh which it isn't in the main one yet because I've only just I I put it in this Branch um let's mess these up a bit do some things that look ugly and then I can say andtime development reformat this file and look at that beautiful it actually uses your I think scalariform still um but it uses your project settings and just does it right there so that's that's nice all right enough refactorings let's talk about some of the other stuff um debugging is probably the last thing to hit debugging is the area undergoing most development right now it's actually a good it's both a good and a bad story at the moment um the good of it is it used to be fairly feature complete and um you know all the features worked okay but it was was unreliable um it would just blow chunks occasionally and and never really could understand why uh guy called chip SC Bell s bile sorry has been working on something called the Scala debugger and I've actually enim actually has pretty good project velocity at this point to the point where I'm use I'm mostly doing uh the the sublime stuff of it and the server is adding features faster than I can support them in Sublime right now so I'm not really helping them add this add the features there but poor old chip is working on Scara debugger on his own so I'm sort of I'm sort of jumping in a little bit on that as I get a chance to and the great news is the Scara debugger is like super reliable it just works now there's no blowing up or anything but the downside is some of the features kind of regressed a little bit as that was brought in so let me show you what it looks like right now and you can decide whether it's whether it's time to jump in on debugging that it I actually use it for debugging now whenever I can up until a few weeks ago I still jumped back into idea every time I needed to debug something because it was it just had the features that I needed there but it's getting better here and the only way it's going to get much better is if I actually feel the pain and force myself to live in it so that's kind of what I'm trying to do so let's stick down couple of break points break point there and another one here and then what you do is you go into SBT which is running down here you say debugging which turns on the debugging support basically what that does is it has some Set uh oh yeah can came up down the bottom here it has some settings to monitor the right port and wait for a debugger to attach on Startup so now if I say run what it does is it says waiting for the um for the debugger to attach and I have it connected to F5 so I just hit F5 and that did something weird um maybe I don't have it set up for F5 on here let's just do this instead uh debugging start debugger there we go so now we hit a break point and we can come in here and it actually works so this part works well single step doesn't work at the moment so I can put another break point down and and flip to that um I meant to look into single step after the last of these talks that I did a couple of weeks ago and I just haven't had time uh since then but uh I can let it run onto this next one we have watches so we can see uh the the state of the variables I can double click on some of these to expand them it would be nice to have like a triangle actually it does have a triangle look at that I never noticed that before that one has a triangle and these don't wow there's a feature I accidentally found um what it doesn't have right now is pretty two strings on a lot of the stuff this is one of the regressions uh the old debugger would actually say X's is an instance of list with 1 2 3 4 5 six in it uh I can get that but it's fairly tortured right now so what I have to do particularly in the case of a list uh you really get to see the pain involved so you have to got a head and then you have to go into head and you have to find the value of head and then you got a tail you open tail and the tail will have a head and then you look in the head and you get the next one and so on and so forth so it's a bit painful um and the two string I actually have an implementation in the debugger of two string but I haven't built it up and got it supported in here yet so there's work to be done on that but what I as I say it does actually work quite nicely uh from a reli the features that are there work great it needs some more features adding and probably one of the ones that's really high on my list is it will show you the watches for variables that are in scope there's no way to to add a custom watch or a custom um uh expression to evaluate right now and I use that a lot so I that's really getting high on my list of um pain from using this all right so that's debugging that's probably about all the features I really need to go into for now uh I should be able to let this continue oh yeah it's counting down and there we go and it finished and if you want to turn if you want to go back to non- debugging mode you just say debugging off and I don't know some somehow that F5 turned on red squigglies in my I think it's doing I think it's doing a spell check to get computer I yeah no I swear it was F5 but somehow that's now doing spell checks in there rather than the keys that I expected this is you know who wants who wants a boring life where everything is explained and completely predictable I like a bit of excitement all right so missing features uh find usages is coming class pass 30 is something that I want to add in Sublime but it's already there in in emac version um the other thing though is that I think this is part of the bigger um offering here enme what I've shown you is all the features in enzyme what I haven't shown you is a bunch of stuff that um uh the other plugins in Sublime do that make life really really wonderful uh one of my favorites it has the mother of all um aligners so if I do something like X's match and then case head uh head K's 2 K's tail and then do another one here case head uh nil or something like that and uh this sort of thing I can do all sorts of magic in here the the Align by uh lets me do all sorts of things the fat arrow is the um that I actually added that one cuz that's one that I'm going to use a lot aligns it by fat Arrow you can do by spaces or you can even enter a reg X you can put any reg X you like in there and it'll align it do you know how many times I've dreamed of that feature in other Ides it's fantastic so and it remembers the last regex you typed in as well so when you're on a when you're on a prettification spree you only have to enter it one time and then you just go select loads of code and align it all it's great um yeah there you go now what else do you need uh the another thing is uh this yeah this is not I don't think this is combined if I make it now yep um oh it's a warning it's it but it's still a warning though so it's a it's a warning it says it it would fail on the following input uh incomplete match uh this is I think you can see it at the top there this is the list of compiler errors and warnings in the code right now and it takes me straight there that's BT doing that that's not um inside but it will take you any to any of the failures in the code so bunch of stuff that you get in there I've got a bunch of git uh integration uh git gutter uh I can connect up to git GitHub and look at the issues for this particular project that I'm on uh compare this I I don't think this is in a branch so I can't really show you any of the git comparison stuff but you get the idea lots and lots of different plugins that make um make for good stuff and I can probably show you some of the ones that I've got Let's uh in remove packages and then we'll see what I've got the color ones tell you give you all the different colors load file to repple um I use that a lot in demos it's got marked down support the sidebar enhancements are really nice um that's probably another thing I should show uh although you don't really have the intelligence to say create a new class it is very easy for example to just say new file and we'll call it uh new thing. Scala and it creates it right there and you can start programming I've got snippits I love the snippits I work for a company called sibo right now uh we have the Continuum package that I'm working on I get tired of typing that at the top of everything so that's that's what I'm working in I I get that I can also do the C Imports and that brings in the three Imports that I'm working with mostly that sort of thing so very customizable and and the Snippets can do um uh fields in them and fill in multiple fields at the same time and do things like you can work all sorts of magic with them so it's very nice anyway I think I probably talked long enough on that right when it all goes wrong this is these are things to know so this will happen if you're using it you just need to know the reset operations the first reset operation the simplest one the quickest one is this andme restart that will take down the old server we can see it happening um over here shortly there we go takes down the old server kills it restarts another one that will fix 80% of the things that go wrong now occasionally the the server will have just a complete nervous breakdown and stop responding to anything sensible when that happens your best bet is to go this is what I call the medium level reset quit the editor uh this is a reason I don't keep a lot of other things running in Java kill all Java okay there there wasn't anything there but often there will be a bunch of things running uh obviously don't kill all Java if you've got intell running or something like that but that'll take out your SBT that'll take out your enzyme if they're misbehaving and then you go back and start the editor up and start all over again and finally finally the N the nuclear option when it all goes horribly wrong is you quit you kill all Java again and you do rm- rf. enzyme star and then you say uh SBT or act um enzyme config and you have just nuked the entire thing and you're restarting from scratch that'll clear everything out that enme knows about if it doesn't work after the that go and have a look at the um getting help section first please otherwise you'll get teased if it still doesn't work then I would recommend politely I'm very good at polite and yet firm going and saying hey who broke it who who just checked something in and invariably it'll be something some conversation like oh Sam will say oh yeah I did something last night but that shouldn't have affected that and I'm like I think it affected that and then we'll do a bit of research and often it will have affected them so anyway that's that um anything else to say on it full project reset yeah okay so the last part is sort of a recruiting Drive the first thing I'd say is recruiting users for a long time I used IGN my co-workers would see me using and time and sublim and they'd be like this looks really cool remember that I know where the rough edges are so I don't tend not to stray into the areas where you blow your own foot off and things like that and they'd be like I really want to run this and they and they're like can you help me get set up and I would sit down and I would talk to them about the pain involved before I got involved because I didn't want to become Tech Support to them while they were getting this going I now think that it's got to the stage where as long as you're willing to put up with a bit of resistance it's time for people to come in and start messing with this and in particular if you've got the mindset of you not afraid to take a look at it try things out try and make them better try and narrow down um usually you're not going to get much response out of hey it broke other than the bot saying uh go and read the getting help section and here's a link if you say it broke and I have a feline program that shows it uh here it is that's going to get you a lot more attention if you can put that in the form of a unit test that's failing you're going to be very popular and if you can put it in a form of a unit test and fix the problem you're you're IM immediately promoted to uh beer drinking buddy the next time the next time the group gets together so the bot will never harass you well no the bot will harass you anyway but the bot harassing you is sort of a mark of um of acceptance as well like I say I try and get the bot to harass me I say things like hey uh uh Sam my cat isn't compiling properly and uh that's partly because I don't have a cat and then the bot will say read the getting help section please so it's it's funny I like it um right so that's that uh documentation and setup are there but always there's never been a case when documentation and instruction couldn't be improved so if you want to get involved with that that's great finding and Reporting bugs uh coding uh there's plenty of opportunities there the The prominent languages for the well the server is obviously written in Scala uh the client the clients are all over the board there's coffee script there's JavaScript there's um what is the one typ script I think it is Visual Studio code users python there's some lisp uh whatever you want to get involved with or you could even write your own editor in Elm or pony or something and uh get it going there that would be interesting um if it's not to your taste if you try it and it's too much trouble you're not going to get any fight out of me if you decide that it's just not working for you then there are plent you know it's not like the past when you have no other choice you have plenty of choice now uh this is the the reason to use this is all the things I've laid out because you want to because you it is actually really fast one of the things that I haven't really impressed here but it's actually irritating to me is how much slower intellig is when you go back into it after you've been using this for a while I'm like wow I can't believe some of the pauses you get and they're really noticeable when you haven't had them for a while and all of a sudden you're typing things and it's like half a second for you know a code completion to come up and you're like this unbelievable I've just wasted half a second of my life so you know you really do notice a a difference in uh in that but anyway even even if you try it and you think it sucks or you can't get it working there's quite you know there's a fair percentage of people that are like it's just not working on my machine I actually um we did finally get Simon Asen right how do you say his last name that one um we got him finally working but basically it took me pairing with him for about an hour one morning uh to get him into some kind of working State some people just have trouble getting the thing up and running in the first place I'm not even sure what happened we just did a kind kind of strip down back to barebones build it all up and it it worked better the second time so even if you have a bad first experience just know that things are improving at quite a rate now it's got good project velocity and the improvements are coming pretty quickly so um you know keep checking in from time time even if it's a miserable experience the first time don't hold it against us forever uh because it is it is getting better and that's really all I have I'm happy to answer any questions um and I think there's the uh Alexi was mentioning the office hour kind of idea now as well so um yeah thank you I'll just ask you to repeat the questions for the video yeah yeah sure okay yes I saw Flash the settings and screening had some setting for the garbage collection and you just mentioned something about pause time you know intelligent ising the same kind of garbage collection setting as this and is that Poss different um so the question is about the settings for garbage collection I I think those were just the defaults um I wouldn't say that the pauses that I've seen in enme in particular are I wouldn't put those down to garbage collection pauses it's usually uh something much more fundamental like a lot of the time I kind of glossed over it um but earlier on I hit the dot and then hit control space and we didn't get code completion what actually happened there was there was a timeout and the timeout was probably caused because you know long story short there was a dirty there was some kind of dirty build it had to do a full type check and the client is set up to only wait a certain amount of time for answers and if it doesn't get them in that amount of time it it just abandons that thing so if I if I waited for a couple of seconds to hit control space again it would probably come up that stands to be improved but there are some limitations there in the way that it interacts with um uh with Sublime and in particular the async mode of sublime and what you can insert into the editor window asynchronously um but in all of those cases I don't think it's garbage collection that's the hold up it's actually having to do work like fully type check either the file or the entire project again and that can take a few seconds so you know stuff like that is where the the hold up is I don't know what intellig does um I do think probably some of those pauses there are like likely to be some garbage collection but I also think some of them are going to be the same sort of thing it's it's suddenly got out of sync with its you know view of the the code and it has to do some fancy footwork to try and get it up to date again and I think those are usually the holdups that you see um and they they both have their their moments um another thing I think maybe you didn't notice but the the call to restart the um uh the server at the moment that's a synchr call and it takes several seconds so when you actually restart the enim server your editor will lock up for about 10 seconds while it goes through its little dance it's not like you're going to do a lot in that time anyway um but it is kind of annoying that it just freezes everything for that time and um trying to get more and more of this stuff asynchronous is a a big aim most of the calls are asynchronous at this point but not all of them so yeah uh you're asking the wrong person on garbage collection though I've spent many years in Java and I'm still not sure I could come up with the best garbage collection um strategy on demand I think you you play with it until it works well enough and then you move on so yeah there was another yeah mention that it's very heavy particularly with martion so just curious most of this is coming fromation yeah well okay so the question is about memory consumption um this is something we tell our students all the time this is pretty much the way Scala is right the Scala compiler no offense the Scala compiler is not the fastest compiler that I've ever worked with it's it's a it's a a fairly slow compiler and when you understand the amount of work it's doing you can kind of understand that particularly implicit resolution and traits trait linearization all those things are heavy to do and so one of the and you know again going back to the early painful days of of Scala I remember when Maven was the way you built stuff and Maven would rebuild everything every time it couldn't even do it couldn't because Scala breaks the convention of uh the the file name to the class that's inside of it Java has that uh that Convention of you know the public class is named the same as the file that it's in at least then tools could say oh you Chang this file or you Chang this class therefore I have to recompile this file Maven did didn't even have that option in Scala so it rebuilt everything and would take minutes and minutes to rebuild even small projects and SBT came along and you know built on top of the fast Scala compiler and just aggressively cached everything that it could so they kept everything in memory and just recompiled the bits that it needed to the idea being we'll speed up compilation by doing it less and we'll reuse whatever we can and ever since then I think the biggest tradeoff in scalar compilation time is memory the more memory you can throw at it uh and the longer you can keep that um server running the faster it's going to go it's going to have to do less work and I I think that carries on now I'm I'm getting some go on give us the definitive answer I think a lot of the data structures are actually for your IDE okay I don't so the incremental compiler most of the I mean there is some stuff that it needs to keep in memory and it does get a little bit big but we're talking about you know if you have a million lines of code it gets or something like oh okay so the gr compiler is unlikely to be really be the culprit here I think like you said if you have SBT running you have you know ANM and it's you know not yet graph bu bit thingy and then you know like I'm sure there's there yeah my logic has like gig does fine but yeah I don't think it's a compiler but I can see that there's a lot of data structures you want to keep around in a resident version typically I'm not using the memory for anything else when I'm programming so I don't really care as long and then you'll notice that I've got my little graphs up at the top here this last one is swap uh that's a pretty healthy healthy swap right now if that starts climbing I restart my environment CU I'll instantly get you'll see like the Cliff of memory as it all falls away and then you restart it and things are happy again for a long time so I keep that running as well cuz we deal um with very large uh satellite files and it's surprising how quickly when you see that thing start ramping up with the big satellite FS that I work on you got about 20 seconds before the machine stops responding so you better catch it quick cuz that ramp goes up really quick and you're like oh [ __ ] oh [ __ ] don't die kill kill uh before it gets there otherwise you're you're going to hard restart 201 sorry Linux on the desktop in 2016 just just well that will just that will just cause the problem much quicker it'll just start thrashing like crazy anyway yeah so um yeah it's not something I for my my answer at home was I have this is as much memory as I can get in this laptop uh for my workstation at home I have 32 gigs in it and probably going to get another 32 before too long as well which will just increase the time between restarts of the environment for me so Y how reasonable would it be to try to get this to work with notebook um how cheap how cheap what you said a cheaper notebook a Jupiter notebook oh a Jupiter what is a Jupiter notebook like iyon notebook browser oh you should ask that I I used the sorry now now I understand which J I thought there was some brand of notebook called Jupiter and I'm like oh I haven't heard of that one no the um there is actually already so the question is how hard is it to get it to work with a Jupiter notebook um oh you're talking about enzyme right specifically ah I was going to say because I've got the Jupiter notebook running I use that for demos and training and stuff like that I think I pretty much abandoned the idea because the originally what got me into this conversation was um uh the idea of running it in activator I think in hindsight the environment is heavy enough that I'm not sure it would really work well in that environment um it really is like you know putting an editor on top of it it's sort of like having a a seagull perched on top of a tanker uh you see the seagull but the tank is the big thing that's actually doing doing all the work and moving and um I mean it might be possible to run it and have it would be interesting to see where you could go with something like that but um yeah I I think probably for example running it um with activator it's going to make activator very big it's going to make it a very big big and heavy proposition for people to use so I haven't really looked at that seriously as an option in a long time besides I use Sublime so that's my particular itch to scratch but yeah that would be interesting I use Jupiter scal of Jupiter quite a bit and uh it would be lovely to see it if it did work so all right any other yes quick question this was a little while ago it might be fixing now but how does it handle if you have a lot of provided libraries in your buildt will it resolve those and those up for those as well yeah so question is what if you have a lot of um libraries in your build SBT it works very well for that uh it it obviously will take a bit longer to download them the first time uh because it downloads all the sources and documentation for them uh but it works fine and if you run it on a a project with loads of dependencies the first time it builds up that class path when it says saving class path that will take a couple of minutes it's it's quite a slow that's much faster on iterations you know when you run it again and again unless you blow away your enzyme config and do it all over again then you'll pay that that two minute startup it's about in line with what intellig takes to do the same thing if you open intellig on something with loads of dependencies you'll notice it takes quite a long time for that indexing bar to go along the bottom of the screen it's basically the same thing so I I was saying specifically for provided Library so it's like you have like the test and the runtime scope and there a provided scope you can apply so like we were working on a project that used spark okay and we didn't actually need those were building we were still referencing code from the smart libraries okay I don't know that I've tried that so I would give it a go and see what it does uh we we tend not to work that way I I have done Source dependencies in there and they work fine um you know basically did you know about that you can stick a a GitHub URL effectively into spt and it makes it a source dependency so it just goes and grabs the latest sourer of GitHub I I think Josh showed me that about three years ago and I'm like you can do that and then I did it for like you know a bunch of projects for a couple of months and I'm like you know this has some downsides people keep breaking my [ __ ] and so I stopped doing it after that but it it does it does work okay with that so yeah just answer your question um I think do it just called the update classifiers method and I don't think that will Prov I don't know tried it probably a few months ago I think there's been like a new major verd okay and the other thing is use the they get five to 10 times yeah that has made a big difference um I noticed that on the um the Scala uh so the Scara debugger is pretty heavy uh it uses a lot of well it uses a actually I think it's mostly the code in there but I've noticed that the resolving takes a long time um with Ivy and it's a lot faster with what what is it corser corsier yeah uh it does speed things up a bit that so but that's just the that's just the resolving um the other thing that really slows down resolving is when you use the IV uh it's it's it's got some kind of like little DSL for saying I'll I'll be able to use any version within this range and it's like uh you use a a square bracket at one side and a a paren at the other or something and it it's some little DSL in there that says oh you can use like 1.3.1 all the way up to 1.9.7 when you use those it becomes horribly slow to resolve dependencies I don't know what the hell it's doing but that really slows things down and uh you can call that back by just going in and making a little overrides file that just says you know what stop trying to figure out which version to use and just use this 1.9.1 version whenever I ask for this Library use 1.9.1 I've used that on multip I've I've been seen to be a miracle worker on projects because people are like it's taking you know a minute to resolve all of our dependencies and I go in I'm like well I can see these three things here I'll fix those instantly back down to two seconds to resolve it and and you get to look really cool from that one trick so yeah I don't know how corsier does on that I haven't messed with it enough maybe it does a better job of figuring out Dynamic dependencies edes ites work so I mean it's basically just pluging which changes the I resolution too I can't remember the name who wrote it but it's really incredible it does make a huge difference in the speed yeah all right so office house have we got time I think we have about half an hour so at 9: okay so I shall disconnect or unless there's any other questions so oh [Applause] [Music] okay