Lisp everywhere! Gurudom is around the corner

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone to the minimalist death room for the second time we're organizing this and you know so far we've had some great talks i hope i can live up to that expectation so lisp is the second oldest language used in use today the oldest language is fortran and i just yesterday yesterday there was a fortran to llvm talk so that's also still alive fourth we also had a talk which is quite old it's early 70s i think small talk is also quite old so you know these old languages seem to seem to stick somehow which is great um so yeah i've i've went through many phases in my life uh i know i've started programming in the early 80s and went from you know from pascal to through c plus plus to python ruby whatever elixir scala d and i still like ruby and i still like d so what about lisp um so the first one of the things i learned is that you know the top two percent of the programmers in the world they they can program in lisp have you heard about that statistic so of course when you want to be a top two percent programmer what do you have to do you have to learn lisp so that was an incentive then i ran into a number of projects including gnu geeks which is a package manager i've written in lisp and you know so slowly i started to and it's surprisingly easy to learn you know you can teach a a youngster list probably in an hour i think yeah the basics so that that's that's great but i also discovered the lisp is uh very much a ruby or a ruby is a lisp really you know and i i met matz who was the creator of ruby uh two years ago and i asked him you know say how come ruby is so much like lisp and he says yeah actually people in the early days called it mark's own lisp instead of ruby yeah so there's a lot to share then um so also lisp is a lot like python or python is a lot like lisp and you find these things out but there's something else lisp is everywhere and i'm going to talk about that so lisp you can find in emacs you can find in the education great programs autocad in the early days used lisp julia julie i was originally written in lisp you know that so there whispers there logic programming mini cameron closure in the last 10 years has you know wedged itself into the business market um gnu geeks of course is very much popularizing lisp and and pushing guile to its limits and that's the next talk there we have glue mess john was talking about just now yeah there's a lot of lisp in there and the shell anyone heard of shells lisp there we go so in a nutshell your most programming language language write writes and then braces and then a parameter and list you know the braces are just on the outside that's all you need to know so when people say there's lots of parenthesis in lisp you know math and where most languages handle scope in you know with curly braces in the cc style syntax and you have imperative assignments right and then you do something like uh concatenation and list you write something very similar just looks a little bit different you know so have you start with a with a brace and then you assign the parameters right and then you do something with it but what you can see is that that is very consistent you know because functions are always start at the first position in the brace so that's how they get evaluated and then you get a list of parameters and even for assignment you know it's really a function yeah which has a list so and the other thing is that most lists today they allow you to also use square brackets right so as long as they match up you can you can exchange them with with the braces but interestingly it introduced a scope and one of the things i i found out quite late which is uh embarrassing is that and this is really beats other languages you know i think to the core is when you run lisp in a rappel yeah so you can you can just cut and paste the inside of an expression right and and feed it to the rapple again and so if you do debugging i mean try that in python so here's a famous lisp it's uh it's running in a in an editor and here's an example yeah so emacs is written in lisp essentially it has a very small c core that runs the lisp engine which means that all the configuration is is is done in list two yeah so once you get used to the list syntax you don't have to relearn anything what you only need to relearn is how you know emacs has has created its world of of functions or procedures um which you just can call yeah so i wrote a function at some point that i wanted to copy the line above and i probably did it in the most the most inelegant way um yeah because i wasn't really into lisp then but you can essentially write a function that says you know take take the cursor position copy the line above inject it back into the into the text buffer you can even inject into a different buffer if you want and this is what it looks like you know and it starts it starts to look familiar now and then when you have written the function you can bind it to a key right and this in this case is control backspace let's see if it works yeah right so i wrote this language extension myself you know it's a really minor one but i think it just shows the power of of using a configuration language which is also a programming language so emacs is for programmers so at that point i really would like to emphasize you know in fact i i use vi of him for almost 10 years i started with emacs then in a you know in a in a mind meld i went to vi and then 10 years later you know i went back to emacs and and the real the real thing is that you because this is such a configurable editor it becomes a great programming platform too yeah so programmers love an editor that you can program and that's what emacs is racket so this is another lisp which is really making list popular again and the racket has a record that comes with a shell it's called thresh yeah so it's an unfortunate name but there you go um and i just want to run quickly through it because racket allows you to mix shell commands with list commands which becomes very interesting so you can install racket i'll share the slides and then you can say something like require some modules right and then hey that's a that's a show command see that cat etc hostname and you can pipe it into a lisp procedure and that points into another one so what you can do is say you know um turn some trim a string or you can say um let's see here's the mixer again define hostname is cat etc so that you have to embed it shell again right and do some function operation on it and then you can just run a plain shell script yeah where the parameter is actually lifted out of the lisp evaluator right and that's uh that's already pretty cool but you can also do things you you know you can't even fathom doing in the shell like parson jason parsing jason right so this is a this is a rest endpoint which returns a very complicated json record um and i can actually i can just you know fetch it with within within the shell using a lisp expression and you know the the record in the first stage of the record is a hash is there is a dictionary what are you trying hey aleister how are you all right is it not the black the blue one the black one yeah try ready for liftoff yeah so you can do something very complicated and then you out of this json record you you get you know this this string so in a shell script essentially you can do complicated things you can even do you know you can use sql light as a back end and you know push some state into a sequel light file database try and do that in a shell another thing is the you know the shell scripting program program and probably most of us get caught at this at some point you know the shell when you pass a list of words in there is it a string or is it a list yeah so here's an example here's the shell script that i used to upload some files to my web server sorry to my mail server yeah and you can see that the um the file name has spaces in it okay and when i actually run the shell this script which simply is shell and then using the expansion string star of course it breaks because it starts it thinks these are all different files right anyone bitten by that before yeah so the the rec the rash version is that you um start the shell and you can you can parse the command line using current command line arguments and you can see if you use single quotes it actually sees that words but if you use double quotes it will see it as a string as a sorry as a something with spaces so to write the full script you could do something like this where you say okay we're gonna run a system command the system star calls the rsync and and plugs in the fn which is coming from command line current command line arguments so this is a lambda and you know in lambda the um the actual parameters to the to the to the call are are listed last which is kind of counterintuitive for us ruby programmers yeah so eternity if but racket comes with a with an uh with a nice facility just where you can say for list function name you know that's the parameter fetch it from the command line you know and then run the command and this starts to pretty much look like ruby to me yeah i mean a little bit syntax and then you run it it works right as it should skip this so here's a more full uh uh rash script where i i just showed that you can create a loop yeah so the student file lists the student names with spaces and then um i create a name removing the spaces and then i copy the file a text text text file to the output file and then i run set hey and this is again just a shell command essentially yeah and this is also a shell command so what you see is you can you can mix in a loop you can mix shale crown shell commands again which has you know the normal shell syntax so i think rush is pretty cool and for girl we should we have gash if it could do this type of thing young really interesting so there's more reading here you can read on racket and why is ratio interesting you know because rash is totally hackable through lisp so you learn one syntax and you apply it in different for different things all right the time so there's some hacking guides here uh and this seems to be misplaced somehow what did i do new guile i'm starting with the hacking guys great that should be the last one so the new geeks you've heard of before if you were in the room um is a is a package manager it's a functional package market manager and it's it's essentially written in guile which is a lisp again yeah different there are many flavors of lisp and this is one it's a scheme and you know when you install something with with geeks on the command line you can do something like geeks package install racket emats racket mode and then i'm going to put it somewhere that's what it says yeah and then you load the profile which is the number of environment variables and then you can run the program which is in all direct bin racket and it will give you a prompt i should have given a guideline example anyway so geeks is written in guile so we need to install that first and i'm also installing some some nice packages that go with it emacs ebay gazer or geyser and par edit and when you do that you can do something like this uh i haven't prepared as well there we go you can you can start the rebel yeah with with the uh x where the major command x shell and then run geeks rappel so giggs rapple is really just a command line tool geeks and it drops you stay it drops you straight into a lisp rebel and it allows you to interact with uh with geeks yeah so the geeks package manager and here for example we say okay use these modules use geeks use new packages scheme and then tell me about the racket package and it gives you it gives you information on the record package including which file it sits in the new packages scheme and the line number yeah so you get this this facility where you can actually interact with with the geeks package manager through lisp and you can query data you can say something like package version racket yeah so let me try that if i it's always dangerous to try things on the command line come on come on what did i say racket yeah so here's the package thingy and then i need to say for example package version record version and return to the version that's installed yeah so and there's a there's a lot more to that so you can you know you can get all the information that's in the package manager and if i show you what the package manager looks like that's the wrong one geez too many things are open now my poor small brain so if you have for example here's the package definition in in geeks yeah you could say define public which is the and then the package name which is called ruby connection pool and this is a ruby gem you know it's a it's part of it's a ruby package that comes with ruby and it essentially say you know this is the name this is the version this is where we fetch it from it comes from uh through rubygems right so it's a rubygems uri and you can see that the rubygems you if you know it or sets it from git it will show the you know a git uri so we have a high level abstraction here for rubygems the shaft value just says this is what the the you know the tarble or the shaft value should be like you know so you don't accidentally get another one and then the build system is the ruby build system then it has a native input so that's a dependency it depends on bundler um and then you have the synopsis in the description so this this all describes one package in geeks which is concise right and it's also lisp again yeah so you can understand it now right even if you don't even if you had this one you know this 10 minute introduction on lift that i have given anyway so if you clear the the data that's uh that was on the rebel you can actually get this information that was in the package definition you can just see it here and do something with it you can also interact with the demon i'm not gonna run it now because i don't have that much time um but essentially you can uh you can uh open a connection with the demon which we call s here as a convention or store or geeks demon you know so not much of a convention and then you can make it what we call a package derivation uh of of the package that you want to build in this case or install this is ruby and the derivation is sort of the lowest uh data representation of offer package so it includes all the dependencies and everything and then you simply say something like derivation sorry that's what it returns oh this is how you fetch the file name of the derivation and in this case we want to build it so we say uh uh build their evasions you know with this with the daemon and then take a list of the derivations in this case it's the ruby derivation which is which was fetched here yeah so if i run that it should it should install uh ruby which is always a bit dangerous let me try i gotta paste that live dangerously when you give a demo yeah so it returns true because the package is already installed yeah but so it doesn't reinstall unfortunately very convenient for demo but um yeah so but that's it you know that's all there is to it how many nine okay that's cool and then we have some a concept called the stormone app so when people talk about monas they usually think about things like high scale functional programming languages you can also do this in lisp five no thanks yeah so and the specific specific monadic functions which avoid you to to reference the the demon or the store or the connection every time so you know rather than the earlier uh here we explicitly had to say build derivations s and then something yeah so here we can just say package derivation ruby and you don't have to relate to the i mean the the monad carries the uh definition of the store with it so you don't have to reference to it again and this this this is another way of you know simplifying the code because you otherwise you would have many references to the demon you know and and that's actually not necessary so to capture it all you know with geeks the source code is the documentation i think and we show some high level functionality for building and and and exploring packages um and the fun thing is you can also use a debugger so you can actually step to when you build something you can step through the code that is the package definition and what it does with it um and there's all the unified list syntax so your distro here is a scheme library for hacking you know through the geeks geeks apis and here's some links which are available i'm going to skip this one so just like emacs geeks is for programmers yeah so once once you master lisp you can do anything really so i'm going to quickly touch on another list which is become very important in the in the business environment is clojure um and it's a little bit i mean the list people in general you know when they frown when you mention clojure because it's a little bit different from most lips but uh i think it's you know it is it's not i can't say it's superficial but it has very interesting ideas you know so it's a different conceptually it's a different uh beast altogether but it shares things with the other lisps including the syntax it uh it's it takes a little bit of some freedom when it comes to saying okay you know rather than writing uh where did that go i think something disappeared um oh no that's probably the same so that's a list right but this is a vector right and a vector in in the other lisps or at least in scheme would be would be written like this and this is a hash value or a dictionary and this is what it looks like in in the other schemes you know so there's some some some some differences and i think it was uh this is meant to meant to make it nicer for people who are coming from javascript python ruby and all that but it's the same thing in fact underneath it it will return similar values and then clojure has you know a lot of ideas around functional programming including immutability and and shared state handling which are all all important and it compares to the jvm which is an advantage if you like it and it's a disadvantage if you don't like that and close your scripts which is also clojure translates to javascript so you essentially have one language that can target either the jvm or javascript and i think in a business environment that can be pretty attractive but that's not to say that this is the only way to do things you know because there's a for example viva scheme is a is a javascript interpreter that runs in the browser and when you use that you can do something very simple like this you know which is html and then you script uh the bios javascript interpreter you pull it in and then you can just write the right scheme again and i think this this is actually a very interesting tool we scheme is a racket id that runs in the browser so that's another browser interpreter um parent script takes a slightly different approach it's a javascript generator so it's more like closure script [Music] and spock is the chicken scheme to javascript generator so these are all projects that that can do pretty complicated things and it all originates on the fact that writing a lisp interpreter is not that hard you know a lot of people even learned that uh you know in school in university at least maybe not the last 10 years but who has learned to write a scheme or you know a lisp interpreter in school see yeah that's a few so it shows you it's possible right i mean if anyone wrote written a c plus interpreter here they also exist you know but they're they're very crazy beasts so spock can compile to either c or javascript you know and that's it's a chicken scheme and i'm i'm gonna wrap up now because uh the take home message i think is uh that lisp is one or maybe many languages that serve all i think that's that's the key thing and um you know there are many great lisps lisp is easy to learn this is everywhere it can be used anywhere it's for newbies and gurus alike in my opinion you know i'm probably still a newbie but what is really important in this stage of millennial angst is that uh you know you don't have to worry about what language you have to learn after this right it's not well there's so many people that come to me and say you know should i learn rust should i learn python should i learn r or whatever you know and i'm just say well you know that's fine you should actually you should learn them all but once you reach to the stage that you have learned lisp you probably you know you're over it thank you [Applause] any any questions yeah yeah yeah so the gal rebel saves all the answers that's true you
Info
Channel: FOSDEM
Views: 2,925
Rating: undefined out of 5
Keywords:
Id: JkydjttWKp8
Channel Id: undefined
Length: 26min 57sec (1617 seconds)
Published: Mon Oct 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.