by nudpiedo · 7y ago · 0 comments
Every time I look at a programming language, and at the HN it is every second day, I think about what kind of problems can it solve, and for what kind of platforms these compile/run their runtimes.. and surprisingly not many programming languages inform properly about the most basic feature, and prefer to go deeper into their.
Pharo runs in a VM that's compiled to C and runs as a stand-alone native application on Linux, Mac, Windows. You can also build from source but most people don't and there are some rough edges. There are plenty of libraries and mechanisms for connecting to the rest of the world e.g. subprocesses, sockets, FFI, and libraries built on those.
My favourite computer science paper of all time is about how they develop this virtual machine. https://news.ycombinator.com/item?id=12577087
For deployment, you can run it headless.
You can also deploy as Javascript for Node/Browsers via a tool called PharoJS (http://pharojs.org - full disclosure, I'm one of the principals of PharoJS), but it's a work in progress (with a Slack workspace to support it).
GNU Smalltalk can deploy to a standard executable, so you could do most development in Pharo, and then switch to GNU Smalltalk, but you'd lose the fabulous IDE.
For Common Lisp there are/were many integrated IDEs: Macintosh Common Lisp, Allegro CL, LispWorks, Clozure CL on the Mac, Corman Lisp on Windows upto McCLIM for several CL implementations. A general difference to Pharo is usually that these CL IDEs use mostly native user interfaces. Pharo comes with its own user interface, graphics, window system, display code, event handling, ... Example: Pharo windows on a Mac are not Mac windows. Clozure CL windows on the Mac are Cocoa windows. Similar: most CL systems use native code.
The real commercial Smalltalk machines were underpowered compared to some of the Lisp Machines - for example those from Symbolics - but those were also quite a bit more expensive. It was possible to spend more than $100k for a Symbolics Lisp Machine with accelerated color graphics and HDTV in/out.
The main difference of Pharo with integrated Lisp environments:
1) Pharo uses portable system independent images. Most Lisp systems uses system (OS / architecture) specific images, since code is natively compiled.
2) Pharo code is not native AOT compiled, IIRC. Common Lisp is either source interpreted or AOT compiled - some are even AOT compiled only - with incremental AOT runtime compiler.
3) Pharo uses its own user interface & gui system. Most Common Lisp systems use a native backend for their GUI. Recent exception is Mezzano, which a CL on the metal, which comes with its own GUI.
4) Pharo/Smalltalk usually manages and tracks source code for the user. Most CL IDEs use files and the user works with files and systems of files. CL then more or less tracks the code in these files.
5) Pharo offers to save state in an image between sessions - Lisp systems use that mostly on demand and less as a session state mechanism. LispWorks has some support for sessions.
You can, with a bit of effort, get OpenGenera running on a Linux VM and display on a modern X server. There are a few patches needed due to recent X server changes, or just run an Ubuntu from a dozen years ago on metal.
The trouble is that what you are dealing with is a graphical interactive programming environment. Sure, you can run it from the command line like /bin/perl, but to understand what you are dealing with you have to open it up and try it on its own terms.
If you aren't interested in a novel immersive programming environment then you can safely ignore Pharo too.
I was curious and so downloaded and ran the default image, and I'm beyond captivated by it, but I have to agree that neither the link nor the homepage do a good job of enticing me to do so, or even hinting and what can I expect.
If I didn't feel like setting up and checking out random projects I stumble upon, I would have never even seen what Pharo is about, given the abundance of marginally different programming languages that pop up on HN.
So yeah, I also think Pharo's best "Hello, World" is just opening it and trying out stuff, but maybe it should try to sell itself, at least a little, for the uninitiated?
Guessing this is a hard problem. People have been working on marketing Smalltalk for almost 50 years now. If there were an easy solution I reckon they'd have found it by now :)
Maybe lots of little gifs?
Then try these one-liners in the Playground... https://medium.com/concerning-pharo/elegant-pharo-code-bb590....
Then (and I know its a video) but maybe serverless PharoLambda would interest you... https://www.youtube.com/watch?v=YUbd0-FX6pI
The question is not about a Pharo commandline that exists as part of the Pharo GUI.
The question is about an OS commandline like "GNOME Terminal" with stdio.
I kind of like these systems because they remind me of when computers were weird and different and had legitimate tradeoffs. People’s expectations of computers were still rooted in a physical model of interacting with the world. Computers were still very much trying to prove that they were relevant to the “real world.”
COMMAND LINE:
/opt/src/vw8.3pul/bin/visual nbody.vw_run.im -nogui -evaluate "BenchmarksGame program" -a 50000000
PROGRAM OUTPUT:
-0.169075164
-0.169059907
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...https://i.imgur.com/JwgJ66z.png
You create a new image and then start piecing things together from there. GNU Smalltalk is probably what you want if you want to stick to the CLI. That said, it's not exactly a representative example when you want the same program that prints to stdout or something.
I'm curious to know about this aspect of it because my first step after the hello world is usually to figure out how to host the thing.
Edit: this would be more useful: https://stackoverflow.com/a/17259369
That said, Smalltalk isn't something you use from the commandline typically, or only during deployment or for applying external automation. The GUI environment is fairly key.
The website front page does not show a Pharo program being invoked from the OS command-line and using stdio.
""" $ curl https://get.pharo.org | bash $ ./pharo Pharo.image eval "42 factorial" """
$ curl https://get.pharo.org | bash
$ ./pharo Pharo.image eval "42 factorial"You can load and run a smalltalk source file, at the OS command-line, something like —
./pharo Pharo.image st helloworld.st
You can pre-load smalltalk source files, save a memory image, and use default startup behavior to run the saved bytecode — ./pharo helloworld.image
> deploy that to another machineIt's just moving files (VM + bytecode image) so — rsync, ssh
also a hello world will never ever give you any idea about smalltalk/pharo.
don't be impatient, this is a system worth playing with, it's quite ~amazing.
I finally found out that the magic invocation was to open up a window by clicking on the background, and navigating to Tools -> Playground, and running `Profstef go.` But they certainly didn't make it easy.
[0] https://ci.inria.fr/pharo-contribution/job/UpdatedPharoByExa...
Run PharoLauncher and Load a Pharo image instance.
Once the Pharo Desktop IDE appears type CTRL+O+T to open Transcript - the system log console abnd type CTRL+O+W to open playground - Playground is a window into which you can type. It can be used for any purpose, but is most often used for typing Pharo expressions and equickly executing them.
(There are windows /icon menu entries for these as well)
In playground window type:
Transcript show: 'Hello World'
and press the play 'do it' icon at the top of the playground window to evaluate itYou should now see Hello World appear in the transcript window.
What you just did was send the Transcript objects show method the message 'Hello World'
Lets do a slightly more complex Cut and paste the following code into the Playground window and click the play button. The first part installs the Roassal visualization framework. It only needs to be run once. The second part uses ROassal's Mondrian API which offers facilities to describe and render graphs. Mondrian allows mapping of metric values and properties into visual dimensions, such as shape and colors. Cut and paste the second piece of code into playground and hit play doit icon to evaluate. In the view panel you should see a simple tree class browser of the installed classes in the Pharo image with size of class coloured and scaled to represent number of source code lines in each class. Note lines in speach marks are comments.
"-------------------------------------"
"install Roassal visualization engine"
"-------------------------------------"
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Roassal2';
configurationOf: 'Roassal2'; loadStable.
"---------------------------------------------------""- Make a Simple interactiver Class Tree Browser -"
"---------------------------------------------------"
myBrowser := RTMondrian new.
myBrowser nodes: Collection withAllSubclasses.
myBrowser edges connectFrom: #superclass.
myBrowser normalizer
normalizeSize: #numberOfMethods;
normalizeColor: #numberOfLinesOfCode.
myBrowser layout tree.myBrowser
Traditionally Pharo could only create standalone applications, but the minheadless builds are making good progress on stripping the windowing code to facilitate it being embeddable.
A platform specific VM runs on Windows, Linux, OSX. All those VMs run a single application binary.
Does it compile to other platforms? Binary code, compile to C, to LLVM? Does it compile to other VMs like Java and it is compatible with javascript engines? For me this is a basic aspect of a language.
One of the peculiarity of Pharo (and Smalltalk) is that when you shutdown the system, you can persist the whole system on disk (called "the image"). Next time you open it, you start exactly where you left.
All the development tools are mixed with your code. There is no differences between the coding time and runtime (i.e., you code at runtime). If you are familiar with IRB in Ruby, imagine a GUI running in IRB.
This means that it is hard to see the limit between your code and Pharo's code. Pharo 7 seems to bring a bootstrap process where you can build images from scratch. This is an interesting evolution that will vastly improve the development/reproducability/deployment story.
Please don't complain about downvotes, especially not within the first 23 minutes. It's common to receive one random downvote and a couple more piling on, but given a few hours a decent comment will be back in the black.
As far as I understand it: it doesn't necessarily compile in that sense. You are constructing an 'image', which is basically a living environment that your program runs in, and maybe it corresponds somewhat to a VM. But you're not really treating the code that the VM runs as separate to the VM itself.
In some sense I think you might map it to something like a Lisp machine, where you can interact with a running program and its state through a REPL.
Someone more knowledgeable might be able to elaborate on that (or correct the misunderstandings), but it felt worth offering something other than a straight up dismissal of your question.
This is indeed similar to Common Lisp and Emacs.
Back to the original question: the VM runs on Windows/Mac/Linux and on some IoT devices. The code is compiled to bytecode which can then be JIT compiled further on some architectures/OSes. The compiler and the whole infrastructure is exposed and available on runtime.
Pharo has classes for easy FFI to C and for bundling native libraries. I don't know if it's possible to call back from C to Pharo, but I assume yes (many libraries require this). There is no FFI or other integration with any other language (at least as a built-in, there are RPC interfaces for some langs as add-on packages).
As for "standalone binaries" - almost, as you need to bundle the VM with the image; there are some helper scripts for bundling and then launching images.
The most obvious use case is GUI programming, there's also old-school Web programming with Seaside, data crunching and visualization with Roassal. Other than these killer-apps, Pharo is just as capable as any other high-level language, although with a much smaller selection of libraries available.
Another difference might be that most image-based Common Lisp implementations don't use portable byte-code. Some are using byte-code engines, but those are usually not portable across operating systems and/or machine architectures.