 Hello! I am Markus. I'd like to show you a graphical environment for learning closure and physics. To warm up, let's get our hands on some Bob Dylan lyrics. Come get around people wherever you roam and admit that the waters around you have grown and accept it that soon you'll be drenched to the bone. Come writers and critics who prophesize with your pen and keep your eyes wide that chance won't come again and don't speak too soon for the wheels still in spin. For the times, they are a change in. What I just presented is widely used in learning poems by heart. Maybe you have seen mobile apps of that kind. The method is also well known in computing education. It was termed Parsons Puzzles in 2006. It is a topic of active research at least since then. The title of my talk is Functional Physics, along with visual blocks. The table of contents does not show this title. We need to complete the puzzle. I think that puzzles are ideal for learning functional physics. A puzzle is asking you to think about the design of an algorithm. You do not worry too much about the actual code. Your focus is on the problem domain. The syntax of the language matters less to the user. This feature is very compelling when it comes to Clojure and Lisp. The attitude towards Lisp in science is best described on the Pirate website. Pirate is the programming language for introductory computing. You heard about it on Friday in the talk on data centricity. Much as many of us love parentheses, we fear that Lisp will always bump into an acceptance threshold due to its syntax. We are delighted to see the growing adoption in industry of languages like record and Clojure, and maybe the days of parenphobia are over. But academics are far more height bound than industrial programmers. I also see that the Lisp acceptance threshold exists among scientists. And for very relatable reasons. For a physicist, a method or theory is a valuable and hard-earned thing. It will only be given up when experimental facts force her to do so. I think that an academic needs to be height bound like this to have any chance of making real progress. Plus, scientists always have concern for their self-efficacy. This means they will be inclined to look at the new method or experiment only when it is short and elegant. The most elegant formulation of physics I know of is presented in the SICM book by Sassmann and Ristam. SICM stands for Structure and Interpretation of Classical Mechanics. But this approach involves programming in Lisp. And typing on a keyboard is certainly not as elegant as writing with pen and paper. Because of this, I wanted to bring Clojure nearer to pen and paper with the method of Parsons puzzles. Let's start with the Algebra. This workspace shows a simple math example. We calculate the average of 20 and 40. Drag 20 in front of 40. And divide by 2. The result is 30, as expected. This was the first example of solving a physics puzzle. For a scientist, I think it is clear enough. But a note is in order. A programmer who knows that CLJ tiles is written in Clojure expects a notation which differs from the common one. To clarify this, we open the parser by right-clicking on the workspace. And type plus 1, 2. You can see that the parser converts Clojure code into the usual infix notation. The reason of course is that the notation in the workspace should be as similar as possible to pen and paper. The code which is generated is displayed on the lower right. It is proper Clojure code. The code is for informational purposes and read-only. It is handy for pasting into an editor and starting to develop own programs. The idea is that users will learn to read Clojure code while solving puzzles from easy to more and more difficult levels. It is important to say that normal users will only work with the mouse and not use the keyboard. The parser only is needed for creating puzzles, which is the task of dedicated coders. While normal users are not concerned with creating puzzles, they certainly want to understand them and investigate the puzzle pieces. This will be covered in the following example. When I run this workspace, I get an error message. It is actually not called error message, but code interpretation result. Sometimes a workspace is not yet meant to run. You did not make a coding error, you just ran early. So the name error is simply wrong in the case of puzzle solving. Right-click on the number 2 and inspect. You now see three reasons why no end result is shown. The first reason being the variable the average dangling on top. The second is for the ill-formed dev. The third again for dangling the average. There is more than one reason displayed because inspect tries to run every expression separately. This is different from the run button, which stops evaluation at the first ill-formed expression. Move the number 2 out of its block and inspect. All of a sudden you get the result. Clojure was able to evaluate the expression despite all the other unsolved issues. The value 2 is printed together with its type, which is number. The display of types is possible because within CLJ tiles, parts of SICM are specced via Clojure spec. I think the type number is the most important one in functional physics. This is because numbers provide the connection from theory to experiment. I think types help in learning physics with SICM. Usually data is presented to the user just as a string of characters. It all looks very similar. But when additional type information is displayed, the data gets a shape. When it is typed, a piece of data is experienced more as a thing of some kind, a text, a symbol or a number. Later on we will learn about several other mathematical objects. Types will make learning about them easier. Another idea for flattening the learning curve is to present the same puzzle at several difficulty levels. So we look at two different workspaces, which contain the same puzzle. Here we see a simple function definition. The puzzle is very easy to complete. In the Violet block, the function say welcome is called with the value closure. When the workbook is run, the text welcome to closure is printed. To show a bit more in detail of what is going on, inspect the parameter called what. Indeed, it carries the value closure and is of type text. On the next page is the same puzzle as before, but split up a bit more. You can see that the blocks have different colors, depending on the number of slots. Blocks with one slot are violet, two slots is green, three slots is blue. And there is the pink block with no slot. Now we solve the puzzle. It should help that we have already obtained the solution before by solving the simpler version of the same puzzle. Here the colors play out nicely and separates the different blocks in a clear manner. The blocks with one or more slots are all constructed in the same way. They start with a name, like deafen, print line, say welcome. The deafen is not special in any way. It is just displayed vertically. This can be changed using the context menu. But that does not make sense from a code formatting point of view. We go on to a bit more sophisticated math now. I will show the printing of color vectors. With this, we enter the domain of the SICM book. Originally, the SICM utils are written in MIT's scheme. In the last years, the SICM utils have been ported to Clojure by Colin Smith. Sam Ritchie enhanced and ported them to Clojure script. The workspace I show here has an explanation at the bottom. So it should be easy to complete. As you can see, in SICM, color vectors are created with a function called up. After pressing the run button, you see the correct result. 1, 5, 9. Inspect the whole green block. First of all, the vector is now nicely formatted. And second, we see that the result is a color vector which consists of three numbers. Now inspect the right blue block. Here we get the new type, an expression. If you inspect pi, you get the hint why this is. Pi is a symbol. Apparently, when the function sign is fed with a symbol, it returns an expression. So we already have four different kinds of mathematical objects in this simple example. There are numbers and symbols which we already know from standard Clojure. In addition, we have a type called color vector and a type expression. They are provided by the SICM library. All of those mathematical objects can be used in calculations. In other words, we have a computer algebra system in the browser. Now fill the upper left slot with the green block. Press run. The result is printed nicely formatted as before. This time without the types. Up to now, we had two kinds of blocks. On the one hand the simple pink block and on the other hand the remaining blocks which are mainly for calling functions. There is no obvious way to do higher order functions. For this, the beige block is introduced. It always has exactly two slots. The first slot carries the higher order function. The second slot carries the one single argument. Look at the violet block which has the familiar form for calling functions. Its one slot is filled with the string 3 equals. Now inspect the block. The result of this block is a function with exactly one parameter. We want to find out what this unnamed function does. For this, we fill the first slot of the beige block. After pressing run, the result is the text 3 equals 3. So the string 3 equals within the violet block is concatenated to the number 3. We are given the definition of the higher order function above. It is called this returns a function. It takes some text as an argument and returns an unnamed function. This unnamed function itself takes a number as its single argument and returns a text which concatenates all the data. The beige block takes exactly one argument. Every functional programmer knows what this means. CLJ tiles demands carrying of higher order functions. Thus, the beige block is another stepping stone to LISP. The insistence on carrying makes code containing higher order functions more readable. The most important application of higher order functions within SICM is taking derivatives. In the following workspace, we will take the second derivative of the trigonometric function sign. For this, we need to remind ourselves that pink blocks not only take texts or numbers, but also the names of functions. Inspect the pink block T. It is a symbol. Inspect the other pink block. It is a function. While its name is not displayed at the bottom, the block itself reveals that it is the trigonometric function sign. To calculate the second derivative, drag square T into the first slot and sign into the second slot. Inspect the whole block. It is a function. But it is unnamed. We need to apply it to some argument in order to explicitly see how it looks like. So, finish the puzzle and press run. The result is minus sign, indeed the second derivative of sign. Now, take another look at the result. It is interesting to know its type. One might guess, it is a function. The derivative of a function always is a function, after all. That is perfectly true, but there is a catch. Inspect the whole block. It is not a function, it is an expression. Inspect the inner block. A function. This is the real second derivative of sign, an unnamed function. It is notable that this unnamed function knows nothing about a symbol or a variable named t. You can even replace t with pi. Inspect and you get a meaningful result, the number zero. In the last step, we calculated the derivative of sign at point pi. And we got the number zero as a result. There is a more general version of this. It is called a function l by physicists. This is a construct which takes an arbitrary function as an argument and returns a number. Again, while a function like sign takes a number as an argument, a function l takes a function as an argument. On blackboards in physics classes, sometimes a dot is used as a placeholder for the argument within a function l. The corresponding notation in blocks is quite obvious. I split out the sign block to leave an empty slot. This slot now can be filled with any function and the result of the block will be a number. Hence, the block is exactly the thing which physicists call a function l. This block cannot be executed anymore. In the context of the interpreter, this function l does not exist. But in the context of physics, it does. This well-known construct of physics is just not understood by the computer in this form. But a tutor can create, interpret and explain it very well to students. So, my claim is that graphical blocks can form an independent notation beyond their execution as a computer program. But then they require a tutor. Concerning notation, you might have noticed that the base block can be misused. With it, one can construct a normal function call. For example, sign of t. This notation should not be used. The correct notation is revealed by the parser. In the base block, the sign can be removed. But in the violet, it cannot. So the violet block is not in line with the list-by-deal that goes by the slogan code is data. We have already seen another such break in tradition when we had a look at algebraic expressions with infix notation. Again, the reason is that the notation should look as similar as possible to pen and paper. Coming from this complex topic about notation, I'd like to add a remark on Parsons' puzzles. As far as I know, CLJ tiles is the only environment using Lisp for those puzzles. A Google search leads to a Python implementation. The original paper by Parson at L is from 2006. It seems that from the beginning on, the idea was to arrange whole lines of code. Compared to the line-by-line approach, the use of Lisp offers a new vision. Parsons' puzzles in really two dimensions. And with this, Lisp offers a much faster space of possibilities to construct tutorials. A sophisticated possibility was the example just shown before. Because the puzzle showed a rather deep idea, it required a tutor to understand. It is important to note that a domain expert does not need to know how to program. The puzzle is already there and can be used as easily as writing formulas on the blackboard. Even more, I think the cognitive load is reduced by using puzzles instead of pen and paper sheets. This concludes our deep dive into puzzles that show the principles of functional physics. Let me come to a more higher-level overview of a specific physics example. At Clojure West 2017, Colin Smith showed the example of the driven pendulum. The demo is on his blog page. In the last chapters of CLJ tiles, the equations for the driven pendulum are developed puzzle by puzzle. I will give a brief overview of this example. It starts with a very simple workspace containing the definition of a freely moving particle. In the next steps, we introduce the kinetic energy and the gravitational force. This demo here is meant as a high-level overview, so I will not go into details. But all the workspaces have a description and a solution for further studies. As an intermediate result, we arrive at Newton's equations for a particle in the gravity field of the Earth. As a concrete example, think of a flying cannonball. Notice that the equation has two parts, because the ball can be shot forward and upward and anywhere in between those two main directions. In the next workspace, we make a pendulum out of the cannonball. We suspend it as a weight on a pivot. Thus, it now describes a swinging movement. This step is arguably the most difficult part to understand. Notice that Newton's equation now consists of only one part because the weight can only move at a fixed distance around the pivot. In the last step, we introduce the moving pivot and arrive at the final equation. This concludes my overview of the driven pendulum and we come to the summary of the talk. I presented examples in theoretical physics as a series of Parsons puzzles. Anyone can attempt to solve the puzzles just by opening a web browser. Puzzles help smooth the rough edges of lisp. CLJ tiles achieves this with the following features. Math formulas are presented in the commonly known infix notation. The various colors separate nested expressions and they do not start with parentheses. This combination is meant to resemble more the familiar math notation for functions. Higher order function calls have their own special block which takes only one argument. Evaluation of expressions is very easy using the inspect functionality. The indication of data types helps in understanding the various objects that populate physical theories. So, puzzles help to overcome the acceptance threshold for lisp. But lisp in turn augments puzzles. It really levels them into the second dimension. So, lecturers can present sophisticated examples that go way beyond beginner's tutorials. All in all, lisp and puzzles are a good match. For an outlook, I can only say that CLJ tiles was a private endeavor. I'd like to thank all the people who gave me advice and support. The dream is that CLJ tiles opens the door to lisp. A small crack into some of the physics classes that are traditionally based on pen and paper. Thank you for watching.