 what is public yeah sometimes our friends will snoop around get the URL for the live and they will hear us talk before it all right i shall start the countdown 15 10 5 4 3 import episode 48 it's 8 July 2017 streaming directly from Singapore it's Rebuild Live this time on Rebuild Live we'll be chatting about Scala programming language with Hawi hey welcome to episode 48 of Rebuild Live i'm your host Sayani and on the sunboard is Chin Meg and our guest today is Lee Hawi good morning Hawi hello all right so so we got to know Hawi because he just tweets and shares a lot about Scala yeah a lot about Scala and we also heard him talk at the news hackers oh yes that's the first time he had a general talk about how to debug or like get into the code base of any unknown open source project that was a really nice talk yeah and that's how we got to know Hawi through NUS hackers and then we just saw that he was just sharing a lot and if you don't already know please check out his vlog while we get through this live broadcast LeeHawi.com and also his open source projects which are mostly listed on github.com slash LeeHawi so we are here to talk about Scala about open source about anything that Hawi is hacking on coding so Hawi why don't you introduce yourself oh hello everyone so i'm Hawi i'm a software engineer currently based in Singapore previously i've worked at Dropbox in other places and i've done a lot of work open source around the Scala programming language so that's been kind of a hobby of mine with many side projects that over the years have been used by a number of people and i guess i like it enough that i keep working on it despite the fact that's not really making any money it's just a hobby which reminds me patreon right how you're on patreon so yeah if you like it's open source projects if you use it contribute on patreon okay great so audience thank you for joining us on a live saturday morning we'll be talking a lot about Scala about open source and Hawi's projects and uh if you have any questions for Hawi on Scala please drop it on getter.im slash rebuild sg slash live and we will pick it up and how we will answer them so Hawi why don't we dive straight into what is oh wait don't you forget the malformed query we have we usually have a welcome gift for a guest yes we do so the beginning of every show we welcome all our guests with what we call a malformed query so malformed query is sort of a question that i'll ask you how you which you can kind of answer if you want it's more like a pun or a riddle so your your malformed query is what did the array say after it was extended what did the array say after it was extended array um in javascript they would say undefined well this one said this one said stop objectifying me oh my god that's a good one well now that everybody is awake let's move on to a real topic of the day which is scala programming language okay all right so Hawi why didn't you tell us what is scala programming language sure so scala is a relatively new programming language i think it came out a bit over 10 years ago which is quite young in programming language terms um so it's a kind of a it's a kind of a mix of a object oriented language like java and a functional language like or camel or haskell and it happens to run mostly nowadays on the java virtual machine although now there's also the back end which runs on javascript called scala j s right um so people have traditionally used it for a lot of things we're mostly around either compilers or distributed systems or websites um and it's quite uh broadly used for as far as niche languages go okay it's very interesting because when i looked into this right i saw that it had a very strange uh background says oh it's both functional and um and or op right like how does it pull it off like that's generally these two these two camps are considered like you know for the opposites right yeah um so it's a bit unusual in that it's actually in many ways more op than java is where java is often considered the canonical op language yeah it is um so you can create objects objects have methods objects have fields and you pass objects around and everything is object including things like integers of other primitives that aren't really they aren't really objects on the underlying runtime but the language pretends that the objects and it works well enough in practice okay um but it's also functional in that it encourages you to do things i guess the main what makes it functional is it encourages you to do things without uh changing variables so you define so the default default variable is actually called value not variable and value is basically a final variable in java um and okay so it forces everything to be final so that you you wouldn't be able to change it so is it the unmutable yeah unmutable so it doesn't quite force you but it encourages you to make things final and it provides some nice tools that make it easier so for example um like if you program in java a lot you often have this thing where you create the object and the objects in this half baked state doesn't really work yet and you have to call a bunch of like setters or builders on object in order to make it work yep um and in scala you don't need to because objects can take named parameters and optional parameters so whereas in java you need this builder to say like i want to set only these three parameters out of the maybe 10 possible parameters in scala you just make them optional and you no longer need a builder which mutates the object now you just set them all at once and your object is ready and immutable you can't change it and often you don't need to interesting that's very interesting because immutable like like we're talking about immutable objects or immutability is a very functional programming concept but it's interesting that you can actually work quite well in the op setting as well yeah so um i guess the way i program scala which is different from many other people um people have the whole range of like java like scala to haska like scala the way the way i program like scala is basically using it like java except the places where java makes you do silly things due to its the language design in scala you often have a better way of doing it so for example um in java people often don't mark variables as final even when they could be final just because it's tedious and verbose and um generally a pain to remember to do yeah whereas in scala um calling something of value which is val is the same as call it is the same amount of verbosity as calling something a variable which is val those two keywords are both short and the same so you just use immutable vowels whenever it's convenient then you never have this problem of oh it's over both i'm too lazy to do it okay but if you're gonna if you see i've not really looked into the syntax too closely but if you're saying if you use syntax like val so does it also do type guessing kind of things where you just say it's a val and if because of what type it is or yep you also put your type in it does type inference like c sharp like c sharp does and i guess java's going to at some point true true yeah that's what it was a java nine that was going to have that or i think java ten so another five years maybe it'll take a while very interesting all right so how we let's talk about scala being used in large modern applications to be honest i first heard about scala when twitter started using it this was a big news back in the day right when they were using rails i think and they refactored some parts of it into scala yeah and it was in the programming it is a big thing because it's sort of uh you know a lot of people were like oh you know this is how we make apps and suddenly realized oh no there's a whole different world when you start to start skating and then you have airbnb and four square like seriously large modern applications are using scala and how are you why do you think scala is so attractive for this what are they using it for so i think it comes down to a number of different different factors there's no one like magic bullet that makes people want to use scala but the factors are things like it's concise so people like python and ruby over things like java because java so both python ruby are concise and scala is about as concise as python and ruby are often feels like you're writing a dynamic language in how little code you write to get something done um on the other hand scala is also very safe you have the compiler that helps you check things right and this is the flip side like people like java because you it's you have the compiler and it says but then writing python or ruby if you make a typo it'll get caught um and scala is like more like java and perhaps even safer in some ways um people like scala because it's relatively performance so it runs about as fast as java and for all that people say about javascript being web scale and fast um it's actually about five times or ten times slower than java is and python or ruby on the other hand about 25 30 maybe 50 times slower than java is so scala is about as fast as java maybe one or two times two or three times slower depending how you write it um but it's actually a big difference in that sometimes you don't need to care about caching anymore because your thing is fast enough already you don't need to care about parallelism you don't need to care about distribution it's just already fast enough um i guess the last two things also are related to running on the java virtual machine is that um you get all the java tools which are very nice so things like if i have a server in production somewhere and it's misbehaving i want to insert a profiler into it from my laptop and see what's taking up all the time because it's running a java virtual machine i can google it find stack overflow answers of how to insert a remote profile onto my web server and it just works whereas yeah trying to yeah trying to do the same thing in like python or go or like say javascript you can make it work sometimes because often much less much less standardized and much less common and much more difficult to get working interesting because because it it it compounds down to jvm bytecode all the jvm tooling especially like what is it profiling and several enterprise level tooling can be directly applied to this right so you don't have to you don't have to do almost anything yeah or you don't have to create your whole new scala tooling you just use a java thing and it works great and the same applies for libraries so like if you have a small like university homework maybe you don't care about libraries but if any big application you have like weird data formats that some guy wrote you'll have some weird like third party service you integrate with and some weird sdk that you need to integrate operate with it and with like with scala on the jvm you can often just use a java library and the java has a huge number of libraries all sorts of things like you want to read shape files you want to manipulate microsoft office documents you want to interoperate with matlab all these weird things that you may not need but not everyone will need all of them but everyone will probably need some of them and different sums of them and if you're on scala you don't need to write your own like matlab interoperation library just use a java one and it works great true yeah matlab is actually all mostly in java right the the ui at least the ui is in java yeah and the underlying is all sorts of high performance stuff yeah yeah i don't know fortran or yeah possibly yeah i'm not i won't be surprised if it is some yeah some fortran packages at the back blast and all that stuff yeah interesting no what one of the things he said that was really interesting to me was you know java gets a lot of um shit for a lack of a better term in in you know the programming world for being you know verbose and hard to write and slow i'm guessing the slope mainly comes from the fact that jvm is slow to start yes but uh we know when i start looking at people who are doing really high performance stuff or talking to people who are doing stuff where it's very critical to be super high performance i i see a lot of people going back to you know java or at least jvm-based yeah so which is very interesting to me because i feel that you know i think it gets a lot of bad rap for being you know like something that's enterprisey and not so cool but for no reason yeah well i guess slow could mean two different things so one is startup performance and the jvm really does take a long time to start so for example um i have a small one of the tools i built the ammo knight rappel in scala runs on the jvm a few megabytes of like executable and it takes half a second to start even before you can't actually running the code the half a second just spent like loading the code into memory before you can start doing things so you compare it to say python python starts in 30 milliseconds right so more than 10 times faster and you compare it to something like bash bash starts in four milliseconds so a hundred times faster so that's a real problem but if you're doing kind of back end systems maybe it's not that big a problem because the server starts and then hangs around for a while and once the server warms up it actually gets really fast so i think the normal benchmark typically typically put it around like two times slower than c plus plus to maybe like five times slower than c plus plus for many things which is actually really fast yeah it is yeah like and i see that because of that is a lot of this you kind of like what talk about ripples or in program shells that people tend to use a lot because they don't want to keep restarting jvms yeah i see this a lot in the java well i've never seen this so much in the other programming languages right but that's that's very interesting so other than that are there any other things we missed out about why what makes scala attractive i guess that's most of it like it's just a bunch of different properties somewhat unrelated but all quite useful if you're making a big application what about like getting people on board is it really is it a language that's hard to learn because you know if you look at looking at big teams one of the things they always worry about is like you know how can i get all my engineers to learn this new new framework on your programming language um i think it's definitely harder to learn than many other languages um and part of the reason it's harder to learn is because it's this hybrid language both object oriented and functional and so there's a lot of different ways to do the same thing which is often problematic so if you have a team that's writing the very object oriented side of things like basically using scala like java and you have a different team that's using scala like haskell um they're not going to be able to talk to each other or interact with each other well the code can interact but the engineers will not be able to understand each other's code because it's so different it reminds you of poll you know it's like people write poll but everybody writes poll in a different way you can you can never understand each other's poll yeah so i think it's somewhat different in that you can usually understand your own scala because you write in a certain way and that way is reasonable whereas you often cannot understand your own pearl you come back five minutes later like it's not just different but it's also just hard to read very scala um what you'd have to do if you wanted to have a team working on it is you have to be pretty strict in saying this is a kind of scala we're going to write so we're not going to be writing that extreme or that extreme we're going to be writing this um this point in the spectrum and we'll just standardize on it just because that's what everyone in our team is going to do and we can then understand each other's code much more easily are there are there tools in the scala ecosystem for doing things like linting or you know or somehow categorizing these kinds of dialects i would say i know however you want to go not really but i guess one thing that differentiates things is what libraries you use so for example if you're writing python you can basically put in any library and you can expect it to work more or less the same way because everyone writes python more or less the same way or if you're writing go for example everyone writes go in about the same way and same for java on the other hand for scala you basically have the you have the neutral libraries everyone uses then you have the extreme libraries on either end which if you don't include in your project you probably won't end up on the extreme but if you do include those extreme libraries for example the more the more um more opinionated functional programming libraries right then you better get everyone get everyone in your team on board with it before you include it you just include it as like part of a bigger people request and hope no one notices yeah all right so now that we know a lot about the good things about scala and the differences uh what is scala not good for like what doesn't work so well sure so there's kind of two different questions so what what doesn't work so well is for one we already talked about how you can write a whole bunch of different kinds of scala in different styles and that while some people say it's a plus it's definitely problematic in practice um another thing that doesn't work so well is um the compiler is really slow so it's not the slowest compiler in the world I think like for example the scss compiler is slower and the the rough compiler is sometimes slower and the google web toolkit compiler is sometimes slower but it still is definitely on the pretty slow side of compilation and it doesn't work for the same kinds of workflows that you do with python ruby or ruby so um for example if you're writing python ruby code you'll be running the code over and over and seeing the behavior at runtime and deciding how you want to change the code to make it behave whereas it's scala you can't do that because every time you run it's gonna be like at least one or two seconds just to get compiled before it starts running so you have ended up with a different workflow where you have to think a bit more before you run the code and the language helps you so for example rather than running the code to see what type of variable is you can just ask your editor hey what type is this and it'll tell you or rather than running your code to see is this did I pass the right number of functions you just type it in and wait for the editor to tell you did you pass the number of functions otherwise it'll give you like a red squeaky underline um so you have to change your workflow to get around the the slow compilation and it works okay but definitely is a downside compared to something like python where you just like splat out the code and run it and instantly does what you want or not um I guess the last thing is that some of the tooling surrounding scala is confusing so for example scala has number of id is but they don't they don't generally work as well as java id is like java id is really spoil you because they're so perfect everything works perfectly everything is so tightly integrated whereas scala id's are a bit more like python id is so if you've used like pie charm for example or you've used like wing id or um it generally works maybe like 80 percent of the time and the other 20 it just can't figure out your code or doesn't work for some reason and it's still very helpful I use pie charm a lot at dropbox and many others do but it won't give you the polished super integrated experience that the java id may give you um yeah in fact howie you also wrote a blog post which is uh more on the technicalities of scala programming language warts of the scala programming language so if you have a chance go read through it he actually talks about the language structure and the properties in the language and goes through the warts of it so that's that's another take on scala programming yeah so that blog post basically covers many of the more small low level things like this piece of syntax is annoying unnecessarily or that piece of syntax is error prone um so I think scala has many of these like many other languages and that I guess the hope in writing that blog post is that eventually can build consensus and try and get them fixed right how does it work with the community is it um is it the community driven uh like language decisions and stuff like that or um I guess it's not quite fully community driven so if I were to describe it it would be kind of like an oligarchy sure so it's not one person in charge of the whole everything but it's a small number of big organizations who have the most say in what the language is going so you have the university which first created scala I think that's etfl in Switzerland they're one big party you have um typesafe which is a company that it works on scala commercially now called like band I think and you have a few other like big parties who have most of the um most of the mind share and who have most of the say in what the weather language is going right um so if you're like a random person using scala you probably won't be like it's not like many others like rust where they have or python where they have big open like votes and stuff on whether you want to do language features but there is a general consensus process where the big parties will try and find a consensus among themselves it's generally will work for them and if it works for them it'll generally work for most people because they're pretty disparate like you know one's an academic lab and one's a company and others are like product companies using scala for other things right yeah that's a different point of view but there is always a lot of conversation about this and they're open with hearing your views so when you write a blog post like what you did you can kind of get this word to them yeah so like me writing the blog post I don't get a vote but okay if I can get them to listen then these guys also because they are the ones doing all the work so it's since you're doing all the work you try to get them to believe what's worth working on and then hopefully they'll do it right okay it's interesting to always know how language standards and are built for the next version so the next segment we are going to be talking about tools for scala and that's going to be a big segment I think so audience if you're listening to us drop questions for how we which we already have a few we have a few questions already questions but if you have more questions just drop them in the getter.im slash rebuild sg slash live and we will pick it up for how we later so let's talk about tools what are the common tools that you use every day in your development? Sure so the most common idea when you everyone uses is IntelliJ yeah so I think it's like Java yeah so IntelliJ supports Java it supports Python, Ruby, PHP, JavaScript like basically almost every language under the sun and it also supports Scala and within the Scala community IntelliJ is definitely the most popular choice I think at conferences they often have these surveys of what tools you use and IntelliJ is usually something like 60 to 70 percent so it's quite a large number. So for IntelliJ it's a plugin for the Java ID right for Scala or is it a separate ID? It's a plugin but there's no real distinction in IntelliJ like the Python plugin and the Python ID are basically the same thing. Oh really okay yeah so apart from the 60 70 percent using IntelliJ if I remember correctly the rest is split pretty evenly between people using in Eclipse people using Sublime people using Vim and Emacs people using Atom so they all have Scala support to varying degrees and there are people using all of them this is not as many so that's as far as IDEs go as far as build tools go everyone basically everyone uses SBT which used to be called the simple build tool but people realize it wasn't so simple so it's been renamed to the Scala build tool so that's I guess an ongoing pain point in the Scala community because it's somewhat slow and it's very confusing so there are people working on trying to make that better but it's taking quite a while so that's that's a equivalent of say Maven in the Java world or like setup tools in the Python world or NPM and Gulp in the JavaScript world so in Scala it's called SBT package manager so Scala uses the same package system as Java so there are a number of managers that can work with it for example Gradle or IV or SBT itself and it's a new one in Scala called Corsair which came to be faster and it seems to be pretty good but generally the Scala packages are Java packages so you publish a Scala packages the same like Sona type Maven central package repositories and you as a Scala programmer can pull down Java packages basically trivially and in the same way a Java programmer can pull down Scala packages if they wish to do so so it's the same there are a bunch of different like front end tools to the package system but it's roughly the same package system as any Java programmer would be used to right what about hinting or linting use something as far as linting is concerned there are a number so one's called work remover which attempts to raise errors if you use certain language constructs in more error prone ways there is there's a new there are a few automated format the code for matters so there's a old one called Scala reform and a new one called Scala format Scala FM P that's how it's felt and those try to like standardize the formatting of your code kind of like how go format will standardize the formatting of go code those as far as I know are the most popular ones there are several other smaller ones that haven't gotten as much usage yeah all right so why don't we now talk about the tools that you are building you're building some Scala based tools let's talk about ammonite sure so ammonite is used mostly for scripting purpose yeah so ammonite is a Scala repel and a Scala script runner so the repel is kind of so Scala has already had a repel that lets you enter code interactively and that's used heavily for things like spark where you want to explore the code explore the database or explore the big data cluster interactively okay so the default Scala repel is kind of like the default python repel I type in python and you get the repel it works but it's not very nice to use everything's black and white there's no code no code highlighting yeah there's no history in between repel sessions oh dear that must be very painful so it's it's okay but it could be better and that's the Scala repel by default is in a similar situation it works but it can definitely be better um so the ammonite repel is kind of like the Scala equivalent to the ipython repel so if you use the ipython repel you get coloring you get multi-line editing if you want to define like a four-line function you can go up and down edit your function you define if you define the value even if you didn't assign it to a variable it has a input has an input array and output array so you can go back and fetch like oh what's the variable what's the result of the computation uh three commands ago and just fetch it out um it pretty prints the output so it's nicely formatted and multiple lines indentation so that's what ammonite does for Scala and I guess it's meant to meant to serve the same purpose in that if you're using a repel all day um you don't want to be trying to dig through unformatted black and white text you want it to be nicely laid out for you because computers are good at that and that's what ammonite does um and also tell us about your new version of the ammonite that you just launched like what features it has sure um so i i recently released i guess the 1.0.0 version of ammonite and it didn't really have any new features at the previous like 0.9 for something versions didn't have um basically it's the same old version just labeled with 1.0 because it kind of stabilized versus what the old versions were right so the old versions are pretty experimental um so if you use a feature in the wrong way if you as a programmer made a mistake it give you like confusing error messages and big stack traces um some things weren't colored nicely so it's hard to read um there were some missing features that would have that are very simple to implement that would have made it a lot easier to use for example being able to like run a script and automatically rerun the script when you save the file um that kind of really small like polish things that's basically what the focus of ammonite 1.0 was so all the features are basically the same features that people are used to like a wrapper a script runner loading loading packages from the standard package repositories but all the small things like making sure error messages are understandable making the output nicely colored adding a bunch of small features to make it more convenient to use that's what 1.0 meant and i guess 1.0 meant that it's ready for you to use all this stuff is pretty solid and you don't need to worry about bumping into rough edges when using it cool al what are your future thoughts about one point the future versions of ammonite sure um so one major pain point currently is ide support so ammonite the rebel doesn't need the id because the rebels as a rebel runs in your terminal um but it also provides like a script from script running functionality so kind of like how you can write python scripts and run them without the big like package file sorry project file and ide like package system um ammonite also lets you run scala code just by putting some lines in the script and running it without worrying about like all that setup so it works but ide is currently don't understand it so that means that when you're editing ammonite scripts and ide you lose a bunch of the nice things at scala that you people use scala for so things like being able to press dot and have to automatically drop down yeah things like having your um if you import something doesn't exist having it show up as error message and if you press tab after half typing a variable name have it automatically completed for you yeah that's just a rebel way of uh yeah typing it so that works in the rebel but it doesn't work in scripts and but it does work in normal scala code because normal scala code has good ide integration the ide understands that code so i guess one thing that i want to get working at some point is to make the ide understand understand ammonite scripts um there's no real like theoretical problem behind it there's no like difficult engineering like algorithms or anything it's just i need to get get some time to or find someone who has time to go and like integrate it with all that intelligent like internal systems that they use and integrate the eclipse integrate it with like visual studio code and it's basically a bunch of plumbing work very hard plumbing but just plumbing but once i get that working it'll be very nice editing of scripts and ide with the same like full id support you expect from writing scala or java all right cool nice yeah that that sounds like a quite a useful thing that you also want um let's us talk about uh say using scala with uh web uh programming languages like say javascript yep um what you want to know about it i think you have worked a lot with scala js yep so scala js is a new backend for the scala language so traditionally it compiles with java bytecode runs on java console machine now it also compiles to javascript code which can run on the browser you can run load js you can run on your tesil javascript microcontroller if you so desired um so it's actually a bit surprising how well it works um it the code generated is fast so it runs about one two times slower than if you had written the javascript itself which is often not a big deal and compare you write your code in scala and then yeah kind of compile it to javascript yes and then you can run in the browser you can access the dom the browser dom okay so front end as well front end as well as back end yeah and you can access third party libraries so i think the most popular front end framework with scala js is react js the the javascript react js library from facebook yeah and many many people are using react js like jquery um moment js all the javascript libraries are available from scala js as well as many of the scala libraries that you use in the skip that you would use when writing scala on the jvm interesting so so people have like wrapped around scala js around all these libraries or is there a easy integration or import functionality sure so i guess there's three ways you could use these libraries one is you could use them raw so if you use them dynamically you don't get any type checking and you don't get any editor integration sure but you can call any function you want and call any api you want directly and it just works if you it works if you use it correctly and if you didn't use it correctly it will fail at runtime so that's just kind of like what it's kind of disappointing coming from scala but that's how it works in javascript land anyway everything blows up at runtime and you get no editor help so then the second way of using these third party libraries is you can define uh uh type stubs so if you use typescript for example you can define dot d dot ts files which don't contain the implementation code but they define like oh this function exists it has these arguments and returns this this like string or list or array or something reminds me of the old school c header files yeah so it's basically the same and scala js also lets you do that the syntax is pretty similar to the the way it works is pretty similar to how the typescript header files work except in scala instead of typescript and that basically lets you call the javascript functions the same way directly almost the same syntax as if you call them dynamically but now that you have these header files if you make a mistake it'll get a compile error and if and it also means that you get like editor integration like press dot you can see the list of functions you can call you can press tab to autocomplete things then all the things you'd expect from normal scala code and then there's a third layer sometimes people will go to is that to wrap a javascript library in a more scala friendly like wrapper so this is totally optional but for example many many things that you do in javascript you'd have a slightly different way of doing in scala indeed for example in javascript you use esx promises maybe for asynchronous return values in scala you'd use a class called scala concurrent dot future which is basically the same thing but that's just the way people do it in scala land so people would take third party libraries and wrap it to make it more idiomatic scala or for example in javascript people return nulls or undefined if something doesn't exist and in scala people prefer to return option optional class optional class the way it is in java java 8 so in that in that way rather than right so you don't need to do this you could always use javas use the javascript library as if you'd use it from javascript but if you're using the library a lot or if many people are using the library which is the case for example for react j s then often someone will go and wrap in a more scala friendly wrapper to make it fit in better with your scala code right but if you really want to for example maybe there's a new function that hasn't been wrapped yet you can always just call it directly dynamically and bypass all this wrapping gotcha all right all right that was a lot about scala now before we go on to the last question audience if you have any questions for how we drop them on to the live chat get our dot im slash we will sg slash live so how we want last question on scala before we go on to the audience question sure um what are what is the future of scala that you're excited about any upcoming features tools um so there's a few um probably the biggest improvement that people are working on is speeding up the compiler okay so that's definitely the number one pain point everyone complains about when using scala um and i think the late the latest uh snapshot version of scala has something like a 20 speedup which is quite substantial like it means if something took five seconds in i think four seconds and that's great if you're running the same code like compiling over and over throughout your work day do you know how they did it in the compiler code um it was a lot of hard work and profiling and experiments to see if things make things faster so often it's not very obvious why things are slow because like performance isn't just how much code you run but how you run it so for example like if you run if you run a bunch of code that creates and destroys objects very quickly yet that runs faster than if you create a run bunch of code that creates a lot of objects first and destroys them all later um because of like memory and cache performance so that's kind of often very unintuitive because you're running the exact same code creating the same objects and destroying them but in the end the code just runs runs at different speed and it's often not clear why so my impression is that the the core scala team has spent a lot of effort building up benchmarking infrastructure and running all sorts of these experiments to see like empirically if I shuffle this around will it be faster or like where are the actual places where which are causing my code to take a long time um so that's performance um in terms of the language itself the there's a new version of scala coming out eventually it's not clear exactly when yet but they're calling it scala three provisionally um and code name dot e due to some like clever pun on one of the implementation details um but so that version of scala is meant to clean up a lot of the um I guess the craft that's accumulated in the scala language so like many parts of language have kind of evolved over the years and weren't really designed so for example scala has inbuilt xml support because xml was really popular 10 years ago and scala came out like everything was xml at the time it was a json yeah and now like everything's json and in five years time there'll be something else and so in dot e they're trying to like get rid of this xml support and you know replace it with something more general um then dot e also the scala um type checker and compiler has also had a lot of weird bugs in it due to how it's evolved like many parts of the compiler kind of have together until it works but no one really knows why it works and as a result it's very hard to debug bugs they don't know why it works in the first place or you don't know like if it doesn't work like or if it's behaving if it's behaving strangely you don't know whether it's meant to do that or whether it's meant to do something else because you don't actually know what it's meant to do um so dot e is a copy rewrite that i guess is actually designed rather than evolved so they have a good like foundation of like how is the language meant to work and if something is behaving in a certain way you have a good idea of like is this a bug or is this just how it's meant to behave um and as a result they cleaned up like a huge number of bugs in the language um often more bugs that occur in more like obscure cases that you don't bump into day-to-day but still bugs that people will eventually bump into and cause problems so they cleaned up all that or most of that stuff um i guess the last thing that i think is quite interesting is so scala has a new native code backend so scala compiles with java bytecode scala compiles to javascript as of three years ago and there's experimental new backend that compiles to x86 assembly or arms assembly or whatever using the llvm like backend um co-generator so that is quite exciting because it solves some of the big pain points of using scala in some cases which is that it takes forever to start and warm up so rather than taking say like 0.3 seconds to start and warm up or 0.5 seconds starting warm up um there's a bunch of new benchmarks using the new scala native backend and it takes 0.001 seconds to start which is like way better so so steady state is not going to be as fast as the jbm for quite a while but the startup time makes it so much better if you're creating that command line tools you know you run it you you run some command in the bash shell you don't have to wait half a second for it to run just to run instantly um and just like scala j s um and unlike many other like new languages scala native can benefit from like all the scala libraries which already exist right so like for example they've ported the new scala metaprogramming uh library to scala native with basically no no changes to the code itself and the whole thing just runs immediately and you can imagine like all your scala like json parser scala serialization library scala html generator scala like whatever all this stuff does not need to be recreated you just like adds a flag to your configuration and cross compile it to scala native and it should work out of the box so i think that's quite exciting because you basically have a whole new whole new native programming language but without all like the bootstrapping like um critical mass problems you get when you're trying to write a new language because almost out of the box you have the critical mass of programmers who you know how to write it books that teach you how to use it and libraries and ecosystem and tooling of like that you'd want to use when you're actually using this language for real work oh that's really cool so i think it's quite exciting and hopefully continue pushing it and it ends up in a good place great so where should scala programmers interest people go to check out these conversations happening is there some online forum or um so if you're interested in like work helping out with the scala language itself um i guess first if you're interested in just learning more about scala or like asking questions about scala like as a learner which many people will be then there's a user forum called users.scala-lang.org and that's like a i think it's a discourse channel which lets you sign up as a mailing list and you can go and ask questions about how to use scala why my your scala code is not working etc and if you're interested in then like contributing like you want to help push some library forward you want to end up helping contribute to the compiler the native backend the JavaScript backend then there's another forum called contributors.scala-lang.org and that's where all like the core team hands out which you know the guy's working on the various compilers and various core platform libraries and if you want to ask questions like suggest suggestions um talk about your new your new project that you want to get people interested in that you know more advanced people who'd be able to contribute rather than just learn then that's the forum that you want to go to um and each of these projects has its own github channel typically okay so there's like the scala-native github channel there's the scala.js github channel um there's a scala-scala github channel and if you go to the the the project github page it should be easy to find from google um you usually have a link to github channel you can go in and ask questions and generally talk to people about it all right great so audience don't worry we will put in all these links in the show notes yeah so you can just go to show notes and check them out check out what's happening in the scala land so chin may that was a lot about uh scala programming language yeah it was great audience questions right yes we have we have four audience questions for now and more if they come pop in so let's go to ayo polling all right so the first audience question is from yujin and he says that he's not familiar with scala but he wants to know if there is an equivalent to psychic learn or pandas uh on in scala side of things uh and if there if he's someone who's familiar with r or python is can he pick up scala for doing data analysis and modeling um so there are equivalents but they are not nearly as uh ubiquitous or as popular as the python equivalents so um um for i think for as a as a numpy replacement there's a project called nd4j or nd4s i can't remember what it stands for but it basically gives you like numpy style um big arrays that are big matrices which are fast and quick to work with okay um as far as the psychic style uh the psychic style library is like in terms of neural networks and pandas in terms of data frames i'm not very familiar with what what the equivalents are okay um yeah so is it a common use case though do people use scala for these kind of things or is it not yet yeah like data modeling and data science stuff my impressions that people do use scala for it but i'm personally not that familiar with that side of the language so a lot of that stuff happens around spark which is like the very popular distributed data processing system that people use now and my impressions that they have all sorts of things for like running running regressions or hyperlog whatever in computations or deep learning or machine learning algorithms but i'm not personally that familiar with exactly which libraries are the most popular nowadays all right okay next question is from mike and mike asks are you a fan of the play framework um i think it's the java play framework that mike is talking about it's scala it's all it's scala okay so play play play framework 1.0 was a java framework and then play with a scala plugin and play framework 2.0 is now a scala framework with a java front end for it so it can be used in both java and scala um now the internals are already in scala because the guys who wrote it became scala fanboys after using the language um i guess it seems like a nice framework i i've used it a bunch in the past when it was quite new and it seemed to do what it did on the box um yeah it gives you nice things like live reloading in the browser nice error messages error formatting a bunch of good conventions um i guess if you if you're making a website using java sorry if you're making a website using scala the play framework is a natural thing for you to start with um and later on if you want to replace it with your own special web server like htp4s or akahtp or something you can go do that later um and play frameworks good defaults good tutorials lots of material online and easy to get get going so i guess it's like the rails for ruby kind of thing yeah i think like the intention is it's meant to be like a rail style experience but just like way faster and safer of course yeah cool the next question is interesting yujin asks again um and i think the answer even i might know the answer to this he's he says i want to replace my shell with a scala shell any recommendations sure so like so you continue a bit just just like how one would use ipython for day-to-day file operations and scripting i think i might know the answer yeah so like the the my avatar repo project has a shell shell module that let's use it as a system shell there you go yujin yeah so you can ls you can cd you can sub process you can you can start your python shell from an ammonite shell you can basically do anything you do in bash in ammonite and there are some tradeoffs um the good points are that for one using scala is a much nicer language than using a shell using bash for example bash is good for trivial things like ls but let's say i want to ls the files and find the top 10 files of extension dot class in terms of sorted by file size or i want to list the folders it lists the sub folders in my current folder and i want to find the top three sub folders who have the most number of files recursively within them so all of these things are kind of tricky for you to do with bash like there's probably a one line command that does it but you probably will not remember what that is whereas with the ammonite shell using using ammonite as a system shell you can probably figure out just with a few like for loops or with like a few backs and filters exactly what your what command you want to run to get these um get these results get these results um so the downsides of ammonite shell are things like um it's scala it takes half a second to start up start up the first time and the scala compiler is slow so it takes about two or three seconds for the first command you run and takes about a quarter of a second for every subsequent command okay so once the command it starts running it can run really quickly so if you want to run like a gradient descent algorithm in your shell it will run way faster in the ammonite shell than in the bash shell but on the other hand if you're writing if you're writing like lots of really small commands just like poke around that stuff runs slower in ammonite because of the startup overhead for every command all right um it uses a lot more memory than the bash shell so i think it by default they will use up to about 400 megabytes of memory per shell instance to run scala because i'm guessing that's because jvm right you need one one instance of jvm per shell uh it's not just because jvm so jvm would probably go down about 50 megabytes if you're just a jvm but it's because a scala compiler is a pig and uses like all your memory and all your cpu so like i think practically you can probably make the scala compiler use maybe 300 200 megabytes but it's not going to get much lower than that the scala compiler is just really big really heavy and really resource intensive and like this core scala team is trying to make that better but that's the state of the world right now okay so those are the reasons why you would not want to use the scala to use ammonite scala as a scala as a system shell and the reasons why you would may want to explore using it yeah cool so i guess what what you said earlier with like using that as a way to access spark and then poke around data might be actually a very good use case yeah so if you're using it for to poke around like data structures and not your file system for example um you have like this big like graph data structure that's in memory that's for example maybe your friend graph or you're interacting with a database and you already have scala code interact with the database from your production environment and you interact with the database from your shell then that's ideal situation for using ammonite perfect all right thank you for answering all our audience questions now let's move on to the next section which is called pics so the way we do pics is we go around the table so i'll start first and then let's say any do it and then we'll give you some time to think about it how we we pick one to two things that are interesting to you that you just you know just figured out just found out and you would like to recommend to our audience to try out it can be anything can be blogs books apps tech you know or non-tech even foods meetups whatever so i'll start with something that i've been playing with uh it's a small tabletop or benchtop oscilloscope you want to say it's like a small little board that i got recently from kickstarter yeah and it's super handy for doing simple debugging electronics kind of stuff so if you if you audience want to check out the open scope i will put the links this interface it runs on a browser right that's the coolest thing yeah that was the coolest thing about this was um you the whole ui for the scope is actually in the browser okay so you have the oscilloscope in as a small piece of hardware but it doesn't have any screens and all the ui happens in the browser i think this is a very interesting uh yeah like the hardware interface web ui i think this is a very good interesting direction and i'm super curious to see how well it works it works all right i think the web ui is very young so it'll take a bit of time to to move forward but i think at some point in time this will be a very cool sort of interaction mechanism so i'll put i'll put the links in the show notes if anybody wants to get it i think now it's out of kickstarter you can actually buy it already okay it's by digilent it's by digilent yeah all right so i have a couple of picks very quickly one is a breadboard power supply by yw reward so you know whenever we play with digital hardware we need either 5 volts or 3.3 volts and i found this breadboard little tiny breadboard power supply super useful for prototyping my hardware stuff and my second pick is a book it's called deep work by cal newport i recently read this book and i felt as a developer or even as any people knowing how to do deep work like really concentrated deep work for three to four hours is super important and this book kind of talks a lot about it so go and have try out chinme's open scope or the breadboard power supply or even the deep work book howie what about you sure so um i guess this isn't really related to tech but no you can't i i don't matter i recently found out that the new east coast park to changi by by cycling route has been reopened so they were doing a bunch of they're doing a bunch of renovations around changi airport because they are doing terminal terminal four terminal five yep but it's open again now so you can start from east coast and cycle one way to either the marina bay sands or you can cycle the other way and go all the way past the airport to changi changi village oh nice if you wish you can cycle all the way back through like budok and tampines and gailang and end up back at east coast park if you want to like return your bicycle there so that's actually quite fun if you're if interested in cycling because for one the route is really flat because it goes along the ocean so there aren't any like huge hills or anything secondly it's really scenic and really cool because you have the sea breeze and you're by the ocean and lastly there's a very pleasant straight most of the basically all of it you don't need to go along the road most of its park connector so you don't need to be fighting with cars and trucks trying to like survive on the main expressway oh yeah so if you're if you're free and have a day and you like cycling can you spend like eight hours i think last time i took like six hours did it make one big loop maybe 30 40 or up to 70 km around that area and it's just really nice and really relaxing yeah the cycling movement is really really going strong in Singapore and especially with the park connectors you can just cycle anywhere i cycle a lot along the punggol area as well and by the way i i learned cycling this january yeah well i i learned cycling when i was 20 years old so exactly so there is no better age to learn cycling than now and try it out if whether you're in Singapore or you're going abroad to explore the cities on a cycle that's a that's a great trip thank thanks howie yeah that's it for me yeah yeah um let's talk about event the event groups that are happening all right um we want to talk about slightly about the Singapore Scala programmers they actually have meetups in Singapore as well i have not attended it how we did you have a chance to attend it yeah i think going to it all cool yeah so uh they seem to be pretty regular they had like 40 over meetups and oh so what happens there like talks and the sharing yeah usually it's someone talking about their work and so most of them are let's see there's a bunch of small companies using Scala in Singapore okay whether like startups or banks using it for spark or someone trying to implement like a new clever algorithm in scala um and so people come and share about oh these are some techniques i've learned using scala or this is some approaches i've done or these are some tools i've recently gotten experience with and then people come and talk and they'll give a talk presenting what they've learned and people ask questions and talk about oh how does that gel with what i've learned how's that gel with what i want to learn like does it make sense for me to continue using the tool that you suggested right along with the url so for online links to scala go and attend the Singapore Scala program is meetup and lastly i also want to mention make a fair Singapore it's happening at the end of this month the 22nd and 23rd July so make a fair is all about software hardware art science biology cooking it's really a mish mash of ground up kind of an open source open maker culture meetup so if you want to check out about this community i highly recommend you to go to the sign center it's happening in sign center this time it's happening in sign center on the 20 it's on a weekend 20 and 21st of july yes that's right so check it out me and chin may had the chance to solder some stuff yeah we were helping out in one of the installations so we sold it a bunch of boards so yes you will you're guaranteed to find some inspiring projects that are going on there so go and head down to the Singapore make a fair at the end of this month all right and the very last segment we have is electric plug plug plug plug plug all right howie how can people reach out to you um so i guess it i have a github account with my email on it so if you search me howie github you'll find it and you'll find my email and you can contact me by email um if you're using one of the projects i've worked on for example eminite or some of my libraries like fast parasol scala tags um each of those projects in its own github channel so okay maybe not even me but there'll be tons of people there who use the project and if questions about those someone will answer you um and i guess lastly i've uh if this is this is a plug section i'll plug my blog um so it's www.lihaoii.com um so i write a bunch of things about scala but also about other topics so i wrote a blog post about like um about working with Singapore with Singapore's um government data atis or a blog post about um a blog post about diving into unfamiliar code bases so if you're interested in programming and or interest in or particularly interested in scala um there's definitely worth taking a look and having a read yeah cool yeah it was very interesting i i when i started uh researching for this episode i did read uh and it was a bunch of really cool articles so highly recommended yes very very technical very long ones but it's totally yes very long that's very true yeah a bit too long probably how he takes the time to write his blog posts yes yes definitely cool maybe i will also recommend engineers.sg slash presenters how we also gave a few talks especially the ones that we talk spoke about uh uh yeah he spoke about Singapore's open data he has a video on it there is also the one at the nus hackers the friday hacks so diving into other people's codes so if you want to check out uh how is videos of talks this is where you go to we'll put all the links in the show definitely yeah thank you so much how we for joining us on a saturday morning talking about scala and uh we hope the audience got some kick out of it like if you're a programmer and you want to just check out another new programming language scala is the one yeah definitely yeah absolutely all right thank you how are you so much thanks that's it for this episode 48 of we will live we will get together again online on another saturday morning with another cool guest until then return zero