LIPS Scheme
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Subtitle |
| |
Title of Series | ||
Number of Parts | 542 | |
Author | ||
License | CC Attribution 2.0 Belgium: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/61494 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
00:00
Numbering schemeExtension (kinesiology)Power (physics)Software developerFormal languageText editorOpen sourceXMLComputer animation
00:27
Atomic numberInterpreter (computing)DisintegrationRecursionUltraviolet photoelectron spectroscopyNumbering schemeCore dumpStandard deviationCodeFile formatWeb browserIntegerNumeral (linguistics)TowerMacro (computer science)Library (computing)Extension (kinesiology)Type theoryWitt algebraParsingUnicodeCompilerBinary fileParsingSimilarity (geometry)Physical systemFunctional (mathematics)ImplementationRun time (program lifecycle phase)Vector graphicsNumbering schemeCodeRevision controlPower (physics)Multiplication signInterpreter (computing)Library (computing)Computer programmingDemo (music)Branch (computer science)MathematicsBeta functionLink (knot theory)Projective planeNumbering schemeRepository (publishing)Formal languageMacro (computer science)Source codeDialectFunctional (mathematics)Latent heatSoftware repositoryElectronic mailing listCharacteristic polynomialKeyboard shortcutWeb browserImplementationWebsiteProgramming languageLimit (category theory)Pattern languageRegular expressionData structureMessage passingVariable (mathematics)IBM MainframePositional notationStatement (computer science)Different (Kate Ryan album)Type theoryTraffic reportingElement (mathematics)Extension (kinesiology)MereologySystem callRecursionSign (mathematics)Parameter (computer programming)Web pageMachine visionStudent's t-testPoint (geometry)Virtual machineTerm (mathematics)Lipschitz-StetigkeitComputer configurationForcing (mathematics)Sheaf (mathematics)Single-precision floating-point formatObservational study19 (number)Line (geometry)Goodness of fit2 (number)Coma BerenicesInheritance (object-oriented programming)Perfect groupStatisticsGraph coloringWeb syndicationPlanningWater vaporLattice (order)Local ringAlgebraic closureEndliche Modelltheorie1 (number)Directed graphComputer iconDesign by contractComputer animation
06:49
Data structureSeries (mathematics)SicMereologyLipschitz-StetigkeitSoftware developerInterpreter (computing)Binary fileAerodynamicsNumbering schemeMacro (computer science)Operator (mathematics)Numbering schemeCodeWindowData structureTouchscreenSoftware repositoryFunctional (mathematics)MultiplicationInterpreter (computing)VideoconferencingPerformance appraisalWeb pageData conversionComputer programmingTerm (mathematics)Source code
07:58
ExplosionProcedural programmingKerr-LösungText editorAlgorithmNumbering schemeFormal languageMcCarthy, JohnSequenceVariable (mathematics)Positional notationCodeParameter (computer programming)Performance appraisalSymbol tableOperator (mathematics)ParsingMacro (computer science)Process (computing)Logical constantData typeEquivalence relationNumerical analysisOvalBoolean algebraType theoryDemo (music)Patch (Unix)ACIDChainRow (database)RoundingParsingMIDIGEDCOMNormed vector spaceElement (mathematics)Predicate (grammar)Constructor (object-oriented programming)Physical lawInclusion mapRippingTerm (mathematics)Electronic meeting systemLambda calculusNumbering schemeData typeDifferent (Kate Ryan album)Bus (computing)Revision controlCondition numberSimilarity (geometry)Right angleElectronic visual displayFormal languageExtension (kinesiology)Group actionFunctional (mathematics)Row (database)Sign (mathematics)Presentation of a groupInstance (computer science)Water vaporCompass (drafting)Thermal expansionCellular automatonInsertion lossState of matterWorkstation <Musikinstrument>Interactive televisionCodierung <Programmierung>Data storage deviceParameter (computer programming)SatelliteCore dumpLatent heatWeb pageCodeObject (grammar)Vector spaceRepresentation (politics)Type theoryLibrary (computing)Hash functionArray data structureNumbering schemeSoftware repositoryRegular expressionString (computer science)Set (mathematics)WritingGraphical user interfaceProbability density functionSocial classPositional notationWeb browserResultantError messageSource codeJSONXML
15:20
Pay televisionRow (database)Error messageData storage deviceMenu (computing)GEDCOMActive contour modelMathematicsACIDConstructor (object-oriented programming)Execution unitWechselseitige InformationMaxima and minimaVector spaceNumbering schemeRange (statistics)Line (geometry)Type theoryInternet forumComputer iconGamma functionNormed vector spaceEmailIntegrated development environmentPopulation densityMacro (computer science)Category of beingLibrary (computing)Object (grammar)Latent heatRegular expressionArray data structureSet (mathematics)Vector spaceWrapper (data mining)Unit testingSource codeSymbol tableSocial classInstance (computer science)Integrated development environmentElectronic mailing listFunctional (mathematics)String (computer science)Numbering schemeRepresentation (politics)Key (cryptography)Data storage deviceConstructor (object-oriented programming)Extension (kinesiology)Numbering schemeMoment (mathematics)Parameter (computer programming)TowerElement (mathematics)Standard deviationLocal ringWeb browserReading (process)Operator (mathematics)CodeMultiplication signType theoryCASE <Informatik>CAN busPresentation of a groupPoint cloudGraph coloringLipschitz-StetigkeitTerm (mathematics)DeterminantBitWorkstation <Musikinstrument>Complex numberSource codeJSON
22:42
Demo (music)Error messageConstructor (object-oriented programming)Row (database)Maxima and minimaMenu (computing)World Wide Web ConsortiumFormal languageKeyboard shortcutEquivalence relationLocal GroupRepresentation (politics)RepetitionDialectMassLambda calculusLink (knot theory)Musical ensembleFrame problemRule of inferencePresentation of a groupGroup actionFunctional (mathematics)Demo (music)System callMultiplication signMathematical optimizationSoftware testingLimit (category theory)Equivalence relationChainObject (grammar)Wave packetIntegrated development environmentInsertion lossRegular expressionStack (abstract data type)Atomic numberWebsiteLipschitz-StetigkeitPhysical systemNumbering schemeString (computer science)Continuous functionProgramming languageThermal expansionDefault (computer science)CodeMacro (computer science)Inheritance (object-oriented programming)Library (computing)EmailArrow of timeSet (mathematics)Fundamental theorem of algebraFiber (mathematics)JSON
30:04
Program flowchart
Transcript: English(auto-generated)
00:05
Welcome to my talk, LISP scheme, powerful introspection and extensibility. My name is Jakub Tienkiewicz. You can find me online with my handle jkubik. I'm a senior software developer from Poland. I focus mostly on JavaScript language.
00:21
I'm open source developer and Polish Wikipedia editor. I'm also a mentor and editor. We will talk about LISP and scheme history. We will do quick introduction to scheme. Next, we will talk about LISP scheme history. And the most important part of the talk is about LISP scheme, how it works.
00:42
To get most out of this talk, you need to know basic of JavaScript. LISP was presented in 1960s by John McCarty and his famous paper Recursive Functions of Symbiotic Expression and Direct Computation by Machine Part 1. Part 2 was never created. It was based on Lambda Calculus by Alon Houtart.
01:03
And the paper explained the eval function that was written in the LISP itself. One of McCarty's students, Steve Russell, decided to implement the eval function on the IBM 704. And it was the first interpreter of the LISP language. The syntax of the interpreter was a little bit different than the one described in the paper
01:25
because of the limitations of the keyboard on the IBM mainframe. LISP stands for LISP processing. The most important thing about the language is that it's homoiconic, which means that the LISP code is represented by LISP, the main data structure.
01:42
It was heavily used by AI research at the beginning, and it was great source of inspiration for most modern programming languages. There are a few so-called dialects of LISP which are used today. Scheme, Clojure, MXLISP, Racket and CommonLISP. Scheme was invented in 1970s at MIT by Guy L. Steele and Gerald J. Sussman
02:06
when they investigated the actor model. The language is defined by specifications R and RS, which stands for Revisited Report on Language Scheme, where number indicates how many times it was revisited. Second version was Revisited Revisited, so it used power off to make the name shorter.
02:27
There are also official extensions to the language, SDFI, Scheme Request for Implementations, which adds new language features. The official website for the language is Scheme.org. Now let's talk about basic of Scheme.
02:41
In most modern programming languages, when you have a function call, you use syntax like this, where you have a function name, and in parentheses, there are arguments separated by a comma. In LISP and Scheme, on the other hand, the code is created from S expressions. A LISP created by parentheses, where first element is a function,
03:04
and arguments separated by a space. And you can mess those lists. What is important with this expression is that those are not operators. They are plus and aesthetic symbols, which are names of the functions. So they are in fact function calls. So they are written in the same way as a sign function.
03:23
As I've mentioned, code and data use the same data structures. So it's important to distinguish data from code. This is done by quotations. The first expression is code, and the second is data, a list of numbers. To define variables in Scheme, you use define. That can also be used to define a function.
03:43
And let is used to create local variables. And this is how you define an if statement that will print a message depending on a boolean expression. Define, if, and let expressions are special syntax which works differently than the normal functions.
04:01
And you can define your own syntax like this by using macros. For example, we can define macro throb, that when passing expression with infix notation, will sum the numbers using prefix notation. In Scheme, there are two types of macros. First, are list macros that accept code as data and return new list that will be evaluated.
04:23
And the second are hygienic macros that use pattern matching syntax. These macros are used probably by all list dialects, but hygienic macros are specific to Scheme and dialects based on Scheme. To learn more about Scheme, I suggest a book, Sketchy Scheme by Nils M. Horn.
04:42
You can find the older version of the book on InternetR Hive, but I suggest to get the latest version from this link. The main topic of this talk is LIBS, Scheme implementation written in JavaScript. So let's quickly talk about history of this project. It started on CodePen as a list based on Scheme.
05:04
I wanted to create Emacs in browser and wanted to have something like Emacs list. That's why LIBS, from the beginning, have an optional dynamic scope that is a characteristic feature of Emacs LIBS. A picket scheme, because it's much simpler than other dialects.
05:24
You can still find the first version of the interpreter on CodePen. LIBS was inspired by Emacs LIBS and Python, mostly about the introspection features and that all functions have documentation inside the code, which you can access from the repo.
05:42
The last version of LIBS that you can access from the NPM repository as a stable release is version 0.20.3. But on a certain point, I decided that I want a full Scheme implementation, not only LISP based on Scheme.
06:00
And I've started working on the code on the devil branch. But at one point, it turns out that there are way too many breaking changes to release the next version. That's why I released it as 1.0 beta and the latest version is 16. At the beginning, the whole code was written in JavaScript.
06:20
But when I was making an effort toward full Scheme implementation, more and more code was written in Scheme. Now almost half of the LIBS code is Scheme. And now there is a time for the demo. This is the official website for the LIBS project. And what's cool about this is that here you have a bookmarklet
06:42
and you can drag this link to your bookmarks and execute it on a different page. For instance, here, there is a first lecture of the structure of the interpretation of the program, a classic video lectures from MIT.
07:02
You can evaluate Scheme code that you see on the screen.
07:21
The feature of the repo is that there are syntax highlighting and parentheses matching. And also, each macro and functions have documentation if you hover over the name. Here you have documentation for define. Here you have the documentation for asterisk, multiplication operator.
07:41
You can also undock the panel with the repo and use it inside a window that you can drag and drop on the page. Another cool feature of the repo is that you can execute it on PDF files.
08:04
But I've tested this only on Chrome browser. This PDF document is Scheme language specification. But it often give problems if you try to execute code that is inside this document in the repo. For instance, on page 12, there's these quotations.
08:25
And if you try to execute this code in the repo, it will give you this kind of warning. But you can fix this error by executing this code.
08:41
You execute it. Suddenly, you can evaluate this expression. This set special, a special kind of function that create syntax extension. Here you can have documentation for this function.
09:00
Syntax extensions allow to define new syntax similar to the one defined in JavaScript, like those quotations. Here you can see vector literals defined by hash sign. Vectors are also created as syntax extensions. And Scheme vectors are just JavaScript arrays.
09:23
Similar syntax extension is ampersand that define JavaScript object literals. Here we can see that the representation of object literals looks the same as the code.
09:41
This is another feature of Libs that allow to define new representation for different instances. Scheme vectors are also defined in the same way. You can use both features to define homo-iconic data types.
10:31
Records are the way to define new data types in Scheme that is defined in this specification on page 27.
10:44
You can define syntax extension for this record.
11:05
The third argument to set special indicates how the make person function should receive the arguments, the list or as a normal arguments. This feature may be removed in the future to simplify the code. The dot notation in the last argument is taken from JavaScript
11:23
to simplify interaction with the hosting language. Libs is a global object that you can inspect with the dir function inspired by Python.
11:44
In the same way, you can access any JavaScript object or a function.
12:02
But let's go back to our record example. A person is a class and you can create an instance of that class with a new macro
12:23
or with make person function created by Scheme record type. We can also use our syntax extension to create a new person object.
12:54
Now, let's add the representation of this new data type.
13:40
And now we can evaluate the code and have the same representation. The Q parameter indicates if the result should be quoted or not.
14:01
In the wrapper, the strings are quoted because they use Scheme write function. But you can use display function that don't use quotations.
14:27
But with set wrapper, you can make representation of the records without the new syntax.
15:18
With this feature, you can easily serialize and deserialize custom data types.
15:24
For instance, when saving in browser local storage.
16:07
We use eval because a read returns a list as data that needs to be evaluated to get the instance of the person object. To get the property of the speaker object, you can use dot special macro
16:27
or you can use JavaScript dot notation. The next feature I want to discuss is introspection. You can use a proposed function to search the environment.
16:48
This is a list of functions and macros that match a given string. In this case, vector. You can also use regular expressions to make the search more specific.
17:18
And this is a list of typed vectors.
17:20
Each of those constructors have also the syntax extension that allow to create those vectors according to Scheme specification. Each Scheme typed vector is, in fact, JavaScript typed array.
17:44
And each of those arrays have its own representation. So they look like the code that defines them. You can access the documentation and the source code of the every function, macro and firebird defined by libs. You can access the name, the documentation
18:12
and the source code of this function. What's cool about the code is that it's a live object that you can modify.
18:44
The double underscore syntax is inspired by Python magic properties. You can also inspect the internals of other libs objects like symbols or numbers.
19:24
Libs support full numerical tower. Here's a complex number, but it's not yet fully unit tested. So there are no guarantee that everything works correctly. By 100 percent. You can also inspect the list object.
19:53
The instance of function use JavaScript instance of operator to check if argument is instance of the object.
20:01
Here it check if X is libs list and it written true. You can use the standard list function to get the third element of the list.
20:23
But you can also access internal pair objects, define it by libs. The proposed function that I've showed a few moments ago
20:43
allows to search the environment. But in libs, you can also access environment objects themselves and do cool things with them. You can inspect them.
21:06
As you can see, there is double underscore and property that you can read.
21:23
Object keys is a JavaScript function that returns array of strings. So it's represented as a scheme vector. Those are all objects defined inside the repo, including libs internals. You can see our person class and you can access it using environment object.
22:25
Make person was our representation of the person instance using set wrapper inside the environment object. There is also another double underscore property parent, which allows you to access lexical scope time.
23:19
You can access both X fibers from the scope time inside a one expression.
24:07
You can also modify the scope inside the chain.
24:35
Set is generic macro that allows to modify any JavaScript object, not only libs internals.
24:42
Another feature of libs is that you can access stack frames of function calls. They are also environment object inspired by the R programming language that has a lot of lisp under the hood.
25:53
Here, the function test can modify the scope outside the function call. Another function similar to parent frame is plural parent frames,
26:02
which returns a list of stack frames. With both parent frames and underscore code access, you can modify the function that call a given function anywhere inside the call stack chain.
27:00
The long arrow is a macro for invoking methods and the collie is libs object similar to JavaScript object with the same name. The long arrow macro is a convenient method to create the chain of method calls.
27:44
This code demonstrates another fundamental feature of libs, where everything is automatically assigned by default when needed. Fetch is a JavaScript function that returns a promise which resolves to a resource object. That object has a text method that also returns a promise.
28:04
Here we can skip them, which makes the code simpler than the JavaScript equivalent. The match in the code is a string method and the number one returns first group from the regular expression. The whole expression returns the main header of the libs website.
28:21
But when needed, you can quote the promise and use it as an object.
29:12
Now let's back to our presentation for a final thought. As you was able to see from the demo,
29:21
libs is pretty flexible and powerful, but it has its limitations. One of the limitations is that macro are on time. There is no macro expansion time. There are also some performance issues. One of the reason for it may be the lack of macro expansion time. But you can fix those issues by embedding JavaScript code inside libs.
29:45
The most important things that are missing are first call continuations and tail call optimizations. And also the syntax rules scheme hygienic macro system is not working exactly as it should. All this can be improved in the future.
30:01
Thank you for listening to my presentation.