Welcome to the fourth Func Prog Sweden MeetUp 2024 – Online

    This MeetUp will be streamed live online on the Func Prog Sweden YouTube channel: https://www.youtube.com/c/FuncProgSweden

    The program starts at 18.
    00:00 Stream start
    09:39 Introduction by Magnus Sedlacek
    13:32 Building a Vite plugin for F# by Florian Verdonck
    57:34 Introduction to Roc Progamming Language by Richard Feldman

    Building a Vite plugin for F#
    F# can be transpiled to JavaScript via the Fable project, offering a powerful alternative to vanilla JavaScript in the browser. Vite, having conquered the front-end world, is the preferred tool for many developers when starting a new front-end application.

    What sets Vite apart is its exceptional plugin system. The integration of Fable within this system presents a fascinating case study, marking a blend of JavaScript tooling (Node, Deno, Bun) with dotnet. In this talk, I’ll delve into the technical aspects of running transpiled F# code in the browser using the Vite development server, and also discuss the developer experience and design considerations relevant to this use case.

    Prepare to explore the synergies between F#, Fable, and Vite, and understand the craft of bridging diverse ecosystems to enhance the developer experience.

    Florian Verdonck
    I’m Florian, a freelance software craftsman.

    I do consultancy, training and open-source development.
    Currently, I’m active in the F# community, working on the compiler and tooling.
    https://github.com/nojaf/
    https://blog.nojaf.com/
    https://amplifyingfsharp.io/

    Introduction to Roc Progamming Language
    https://www.roc-lang.org/

    Richard Feldman
    Creator of the Roc programming language. Author of Elm in Action.

    https://github.com/rtfeldman
    https://www.linkedin.com/in/rtfeldman/

    Post-show chat
    Once the live stream is over we will do a post show chat on the FPS Discord Server, where you can join and ask questions and meet more community members (this will no be recorded).

    Invite for the FPS Discord Server: https://discord.gg/rMT6xRPwgZ

    Video sponsor – Ada Beat
    https://adabeat.com

    Merch
    If you want to spread functional programming and support the channel, buy something from the shop:
    https://funcprogsweden.myspreadshop.net/

    #funcprogsweden

    e e e e e e e e e e e e e e e e e e e hello and welcome to Funk PR Sweden my name is Magnus sasek and I’m the host and organizer of funr Sweden first I would like to welcome back all our recurring participants welcome back to funr Sweden and then welcome all new participants to funr Sweden funr Sweden is the Meetup where we explore functional programming languages like husk rust agda Scola earling and more we also explore functional programming Concepts and paradigms and finally we also explore functional aspects of imperative languages like yava C++ and python then let’s head over to today’s agenda first there will be a short introduction by me Magnus and then we’ll head over to the first presentation building a v plugin for fshp by floran Florian will explore the synergies between fshp Fable and white to understand the craft bridging diverse ecosystems the diverse ecosystem to enhance the devel V ER experience lorian is currently a freelance software Craftsman then the second presentation will be introduction to rock programming language by Richard Feldman rock is a functional programming language that has fast friendly and functional as its slogan um Richard has also promised some live coding uh during the presentation so we look forward to that then after the live stream we’ll head over to Discord and you can ask the presenters questions that are a little bit more elaborate than you can ask in the chat but first uh thank you very much a beat for uh sponsoring the live stream uh if you want to know more about a beat head over to their web page ae.com or check them out in social media then the coming schedule for the rest for the coming months uh 11th of June we’re back with another fun proog Sweden uh then we’ll set dates for August and September and come back with that and remember if you want to present or have someone you think you should present please just contact them contact me Magnus either on the Discord server or on meop or on social media if you’re interested and want have some material that you want to come and present at the fun prog Sweden Meetup then of course if you want to support the fun prog Sweden Community you head over to Meetup and join our meetup group and make sure to head over to YouTube where you’re looking right now and make sure to subscribe also to the channel and of course you can always join the Discord server fun prog Sweden Discord server you’ll find the invite on both the Meetup and on YouTube um where you can meet other people interested in functional program so if you have questions during the presentations please just write them in the chat and I will bring them up to the presenters uh also if you want to get a t-shirt like this head over to the shop and buy one uh we don’t make any money on the t-shirts these are just for fun and promotional of functional programming with that let’s get started first present C warm welcome Florian hey yeah good welcome to funr Sweden Florian thank you all right can I dive in we see your presentation wonderful thank you all right not going to lie little nervous but here goes welcome everyone my name is floran and today I want to talk about a v plugin for FP so this talk is going to be about FP JavaScript front end tooling um before we dive in just a little bit about me I am a Belgium freelancer I do a lot of my work in open source development these days I’m part of a organization called G research um their open source software team and because of that for the last two years I’ve been able to work on a lot of FP open source tooling going from the compiler uh to various other development toolings uh I think like jet bra Rider their F tooling is actually open source as well uh contributed a little bit to the ionite family of projects so I’m definitely um very interested and very uh inversed in the DF ecosystem and I’m also a little bit of fable Enthusiast which brings us to the the topic of today uh I’m going to cover a lot of things uh which are very Niche and going to be a bit of a deep dive into a lot of stuff so let’s go down the rabbit hole but start out easy with just a little bit of a glossery and sort of build our way up first off I mean I kind of assume we all know what f is but in case um somebody’s really outside of the net space FP is like the younger sibling of C it is functional programming for the net runtime think of it as the O camel or or has for.net um but yeah I mean F’s been around for a while so I don’t think there’s there’s much need for introduction uh I’ll be using F today during some demos but not really touching a lot on on sytax it it’s definitely just a an ml language in that regard then next we have fable fable is a compiler or transpiler that can transform F Source codes to other languages um the most popular and starting point was F to JavaScript but these days you can also transpile to uh python to PHP to rust and and some other languages but when I talk about Fable today I really mean like FP to uh JavaScript because that sort of ties into the uh the whole V story then we’re going to talk about vits vits is um of V so that’s like the the name of the development server V is has a similar sphere to what you uh what you may have known from from weback they are fundamentally different when it comes to their implementation but they can both launch like a def server where you can edit front-end assets like javascripts HTML CSS do little changes and then have like an instant browser refresh um to reflect what you currently are are doing vit has a lot of good um outof the Box standards so it ships with a bunch of default plugins and you initial feed experience is actually quite um quite good in terms of what you’re after the critique of like something like webpack was that there’s a lot of configuration and you really need to understand the internals about how bundling Works v um is like a very much nicer way of of getting going and the moment V can’t you know help you out of the with the out of the box experience you can use plugins um to to cover all your needs Okay so now that I’ve explained a couple of words I want to tell you well why did I create a plugin in the first place as I mentioned Fable transforms F to JavaScript so at a certain point an f file on disk is a became a Javascript file on disk and then vit can just pick that up and then kind of rolls with it um so in a certain sense vit doesn’t really need to know that your um f was sorry your JavaScript was once an F 5 file so the the thing is that connect as a sort of a pipeline and that’s really nice but at the same time it’s a little clunky and I kind of want to demonstrate how you would do it today how you would create a a fable application and then hook it into feet and talk a little bit about how that experience looks like you will need a javascrip runtime because that’s simply what uh what we’ll need for Feats I’m going to use bun because I’m a bun guy but you totally do not need to use bun uh most people still use note or or Dino uh but you know just fair warning I’m going to use bun today and I like saying the word bun first up we’re going to do bun create feed to scaffold our Feed application I’m going to call it my feed project there we go and I’m going to do a little demonstration with react to uh highlight one of the nicer features I’m just going to choose JavaScript and eventually we’ll go and then use Fable for that so first up let’s go my V project open this in vs code I need to install my dependencies this is this is all very typical front end stuff and once I did that I can do Bun Run def which starts the V def server if I open that the browser opens and this is really a very nice introduction if you’ve never ever seen this but this is a react application so it didn’t really cover react but it’s not super important to understand much of react but in any case I have a little application it uh has a counter I have a component that’s linked to that and what I can do now is I can edit the the layout of this components save the file and then it instantly refreshes the browser without doing a full page reload and you can see that my counter is still intact so that is really the the power and the magic of something called feat uh which is this St tool tooling now it’s not the first of its kind but Vally pushed for this entire experience this hot module reload as we see it here uh to be part of like an um an an official browser standard so that’s that’s sort of the one of the key differences that breed far far to the table if I now want to do basically the same thing but instead of going with a jsx or JavaScript file and use a fable file I can um start with creating a new net application and I’m not going to lie I actually need to do a couple of CLI commands to really get going so I kind of prepared a little script but I’ll go over what what I’m actually doing um in a bit so Powers cell new Fable it really is just a succession of net CLI commands but we need an F Shar project we need uh the Fable CLI tool we um needed a package for the react binding so we just needed a couple of things and when I do a net tool list it shows all the net tools I’ve installed and one of them is Fable which we can use to um compile the JavaScript I’m going to use the word compile where I sometimes actually mean transpile so depending on how nitpicky you are I mean it’s it’s the process of putting the F to Fable so that’s those those can be uh used interchangeably um cool so quickly I scaffold it an FS project because in FP the file order matters if I have like a bunch of files in this so imagine I I I I don’t have like an extra file but imagine a hat if I have something in a FS then a cannot use uh any functions that are defined in library because the order and F matters you can only use uh certain functions and then records after they have been defined and that’s why you for one reason needs to this FS BR file uh instead of just you know um going with like something file based and importing from a certain file now we can use Fable the net tool I just installed pass it this app FS Pro it will look into that and Target all the files over here this Library file is empty I’m just going to scaffold the the same code as you would have for the react components so over here we have like a fragment it has a diff and anchor tag I just tried and mimic the same thing there’s a fragment there’s diff there’s an anchor Tack and this this FP DSL just takes in uh two lists so each of these things which has like an HTML element kind of name just looks at uh takes two list the first one for the properties and then the children so this is you know very hits very close to to what react is doing and I am going to say that I want the extension of the compiled file to be. jsx and that’s because V is um you know is has a way of dealing with jsx files that’s how it really wants the react thing to to play out now I created uh I ran Fable I have now Library jsx which has a fragment and also jsx syntax so these things look very similar when I do uh Bun Run death I’m starting the web server again I am now in instead of going to import app from the app jsx file let’s go one level up and then use the library jsx over here and then you have this hey from Fable and if I click on this and update this a little bit well it doesn’t work because the Fable command was like a onetime thing so I um I’ll need to split and go to like another terminal do the net uh fa app jsx thing again and pass in a watch flag so it keeps watching my files and once it’s done that we’ll have more or less the same experience that I had in my jsx components so it’s starting it says Hey from Fable I changed the file and it updates automatically so that’s good uh but I’m a little bit annoyed by the two terminals there’s actually something we can do about that if I were to start my stop de Dev server sorry over here close that I can actually run the Fable command again and then pass in a run uh argument and then go with bun run def so for those who have absolutely no idea what the Bun Run def does it just runs the scripts uh defined in the package Json which then again runs beat over here and um and if I do that then both are sort of going to work together in the same um in the same terminal so Fable first and after compilation it started whatever I passed it over here and now we have the same effect in uh in one terminal so to speak all right so that is how they would recommend you to do it today and going back to the slides I’ll um I’ll have some some some reservations on it and I’m going to do a little bit of nitpicking first one is that I think Fable is kind of weird uh I don’t really know any other tools in this whole V ecosystem where I need to start the other tool first and then start V so that just doesn’t feel really good to me um when you look at something like Elm you wouldn’t um you wouldn’t do it that way there would be an El plugin which which sort of foreshadows what I was after and the you know the other thing is that if you’re I’m a consultant and if I go into a company and they already are using V and typescripts and I need to explain this whole thing yeah yeah but we should use Fable because it’s FP and functional and way more cooler then having to explain this way of doing it will just feel like a step back so I don’t quite you know it doesn’t quite feel well in in terms of what is the rest of the ecosystem doing and V is a lot bigger than than our little Fable universe so it it should of should be the leading case in this another thing that really bothers me is that I first need to write the um the Java script to the disk and then V reads it again from the disk so it that feels a little bit unnecessary if that could be done in memory feel that would be more efficient it’s not the like not the memory or the performance thing that really bothers me but it’s just that it could go wrong like what if Fable is still writing to a file V already reading it stuff like that so that that’s just something I kind of want to avoid and then lastly um actually forgot to mention this but if V is configured I I want it not to watch my f file so there’s a little bit of a configuration that you typically need to do the docs recommend that V does not watch your FP files because Fable will watch them itself and then you end up with like two Watchers which I you know I just don’t really like that um separation of serm kind of thing so clearly these are all definitely nitpicks doing this experiences I just showed you is still very much uh enjoyable and using Fable really is a bliss so if you’ve never ever played with it I definitely recommend it however I feel like it could be slightly better which brings us to the topic of the day the the feed plugin and without further Ado I’m just going to demonstrate the damn plugin so going back to vs code I can first remove this little bit because now I do want V to watch my files I’ll need to install a couple of dependencies the plugin and also be installed uh from mpm and I I’m also going to install V plugin inspect I’ll show that in a little bit later in a demo why that’s interesting and for the vug in Fable I also add the dash dash trust uh parameter when installing what that actually will do is run the post install script of the feed plug-in Fable and that’s actually very important because this will compile a net binary which the plugin will later use in this run um the dash dash trust f is is a bun thing and what it ends up doing is that it puts your uh your installed dependency into your trusted dependencies which again runs the posts install of the of the installed package and us um gives us the binary I am going to configure these things so I can import inspect from feed plugin inspect I can import bable from the plugin Fable and I’m going to hook these in so I want Fable first then let’s do react and then do the inspect thing uh for the Fable for today we are using in jsx so my JavaScript code still contains jsx and Fable needs to the plugin needs to know about that to to further transpile that anyway um if I now remove the library jsx do a bu run def you can see that we have a a lot more logging going on uh the Fable plugin it currently makes a lot of noise and right now we get an error because I just removed that file so if we change that what we can now do is instead of importing the compiled file on disk we can just point it to the f file and then V picks that up transforms that fire Fable uh because of the plugin and we actually have the same result so when I do the counter I go over here I were to update or add like some some new content I say hey and then oh nice it refreshed but my counter is on so kind of almost makes me look bad but almost before diving in let’s take a look at the inspect uh endpoint so because I added the other plugin I can go to like the inspect over here and that shows you what happens in every file that was served to the browser so in this case all these files went through the V pipeline I go and see for Library FS the first thing that happened here was it was loaded from disk that’s just by the core plugin of V then my fable V plugin V thing kicked in took all this uh source code in F and transformed it via Fable to JavaScript you can also see that the jsx is already compiled that was a little extra flag I needed to set in my uh configuration not the plugin and then this import analysis just well allows us to to see what we’re seeing right now uh however the there’s one thing missing and this is just your react component and to have the wonderful fast refresh magic going it needs to be wrapped again and luckily that’s just a bit of a configuration so in that react plug-in I can say uh includes and pass in a regular expression so I want to say everything that ends on jsx or FS over here uh there we go so counter hey and delete it see C still four so yes that worked and then the inspect will add one other uh transformation and that’s because of that react plugin it will actually take all of this and wrap it in what we call the fast refresh hot module so this import meta hot that’s the um well the web standard I talked about that Fe trying to embrace to make this this whole experience work and fast refresh run time that’s really like the the react implementation detail to get all this magic up and running H so that was definitely um let’s try go back to the slides uh that was my demo and I feel like this is a slightly nicer experience but the next thing would be how does this even work because you know as I mentioned net uh Fable uses net so it uses like the F compiler and all that and V plugins are just javascripts so there must be some dark arts involved in in get this up and running and that is totally the case the the way it works is that during that post install event of our package AET binary was compiled um I I could have just shipped the binaries but I’m I’m actually shipping the source code and it compiles a little F project which is what I call the demon or the the sort of language well it’s not language server but sort of server. net endpoint and then the plugin from JavaScript communicates to that via Json RPC it spins up the process and that process will have receiving messages via the standard input and then giving responses VI the standard output and that’s how I sort of bridge the JavaScript runtime and the net runtime when a v plugin is actually a set of call back so when it starts um you can sort of choose in which uh life cycle hooks as it as it were are you are you interested and that uh is basically when a certain call back hits and we need to talk to the server we send our Json payloads and the server responds and then we sort of return um return to resolve a promise which then leads us to continuing the defeat pipeline the plugin system itself is based on a set of callbacks from uh rollup so a v plugin is in 90% of the cases also a compatible roller plugin depending on if you you know have the the common set of hooks implemented in our case the story starts with Bill start that’s really like something that runs once at uh the start each plugin gets a chance to hook into what the the build start is that happens after the Fe configuration was sort of resolved and in our case we need to detect okay where’s the F project because that’s very important that contains all the files in the project and it also has um a set of references and um we we need like a lot of doet information to eventually get the compiler arguments once we have the F compiler arguments we can um type check the entire project give that to Fable and then Fable will have that typed tree of F and transform that to Java script we prematurely um we prematurely transpile everything up front and I just send like a dictionary or a map back um from the net process to the plug-in and like hey this is like every f file path is then translated to its corresponding JavaScript when the browser is uh requesting a file from the V def server it will hit the transform hook in that transform hook uh we did import app from library it will then detect that Library UHA FS URL we do a Dictionary lookup return to JavaScript and that’s how it gets to the browser when we update our f file because we we are uh V is going to know that this was now part of our um loaded assets the inspect plugins for the list sits and when you change one of these files the handle hot update hook kicks in and then we have a chance to talk again to the server let it know that hey this file changed and and maybe one or more files are going to change um because of that it it kind of has a bit of a ripple effect at times and then eventually the server replies we update the dictionary and then the transform hook will be called again and uh everything uh updates one last Hook is then the watch change because there are also certain files you want to know if they changed then we need to invalidate the project because when um for example the uh the F project file changes it’s pretty much a guarantee that all the files we we no longer can rely on the cach and we need to just reload everything but that happens more often than you think when you add a new get package which is like the net dependency when you add a new file you really need to be sure and um that’s why we’re we’re watching a couple of files so that um we constantly you know keep the the browser up to date this um this actually came with a fair set of challenges and I definitely want to want to highlight a couple of things because they’re a little less known and it’s kind of interesting to to break them down the first one was that we saw Fable is a CLI tool and I yeah I wanted to do things a little bit different uh with the CLI tool and I just had to uh carve out a little bit of the the bits and pieces that I’m actually after what I want from Fable is more or less just an API function that says hey for this javascripts sorry for this F and its project and all its settings I actually want you to return the JavaScript as a as a string or like a buffer but there was nothing really out there that that does that it happens inside of the command line tool but if you you can’t just pass it and give it the the the input arguments that I already had you you can start it and then it will figure out everything on itself but then yeah it’s um it always writes to dis so there’s just a lot of things happening inside a CLI tool which I don’t really want and I can’t really just run at one time and get the the result so tldr is that I just had to go into the code base and try and extract the things that are useful into a separate project uh so we could have another library on on nit and what are the more challenging things is it wasn’t just moving some files and codes it was um yeah it was quite a refactor and it’s one of those things where I am not a fable maintainer I happen to know the Fable maintainers so we we talked about it uh but it was definitely a big ask and what I kind of want to highlight is that I feel the only way I got away with this was just by explaining my ideas carefully through some online calls uh with the maintainers really you know have them believe in the story and you know get their blessing to to really do this so I definitely want to thank Maxim in particular but when you want to do these kind of undertakings in open source it really helps to to sort of call um face to face or well remotely the the next challenging thing was the Json RPC it’s sounded like a good idea and it it’s wonderful when it works but when it doesn’t it it really sucks so one of the things that you really need to respect is that you just cannot lock to the standard output Fable was constantly logging to the standard output and I believe that in the part I carved out it wasn’t there yet until it eventually appeared that it was and that was quite the needle in the hay because all you get is like hey the the Ser the plug-in cannot deserialize the response from the Json RPC uh endpoint that that’s talking to and that that’s all you get so it it took me a while until the penny dropped that oh I’m probably messing up my own Json payload by something that’s right for the standard output and then I proposed to have hey can we not have a logger interface to to deal with this so I had to go into the Fable code base again extract everything after an an ey logger which again the maintainers were you know were okay with um the CLI tool which you saw earlier in the demo still just uses a implementation that logs to the console but then inside of my plugin I write everything I keep it all in memory because I just absolutely cannot write the standard output and lastly I want this you know never to happen again like it’s very easy to um for somebody new contributing something to Fable very unrelated but doing one simple test loog and then eventually that gets shipped and can just ruin the communication uh between the net process and the the plugin so I wrote something we call an F analyzer which does code analysis of the f file and it’s going to fail the pr to the Fable build when somebody is trying to lock to the standard output and not use the loger interface so that’s something I I enter to preserve that it still keeps working another fun thing was what happens when multiple files changes I gave you a very you know um easy demo so speak I change one file and then that reloads the browser but what if you rename a function and on the definition side it changes and it’s also used in a couple of other files so all of a sudden you basically get multiple handle hot update call backs and they all need to resolve a promise and if you they all need to contact to the server and if one of those endpoints trigger you kind of already know that at most one file changes but in practice depending on the your side of the F project graph multiple things could change so you either you know you also don’t want to do the same work multiple times and that’s why I try to batch these things via reactive extensions to have a little bit of a a buffer window capture all the calls and then eventually if um you know depending on what changed send a different message to the net process because maybe two files just changed or another good scenario was when you format all the files then it also went kind of crazy so it’s good to batch these things and potentially you’re also like adding a file which will definitely trigger a um a handle hot update hook for the new file you added but also for the project file so the project file eventually wins and then you know that oh I need to invalidate everything so that’s where where batching was um was a good strategy um and next thing is that V is very popular we all love it it works wonderful and I you know would definitely recommend people doing something front and use a tool like feet uh but when it comes to the plugins it turns out that really not that many people are um writing Ved plugins and it is just difficult to to wrap your head around there is documentation but you either have to look into the rollup documentation or you don’t get like the satisfying answer because a lot of the documentation explains to what they expect in a happy path but doesn’t really touch upon what if I I know I cannot process the request but it definitely is my request to process how do you properly communicate that is it okay to trow is there a better way of doing it so those kind of things are are definitely tricky and there are not really that many people uh in the feed community that write plugins and I just don’t really have any friends there so the hard thing about the V plugin is that I felt that I had to you know develop this on my own because I’m bridging two foreign worlds that usually don’t really interact so the the sad part is that I never really had a sparring partner on a call to talk about the specific things lastly I want to talk about what happens inside the net process um it’s kind of tricky to because I I told you I cannot log to the standard outputs and it’s kind of tricky to see what really happens inside I try to do things as straightforward as possible but it was often um misleading when I developed something on my uh on obuntu like the WSL site and then tried it on Native windows and then I had subtle bugs that appeared where I was like but this was working on on Linux so what’s what’s up with that um and they add a little bit of functionality to debug what’s happening inside the net process uh call it your uh home brew uh grpc sorry not trpc um Telemetry kind of solution so if I go back to the demo here and I stop it uh let me add one environment variable if I do a bun run def now you’ll see that it locks I’m starting on um 94 and that actually gives a log of everything that’s happening inside of the def tool which is also very important so I I get this project change that’s the first Endo that the build start hook uh calls then it has this response of all the uh do net things it needs to know because unfortunately that’s a bit of the reality net needs a lot of information for the F compiler to kick in um and then eventually I have these logs like hey it’s type checking it succeeded it’s going to send this back to the client uh when I were to update a file over here I can see that more uh locks are being added so that’s kind of nice and one interesting thing you can’t really see it but this is a lock that’s actually coming from Fable itself so I can reuse the entire ey logger thing um and if I ever need more information about what’s happening on the Fable site I can just opt into that um when I contribute some some more locks so that’s definitely uh has been very helpful in terms of figuring out what’s what’s really happening um and now I do want to answer a little bit of a question should you use this I feel like it’s nice feel like it’s nice Tech but I definitely value honesty and I want to be upfront about a couple of things um is this whole thing sustainable well it’s something you can’t really you know ask funding for and yeah I mean everything that it touches is free to use fabl 3.net that’s free VV so it it feels weird that this becomes like a product and I also am not using this really in an Enterprise context so I did a lot of FP work but my recent clients are not using any Fable so this was really just a pet project and I can’t say like hey I use this every day I know it works that’s not kind of it I use it for my project which I temper with in the weekend and that’s sort of the little bit of a reality there I also went to fdam this year uh fom is a one of the largest open source um conferences in in Brussels and I I went to see a talk take your open source project from surviving to driving where the speakers kind of mentioned that you need to have a plan when you’re making something from for open source when you’re putting it out there and you’re sort of like inspiring people like hey this is cool Tech maybe use it there needs to be a little bit more to it because we see all all of the time you typically create these things out of passion you definitely find the energy to to prototype that you’re happy you’re I’m kind of proud of what I did here so I published this on mpm like hey people can use this but when I came out of that talk and they they were like yeah but is this sustainable is this really a good idea for businesses to start use I was like yeah I I have no plan whatsoever with this um so I have a couple of options of course I could maybe hope that this gets adopted by the Fable maintainers and then we move it there but at the same time I don’t feel good about you know putting additional burden on them um they’re already you know there’s not enough manpower to maintain Fable today so just adding another project of the week doesn’t feel right and purely on a logistic level if I move it from my local so from my own user get up repository to the Fable one in in practice I just see it dying under a different name so that that doesn’t solve anything if if there’s nobody else ever going to touch it I could try and build community I could try and convince existing Fable users to start using this then try and trick them into maintaining this and um truth be told that’s very difficult uh this whole project touches a lot of Niche things which most developers don’t really come across quite often I’m talking about the the net compiler site the sorry the FP compiler the Fable compiler um the each plugins it’s less done and it’s very hard to find people to to Really you know have have meaningful PRS for for these kind of projects uh it also just sits into moving a lot of moving dependencies there will be a new version of feat there will be a new version of fable there will be a new version of do net and FP will this all keep on working um maybe but also so definitely maybe not so yeah who knows that’s just a little bit of a a reality check there that it just sits in between all these other pieces so it’s hard to say what what’s going to be the outcome of the code I have right now in say half your time and frankly I have to admit I’m a little bit out of juice uh in terms of supporting these kind of things so yeah um if anybody’s interested this project is really open for adoption I’m Happ happy to transfer it to anybody that you know wants to uh use this wants to get the most out of it and then T you know the Project’s best interest at heart so please reach out if if there’s any interest uh to answer that question should you use this today absolutely um it it worked fine for me if your project is not doing uh is a little bit along the lines of what I had and what I tested then it will probably work fine for you if you want to use this uh for a project that has a long longer run um you might not be afraid to need to be afraid to actually Fork it and potentially fix something on your own if I don’t have the bandwidth to review any PRS or or anything um that’s that sounds a little Bleak but it’s just a little bit reality so I definitely want to I don’t want to exclude that part and make this sound as a very oh definitely use hot new thing kind of kind of story but that being said I did write some documentation so if we quickly glance over this there’s U this little documentation how does this work uh technical implications so it it touches a lot of things how do you configure everything based on what you might have how does the debugging thing work so I I do very much you know I’m uh I was passionate to really see this through and I also because I’m giving this talk that that kind of helps to to see it through and I also gave a amplifying f session where we went through the code base I explained the rationale about um certain technical things and yeah I feel like it definitely isn’t a good place to be adopted there’s there’s not you know you can’t really have the argument like I don’t know the code base I did some Fair attempts to explain how how the code works if you never heard about amplifying F I definitely want to wrap up with this it’s um it’s a new initiative that tries to improve the F ecosystem f is owned by Microsoft and the f team does a fantastic job however they are very focused to the compiler and to its tooling and visual studio anything else you use in F is typically you know from the community and the community needs a little bit more love that’s why we organized um online sessions we have a lot of recordings where we try and explain people how do you contribute to all these complicated projects going from the compiler to uh parsers Lexus LSP um some more other open source projects that are that are interesting and we really just want more people to um to contribute because we can definitely use the hands we also gave an F Essentials course this was a partnership with Ian Russell where we tried to explain FP to newcomers and during a 12-week course which was free we had a weekly stream again with Ian where we just teach people how how F works so we definitely just want to want to keep that energy in in the F Community we recently also have an open Collective uh the tldr there is that if we get some money we can do more and good in DF sh um Community we can think about sustaining um some of the maintainers of these projects the the faal uh maintainers are definitely on that short list so yeah definitely check that out we we have a website you’ll you’ll find all the good content there and without further ado that was my talk I was Florian thank you so much for listening if there are any questions I’ll be happy to answer those thank you very much Florian thank you very nice presentation thanks I wanted to start with like before you presented all like the initiatives with FP amplify Etc like is this the call for more devs and funding for white then you kind of went through it but if there people want to reach you where should they go is it like visit your web page I think we put the link out on the Meetup page if people is that the place to contact you yeah and uh for the V plugin specifically I would suggest the discussions tab on on GitHub um to sort of poke me there yeah cool uh people are sharing in the chat saying very nice presentation uh we have one question it’s like will there ever be a way you can do get get out of um like is there a way that FP can do without react like Elm with without white or without Fable just pure coding um definitely but uh so the the short answer is yes you could possibly do everything in net and um try and have that same experience MH but on a practical level the the JavaScript Community is just so much larger and they they buil these Fantastic Tools like feeds so I don’t know on a practical level it it feels a little bit um you’ll you need a lot of hands and a lot of you know investment to get on the same level as existing things which are out there and which are hyper the day maybe but they they definitely kind of work well so um yeah it’s a trade-off it it’s I see in theory no reason why you couldn’t have a nice experience with only the net um but yeah it’s you know could take years of a full-time work to get that place while yes while V is just out there so I don’t know yes yeah there was a question I kind of agree with you uh a lot of people are in in thanking thanking you for your presentation in the chat like awesome talk and like I have very positive experience with fa which people can recommend So yeah thank you again for your presentation and um if people want to ask you more questions you will uh join the Discord server later if they want to elaborate more have more questions maybe talk to you around joining beat project Etc or other initiatives you had we’ll also post all the links you have to all the places uh Florian so people can find them afterwards also of course if they’re interested and want to join again thank you very much for your present ation thanks and now we will do our second presentation welcome to Funk Brook Sweden Richard hello hello and welcome yes all right uh let me uh share my screen real quick thanks everybody for coming all right uh let’s rock away or all right sounds good do we do we want to do anything before I kind of get started or we just uh ready to go ready to go hit it away we see your screen okay great so thanks everybody uh I’m Richard Feldman and we’re gonna talk about an introduction to the Rock programming language so I’m kind of G to assume that everybody here doesn’t have any familiarity with rock so I’m going to kind of explain some basic high level stuff and we’re going to do a whole bunch of live coding um I did want to start by noting though that uh for those who are like completely unfamiliar with rock um this is not going to be one of these introductions to the language where I expect that by the end of it you’re like okay cool I’m ready to go and like write Rock programs it’s more going to be like I’m want to give you an introduction to what the language feels like what it feels like to build stuff in the language and I’m definitely going to explain some Concepts along the way but don’t feel like you’re getting lost if I’m not explaining every single detail so we will have some time for questions at the end um but my intention here is explicitly not to try to give you a really deep understanding of the language we got a whole tutorial for that if you’re interested um but rather to uh to to give you sort of a feel for like this is what it’s like to build Rock programs here’s kind of like the way the language uh sort of feels um so briefly uh it is a fast friendly functional language it’s under active development I would say that it’s sort of mature enough that if you want to use it for real things you absolutely can however it’s also pretty bleeding edge like you can expect some sort of alpha level quality of things um there’s definitely some compiler bugs we may or may not run into one of them today um the ecosystem is quite small at this point uh it’s not battle tested at all nobody as far as I know is like using it in production for you know serious stuff like there’s there’s kind of little projects here and there um but at the end of the day if you’re interested in sort of uh you know being on the bleeding edge and getting like the early experience of using a language that has a lot of nice characteristics I absolutely recommend trying it out and and trying to build something with it okay so this is a little bit of snippet of rocks in taxs obviously we’re going to see plenty more rocks in taxs but very briefly this is an assignment so rock is a language where uh you don’t have a concept of mutation so once you assign this it cannot be reassigned later um this is list.map this is a function call so function calls and rock are done with whites space there and then finally this is what a Lambda looks like in rock like an anonymous function you have a little backslash which is you know kind of looks like a Lambda if you squint a little bit um and then an arrow after the arguments and then this right here is a string with a little bit of string interpolation and so we’re going to use all that stuff uh over the course of this live coding so fast friendly and functional uh generally speaking what we mean by that in terms of fast it’s like we want to have a f fast compiler and fast runtime that like both of those are are Valu so we’re going to see a fast feedback loop as we’re doing this live coding um not going to get into any benchmarks and stuff but we’ve got some benchmarks around of uh you know being quite a fast language uh we try to generally be faster than go but not as fast as really systems level languages that do their own memory management so we’re not trying to compete with like rust C Zig C++ languages like that but rather among languages with automatic memory management we really kind of want to be the fastest game in town friendly uh so you know user friendly uh sort friendly syntax friendly error messages friendly Community all these things are important to us and finally functional we are at Funk prog seden and this is a purely functional programming language as in functions don’t have side effects um all effects are managed explicitly which early on might not feel like that when you look at the syntax of a lot of the io we’re doing but I’ll explain a little bit later on um how actually under the hood these really are genuinely All Pure functions okay so with that very brief introduction to the language let’s dive in and start looking at some code I’m going to be using the Zed editor this is my has been for quite a while my favorite code editor um actually I like it so much that I’m joining the company in about a month uh to work on Zed because I just man I’m just like this is the way that editors ought to be it’s really fast it’s really lovely and we’re GNA see a bunch of it today so this is sort of hello world this is a really really basic just like main equals standard out. line hello world I’m going to talk about this other stuff up here a little bit later you can probably kind of guess what the Imports do they import modules um this this part is what we’re going to talk about a little bit later this is sort of how you bring in packages um and we’re just doing hello world here so let’s just run this at the command line I’m going to say rockd demo. Ro and there we go hello World um and uh let’s you know we can modify a little bit add some exclamation points rerun it again hello world very cool let’s make it a little bit more complicated um so I’m going to change it from just printing out hello world to uh to first printing out uh enter your first name oops first name and then we’re going to do uh first name equals uh St in doline and you’re seeing we’re getting an error right there real quick and I’m going to explain that in a sec and then uh enter your last name and this is going to be last name and then finally your full name is first name and hey thanks co-pilot cool so already we can see that we’re getting a couple of errors here and this is because rock is a fully type checked and fully type inferenced language um so it’s giving me an error here because I have not imported the s in module here module not imported so as you’ll notice like early on I’m actually going to write no type annotations for quite a while and then later on I’m going to go through and add type annotations because they’re totally optional in rock and I want to show you sort of the trade-offs of if you want you can start off writing without type annotations um or you can write them from the GetGo and then you can optionally add them later so let me go ahead and oops import uh standard in okay and there’s that and now let’s run this enter your first name Richard enter your last name Feldman and there we go your full name is cool okay so this is a little bit of IO here um I’m going to talk about this exclamation point operator a little bit later but basically you can kind of get the idea of like the things that are doing effects like printing out to standard out reading from standard in they have the exclamation point after them um whereas other functions like that list.map that we saw earlier on the web page uh those those don’t have the exclamation point because they’re not doing any effects cool all right so that’s a basic command line uh but as a lot of people have told me that one of the things that they’re most interested in using Rock for is for web service and this is another one of the use cases that rock is targeting so let’s take a look at that real quick so I’ve got one of these open in another tag tab rather so this is a really really basic uh web server so written in rock and all it does is whenever we get a request in we actually ignore it so if you have a any kind of variable name or argument name that starts with an underscore that means it’s going to be ignored if I take off the underscore it’s going to be like hey this is unused um which you know fair enough so underscore is just there to silence that error um and then essentially all we’re doing here is every time we get a request in we’re saying task. okay meaning like I’m just sort of responding with this value and we’re saying status 200 no headers and the body is just s.2 utf8 hello from the server so I’m going to open up a different terminal Tab and do one once again Rock Dev but this I’m going to do server. rock okay so now we’re listening on this port and open this up in the browser hey hello from the server fantastic all right so uh and of course we can change this you know we can throw some more exclamation points in there and then I have to restart the server in the future we like to do um hot code loading and we sort of have a design for that but right now it’s just uh you do actually have to restart the server every time but as you can see it loads up pretty quickly um all right cool so let’s let’s make this server a little bit more interesting because right now it just sort of hardcoded always returns that thing um and let’s do this by actually looking at the requests so we’re going to do a little bit of pattern matching here um so this is actually an example of like co-pilot obviously isn’t like language aware this right here kind of might look like it’s valid Rock syntax but it’s actually not like this is a little bit of like hallucination kind of so I’m just going to ignore that um that is something you have to watch out for I mean with co-pilot in general but also you know especially with like a new language um so we actually want to do is request. URL and we’re going to just match on uh Slash and have slash continue to do this um and then I’m going to add another Branch we’ll refactor out this code duplication in a sec uh let’s see let’s do um slash Fu and then Foo is going to say FU and this one’s going to continue saying hello from the server now you might notice that we’re getting an error for all this so what is the exact error here well the problem is essentially that well first of all that I deleted a close quote there um oh yeah by the way we have a rock format running on so this is the uh The Zed extension incorporates both Rock format which is a formatter that’s actually built into the language it is zero configuration much like go and rust formatter so you cannot configure absolutely anything about it which is a feature because that means that there’s absolutely no settings to argue about on your team um and then also uh it it comes with like the the language server has like an LSP and stuff like that so uh it’s got you know basic autocomplete and stuff like that it doesn’t have as many um things as other uh like LSP implementations do but uh it does a pretty nice job at any rate the reason that this is uh um giving us an error is unsafe pattern this when does not cover all the possibilities okay so what are the possibilities that’s missing well we’re only currently matching on two different strings but of course there can be infinitely many strings in theory so let’s just have a little default here that that gives us back like a 404 error um and this will just say uh not found okay like I said we’re GNA make this a little bit nicer later on but for now this is a very very basic web server that will uh do a little bit more so now we’ve got the uh the root which still says hello from the server with one exclamation point we’ve got our slfu route and uh sorry uh that that says Fu and then if I do anything else like some gibberish in here it just says not found all right very nice so very very basic web server um we can refactor this out a little bit uh so let’s see I’m going to make a little function here called um respond and it’s going to take uh status and it’s going to take actually I’m just going to always hard code the headers to be nothing and then I’m going to take uh body which is going to be a string um uh so let’s just refactor this out and I’m going to do a little bit of multic cursor stuff here and this is going to be respond with uh status and headers uh we’re going to delete the headers right and then the body and we don’t need the S out utf8 because we’re gonna actually do that inside the uh thing and there we go uh okay so now I’m going to recreate that so task. okay uh this is a little thing called record punning so it’s basically like instead of writing status colon status I can just write status comma um and then headers we just said we’re going to hard code to nothing and then body is going to be uh s.2 utf8 which is basically uh because it’s sending back raw bytes um we are doing that uh oh yeah and I don’t want these anymore okay great one of the things I love about code form matters is you know when you’ve like fixed all your syntax errors because you hit save and everything just sort of snaps into place very nice all right cool so uh let’s rerun this and confirm that uh you know I didn’t I didn’t break anything uh oh two errors what did I do wrong let me uh sort of full screen this this is not planned I I don’t actually know what I messed up here um we’re going to find out okay so looks like we’ve got a body which is a list of btes header which is a list status that looks okay uh maybe header should be oh oh yeah yes okay there there’s the clue right there maybe the word header should be headers oops that was a typo on my my bad okay so it shouldn’t be header colon it should be headers plural there we go okay now let’s run it okay nice all right and now if I go back here we should see the same behavior as before SL food and root great okay so we got like a nice little server here that’s working um but of course this is not uh this is not like commonly what we’re doing when we’re doing a web server usually what we’re doing is we’re sending back some HTML or some Json I’m not going to show HTML here because I don’t have anything like really fancy to demo Rock does have some dsls for generating HTML um but uh but the way that rock handles Json I think actually is pretty cool here so I want to make A New Path here actually just going to repurpose Fu and say this is gonna be SL Json and here I’m gonna actually make I’m gonna make another helper function um respond Json and so this is going to be uh give me the status then give me some Json here as a second argument and what I’m going to do here is instead of the body being I’m going to uh call s.2 utf8 on that body stir what I’m going to do is I’m going to do uh encode dot2 bytes and encode do2 bytes takes two arguments so one is the thing that we want to encode which is Json and the other is uh the actual format that we want to encode it in so in this case Json now it’s yelling at me about Json because I don’t have a Json module imported fair enough I already did add the Json package here um so I can just import that oops okay so in code. two bytes takes the thing that you want to encode and then it takes the format so json. utf8 is basically saying I want to encode it as utf8 encoded Json um I could give it something else I could give it like CSV I’d have to import a CSV actually I don’t know if ‘s done CSV kind of think of I think someone’s done oh maybe they’ve done CSV I don’t know XML whatever um the point is that what I’m about to show you is not specific to Json I just we happen to have the most R Us Json implementation plus that’s the one that everybody always asks about um okay so I’m going to change this one to be respond Json and that will still be status 200 and again co-pilot this is totally wrong that’s not rock code at all um but I am going to put something in here so uh sure we can put a message like that and then um let’s do a Boolean like um is 1 + one 2 and that’s going to be 1+ one yeah okay that was correct good job um let’s put this on multiple lines all right nice so basically this is gonna encode this record right here as Json and then it’s going to return that back uh from the server so let’s rerun that server and now when I open up slash Json cool we see some Json here so this is is you know you’ve seen this in plenty of languages you have something like you know json. stringify and you just give it an object literal in like JavaScript for example and it sends it back from the server but it is kind of cool seeing this in a fully type checked language uh not a dynamically typed language at all rock is not dynamically typed it’s not gradually typed there’s no type reflection none of that stuff um this is just like it’s this uh Json encoding right here is responsible for saying I know how to take a rock value like this and figure out how to turn it into Json and that’s exactly what it’s doing here pretty cool but what’s much cooler than that is seeing that in action on the other side on the client when we’re decoding Jon so let’s see what that looks like um so let’s go back here to this thing uh let’s Okay we don’t need standard in actually want to comment that out because we might want to bring it back later um let’s see uh what are we gon to do I’m gonna say let’s do all right so first of all I need to bring in my Json package here um so now we’ve got that and I’m going to need to import Json as well so with that and next we’re going to say uh okay so first I’m going to go get some Json so let’s oh I need HTTP that’s important um HTTP cool uh so I’m going to do http.get and the URL is going to be uh no HTTP Local Host actually I’ll just copy this out of the browser great so we’re gonna go get that uh exclamation point because that is an effect for sure um and then the format is going to be once again json. utf8 and so we’re going to get this uh Json back and I’m going to say uh got this actually no I have a better idea I’m going to destructure this I’m not going to get the whole thing as a Json value I’m gonna actually say you know what I’m just going to get message uh and also is one plus one two just GNA get both of those right there um and in fact I’m gonna do a conditional based on this uh so let’s see getting some Json and then I’m going to say if this other stuff if is 1 plus one two then uh yeah so sure then we’ll print out is it 1 plus one equal to two otherwise yeah cool that that actually was kind of a cool little co-pilot autocomplete um however I actually would kind of like to always print this message so let’s do this got this message um which is just going to be message okay um and then we’re going to do this conditional great so what I would like to see this do is is I want to print to print out getting some Json and then it should say got this message which should be the message that we got back from the server which is Hello from the server um and then uh hopefully it will it will agree that one plus one is two uh in which case it will take this first branch and print out one plus one double equals 2 so I’m going to leave this server running in this tab and I’m just going to back over here rerun rockd demo. Rock hey getting some gra on got this message hello from the server 1 plus one equals 2 all right very nice so again this is not necessarily something that is all that impressive if you were like a dynamic language like JavaScript um all sorts of languages will do this they’ll like you know get Json out of a thing they’ll just turn it into dynamically at runtime whatever types you need it’ll decode it into the appropriate format none of this stuff is all that revolutionary if you’re talking about a dynamic language however there is always this problem that I’ve always encountered in Dynamic languages which is not a problem that I have in rock and the problem that I always have in Dynamic languages is that the error handling for all this stuff gets really messy like so far I have been operating in what I like to think of as sort of script mode in other words I’m writing something this code that feels very prototype very kind of jamming everything out there as quickly as I can um I’m not handling any errors anywhere I’m just kind of letting everything fail in sort of default ways I’m not really thinking about error handling and in Dynamic language this is where when I start to think about okay I want to actually make my program more robust now I’m done prototyping I now want to sort of transition from demo mode into sort of hardening it mode and making it more reliable this is where the language starts fighting me and it starts feeling unhelpful because I start to think about like well where could these errors be like what happens if one of these fields is missing like what happens if I try to get these things out of there but this thing instead of saying message it says you know mess and there’s no e on it like what happens if if that’s there or instead of message that says I don’t know MSG or something like that um you know this code is completely separate from this code it has no idea that that happened like what’s going to happen and usually what happens in Dynamic languages and also in gradually typed languages like typescript for example what’s going to happen is that this is just going to propagate through my program it’s going to be like this is going to become null or undefined or something like that um it’s going to print out got this message and it’s going to print out null or undefined to the user um if 1 plus one you know being two is not a Boolean we might get a runtime crash or something like that later on um especially if I got an actual number in there all sorts of things that can can go wrong that are um really frustrating and difficult to deal with so let’s see what happens in rock like I I have not uh you know changed anything other than I just made it so that this is uh returning MSG instead of message so let me go back restart the server and let’s just confirm real quick that that is working yeah cool so when I visit in the browser we can see that it’s coming back with this now I didn’t update my client code so these are out of sync right now obviously I could make a third Rock file and have them both import it but where’s the fun in that let’s intentionally break it so the server is still running this thing has no idea uh this client over here the CLI has no idea that the server um was was doing that has made that change it’s still looking for this message with the old type so let’s see what happens when I actually run this program exited early with error HTP decoding failed huh okay so we got some sort of error in here that says like decoding failed um but notice what we didn’t get we didn’t get this this didn’t happen it didn’t print out got this message and it also didn’t take either of these branches and printed that out it’s almost as if and this is exactly what happened the program exited right here like it was doing this http.get and as soon as it found out that this thing was wrong it immediately exited early have you ever seen that before have you ever seen it where this isn’t null it isn’t undefined it doesn’t propagate through the program but rather it immediately fails right at the decoding site even though we have not written a single type declaration in the entire 20 minutes that I’ve been demoing this I’ve written zero type annotations no type annotations here no type annotations here this is all just type inference but what’s happening is that essentially Rock’s compiler says I know what these types are because of type inference I know that message for example is a string because you’re printing it out in string interpolation I know that this is a Boolean because you’re using it in a conditional conditionals have to be booleans so it knows that it’s expect something a a record field called message that is of type string and it’s expecting one of these that’s of type Boolean and if it doesn’t get those it’s going to fail decoding right when we do this http.get right here because I said I expected utfa Json and also from type inference it knows that I expected this shape of Json this fails right away even though I didn’t have to spell out you know here’s what the schema is here’s why I didn’t have to declare anything it just figured it all out from type inference so this is a good example of something that’s always been a goal of mine for rock is trying to learn from Dynamic languages but also trying to improve on it by bringing in things from the static type checking world so if you if I stopped you right here and I didn’t run the program and I just showed you this code you might say this kind of looks like python it’s really concise it’s it’s there’s not basically no ceremony anywhere I’m really printing out the absolute bare minimum worth of instructions to specify here’s what the behavior I want is same thing on the server um and yet what we’re actually seeing is that we have already more robust error handling than I would get from a python or a ruby or something like that that’s dynamically typed and in fact even in those languages when you add static typing through gradual typing you still don’t get this either you get the behavior like you get in typescript where this is still null or undefined and it sort of permeates through the program or you have to explicitly write out your types and like annotate it and say I expect message to be a string and I expect this to be a bull and they both have to be there and so on and so forth I’m not saying those are bad things those are perfectly reasonable things to want to do and you know in lot of cases there’s a really good argument to be made that it’s best practice to do that anyway but the point is that part of the design philosophy of rock is that different workflows should be supported it should be possible to start with a workflow where you say I want to start out in prototyping mode really low ceremony and then transition gracefully into really robust hardened ready for release you know public use mode so now let’s take a look at that okay so we already saw sort of what we’re getting for free in terms of uh type inference now let’s start to actually get some types involved so first of all I’m going to let me go back and actually fix this thing so that it uh it’s not going to break um although we’ll we can like redemonstrated breaking it later if that’s uh useful but um one of the things I mentioned earlier is that we’re not handling any errors here and there actually quite a few errors that could happen here for example what if I do this HTTP and you know we saw the Json could be could go wrong but only thing could go wrong is like I could just give it the wrong U URL right so instead of Json I could say sljs that URL doesn’t even exist that’s going to hit our 40 cor path right here um another thing that could go wrong is my network could be disconnected I’m not going to demo that because if I disconnect my network uh We’re not gonna be live streaming anymore um also uh I mean there there could be a timeout there’s any number of things that could go wrong here but I’m not handling any of those right now um similarly actually I mean it might not sound like it but even printing to standard out can go wrong like there’s various IO errors that can happen if like the the pipe gets broken stuff like that um all of these things that have an exclamation point these could potentially cause an error and currently I’m not handling any of those well let me change that real quick so all I’m going to do I’m going to change absolutely nothing about my implementation I’m just going to change uh put a type annotation on Main and here’s what I’m going to do okay so I just added a type annotation to Main and I didn’t do anything else so what does this type annotation say so first of all in rock type annotations Go On Their Own Line um I’ll explain the benefit of that a little bit later but uh basically what this is saying is that our main right here has the type task and task has is a type with two two type parameters first is the succcess type so a lot of tasks like for example if I did like http.get utf8 it would say like oh I get back a string this particular main task doesn’t produce anything so we just say empty record which is kind of our shorthand for like nothing no no no useful information here and then the other type parameter is essentially a list of Errors like like things that can go wrong so what I’ve done here is I have given um the command line app basically has one error that you kind of always want to have which is sort of this generic like like hey I want to exit with a non-zero exit code and then I want to print out some string to standard error that says uh you know what what went wrong like some information for the user now you don’t have to use this there’s other ways that you can exit if you don’t want to do it um in exactly this way but uh this is a really convenient way of doing things and basically what I’m saying here is I’m saying okay this main task has handled every single error that could possibly come up except for this one except for the explicit sort of graceful exit everything else has been handled I promise and we notice we’re seeing a red sgle there so let’s just see what exactly the rock compiler here is saying um for this particular example I actually want to do something different than what I’ve done before I’m going to use I’m going to go full screen on the terminal and I’m going to use instead of rock Dev I’m just going to do rock check so rock check is basically just type check it and tell me what the um the problems are don’t actually try to run it all right so rock check says hang on a second there’s a mismatch here so what’s actually happening is that I’m getting out this thing this is the list of error so we saw it’s a task with the sort of empty record meaning you know I I don’t produce any output here’s all the different errors that can happen in this program HTP decoding failed remember we saw that one earlier when I made the Json fail also there’s a number of things that could go wrong with HTTP itself like the body could be wrong request could be wrong bad status is like a you know 500 error something like that network error uh timeout also when we’re printing the standard out like I mentioned you could have a broken pipe it could be interrupted before it finishes printing um out of memory unsupported W block like all these things are things that the operating system can say went wrong when you’re trying to write the standard out I didn’t handle any of these but notice that the compiler knew about them like all that happened for me to get those compiler errors was I just put on a type annotation that claimed I’m handling all the errors except for that if I replace this with an underscore this is a rock uh type annotation feature if you want any part of a type annotation you can replace with an underscore which essentially means hey I don’t feel like annotating this part like I’m saying this is a task but I’m not saying anything about either of those in fact if you really want to you can go as far as to say like col underscore this doesn’t do anything I’m just saying like hey I’m annotating main with nothing um important to note this is not at all the same as like the any type in a lot of Ang languages this is underscore means like I know compiler that you know what the type is I’m just not choosing to write it down so underscore essentially means just go back to your normal type inference for this part of the type so when I do this what I’m saying is I am claiming that main is a task that produces nothing and then underscore for the error type meaning I’m not I’m not making any claims whatsoever about what I think the error type is here but I can still break this like if I say task string it immediately gives me an error because like no no no this this doesn’t produce a string what are you talking about standard out. line doesn’t give you a string what are you what are you saying here so if I do that it’s fine um and then also if I do this again it complains because it’s like no no no that’s not what this error type is I’m seeing more errors than you are claiming are actually happening here so how can I fix that I’m I’ve got these different errors here how can I make it happy and and say like okay I actually agree with you this is the actual error type so in order to do that I have to actually handle the errors like there’s no way around this that’s the only way that I can get it to actually handle uh these these errors that I am claiming to handle is I have to handle them so this is important because this means by adding that one line of code I have instantly switched from sort of script mode getting up and running real fast prototyping mode to like no no now all the errors need to get handled and unlike your traditional try catch where it’s like yeah I don’t know wrap everything in a catch and then hopefully you catch them all you know got to catch them all it’s like no no here’s the list here are the things you need to handle like this is this is the errors these are the ones that your program can produce there are no other erors that your program can produce these are the ones you need to handle Okay cool so let’s actually handle them so the way I like to do this is I like to just um sort of split this out I’m going to uh make a little thing called run and then I’m going to change main to just be uh run I’m actually using the pipe operator I’m a fan of the pipe operator um we just had an F talk right before this and uh Rock got the pipe operated from Elm which got it from F so rock is like a direct descendant of the elm programming language but Elm is designed for sort of browser based uis it compiles the JavaScript um rock compiles to machine code or to web assembly we’ll see a little bit of web assembly later um and essentially uh so you know that’s that’s a little bit of where the pipe operator came from in rock um anyway so I’m going to run this I’m do test. map error and I’m going to write a function called handle error um so handle error doesn’t exist yet okay I’ll make it exist and this is going to be uh give me error and I’m going to handle it with oops no that so this is another thing that kind of happens with co-pilot sometimes it starts writing like Elm syntax so we say when is and rock uh case error is is the syntax that Elm uses for pattern matching um and rock and Elm have a lot in common because rock is a direct descendant of elm but uh you know that that’s one of the things that is different about it um okay cool also these errors it just totally made up and they’re all hallucinations and wrong um but fortunately we can see exactly what they are they’re right here so let me just grab those out of the compiler error message um I’m actually not going to handle these as uh granularly as the compiler error tells me so this is another nice thing about error handling in rock is that um we can be as granular as we want to be or not with this so for example I’m going to say okay if HTTP error uh HTP decoding failed oh that’s a good yeah failed I like that thanks um and we’re going to do exit status code 42 sure and I’m just gonna actually comment these out for now um and I’m going to come back later and do them and so for right now we’re just going to have uh I don’t know whoops exit yeah exit one uh something bad happened cool and I’m going to bring those back a little bit later all right so uh now in summary what we’ve done is I’ve extracted my sort of happy path logic here into this thing called run and then I’m basically saying Okay Main is just going to do that and then it’s going to handle the error um using this uh handle error function so if there is an error in any of these exclamation points what’s going to happen is it’s going to short circuit and come down here and uh run this and that’s and it’s not going to continue at all cool so uh now we should be able to see um let me uh bring this back and go back and do rock Dev so failed to decode Json cool so that’s that’s what happens when we do this and uh the the Json decoding fails and then we we come back down here we see error is htb decoding failed and um you know we failed to decod some Json um is actually let me pause real quick this this is not planned but I’m actually kind of curious why did Json decoding fail I thought I changed the server back oh did I change it back but I didn’t restart it that’s probably what happened let’s see let me just double check okay ah okay yeah that was the problem I didn’t restart the server all right okay well cool we confirmed that on the happy path still works now let me break it again and then we’ll get that error all right um okay so now we should get the error again great fail to decode Json okay now again notice that uh this what what happened here is we we printed out getting some Json right that happened then we got right here and again still no type annotations on this we still only have one type annotation in our entire program which is up here um and uh we did the http.get the decoding Json decoding failed because we were looking for a field called message but we didn’t find that instead we we had this like other field by with this other name but that’s not what we were looking for that decoding failed on this http.get the exclamation point one of the things that it ends up doing is short circuiting short circuiting goes all the way back to here map error runs handle error says okay I’m going to take over from here and now we have we uh did a pattern match on this and translated to this fail to decode Json great okay now I’m going to do a different error so here I’m going to uh I’m going to just get the URL wrong and this way it won’t even get to the decoding step so now when I uh run it says oh something bad happened Okay cool so here we you know same thing happened except that rather than making it to this branch in the error handling uh we came down here okay so let’s uh rather than just handling everything like that I’m going to um I’m going to bring the two back uh and so I’m actually going to delete the underscore for reasons that I will explain later okay um so we’ve got HTTP error uh I’m gonna actually yeah why not I will handle so I’m think this is going to be a bad status 404 uh not found oops I guess I need to actually do the exit uh exit sure exit 404 why not um and then for any other htb error I’m I’m going to say uh exit I don’t know one Whatever 11 sure uh some other HTP error okay and then uh and then we had sit out error what’s the other one and I’m just going to say yeah sit out is broken hopefully sit error still works otherwise you won’t see this message okay cool um all right so let’s uh let’s run again and now we should see not found because we hit this uh error 404 Branch now let me demonstrate something else here uh so I’m going to go back to rock check mode so here Rock check should say like okay cool by the way um this is something that we always print out when we’re doing uh Rock check among other things we have a timer that starts when you first run the rock command line app and then it ends like right before you know printing this out and essentially what we’re always trying to be really mindful of is like how fast are our feedback loops and this is hardcoded to be milliseconds like we actually like it’s just Ms is the string that goes in there we don’t have like a fancy like oh let’s print out if it’s like you know seconds or like because basically my view is like if it’s ever not milliseconds that’s like we should try to fix that somehow we should try to improve that um obviously there may be like some gigantic code bases in the future where like even with caching and incremental compilation and stuff we still can’t um you know keep it like under a second but that is kind of my general goal is like as long as we can possibly have it be the case that like rock check especially is is under 1 second even for really big code bases and the way we can achieve that is with incremental compilation and caching and stuff we really want to um to to maintain that if we can Okay cool so this currently works fine but now let’s see something else cool um what happens if I don’t handle some combination of these things like for example what if the only HTTP I’m handling is specifically I got a 404 back so I’m just going to comment out that Branch boom instant error what’s the error this wind does not cover all the possibilities uhoh yeah it knows the comp iler knows and by the way the compiler knows even if I don’t annotate anything I’ve deleted all type annotations from this program now what happens if I comment this out same exact thing so the type annotations really I wasn’t kidding when I said they’re optional like it’s the compiler knows it it just it knows and um so there’s no escape hatch here there’s no way to turn off the compiler there’s no null there’s no undefined there’s no any type none of that stuff there’s no way to trick the raw compiler into accepting something that has invalid types because it’s just designed to be a sound type system but at the same time as you have seen even though it’s designed to be a sound type system we’ve also used other design techniques for the language to try to make it so it can be really nice for prototyping and then also it can be really nice for reliability later and you can transition between the two really seamlessly like this cool so I’m going to put back my main type annotation because again the whole reason I wanted to put here put this here is because this is the way of sort of making the compiler say hey you need to handle these errors because you’re claiming that they are handled The Reason by the way that I was allowed to not put any type annotation here and not make any Claim about this is that one of the features of the basic CLI platform and I’m going to talk about Platforms in a sec is that if you choose not to handle certain errors by default the behavior that you get is that error message that we saw where it it sort of has a default error Handler that says okay if we run into some error that you didn’t handle like other than this exit one which is you know defined to be the graceful exit one um such as a decoding error such as an http all it does is it really just says I’m just going to do you know print a standard standard error like hey something went wrong and then just you know sort of uh printing out the the raw code um something that you can do here is if you want uh you can say like you know other um and I can do inspect do to stir other um that’s a thing that you can do and I guess I’ll just uh I can demo that really quick um yeah so basically like what this does is it essentially just prints out like the the the translation of the rock code to string this is really not something you should use for using facing stuff this is mainly designed for like logging for example if you want to just like I have some gigantic Rock value and I want to just log it out um I don’t want to like you know have to go all the way to um you know uh like like traversing the entire record and turning everything into Strings manually um by the way also uh I’m not going to demo that here but if you uh a common question around this is uh do I have some way of making sure that Secrets Don’t making into logging the answer is yes um you can make your own opaque types and you can Define with your custom types that you’ve created exactly what happens when this inspect dotster runs on them which includes for example saying I’m just going to always print out some asterisks you know because this is sensitive stuff that should not end up in logs um cool okay so let me put that back um right so you can kind of see um a couple of things about this so one is that uh I I had to handle every single eror that happens in here uh because I again I’m claiming that I’ve handled them all um as my program grows I don’t need to worry about like what happens if I introduce some new type of IO where uh I I didn’t handle that error like at all um well let’s let’s do that and see what happens so I’m going to import c. standard in and now I’m gonna let’s let’s make this URL um come from uh standard in UHS um actually okay I’m going to get that on my clipboard because that way I don’t have to S inline and yeah should now say you could already see the error popping up right there yeah thank you co-pilot um what do you think the error is hey it’s we didn’t handle standard in error right here so if I uh I’m G put that down there so I can get back on my clipboard really easily but uh stin error uh Sten is broken or broke I guess I guess you know I shouldn’t claim it’s broken but like whatever it it broke um all right great so uh yeah so now uh we can see that again instantly just the fact that I started using standard in it immediately gave me an error because it’s like you didn’t cover this one so this is one of the other nice features about rock is that errors accumulate um it’s figuring these out not dynamically at runtime on the fly but rather statically based on type inference of just seeing like here’s all the different errors that each of these different operations can do it knows the the full list of those and then it makes you pattern match on those this is an exhaustive pattern match um in order to handle these things um one other thing uh I I just kind of spoiled it a little bit but um one thing you can do is even if you don’t have any type annotations so again I’m just going to delete this one um you can always find out the type by just hovering over it this is like part of the uh the rock language server so it’s just telling me like hey the type of this error is HTTP decoding failed HTP error Etc um it just it just knows exactly what those types are um and even if I just change this to like crash uh oh this is sort of your uh your panic button uh crash in in Rock by the way is not like try catch there is no catch crash is basically intended for like when you get to something where you’re like this really should never happen there is no graceful way to recover from this if we ever possibly enter this you know code branch which ideally you can always rule these out at compile time with careful use of types sometimes you can’t that’s it’s it’s for those times um you know I’m getting this like unused argument here but I think ah it doesn’t know now okay all right fair enough um so uh yeah like it does need um if I’m too I wonder if there’s some way I can okay let me see if I can figure it out a different way if I can hover over the right thing to figure out how to get it to say that error without any type annotations okay that’s I mean this works but it’s kind of kind of it’s kind of big to look at but as you can see okay actually let me all right let me try putting this back um crash blah okay I’m just going to try this out and if it doesn’t work doesn’t work but I think I should be able to still see yeah there we go cool so um yeah point is that the compiler knows like it knows the exact set of things that can go wrong in this thing just from uh type inference and you can tell that it does because I’m not running the program nothing is running right now okay the server is running the other the other Rock file is still running but you know like this is just static analysis it’s it’s able to figure out here’s the exact set of errors that are happening here and by the way this um error accumulation feature this is actually not specific to errors this is actually just a general Rock language feature um called tag unions I’m not going to get into too much detail on how tag unions work but in a lot of languages for example um you have a typical thing where you’d say like like an Elm it would be like type color equals and then you would have like red yeah red green blue so in rock the way that you do that is you make a type Alias of red green blue these basically do the same thing the difference is this is Rock’s uh like syntax for type Alias you basically just like make a type annotation where uh you’re naming the the uh the type Alias um basically what this is is this is an anonymous some type so actually if you want you can go into rock reppel which I’m gonna actually demonstrate on the website because we have a reppel up here um I can just put like red in here it’s like oh cool that’s that’s red I just made up a some type that only has red in it um and you might be wondering like well without doing a type Alias how am I going to get two things in there and the answer is if I do okay let’s let’s see if the reppel knows one plus one is two um red else blue what it’s going to do is it’s going to say Okay cool so the answer is red because it took the branch of course but also notice that the type of this is now either blue or red so again I’m not going to get into all the details on this but this is an example of um how you can uh use these sort of anonymous uh tag unions these these Anonymous sum types or Anonymous algebraic data types if you want to call them that um to to get sort of accumulation of values so what’s happening here is that basically again using typ it sees well if we take this first branch of the conditional we might get this tag and if we see take the other branch of the conditional we might get that tag and so therefore the type of this whole expression is inferred to be either blue or red and that’s exactly what’s happening behind the scenes with this task stuff here it’s just that like when I run stood out doline that function produces a task that has a particular set of Errors each one of them tagged with you know something like sit out error um and then when I run http.get again it has a certain number of errors that can happen they’re all tagged with HTTP error htpd coding failed same thing with standard in and so all that’s happening here is really just that the compiler is just using this totally normal language feature um to accumulate errors because you can accumulate tags in general and one type of tag that you can accumulate is error descriptions um this is also another good example of one of the design philosophies behind Rock which is to be a language that has a sort of small set of simple Primitives that work really well together um we don’t want to be a kitchen sync language like a C++ or a rust that just has like a gazillion language features rather we want to have a really small simple set of language features that just work really well together and let you get a lot of like really nice characteristics um together okay last thing I got to talk about is platforms because we haven’t talked about them yet so this is one of the um one of the most fundamental ideas in rock and it’s something that I don’t know of any other language that does this so so far I mean this looks like pretty standard building a CLI stuff mostly pretty standard building a server stuff except that you might notice that here main was a function that took in a request and here main is just a task like I just I just you know built this thing up when put the type annotation on Main we just said it was a task um uh um we didn’t say it was a function whereas here main is actually a function that takes in a request and then returns uh actually a task which um which contains a response or an error now the difference here is that every Rock application so notice the first thing we have here is we have this keyword app and that means that this is an application which is to say it’s an executable um when I’m doing Rock Dev oh by the way something else I can do is I can just say rock build um so rock build basically just makes a binary executable so I can just say oops SL demo um and it just it just runs my thing so when I say rock build it’s building a binary Standalone executable that I can just like ship up to a server or distribute to end users or whatever um also there’s a D- Target so you can cross compile so I can say like Target and then like give it like Linux or Windows or something like that and it’ll spit out a binary for Linux or Windows so we do have cross compilation um and basically the idea here is that um we have this concept of platforms and applications because of the reality that different use cases just want different Primitives so in this in the example of this demo I am writing a command line app so I’m using this platform called basic CLI and notice there’s this platform keyword here like you do have to say like which platform you’re building on and a question everyone always asks is can you have multiple platforms the answer is no because well for reasons that I won’t get into here but essentially it wouldn’t make sense um you can think of a platform as something like a framework uh in the sense of like that’s sort of like the level of abstraction about that you’re dealing with um like when I’m importing sit out and sit in I’m importing them from the basic CLI platform which I gave a little Alias of CLI for short so I don’t have to write out basic CLI or this whole long URL every time um by the way the way that Rock’s package system works both for platforms and for other packages is that the reason this URL is so long is partly that we’re using you know GitHub releases but also at the end of every one of these there is this uh hash which is actually mandatory and checked so this is a security feature that means that we can sort of verify the contents and we do um on download which basically means that we don’t have to worry about uh like the contents changing or like this URL gets taken over or like somebody’s GitHub account gets compromised that’s not going to be a problem because even if that does happen you’ve got this uh the you know the hash of the contents uh this is a Blake 3 hash um that’s that’s going to validate on download so anybody who takes over this URL can’t possibly you know change the contents of it without also changing the the hash or else it’s going to fail so basically we have this like really nice bakedin security feature for that um and so there’s no like node modules directory like if I LS this directory um we have like the you know the demo uh executable that got built the server executable that got built um and then these are just some other things in the directory uh for for later but um and then the two. RO files um so yeah so every application has a platform and the platform is responsible for things like your IO Primitives so usually like standard out and standard in in most langu is those are part of the standard Library those are not something that you get from like a framework or something like that and the reason that we do this differently in rock well there’s a couple reasons um one is security so uh because these come from the platform we haven’t made this yet but we have a design in mind for basically making a uh an alternative to this basic CLI platform that’s maybe going to be called like safe script or something like that and the basic idea would be solving the problem of I want to download a script from the internet and run it and like not worry that it’s going to give me a malware or something like that on my computer and the idea a would be that this would have the same API as basic CLI as in like the same public facing standard out standard in all that such that I could just like literally just change this URL right here and nothing else about my rock file and now it’s running in uh safe script and essentially now the behavior would change such that whenever this script wants to do IO like this HTTP thing or if it were doing like a file read or a file write it would prompt the user and say hey this script is trying to do an HTTP get to this URL do you want to allow this or not and you could say things like yes I do or no don’t or maybe like yes but only to this subdomain or you know something like that um and the purpose of this would be to try and essentially mimic what the browser does in terms of safe sandboxing so that I can download this script from the internet I have no idea what’s inside of it but as long as I see that the platform that it’s using is safe script I can just run it with full confidence because I know there’s no escape hatch here there’s no way that that script can possibly be doing any IO other than stuff that’s going through the safe script platform because there is no IO coming out of the rock standard Library that’s just not a thing the entire standard library has no IO Primitives whatsoever it’s all done through the platform and two There’s No Escape hatches like cffi or something like that again that doesn’t happen either it’s all going through the platform so you actually can legitimately download an unknown untrusted script from the internet from anybody and run it and not worry that it’s going to mess up your computer because if it tries to do anything that might hurt your computer it’s going to prompt you first so that’s one of the thing one of the reasons that we have this um platform designed with these IO Primitives but another is just that certain IO operations just don’t make sense in certain use cases for example standard in blocking to read from standard in like we did here is that a thing that makes sense in a web server like do you want your web server to be able to like block on reading from sard in I don’t that sounds like a mistake if anyone ever does that and yeah maybe I when I’m writing my web server I would never accidentally do that but the point of having this be in the platform is that now if I use some package like this Json one or something like that that I got you know off the internet that’s sort of like platform agnostic like this Json one we’re using in both of these two different use cases even though they have different platforms I want to make sure that any kind of sort of platform agnostic package that I’m using is only going to be using Primitives that make sense on my platform in other words if I try to get a package that’s used that’s relying on standard in being available and it’s not I want to get a compiler error for that I don’t want to like find out about that at runtime or like have it like block on standard and I want to just be like no no you can’t use this thing because it’s trying to do something that is not available or doesn’t make sense in the context of a web server and for even more extreme example of this for my final demo of the presentation let me show you a web assembly Rock program so I didn’t make this and I also didn’t make the platform for this um so anyone can make a platform by the way this is not like we have a hardcoded set of them it’s just like it’s just part of the language you can make an application or you can make a platform or both if you want um so this is Rocky bird so uh Brendan Hans connect made this and I I think Brendan and some number of other people collaborated on the platform but basically there’s this really cool sort of retro gaming style platform called WM 4 um and the basic idea behind WM 4 is it’s a way to give you uh sort of the experience of like coding an old school game if you’re curious for the code for this it’s up on the Internet under Rock Waz for and Luke Boswell’s um uh GitHub account and you can see like you know here’s the text Rocky bird click to start you know um we’re not going to go through the code on this but I’m going to show you the game real quick because it’s fun and I’m probably going to die right away let’s see what I can do all right oh one oh two okay oh three oh my God this is very stressful okay it’s worse than live coding all right anyway so that’s Rocky bird it’s fun little game I think my high score of all time is like eight so um you know it’s it’s it’s Flappy Bird but in rock um but the point is talking about platforms like somebody made this platform for this right so at the top here you’re just importing the WM 4 platform and when you look at the Imports here it’s like you’re not seeing anything like standard in you’re not seeing HTTP um not only does standard in not exist because like thees does that make any sense in the context of this thing but also you’re not going to find any like file IO Primitives file IO Primitives totally make sense for CLI and for server but like you’re in the browser you can’t access the file system that’s just not a thing here and so part of the reason for this design is to give people a away to build for lots of different domains I like to say the longtail of use cases is what I’m targeting with rock in other words not just command line apps not just web servers not just retro games in the browser um but also just like things like editor extensions things like um you know uh database extensions Al all these little sort of Niche use cases where you have an intentionally restricted environment where certain operations don’t make sense rock is designed to make it so that in those environments you only have The Primitives that make sense like if I’m building a game for this um web assembly thing and by the way people made a couple of other games on this uh too there like a maze generator and like a a drum machine um and uh you know in the in that world I don’t want to have to worry about any of the dependencies I’m using potentially relying on things like file system access that you know I just don’t make sense in this world um so uh this this concludes uh my uh sort of like demo portion of things and I hope you enjoyed all the live coding all that um if you want to learn more about rock we have Rock line.org um this reppel by the way obviously Rock compiles to web assembly but shout out to Brian Carol he made this work this is actually all running in web assembly in the browser this doesn’t talk to a server at all it’s all just executing right here it’s web assembly compiler Rock compiler compiled to web assembly which is compiling web assembly Rock on the Fly and then evaluating it all in the browser so you can like load this page turn off your internet connection this will all still work just as well um we got some more examples here and then uh down below here we got this little thing where you can kind of click on things and just see like a little explanation of what everything’s doing um pretty similar to honestly like a lot of the stuff that we just uh went over here um and yeah if you’d like to learn more uh this is you know rock line.org is sort of the best place to do it um I highly recommend uh the community tab um rock zip chat we all hang out on there it’s like very active and people are super friendly to beginners asking you know answering questions and stuff like that um and uh yeah uh I’m just really excited about uh you know all the progress the language has made um you know like a year ago I couldn’t have been able to do this demo because just like it wasn’t enough stuff to be able to demo and a lot more compiler crashes as it happened we didn’t run any compiler crashes but trust me they’re out there um and you know if you spend enough time with the language you’ll definitely run into something cuz it’s still a work in progress we don’t even have a numbered release yet um but uh but you know you can download nightly by Aries all the time and um yeah I would uh love to answer anyone’s questions thanks thank you very much Richard very interesting presentation there’s a lot of questions people are shouting out like good presentation yeah some some were already now saying they they’re gonna switch to rock or like use it at least check it out there are a lot of actually yeah it’s it’s not battle tested so you know if if you want to like rewrite everything in rock I would recommend starting with something small so that you’re not you know battle testing in production and you know right away but but uh yeah cool there’s actually a lot of questions I’ll take some questions here and then I think people can join the Discord afterwards and ask them like the more elaborated questions but one of the questions that came up was like why did you choose to write the new language or go for a new new language yeah I mean uh honestly it’s it’s kind of the most common reason there is which is just that you know I I I wanted something like this to exist and there was nothing that quite did it um so I really love the elm programming language it’s been my favorite programming language for years now um but it’s specifically targeted to like front-end web development it’s really really focused on like browser based uis and I always had all these other use cases where I I wanted to use um I wanted to do something else other than a browser-based UI but I really wanted that Elm like experience um separately I also had some like language design ideas that I wanted to explore um that just like wouldn’t make sense for Elm um but the main thing was just like I was thinking about oh I want to write a postgress extension or I want to I was doing a lot of Vim you know now I’m on the Z train because I finally found an editor that has like good enough like non- buggy Vim support um that’s also like very fast and has a nice gooey and stuff but back when I was using just Vim um I was like I don’t really want to learn Vim script I want I want to you know do an Elm like experience where somebody else already built a platform if you will um that that has all the Primitives laid out and and sort of made everything makes sense for me and I can just sit down and say cool I’ll read some documentation here’s how to build a plugin I’m getting this nice Elm like experience type inference um you know all the nice error handling and all that um but but uh but it’s vimscript instead of you know in the browser um that type of thing that’s where this idea of sort of like wanting to Target the longtail of domains uh kind of came up understand thank you um next question how does the cross compilation work what if the platform how does the cross compilation work yeah so uh the short answer is that so rock compiles to like just machine code so there’s no like VM you don’t have to install I mean okay so if you want to like run a ro file obviously you have to have Rock installed but the way it’s able to compile to sort of um you know self-contained binaries is essentially that yeah the rock compiler just spits out straight machine code and it knows how to spit out machine code for like x86 arm web assembly um we have uh incomplete coverage I would say of like these from a um uh like development backend perspective so the compiler does know how to spit out x86 machine instructions and R machine instructions and web assembly all of those are not so we have llvm but also separately we have those backends so llvm for those who are aren’t familiar with it is basically a optimizing compiler back end it’s a way to generate machine code for a Target but also lvm does all these optimizations unfortunately lvm also takes a long time to run so it does a really good job I actually did none I didn’t use optimize mode at all and anything I was just demoing um if I had built with optimizations then it would have like taken longer to build but then it would have run faster um but obviously like the the normal build was fast enough um so uh the other step though that has to happen is linking so after you’ve done all of that um uh like buil generating the machine code you have to link it together with something that will actually produce an executable or something like that so this is where the platform comes in essentially one of the responsibilities of a platform author is that you have to produce sort of a baseline binary executable that’s sort of got all the pieces there except for the compiled Rock application and then we have to link that compiled application together with a sort of Baseline binary that comes from the platform um right now we do this in a lot of cases including on Mac OS with the system Linker which is actually quite slow um we’ve got a surgical Linker that is like really really fast um so actually if I done this demo on Linux the feedback loop for especially doing Rock Dev would have been even faster so it takes like on my machine it takes like this is a Mac M1 takes like 200 milliseconds to run hello to do like rock Dev on Hello World um that’s that’s like compiling we saw like compiling with rock check that took only like you know 40 milliseconds or 20 milliseconds um it takes like 10 times that long to actually build and run and that’s almost all waiting on the system Linker so once we have surgical linking that whole process should also be like well under 100 milliseconds um anyway the point is that all of that logic that I just described lives in the Rock compiler whether you have the rock compiler built for Mac OS or Linux or Windows um so no matter what system you’re on it always knows how to build for Mac it always knows how to build for Linux it always knows how to build for Windows and platform authors also have to provide binaries for all those different targets um so essentially what’s happening is just that like because we know how to build for all those things we just have every compiler no matter which system you’re on build for that Target um so for the systems where we don’t have surgical linking Done Yet those we we can’t cross compile to completely yet um so Linux we have the surgical Linker windows we have the surgical Linker Mac we don’t which means that since I’m on a Mac I I can build for Linux and windows um but if I were on Linux I couldn’t actually cross compile to Mac yet because we don’t have the surgical Linker for that totally working once we do it’ll make the builds faster and finally unlock uh the last piece for um cross compilation for that Target um unfortunately Mac is like the hardest one because the Mac OS like linking format is actually like really old and obscure and undocumented to the point where we know people who have talked to people at Apple and they’re like yeah we don’t know how it works either because it’s like so old and undocumented that like even internally it’s not known but anyway so that that project is challenging but um you know once we get there then we’ll we’ll completely have it including for Mac OS from non- Mac OS targets thanks next question when can people anticipate like a stable release people are asking maybe they want to use it now you know yeah I mean so honestly like I don’t I don’t really have a timeline in my head um it’s more just like uh you know when it feels right um so I I I want to really intentionally be very clear about like you know the stability like right now we’re intentionally not making any stability guarantees we have had a couple of um breaking releases where we’ve managed to uh make it smooth even for people who are still using language so like most recently the import syntax changed it was kind of subtle but if you’re like watching this video later can go back and look at the rocky bird thing um the source code for that actually has different import syntax than what I was using um when I was live coding that’s because we recently had the import syntax change but actually we made it so that rock format like the formatter automatically upgrades you from the old syntax to the new syntax um the new syntax is going to unlock some new language features later um but like we’re still thinking about backwards compatibility we’re just intentionally not making any promises about it so that people like sort of you know their expectations are calibrated right um so obviously like based on what I just demoed you can do a lot with the language right now and there’s a lot of really nice things to to love about it um but at the same time I also want to be just really clear about the fact that it’s like it’s not battle tested there are still compiler bugs that we know about um you know like the the cross compilation like from Mac OS works but but not from other targets Etc um and so uh yeah like I to me the main thing is not like let’s rush to get a stable release but rather like let’s just make sure that anyone who’s trying out the language like really knows like you know clearly what what they’re getting themselves into in terms of this being still kind of like a bleeding edge thing thanks final question uh if you if people want to get involved in rock language is it just head over to GitHub and get involved or get over to the yeah so if you want to if you want to contribute I mean if you want to get involved in rock in general um I I just recommend going to the website and clicking on community and then like hopping into rock zulip because that’s like that that chat is where everybody hangs out including if you want to get involved in contributing um also like I you know if you want to donate to the project um I would love that uh we’re so far we’re we’re using donations exclusively to pay contributors um so uh you know the the more you donate the more work gets done on Rock so um yeah really appreciate um you know any any way that people want to get involved okay thanks again Richard thanks again thanks for having me this is fun yeah it was really fun thanks with that we say uh thanks for tonight or morning or daytime dependent on where you are and for those who are live with us join us on Discord server and you can ask more questions and get all the questions answered that you had and typed in the chats and on the Discord um so please with that have a nice evening day night wherever you are bye and see you in June

    1 Comment

    Leave A Reply