Pharos vision
Jun 5, 2020 16:54 · 1215 words · 6 minute read
In this session we’ll look at what Pharo is. It’s a pure object language. But it’s also an IDE, an integrated development environment. It’s inspired by Smalltalk. That’s its spiritual father. It’s a powerful and elegant language that’s fun to program. There’s a great community of people who do a variety of things with it. What we’ll try to teach you on this course, with the help of videos, is that it’s a living system you can script as you go.
00:31 - You can take Pharo with its MIT licence and do what you want with it. When I say that Pharo is elegant I have arguments to back that up. The syntax fits on a postcard and the simple and powerful object model takes up four lines. I’ll show you… On this slide you have the full Pharo syntax. I mean “full”, there’s nothing else. That doesn’t mean you can understand the syntax just by reading this slide.
01:01 - We’ll have several sessions, deciphering and helping you understand how the syntax is structured. But it gives you an idea of the work to be done. There’s nothing else but this syntax. Likewise, the object model is summed up on that slide. Everything is dynamically typed, everything is an object instance of a class, all methods are public virtual, all attributes are protected, and there’s single inheritance. There’s no boxing, no primitive and non-primitive type, no generic type, and so on. You have everything. You just saw the Pharo syntax and model.
01:40 - We’ll come back to that, but it’s just to give you an idea of the system’s complexity. You have to realise that Pharo is entirely written in itself. What do I mean by Pharo? I mean the strings, characters, booleans, IDE, compiler, sockets… Everything is written in Pharo. So if you master this syntax, written on one page, and this model, then you’ll have access to the entirety of Pharo. I think that this is exciting intellectually because you have this tiny entrance door into a gigantic world.
02:17 - So if you look at the title of this mooc, it includes the word “immersive”. Why is this? Because Pharo isn’t a blackbox. The entire system is fully inspectable, so you can go and see how it’s implemented. And Pharo is reflective. It has a representation of itself that you can use in order to understand it. This means you can get completely immersed in a world of objects. I like this metaphor of the fish tank. A language is usually a blackbox.
02:51 - Pharo isn’t a blackbox, it’s a fish tank, where you can see the objects and constituents of the system itself, but you can also dive into the tank and interact with the objects. So it’s really in that sense that we’re inviting you to play with Pharo. Here I’m showing you an example of an immersive system. What we call immersive or interactive. On the left you have the code. On the right, what it produces. Each time the programmer presses the compilation key, the screen goes blue and the result is on the right. He’s constantly modifying his code and seeing what he’s doing in the right-hand window.
03:40 - You can do this with any element of the system, whether it’s a socket, a file… 3D, like here. But a web server would be the same. The web server functions and you can modify it as you go. Now I’ll show you the supports available if you want to work Pharo outside this mooc. There are several books, all open source. There’s Pharo by Example, for beginners, in several languages. It’s currently being updated for Pharo 5. Deep into Pharo is more advanced, going into the libraries, into less-known aspects of the language and the tools.
04:25 - There’s Enterprise Pharo, a Web Perspective, which puts the emphasis on web libraries, like WebSockets, HTTP/HTTPS servers and templating. They’re all open source. What we’ll use mainly for this course is a web framework, Seaside. You have 300 pages available at the indicated address. You can read the book if you want to know more. But we’ll give you all you need to follow the mooc without having to read the book too.
04:58 - For those interested in other aspects, there’s this book of about 300 pages about the numerical methods in Pharo, going from things like statistical series, to iterative algorithms and clustering. I told you that Pharo is a system to learn from. I’ll give you a few illustrations. We’ll see them again in the videos. Every graphic element of Pharo that you click on… With Cmd+Shift+Option, you’ll get a little menu around the graphic element. By using these menus, you can go directly inside and manipulate the visual elements you’re dealing with.
05:46 - We’ll show you what an Inspector is, an object that lets you manipulate the properties of other objects, and start to implement them. We also have an object called a Finder. So I can ask the Finder to find all the system’s methods that contain the word “match”. It shows me a list, and I can access the method’s code directly. There’s also a tool called Spotter, which you get with Shift+Enter. And you tell it what you want. Spotter will help you find classes, methods or resources. You’ll have videos to explain all that.
06:22 - But, again, Spotter is written in Pharo itself. The Finder has quite a nice function, when you start learning Pharo. There’ll be a video about this too. You can give examples and say: “This is what I want to do but I don’t know how to write it in Pharo.” The Finder will look for methods. I have an example. I say: “I have two strings, AB and C. I’d like to concatenate them.” And I know that the result should be the string ABC. It sounds simple. So I say to the system: “Give me the message, if one exists, “which will let me concatenate these strings.” And that’s what you can see here.
07:08 - It says “,” is a method implemented in SequencableCollection. This will be sent to my first string, and I’ll get my third string. You’ll be able to use this Finder on examples, to make you quicker in Pharo. In this Mooc we’ll talk about object oriented design, which is part of the DNA of Pharo. People who program in Pharo think OO in an elegant way. I’ll show you the exercises we’ll be presenting. We’re often asked how not is implemented. People often wonder if this is an interesting question. It is interesting because fundamental rules result from it. It’ll be part of the exercise. Once you have Pharo and you see how not is implemented, you’ll start thinking in a different way. This really is part of the culture of people who use Pharo: to think a design in a really elegant way.
08:08 - You can install Pharo as described on the Pharo website. Of course, during the MOOC and on the FUN site, you’ll get all the instructions for installing Pharo on any system. Pharo is very easy to install, as a drag and drop, onto any OS. .