
Penrose: create diagrams by typing mathematical notation in plain text - mathgenius
http://penrose.ink/
======
buckminster
It's a bit weird to name a project after a living person without mentioning
them or the motivation for the name.

~~~
escherplex
I was curious about that as well. With the project name _Penrose_ there was a
suspicion (more like a wish) that _maybe_ this was to be prototype work for an
interactive digital rendering of the Roger Penrose _Road to Reality_ physics
tome but a quick poke-around of project members bios turned up no personal
linkage to Penrose. Just happened to listen to Penrose at Princeton when he
promoting that book about 15 years ago.

------
andrepd
WOW! This is an amazing idea and an amazing implementation. Reading the intro
paper [1] and checking the example [2] made me eager to try this. If this can
indeed be successfully worked into a tool for the "laymen" (in computers and
drawing, that is, not in the domains in question) what an great tool it will
be!

[1]
[http://penrose.ink/PenroseIntro2018.pdf](http://penrose.ink/PenroseIntro2018.pdf)

[2] [https://github.com/penrose/penrose](https://github.com/penrose/penrose)

------
stevekrouse
I'm so inspired by this vision. I'm excited to interview creator Katherine Ye
[1] on my podcast [2] later this month!

[1] [https://www.cs.cmu.edu/~kqy/](https://www.cs.cmu.edu/~kqy/)

[2] [https://futureofcoding.org](https://futureofcoding.org)

------
kragen
Has anybody tried both Penrose and TikZ? How do they compare?

~~~
mkl
Penrose currently seems to be a very limited work in progress. Such comparison
will have to wait.

However, in the few Penrose examples shown, all the positioning seems to be
done completely automatically, which is _incredibly_ difficult to make work in
all but the simplest and most standardised situations. In TikZ most
positioning is manual, which takes more effort, but which I think is likely to
produce better results in general.

~~~
JAldrichCMU
Yes, automatic positioning is the goal, and one of the key differences vs.
TikZ (the other being a separation of substance--the math--from style--the
graphical representation). It's difficult, which is why there is real graphics
research in the project.

Penrose enables the user to tweak the diagram manually after it is produced.
Constraint solving continues to apply during the tweaking so that if you grab
a shape, then things attached to it will move as well. Our goal is to get end
results as good as, or better than, TikZ, while staying at a higher level of
abstraction.

~~~
mkl
How deterministic will the results be? One advantage of programmatic systems
is that because they don't try to be smart, you know exactly what you're going
to get, and e.g. upgrading the system won't move things.

Another is that tracking changes with version control systems is easy and
clear. Does Penrose have a canonical textual format that changes minimally as
tweaks are made?

TikZ styles do let you separate substance and style fairly well (though lay
users are unlikely to take full advantage).

~~~
JAldrichCMU
We could make things deterministic by fixing the algorithms and a random seed,
and/or by fully constraining every object in the diagram so randomness is not
used. But that isn't using the real strengths of Penrose, so we expect it to
be a secondary use case at best.

One way to think about the goal of Penrose is that you will get a result that
is predictably good, and you can constrain it to get a diagram of a particular
shape if you want to, or alternatively leave it open and have the solver show
you 3 good diagrams...then you can pick one and tweak it further (aided by
constraint solving as you tweak) to make it great. The problem with drawing-
tool style systems is that you have to adjust the location of every label (for
example); that's the kind of thing that should be solved for you. TikZ doesn't
have a rich constraint language and solver, so in many circumstances you're
left with a choice between doing lots of things manually or getting a poor-
quality diagram.

Penrose will have a canonical textual format, but as it is under active
development, it wouldn't make sense to say it has a stable textual format now.

------
georgeam
It would also be helpful to see a comparison to tools like asymptote:

[https://en.wikipedia.org/wiki/Asymptote_(vector_graphics_lan...](https://en.wikipedia.org/wiki/Asymptote_\(vector_graphics_language\))

~~~
JAldrichCMU
With Asymptote you specify diagrams directly in terms of low-level graphics
primitives and constraints. With Penrose you specify the underlying math, then
one or more separate style files are used to automatically generate diagrams
based on the math. The typical user of Penrose doesn't have to know anything
about graphics, and never specifies any graphical objects; instead, that
knowledge is in reusable style files written by domain experts.

------
platz
> the PENROSE pipeline is designed to be end-to-end differentiable

------
amelius
Upon quick glance, it seems limited to diagrams in the field of linear algebra
and perhaps a few related fields. Is this correct? How broadly is it
applicable?

(I'm still hoping for a tool that can make flowcharts with user-defined
constraints, such as minimize number of edge crossings, then minimize total
edge lengths, etc.)

~~~
andrepd
From their paper, it seems you can write a 'style' file for anything you can
possibly want. Users then write the declarative code you see which Penrose
interprets with respect to that 'style' file to know what to actually do.

~~~
philsnow
this is the exciting part to me; is there any constraint that the output has
to be a 2-dimensional figure? I could imagine a style file that outputs a
blender scene with a time dimension, or a VR scene that you can interact with
in the same way they describe dragging one of the vector heads and having it
recalculate the rest of the model.

------
yosefzeev
It looks neat, although the installer side of it looks to still be messy
enough to warrant my waiting a bit before installing it in linux.

~~~
gerdesj
Yes it is a bit of a palava to get running but you can get it running straight
out of eg ~/src/ with $ git clone
[https://https://github.com/penrose/penrose.git](https://https://github.com/penrose/penrose.git).
Follow [https://github.com/penrose/penrose/wiki/Building-and-
running](https://github.com/penrose/penrose/wiki/Building-and-running) I use
Arch Linux but I'm sure no one will hold that against me (package names like
_this_ ):

You will need a JDK (I installed _jdk8-openjdk_ ) to get a javac (needed when
you run make in src). You may also need _ghc_ for Haskell although the thing
seems to install another one locally. I installed _stack_ and then _happy_ and
then "stack build" finished OK. alias
runpenrose=</very/long/path/in/home/bin/penrose>. Substitute "python -m
http.server" for "python -m SimpleHTTPServer" because Python3 and the rest of
the example works OK.

Simples 8)

------
Koshkin
Neat; now I am left wondering if this could be also implemented as applying a
sty.xsl to a sub.xml in order to get an SVG.

~~~
dan-robertson
Well xsl does not include interactivity, and it’s functions are not much fun.
So I’m not really sure anyone of sound mind would want to implement a
nonlinear constraint optimiser in xslt.

~~~
andrewflnr
You can use XSL to generate code to which javascript is later attached. I did
that a couple times when I was young and foolish. Also, SVG supports JS
natively, I believe.

That's not to say I would recommend it. No objection to your other points.

------
equalunique
Great Haskell project!

------
torbjorn
Cool! Kinda like d3 but without javascript.

------
brian_herman__
Why use this instead of latex?

~~~
MrEldritch
LaTeX is for _type_ setting and notation, which it's quite good at. On the
other hand, designing, laying out, and constructing pretty _diagrams_ in LaTeX
is very much NOT where LaTeX shines.

~~~
mkl
TikZ is good for pretty diagrams, and is entirely contained within (built
with) LaTeX.

~~~
alanbernstein
TikZ creates pretty diagrams. I've had partial success using it, with my
beginner-level LaTeX knowledge. I'm not convinced that it's possible to become
comfortable with TikZ syntax, without hundreds of hours of LaTeX experience.
I'd love to be proven wrong, of course.

~~~
abdullahkhalids
I have had thousands of hours of experience with latex and dozens with tikz. I
still struggle with it. Its just that Latex has terrible syntax for function
declaration, loops and conditionals and tikz inherits all these problems. My
workflow is usually to go to
[http://www.texample.net/tikz/examples/](http://www.texample.net/tikz/examples/)
a lot and use the examples as reference code to whatever I am doing.

The manual for tikz exists but I have never really read it.

~~~
alanbernstein
That's reassuring, if unfortunate. Thanks.

