scala lightbend interview 9 23 16
Recording: scala lightbend interview 9 23 16
hello everybody i'm alexi cropper off the organizer of sf's column and here we are on location at nitro and we have an excellent talk today about play 2.5 so play is this famous scholar web framework which a lot of people i use in to build web apps and we also have two engineers from light valve formerly a type-safe i'll have will sergeant and have greg methane and i'll let you guys tell a little bit more about this homes okay sure um yeah so I just started working at like Bend a couple months ago before that I actually was working on my own startup I've been using play for the last couple years at various companies that I worked at and that's sort of how I got into developing play and yeah I enjoy it a lot I am will sergeant I got introduced to play around well the base or I suppose around 20 when it started actually using scholar as a base and started writing comments in and adding little fixes here and there until eventually I got hired at type safe now light Bend and now work on the Play team cool so I know a lot of the pattern but you both guys we're sorta founders you pick play as the condition of your company so what makes play a good choice for for start-up uh I feel like play it's it just works out of the box it gives you a lot of a lot of good features and and it really just sets you up for you know you don't have to wait with it because with Scala at least in my experience of scholar ecosystem is a lot of different technologies to choose from and it's very helpful to just have some something that does the right thing from the beginning and I think we're a lot of the stuff that we're working on now we're trying to to make it even better for that like make it sort of show you the right way and do things even more in which that's what I liked about play is that you know I don't have to think about a lot of things in play just sort of handles it for me and you know I can think about the real complex problems of scaling the infrastructure mmhmm yeah I had a similar experience working with play is that when you are sought up there are only so many decisions that you want to make and even worse than that the last thing you want to do is unmake a decision when you're working on a start-up you don't have to scrap your technology and restart it using something else and play has such good fundamentals such strong infrastructure especially when it comes to being in a synchronous non-blocking framework from the very start it makes the most efficient use of your CPU it makes the most efficient use of your threads and everything in play um you know it accomplishes a very difficult task of being both simple and easy and correct and those those are things that are very difficult to balance and play does a great job of starting new simple working ends of the hood and letting you swap everything out that you need to so are about rewriting the entire thing let me follow up kind of with kind of this idiomatic are ways to start your apps right so so there are now kind of established ways for people to write full stack sisters where play is used for the backend and angular is used for the front end to give you an example so how how do you guys serve this use case and like what do you see people doing the field maybe like an outline some scenarios right how different teams use play yeah yeah so actually in my experience I've worked in a couple of different environments where we have had a separate JavaScript build stack for the front end and we were using play and we there there are lots of plugins spt plugins that actually helped allow you to integrate with gulp and you can use that we were actually using run one of my previous companies or you can use SPT web and just do everything with SBT and you know there's all kinds of spt plugins for typescript and all this other stuff so there's a lot of different options depending on what your what's best for your team if you have a lot of JavaScript developers then you might want to go more with the JavaScript build tools whereas if you're more back end or Scala people than you would stick with SBT and the scholar build tools so you mentioned as BTW Webmind we can elaborate a little bit for folks who don't know what are this you know what are these tools like how will they make it easy to work with javascript from from scholar right so jess BTW web is basically just a way of so there's these things called web jars which are basically packages of various javascript libraries so those jquery there's coffee scriptures all your there's always different actually coke off script is a compiled thing but there's all these different libraries that people use and you can and get a web jar of it and access the javascript library from your assets in play mm-hmm and it's very similar to if you have a dependency in scala so you don't really have to use a different tool you just require the web jar depend on it and now it's available to you and you it's part of your build system in this version corresponding to the Java scripts are right right its version its version that way so that you know what yeah just much too soon reversion system that'll just rip this I mean the version system is I think it uses two similar types of versioning but it's all in one file I'm a little like jars just work like it's good like you can just you can't you can't unpublish the npm very easily just like like what happened yesterday it's right so that it has it has that advantage to it yeah I mean we all know like what to do the job so I think if you're a bookend developer and if you can get all your SS coming from jars like you know what to do that with a check of them right man is gonna resolve them right species gonna find them and cash that was like an all to do with it right so it's a little bit easier process to work with than if you some other JavaScript devstack mmhmm yeah so will I know that you you will work on the Play website and so let's say you know there is a new developer wants to check out play you guys have a lot of resources can you talk a little bit about what's available what's the documentation like what's a good entry point into the interplay ya know we actually in play to deploy and play two top-five we actually took a hard look at the documentation and revamped a lot of the intro pages to give people a smoother experience into play especially you know if you don't know play if you don't know s BTW if you are looking through everything and saying how do i download this literally the going to play and going to the downloading getting started page actually has pictures and where to push the buttons and want to download this it will bring you to you I which will actually start up typesafe activator allow you to see all of your compilation messages and give you a button to be able to run and restart your application and then from there we have tutorials that are organized by function and by versions so if you are using old version you can use plate you can see how rest api is are being done in late due to three and then for the newer features lock the lock did a great series of blog posts about how to use a curse dreams which are the newest feature in play dot-to-dot five okay and how to actually pull twitter and display them on the web page with that the solution so we don't work out of our own great pool Kinski here at night on he gave when extreme talk at Monte Scala and so like we're big fans great here that played 2.5 supports this so for what is kinda sounds like place is an entry point maybe into the host college system right so I remember that you know ruby-on-rails was the go-to apple web I didn't do the years but kind of play we thought about it so think about its kind of Ruben rails come on rails right in the way it's kind of it to go to away from work and it's kind of gives you everything so so so in your experience when nubes come to scala yes so play right what are the kind of pain points what are the things they learn like immediately and what are the harder things so if you know if a company is kind of trying to see like it plays a good web framework for them but they don't have much Scully expertise yeah what should they prepare for what's going to work like I mean there's a lot of advantages but like what should they expect essentially um I think they especially for people it depends on what language they coming from so if they're coming from rails then rails has a system which includes lambdas and it includes a system that is very much in the style of play in that they both have actions they both have requests and they both within results and they both have the same browsing underlying them so if you look at the routes file for example it will look very similar between the two if you are more java-based then play actually has a java api which lets you do everything that you would do in play with scala and all of the documentation is written again using play 1.8 examples and this is fully a synchronous and fully non-blocking uses java 1.8 completa Buhl's Dage so you can pass all of the concurrent utilities that are in play due to aid in play to 1.8 in job at 1.85 cheese but yeah you don't have to wade into the deep end of the pool and that's one thing that I tell anybody who's starting with play is that if you're comfortable writing Java and write Java if you want to learn play if you want to learn scholar but you don't know very much scholar then it's fine you can write Java code and you can copy and paste it in IntelliJ and actually it will actually turn that into Scala code for you mm-hmm and then you can use it just as you would normally and so welcome the bits that you're familiar with and then only start playing with the more headed or powerful bits of play of scholar when you're ready to okay so yeah they only learned one thing at once don't try to learn everything and become familiar with things as you need to cool so basically having both feel fully featured Joe APR and scallop a lets companies kind of you know you can map between the two you can go to this one you can try it in Java you can see how it works in Scala you can flip between the two you can include both in the same project you can literally have a Java file and Scala file living in the same package next to each other and work perfectly fine interesting that's really saying ah so one question I have about the architecture of play apps right so so we have this basically single page apps which basically a lot of things in the browser right so with this kind of movement to do more stuff in the browser what are the typical patterns because when do you need to go to the server social réseau play basically gives you stuff which exists on the server right then can serve it can give you templates right so can you talk a little bit about the patterns right like what stuff is mostly done like what piece of the web app and maybe you can talk a little bit about kind of what makes it scalable widow for like I was like things like uber also have this ability to scale what are the good bars for play well I think you know now that with the move toward more single page apps I think you'll you're seeing more plays is more used as an API layer mm-hmm and it's really doing a lot of the same stuff that it was doing before just that you're not you're not necessarily rending templates on the server you're you're passing some data down through a JSON or some other type of API mhm and we're just you know doing logic on the front end and that if you have an event on the front end that requires some response to the server you send it either through a web socket or through a REST API of some sort and then play is handling the integration with your database so that might be like a no sequel datastore or it could be you know regular you know my sequel database or you know those plugins for pretty much anything and and yet what makes it scalable is that we don't really have state on the server at least ideally you don't have stayed on the server at a play app and we don't really make it very easy to to to store things on the server so you have to have a back end somewhere you have to have somewhere where you know you might have a distributed cache or you might have a just you know a database or somewhere you know something like that that you're storing your data cool so so he mentions this kind of template on the server so i remember you know that was like a best practice you know by you know head scholar templates right and so and let's look at like this is old-fashioned way to do web apps we shake you know need a few years ago Sam I'm wondering right so let's have a back-end developer right and I don't know much about JavaScript and maybe I don't have time to learn right away so I kind of want to maximize my knowledge of scholar right so so and and kind of then you know the original way is the kind of you have your templates and and then you replace some content so basically when the user interacts with the four you know it goes you know through the server and comes back in and play has validation and like very useful things so so like is there a big difference let's say I want to heavily rely on these features like I want to do is motion in back-end as possible if versus writing a whole bunch of JavaScript and in angular right I wanted like I want to lean on place like what is the minimal amount of JavaScript I need to know right to I mean I can probably do just plain HTML right with playing yeah not do any JavaScript at all right I can do pre-rendering like what yeah is it like a best practice I can you give me like a realistic scenario kak a decent-looking lamp which is fast enough but uses the minimal amount of JavaScript I mean technically if if you want you can use scholar gs4 to build a dynamic front end yes and and you know it's not the most popular technology these days but it is a fairly mature technology so if you want to build everything in Scala you can there's a lot of example prod out there that show you here's how you set up your Scala gee that's front end and you can share a lot of the same models from the client and server I do think you still need some knowledge of JavaScript you need to understand how the Dom works and how how the fundamentals of JavaScript work here to understand something like that but there's no just like browser technology like you need to know all this stuff is surrender you need to understand you need to understand the basics of like what it's actually doing underneath yes but you don't yeah you don't necessarily have to know any JavaScript you you do need if you want to have a dynamic app you do need to have some amount of stuff that's actually running on the front end yes what are the typical partners is like what what kind of works real well so the up is responsive but tough people do in the front end and what is it and like what is okay to kind of do in play and plan is I think a synchronous right like what kind of kind of little a play during the backhand well let's start us company in the front that I mean it's it's really it's not even necessarily something play itself is doing you're choosing your choosing you know right you're just choosing what stuff you want to run on the client on the thread right I remember saw like you do all the data processing like I mean since I'm a cool guy whatever is data like it stops coming out of the database obviously I'll do all the data processing in the background right like if I need to do it like any kind of filtering right and Reformation but like I mean is it is it validation like an obvious like things like you your zip code should be five digits like that's probably really gonna do it in like a snippet of JavaScript right ya know a lot of what play is used for is play can set up a lot of web sockets for you beforehand and it can stream data backwards and forwards between an already established web socket and keep a pretty massive amount of open clients at a single time even with rust one machine we're talking like lots like more than I would theoretically think was possible what's all the rapport going to you I think it was like I think we can get 70,000 with la fully loaded pretty serious yeah no well I mean that it depends on your use case and it depends on how heavily the cpu load is loaded and also how the colonel is figure at that point you have to worry about the back plane but you know you can do a large amount of data and a large amount of throughput with a play application and you don't have to worry about you know do I have to do I have to send something to keep the keep it open do I have to worry about my threading model um literally when people have switched over from using other solutions to play in some cases they've gotten rid of like you know the third or two-thirds of their servers because they're just finding out that play is so much more efficient and that play makes better use of its resources and play scales up a lot better mm-hmm so yeah a play is very good at handling streaming solutions on the front end on linden and on the back end and for handling situations where you have a rich interaction between clients so you know cases where you're actually clicking around where you want low latency where you want like interactive games what you want to be able to have chat applications where everything has to happen mmm play is very good at all of these kinds of things because you know exactly what you're putting in and what you're getting out mm-hmm cool so and probably will confirm up with kind of the future directions right so obviously play was one of the mainstays at some point play that was the main driver for scholar right now i would say spark is probably you know bigger growing butts plays like one of the most established technologies so what do you guys see in that community how do you see like play installations in industry how do you see that community developing and basically what are the sort of next things after plate 2.5 yeah i mean i think that that yeah you're a lot of the growth in terms of like this from the scala community is starting to slow down but i still think that play will be probably most popular scholar web framework and i think that i think it is the other thing as far as i know and i and i mean there really isn't another popular framework there a library and you can use lock HTTP stuff like that but it's really the only very popular Scala web framework that's out there and we want to keep being opinionated and keep trying to push people in the right direction in terms of bill being able to build scalable apps and and that's kind of what we're working on with play 2.6 and eventually three data which is probably going to be the next release after two at six so we're removing more global state so you we make sure that you have a completely stateless app you can run multiple apps beside each other in the same jvm you can run tests in parallel so you we want to make sure that you are set up for writing very very testable code very scalable code very modular code we're you know we're also modularizing more of play for example we're using juice as the default dependency injection framework now we want to move that out and make it more so it's easier to plug in different frameworks we and just we're modularizing one of other things as well and eventually we also want to support HTTP too that's probably a three-pointer feature mm-hmm and obviously you know you mentioned Scala GS we're big fans of colleges with us colleges like a phone a lot year with Holly who is it like one of the right kind of you know happy faces of scholars yes really you know the great work evangelizing it so uh you know like my dream is called developer again like I want my scholar everywhere like how easy is it to integrate colleges of play and can you guys give me at some point like full stack thing where I'm just using scholars yes and play together there yeah yeah they're their templates out there for doing it I think that that one of the focus is Navy 42.6 and 30 is trying to make sure that that experience is more streamlined mm-hmm but there there are lots of examples out there it's not it's not something that's officially supported by light bed technology ask but there's a pretty large community around it right now and that community is yeah really supportive and a lot of the people are using play as their as their web framework and they're just integrating it and it works very well I don't think that that's I think that's probably the most popular way of doing this ecology as these days okay yeah I mean we tried last year and those a lot of kind of fellow kings and kind of you know we're basically had to jump through some hoops like it would be super nice to get basically a kind of kind of elaborate example which casual just works out of the box so we can just do like everything right and especially when it comes to doing like certain picking up picking certain frameworks you're going to use I think recently there are some very good examples of things that used to react forget what it was called but basically youth they use react on the client side I mean they had examples of complete apps that worked in like on mobile and worked on browser using react native as well mm-hmm so and we didn't play as a backup yeah and using play oh cool that's it that's exciting yeah so I will do have anything to add to the future directions like what are your plans would play well a lot of what we're doing foreplay is about making sure that it's open and that it is accessible to absolutely everyone so part of what we're doing again at this talk that we're just going to be giving is asking for feedback in the documentation because one of the problems that Greg and I have is we can't see what new people see also being able to get more feedback on that being able to smooth out the introduction experience and make sure that people know where everything is they know how to get to the templates and they can you know start waiting in at the shallow end of the pool and then you know jump in with the rest of the people when they're ready cool so you know for guys for watching us go to play framework calm play the documentation yep you have some problem you can you search banner very proud of that so yeah we'll told us he just did this today so tested you know kicking the tires and you know something is wrong submit something is wrong scroll down to the very ends of the page and then click in the documentation and it will actually take you to the source code for that documentation you can submit a pull request right there and then do it I just like you