spotifyovercastrssapple-podcasts

elm-visualization with Jakub Hampl

Jakub Hampl joins us to discuss elm-visualization and how it enables powerful flexibility through its low-level building blocks philosophy.
October 23, 2023
#93

Transcript

[00:00:00]
Hello, Jeroen.
[00:00:01]
Hello, Dillon.
[00:00:02]
Well, I think we've been plotting to have an episode on this topic for a while, but
[00:00:08]
maybe we just weren't doing a good enough job visualizing the episode happening.
[00:00:12]
But we're finally here.
[00:00:14]
We're finally here to talk about Elm visualization.
[00:00:18]
And joining us, we've got Jakob Humphel.
[00:00:20]
Welcome, Jakob.
[00:00:21]
Thanks.
[00:00:22]
Pleased to be here.
[00:00:23]
Yeah, pleasure to have you.
[00:00:25]
So Jakob, help us visualize this package a little bit.
[00:00:31]
What is Elm visualization in a nutshell?
[00:00:34]
What the heck is it?
[00:00:35]
So Elm visualization in a really small nutshell is a package that allows you to do data visualization,
[00:00:42]
to draw charts, graphs, whatever you want to call it.
[00:00:45]
In a slightly bigger nutshell, you can think of it as a toolbox full of different little
[00:00:54]
pieces that do each a fairly specific job.
[00:00:59]
Usually things like data transformation into different things that you can use to build
[00:01:04]
your own data visualization.
[00:01:06]
So it's not a predefined set of visualizations that you have to pick and somehow customize.
[00:01:12]
It's tools to build whatever it is you want to build.
[00:01:17]
So it's in that sense, I call it a toolbox rather than, you know, a library or something
[00:01:22]
like that.
[00:01:23]
Right.
[00:01:24]
Yeah.
[00:01:25]
You know, a lot of frameworks have this motto to make simple things easy and hard things
[00:01:31]
possible.
[00:01:32]
But in your docs for Elm visualization, which we'll drop a link to this Markdown document
[00:01:39]
you have a little tutorial on, you kind of say something that's almost the opposite.
[00:01:43]
You say that making a simple visualization will have a large amount of code and making
[00:01:50]
a complex or unusual visualization won't really have that much more code than the simple visualization.
[00:01:56]
So it seems like this low level building blocks philosophy is like a really unique part of
[00:02:02]
this package.
[00:02:03]
Yeah, that's right.
[00:02:04]
And that comes somewhat from experience, you know, because I've worked in a bunch of companies
[00:02:10]
where you start, you start building, you know, your MVP, and you take a charting library,
[00:02:16]
and you're going to be like, okay, we're going to do a bar chart.
[00:02:20]
And so you plot the bar chart, and then somebody comes in and like, well, we need to categorize
[00:02:23]
by this other thing.
[00:02:25]
So let's do some colors.
[00:02:27]
And you're like, okay, and the designer comes in and is like, well, I don't want those colors.
[00:02:31]
I want these gradients.
[00:02:32]
And you're like, okay, that's like, suddenly now my config is like 500 lines.
[00:02:38]
And I'm like, but I want December to be like twice as big as the other months.
[00:02:42]
And you're like, Oh, I don't think it supports that.
[00:02:45]
Okay, I just have to monkey patch this thing.
[00:02:48]
And like, suddenly, your chart is like 5000 lines of JSON.
[00:02:53]
And you know, it's still a bar chart.
[00:02:56]
It's not fundamentally more complicated than any bar chart.
[00:03:00]
But after everyone's done their little specific thing they want, you know, you've you've tweaked
[00:03:06]
literally every knob the library you were using exposed.
[00:03:10]
And this is a real story.
[00:03:11]
This totally happened to me in my first job.
[00:03:13]
So the own vision philosophy is more like, look, you're going to build a bar chart, whether
[00:03:19]
you like it or not, from from the smaller blocks.
[00:03:23]
But that means when that guy comes and says we want gradients instead of colors, well,
[00:03:27]
you're controlling the rendering.
[00:03:29]
So you've already wrote the SVG code that renders the colors, you can just as easily
[00:03:34]
switching gradients, you control the sizes.
[00:03:37]
So you can make it twice as big if you want, you can do whatever you want.
[00:03:41]
They will don't want it in a line, they want a circle, just pop in this extra helper that
[00:03:46]
transforms coordinates, and you're ready to go.
[00:03:48]
So that's kind of the that's, that's really behind this philosophy.
[00:03:52]
And it's in some ways, you could say it's not beginner friendly, it has.
[00:03:59]
And that's kind of, that's kind of the downside here, right?
[00:04:01]
Is that like, even that tutorial that you mentioned, it's fairly lengthy.
[00:04:06]
And it sort of has like, oh, by the way, before you start, you should learn these three things.
[00:04:11]
And yeah, all of those three things are kind of big things.
[00:04:14]
So you have to learn Elm and statistics and SVG, which is not a tiny thing to understand.
[00:04:25]
So like, but, you know, I think, once you've done that, you've already paid the price,
[00:04:30]
and then you get this flexibility to do basically anything, you know, suddenly the ceiling isn't
[00:04:35]
there.
[00:04:36]
So it's, I think, for a lot of use cases, it's definitely a worthwhile price to pay,
[00:04:41]
but it's not for necessarily every use case.
[00:04:44]
But then again, we have other packages in the Elm ecosystem that maybe slot better into
[00:04:49]
some of those other use cases.
[00:04:51]
So there's, you know, a bit of a, I think, you know, you can find it, you're not like
[00:04:57]
stuck if you don't want to pay this price.
[00:04:59]
Yeah, you're never gonna go to your boss saying like, oh, that feature they requested for
[00:05:04]
this visualization, like we can't do that this library doesn't support it, we would
[00:05:09]
have to switch to another charting library that that would cost a lot of time and effort.
[00:05:16]
So we're just gonna not gonna do it or spend a few months working on it, or how long that
[00:05:21]
takes.
[00:05:22]
So yeah, that is quite nice.
[00:05:23]
Yeah, I could see myself if I was building something where like data visualization and
[00:05:29]
charts wasn't like a huge core part of the product, but it's like we need a little chart
[00:05:37]
here.
[00:05:38]
It's not like it's just like a little dashboard with a couple of things that we want to make
[00:05:42]
a little more visual.
[00:05:44]
And maybe just throw in Elm charts, Teresa's great package for that.
[00:05:48]
It's gonna look really visually pleasing without you having to fiddle with a lot of stuff.
[00:05:54]
You don't really have to like dig into SVG and all these things, and maybe that's just
[00:06:00]
good enough, because you never really need to customize that much.
[00:06:03]
But if it's like, we're building a product where the backbone of the product is data
[00:06:08]
visualization, maybe you start immediately with Elm visualization, because you know,
[00:06:13]
you're going to need to customize every part of it.
[00:06:15]
Also, I mean, the thing is that learning is, you know, learning some of these skills is
[00:06:21]
a thing that isn't necessarily an investment that is just related to one particular project.
[00:06:28]
Like, if you learn SVG, you're going to benefit from that in this project, but also the next
[00:06:35]
project and the project after that, you know, and you're going to be even able to be hired
[00:06:40]
on a project that maybe if you hadn't learned it, you wouldn't be and so on.
[00:06:44]
So it's just there is also an element there that, you know, because we're, it's not like
[00:06:49]
these skills that are prerequisites are like, some really specific API that you'll never
[00:06:55]
use for anything else.
[00:06:57]
Again, you know, these are good things to know, if you want to have a front end career,
[00:07:02]
let's say, you know, that they'll come in handy.
[00:07:04]
Like, so I think it's, you have to consider it from that perspective as well.
[00:07:09]
Yeah, that's, that's a great way to look at it.
[00:07:13]
So I hadn't used Elm visualization before, but going through this tutorial, I think it's
[00:07:20]
really cool how it does look like SVG with a few high level helpers.
[00:07:27]
And so it makes me think of like, like people sometimes describe a framework as being don't
[00:07:34]
call us, we'll call you like you sort of pass in code for the framework to call and it wires
[00:07:40]
everything together, and then a library is the opposite.
[00:07:44]
It's like you call the function when you want to use it.
[00:07:47]
This is much more that library approach of like, you're making SVG, but then you have
[00:07:53]
a little helper that helps you draw your axes and things like that.
[00:07:57]
So you're really just making SVG and there are a few little helpers that help you do
[00:08:03]
things in a more high level way and give you some abstractions to work with that.
[00:08:07]
That's exactly right.
[00:08:08]
That that's, and I guess that's also one of the big features that I am really, I really
[00:08:14]
insist on is that it's an optional library, which I mean, if you don't like the way Elm
[00:08:21]
visualization does something, you're not locked into it.
[00:08:24]
You can replace like, you don't like the way our axes look out of the box.
[00:08:29]
There's some knobs you can customize, but like, there's nothing, it's just SVGs, or
[00:08:34]
you can just pop in your own implementation, and in fact, you can drop into some lower
[00:08:39]
level functionality we provide to help you build those.
[00:08:43]
And also the modules, and so to get a little bit into some internals, the modules in Elm
[00:08:50]
visualization are also only depend on each other through their public APIs.
[00:08:57]
So that means that if you don't like the way one of the modules work, you can just literally
[00:09:03]
copy paste its code, pop it into your project and mess with it.
[00:09:07]
And you don't have to copy paste the entirety of Elm visualization because there's some
[00:09:11]
like internal package dependencies, there aren't any.
[00:09:15]
So each module is kind of standalone.
[00:09:18]
If it depends on the other ones, it's just through the same API that you as the user
[00:09:22]
have access to.
[00:09:23]
So that's another axis of customization that you can do with this project, I guess.
[00:09:29]
So that's what I mean by it should be always like optional is, you know, if you if these
[00:09:34]
helpers are helpful, by all means use them.
[00:09:37]
If they're not, you can replace them.
[00:09:39]
I have to say actually, like this, this conversation for me is very helpful.
[00:09:44]
Because like in the past, I have to admit, I haven't really had a huge need for visualization
[00:09:51]
tools in the Elm work I've done in the past.
[00:09:53]
So I haven't like deeply researched visualization packages, but just when I've been browsing
[00:10:01]
through packages that pop up and I see Elm visualization, like I've seen your visualization
[00:10:06]
gallery and that I'm like, wow, this is impressive.
[00:10:11]
Like there are a lot of things you can do.
[00:10:13]
It seems very powerful.
[00:10:16]
But then when I look at the API, I just didn't quite know how to how to frame it.
[00:10:22]
So this conversation is really helpful to like, understand why these design decisions
[00:10:27]
were made this way.
[00:10:28]
Yeah, I think I think that was a bit, that was a big piece that we were missing for a
[00:10:33]
while.
[00:10:34]
And it's, it's one of the reasons I released this tutorial recently.
[00:10:39]
Because my one of my aims is a little bit to bridge that gap between the API seems to
[00:10:45]
be these low level things.
[00:10:48]
And then you have the examples which show you often like interesting graphics.
[00:10:53]
And it's a little bit, you know, that meme with how to draw the owl where like the first
[00:10:58]
frame is like an oval and then the third frame is the length thing.
[00:11:02]
You know, the middle says just draw the, draw the, draw the owl, draw the rest.
[00:11:07]
So like, I think we were a little bit in that.
[00:11:10]
So I think the tutorial is trying to like slightly connect how to think about from,
[00:11:16]
you know, these smaller bits, how to get to something bigger.
[00:11:19]
What are the mental models you should have on connecting these things?
[00:11:22]
And what kind of things we, you know, Visual Studio expects you to do, what kind of things
[00:11:26]
it can bring to the table and how that's going to work.
[00:11:30]
So I don't know if it succeeds in that.
[00:11:31]
But that's sort of one of the my motivations for kind of writing it.
[00:11:35]
Because I also felt that there was a little bit of a that disconnect.
[00:11:38]
Yeah, that tutorial is very helpful, I think, because if you as great as as the Elm package
[00:11:44]
docs setup is, and as great as like your galleries, those are two good pieces, like, but the package
[00:11:50]
docs are reference.
[00:11:52]
And for this, I think you really need like a conceptual guide that walks you through
[00:11:57]
how to think about it and how to set up these basic charts.
[00:12:00]
So very helpful.
[00:12:02]
So maybe we can, like walk through like, what would some of those building blocks that you
[00:12:09]
would use to have these sort of higher level helpers that you use within your SVG builder
[00:12:16]
to do something very simple, like a like a bar chart, for example, like, what would be
[00:12:22]
those abstractions that Elm visualization gives you that you would use to make a simple
[00:12:27]
bar chart?
[00:12:28]
I think the most fundamental abstraction that is used extremely commonly, not 100% of the
[00:12:36]
time, but it's sort of the bread and butter of working with Elm visualization is, is what
[00:12:41]
we call the scale.
[00:12:43]
And you can think of the scale as a way of on the one side, you have your data, which
[00:12:49]
is you can think of it as it occupies some abstract space, you know, let's say, it's
[00:12:55]
speed.
[00:12:56]
So you know, it's this actually from like zero kilometers per hour to, you know, whatever,
[00:13:01]
500 kilometers per hour, if you have really fast cars, I don't know.
[00:13:05]
And like, on the other side, you want to show it on the screen as let's say bars, so they're
[00:13:10]
going to be a certain number of pixels long.
[00:13:14]
And so you need some relationship that can transform between these two different abstract
[00:13:21]
spaces, right?
[00:13:22]
And that's the job of the scale.
[00:13:23]
So the scale encodes is usually most of the scales are bidirectional.
[00:13:28]
So you can go from from one, one space to the other and back.
[00:13:33]
But they also encode in them a lot of the common operation.
[00:13:36]
So like a common operation is you want to show what we call ticks.
[00:13:41]
So you can think of it on an axis.
[00:13:43]
There's those little lines at the bottom with the numbers.
[00:13:46]
That's what we would roughly call ticks.
[00:13:48]
Ticks are funny, because you want them to be roughly evenly spaced, but you also want
[00:13:53]
them to be like human readable.
[00:13:55]
So you don't really want them to have like 25 decimal places.
[00:13:59]
So you would like them to kind of land on nice even values.
[00:14:02]
So there's a fair amount of logic, you know, to do all that stuff.
[00:14:06]
And you kind of get that sort of stuff packaged in this little scale type.
[00:14:11]
And so really what you would do for something like a bar chart is you would pick a scale
[00:14:15]
for the x axis, you would pick a different scale for the y axis.
[00:14:20]
And this gives you kind of an immediate way how to kind of construct a rectangle, right?
[00:14:25]
Because you can then in SVG, you can say a rectangle should have, it has to start at
[00:14:29]
x or x position, it's so much wide, starts at a y position, so much, so much, it has
[00:14:35]
such a height.
[00:14:37]
And both of those numbers you can get from the axes.
[00:14:40]
And then, you know, you just pick some colors and you're mostly, you've got the core of
[00:14:45]
the chart ready.
[00:14:46]
And then you can add extra stuff.
[00:14:47]
So the scales kind of tie on nicely to axes, which is kind of, axes are almost actually
[00:14:53]
in a typical element of visualization, because they're one of the only things that actually
[00:14:58]
gives you, doesn't give you back data, it just gives you actual SVG.
[00:15:02]
But axes are just so common in data visualization that programming them always from scratch
[00:15:07]
is annoying.
[00:15:09]
So then you can take your scale, plop it into the axes, and it will, you know, actually
[00:15:13]
draw the little line with the little ticks and format the little labels and stuff like
[00:15:18]
that.
[00:15:20]
And then just to polish it off, you probably need to put it into actual SVG, add some,
[00:15:24]
maybe some transforms to get stuff aligned nicely, and you're basically done.
[00:15:29]
So that's kind of how those two primitives work to make a very simple chart.
[00:15:35]
Right.
[00:15:36]
And it basically, yeah, and it doesn't necessarily, visualization doesn't really have a strong
[00:15:42]
opinion on how your data is going to be structured.
[00:15:45]
So like, if we were doing a bar chart of Elm Radio episodes, and the popularity of an episode
[00:15:54]
and the date of an episode.
[00:15:55]
So you know, if we have a record that's like, you know, popularity, and episode title and
[00:16:02]
episode date, and that's just a record, a list of records of that type, you know, I
[00:16:08]
mean, or it could be whatever type, Elm visualization doesn't really care because we're going to
[00:16:14]
be the ones writing some code that's going to be doing a list.map and rendering some
[00:16:20]
SVG element for each of those that's going to render the bar.
[00:16:25]
So Elm visualization isn't involved yet, when we're just rendering an SVG element.
[00:16:31]
It's involved when we are rendering SVG attributes.
[00:16:35]
And now it's going to help us for the height of it.
[00:16:40]
To write, yeah, to basically calculate like the pixels, given a scale that we have.
[00:16:47]
Yeah.
[00:16:48]
And that's kind of one of the somewhat, I guess, unusual design philosophies of Elm
[00:16:54]
visualization is that it tries fairly hard, doesn't always succeed, but it generally tries
[00:17:00]
fairly hard to be as unopinionated about the data structure that you want to use, let you
[00:17:07]
do that, which, you know, gives you that flexibility.
[00:17:11]
It's up to you how to deal with how you want to fetch and store and deal with your data.
[00:17:16]
So sometimes it's a tough job for me sometimes as an API designer to actually pull that off
[00:17:25]
because we don't have a huge amount like polymorphism and stuff like that in Elm.
[00:17:29]
So sometimes you have to make a choice and you just get on with it.
[00:17:35]
But in general, the aim is to keep that as flexible as possible.
[00:17:40]
I'm guessing in most cases, you want the user to use their data and to convert them to later
[00:17:46]
lists, Elm lists, or do you take other kinds of types as well?
[00:17:52]
Ideally, we don't care.
[00:17:54]
So for things like scales, we don't really need to see your data at all.
[00:18:01]
We just need to see a datum.
[00:18:03]
I mean, what I mean by that, like if you, for instance, if you want to store your data
[00:18:07]
as a list of records, and then you want to visualize like a particular field in that
[00:18:12]
field, like a scale only cares about that number in that field.
[00:18:16]
It doesn't care if you store a list, store it in an array, if you store it in a record
[00:18:21]
of arrays, it's really up to you how you want to structure your data.
[00:18:25]
If you store it in a tree, it's not really...
[00:18:29]
Now that's not always the case.
[00:18:32]
In some cases, we do need more of that.
[00:18:37]
And in that case, we sort of force your hand into some data structure and then you potentially
[00:18:42]
need to write a conversion function or something like that.
[00:18:45]
But the aim is to not do that if possible.
[00:18:48]
Did you have any influences for this approach?
[00:18:51]
Like one thing that comes to mind for me is D3, which is I think known for like it's extremely
[00:19:00]
popular and yet it's pretty low level, which is kind of interesting, but it's like a powerful
[00:19:05]
set of low level building blocks that gives you a lot of flexibility.
[00:19:09]
And there are like massive books written on D3 and how to plot with that.
[00:19:15]
Yeah, D3 is definitely a massive influence.
[00:19:19]
I acknowledge it even if you look at the readme, it sort of mentions that at the bottom.
[00:19:25]
So yeah, D3 is definitely a big inspiration.
[00:19:29]
We, you know, D3 is a really old library.
[00:19:35]
It predates most of like modern JavaScript.
[00:19:39]
So, you know, there's a lot of like stuff in there that in Elm there's much better ways
[00:19:46]
of solving.
[00:19:47]
So it's not a slavish, you know, re-implementation or something like that.
[00:19:52]
But there's definitely a lot of really good ideas that I think are totally worth stealing.
[00:19:57]
So I did.
[00:19:59]
Could you give an example of something that there are better ways of doing in Elm?
[00:20:03]
Yeah, so like, for instance, D3 has this idea of what they call selections.
[00:20:11]
And so selections are, you can say like, I want to select this DOM node, and then I'll
[00:20:18]
add a handler for when it's associated data changes, I will do this sort of DOM mutation.
[00:20:27]
So it's like, it's kind of a declarative way of doing DOM mutation, but it's a completely
[00:20:32]
different declarative way than the virtual DOM declarative way of doing DOM mutation.
[00:20:39]
It's really like data focused.
[00:20:41]
And in general, I would say it makes things like performant animation quite easy, but
[00:20:47]
on, you know, which is sort of thing virtual DOM, on the other hand, tends to struggle
[00:20:51]
like animation in virtual DOM is often kind of difficult.
[00:20:56]
But it makes a lot of just building stuff the easy way kind of hard.
[00:21:03]
And it's a completely different mental model.
[00:21:05]
So it's again, like adds a lot of a lot of stuff to learn.
[00:21:09]
So for instance, that's something that it's a it's a thing that predates, you know, virtual
[00:21:15]
DOM approaches by probably, I would guess at least five years, but maybe longer, I don't
[00:21:19]
know.
[00:21:20]
So it's so that's a thing that, you know, we could have tried to reimplement, but I
[00:21:26]
see really no point, we have a perfectly nice way of, of dealing with DOM mutation in Elm.
[00:21:31]
So for instance, but also like, a D3 has built in stuff like CSV parsing, it has stuff like
[00:21:37]
timers and dealing with, you know, recurring events, a bunch of stuff that like in Elm,
[00:21:43]
you would just solve completely differently.
[00:21:45]
And of course, it has also a lot of like, completely mutable API's and stuff like that
[00:21:49]
that just are terrible.
[00:21:51]
But you know, yeah.
[00:21:54]
So there's, there's a lot to love about D3, but it's its own world as well, for sure.
[00:22:00]
Right.
[00:22:01]
So with the didn't say that D3 had a lot of books written on on it with the book for Elm
[00:22:07]
visualization, we would it would be a lot smaller?
[00:22:10]
Probably.
[00:22:11]
I don't know.
[00:22:12]
I'm not much one for writing books.
[00:22:16]
The tutorial I think that's, you know, like, whatever, five pages long, I spent like a
[00:22:22]
year writing.
[00:22:23]
So book is not really for me.
[00:22:27]
If someone wants to write a book, I'll be happy to give them some pointers.
[00:22:31]
But you can write the preface or the recommendation.
[00:22:35]
I'll write the blob at the bottom back, which is like one paragraph.
[00:22:40]
Right, right.
[00:22:41]
X is a great author.
[00:22:42]
This is the best book on the subject.
[00:22:54]
And then there's then a second one comes in and like, Oh, no, I have to evaluate it.
[00:23:02]
So the second one can be the newest book on the subject.
[00:23:09]
So I feel like when I read the documentation, I feel like you put a difference between charting
[00:23:19]
and visualization.
[00:23:21]
And I don't know what the difference is.
[00:23:23]
Could you explain that to me?
[00:23:25]
The terminology is kind of isn't great.
[00:23:29]
But there's two fundamental workflows, I think, in data visualization.
[00:23:34]
And one is what we would call exploratory data visualization.
[00:23:38]
And that means you get a data set, you don't know what's in it.
[00:23:43]
Maybe you've got some description about it, but you don't really understand it.
[00:23:47]
And so you want to use some tools to be able to understand this data set.
[00:23:53]
And so you can, you know, a lot of people use Excel for this or Tableau or other tools.
[00:23:58]
But you can sometimes it's much easier to do this in code.
[00:24:02]
And you can have libraries that are really well designed for that task.
[00:24:09]
So in we have Vega, Vega light, our classic examples of this, there's very nice Elm version
[00:24:17]
of that.
[00:24:18]
So I think there's Elm, Elm Vega, Vega, don't really know how it's pronounced, V E G A.
[00:24:24]
And that's really designed for that workflow, like and it does a lot of stuff for you automatically.
[00:24:30]
You know, it can work out a bunch of stuff about your data and render really nice charts
[00:24:35]
based on that data.
[00:24:37]
And then you have the other workflow, which is you usually understand your data set pretty
[00:24:43]
well, but you want to communicate about it to someone else.
[00:24:47]
So it could either be like a journalism kind of aspect where you think you want to tell
[00:24:51]
a story about the data, or you maybe you're building a dashboard in your product, you
[00:24:55]
want to show your customers some specific stuff about data that you produce, other sort
[00:25:00]
of things like that.
[00:25:02]
And there, the it's not so much about speed of constructing the chart.
[00:25:08]
It's more about things like customization, you want to be able to point out specific
[00:25:12]
things about the data, you want to be able to, you know, really emphasize specific relationships
[00:25:18]
in your data set, for instance, you want to make the data set as easy to understand as
[00:25:22]
possible, even if that costs you as the programmer, potentially quite a bit of extra effort.
[00:25:29]
But, but, you know, you, you know, so it's, there's a really different workflow here.
[00:25:33]
And the tools that support these different workflows are, you know, are designed in different
[00:25:40]
ways.
[00:25:41]
So Elm Visualization is definitely on the second side of this divide, you know, where
[00:25:46]
we really emphasize this flexibility.
[00:25:48]
And, you know, you can tell exactly the story that you want with your data.
[00:25:53]
But yeah, you have things like Vega.
[00:25:56]
Elm Charts is a little bit in that more in that camp, maybe as well, where like, it's
[00:26:00]
really easy to get, you know, you throw in some data, you say, like, give me a bar chart,
[00:26:05]
and you have a bar chart.
[00:26:08]
And you know, you didn't have to do almost anything to make that happen.
[00:26:11]
And so you can really right away look at your data and be like, Oh, yeah, there's something
[00:26:15]
interesting going there around, you know, Thursday, 2020.
[00:26:20]
You know, January, like, oh, maybe a pandemic happened or something.
[00:26:23]
I don't know.
[00:26:24]
Like, you can make some sort of influence.
[00:26:27]
It's you know, from that, but but it's a different workflow.
[00:26:31]
And so you get different libraries or a different workflow.
[00:26:34]
And so that's a little bit what I'm trying to talk about there is, is, you know, if you
[00:26:38]
just want to quickly look at some data, this is your turn, kind of taking a, you're killing
[00:26:43]
a mosquito with a bazooka a little bit.
[00:26:47]
So yeah, so you said that with Vega or with Elm charts, you can get to a solution much
[00:26:54]
faster with the downside that you can't customize it as, as much as you possibly may need to
[00:27:02]
in the future.
[00:27:03]
Well, so I should probably mention as well, sorry to interrupt you.
[00:27:07]
It's not just the customization, but it's also the fact that usually these kinds of
[00:27:12]
libraries are built a certain number of predefined chart types, right?
[00:27:18]
So they can, you know, somebody coded in, like, this is a bar chart, this is a column
[00:27:23]
chart, this is a line chart is area chart, you know, and they probably have 20 or 30
[00:27:28]
or 50 variations.
[00:27:31]
And that's kind of it.
[00:27:34]
And if you want to do something that's outside of that, that you're usually kind of out of
[00:27:37]
luck.
[00:27:38]
So that's, that's the sort of other limitation on that side of things.
[00:27:42]
Sorry, go on, please.
[00:27:43]
No, no worries.
[00:27:45]
So if you were to choose Elm visualization, and you did want a bar chart, but you don't
[00:27:51]
know how it will evolve in the future.
[00:27:53]
So you go with Elm visualization.
[00:27:56]
How would you, how would one go about it?
[00:27:58]
Because there's no built in bar charts module in the library.
[00:28:03]
So that's one of the reasons we have this examples gallery that we mentioned earlier.
[00:28:09]
So kind of my recommendation is go there that you know, I've made it, I've spent some effort
[00:28:15]
making it so that like, even on the home screen, you can see everything visually in pictures.
[00:28:20]
So you don't have to, you know, it's not just a directory of GitHub, there's you can look
[00:28:26]
visually and be like, Oh, that kind of looks like the thing I'm trying to do.
[00:28:31]
And they look awesome, by the way.
[00:28:35]
And you can copy paste the code, throw it in your project, and then start fiddling from
[00:28:40]
there.
[00:28:41]
So you kind of have a starter where you know, it sets up all the all the boilerplate essentially,
[00:28:46]
and then you can adapt it to your own data set, you know, and start start fiddling with
[00:28:49]
stuff to get it to where you actually want it to go.
[00:28:52]
So it helps to understand what I'm doing a little bit before you do that.
[00:28:56]
So read the tutorial maybe.
[00:28:58]
But once once you got a little bit of understanding, you should be able to copy paste these examples
[00:29:02]
and code there.
[00:29:04]
In fact, the examples gallery also has has a little little link there called edit in
[00:29:10]
Ellie.
[00:29:11]
So you can also click that and that will open an editor right away where you can start messing
[00:29:16]
with it.
[00:29:17]
So yeah, that can be a pretty good way how to get started on these sort of things.
[00:29:21]
What is the tool that it uses again, by the way, there's a there's a special like Elm
[00:29:25]
examples tool for compiling these examples, right?
[00:29:28]
Yeah, so it's called Elm examples publisher, which is a horribly hacky piece of JavaScript
[00:29:35]
that you know, does compiles all of these things and take screenshots of them and then
[00:29:40]
mix the website.
[00:29:42]
So on.
[00:29:43]
So yeah, that's that's if you want to do if you're also building on something visual,
[00:29:47]
then you want to publish a website with lots of little pictures of stuff, then I've probably
[00:29:53]
done most of the hard work there for you.
[00:29:55]
So feel free.
[00:29:57]
That's also you can find that just on GitHub on under my awesome.
[00:30:01]
Yeah, it's almost confusing because it has the same look and feel as the Elm package
[00:30:07]
websites and I'm always confused like, which website I'm on?
[00:30:12]
I may on the examples.
[00:30:13]
Oh, no, I'm on the docs.
[00:30:14]
Oh, no, I want the other one.
[00:30:17]
Yeah, it's Yeah, maybe that was a mistake.
[00:30:21]
I don't know.
[00:30:22]
I like it.
[00:30:23]
Originally, it looked slightly different.
[00:30:25]
And then I was like, it's kind of jarring going between the two.
[00:30:28]
Made it look more similar.
[00:30:30]
But no, it's great.
[00:30:32]
And the edit in Ellie is is huge.
[00:30:34]
That's, that's a great feature.
[00:30:36]
So what what motivated you to build this package in the first place?
[00:30:40]
So yeah, it's been going on for a while.
[00:30:44]
So back, I think this was in the Elm 17 days on point 17.
[00:30:50]
So that's 2016.
[00:30:53]
I was trying to build my first thing at work, actually, we're using Elm.
[00:31:01]
And this was supposed to be, we had an API that collected pricing information from all
[00:31:06]
the different cloud instances, from all the different cloud vendors.
[00:31:10]
And so we would scrape all the prices of AWS, all the prices from Google Cloud, or from
[00:31:16]
Azure and so on.
[00:31:18]
And there is a lot of prices.
[00:31:20]
I think AWS has about 10,000 different prices for just instances.
[00:31:27]
So it's actually, it was quite a fun problem to work on.
[00:31:29]
But also that these prices constantly change as well.
[00:31:32]
So we were so what I was doing was just building a little website that you could go into any
[00:31:38]
cut, you could put in a Kenny kind of like instance, and we would show you what it costs.
[00:31:43]
But we will also show you what it costs historically.
[00:31:47]
And I wanted to make that historical price chart.
[00:31:50]
Well the chart.
[00:31:51]
And back then there wasn't any data visualization charts in Elm.
[00:31:55]
There was like a really outdated wrapper around D3, but that didn't work in the current version
[00:32:00]
of Elm.
[00:32:01]
And that was it.
[00:32:02]
So I was like, well, how hard can it be?
[00:32:05]
Right?
[00:32:06]
So,
[00:32:07]
Seven years later.
[00:32:12]
Something like that.
[00:32:13]
So yeah, then I built something to scratch my own itch at that point.
[00:32:18]
And then I was like, well, we might as well, you know, make this open source.
[00:32:22]
And so I started really getting into it.
[00:32:24]
And then at some point later, I published the first version that didn't do a whole lot,
[00:32:30]
but it's been, we've been trying to steadily add features and features over time.
[00:32:36]
So now it's actually fairly feature rich, I would say.
[00:32:38]
Now I'm curious, like, what do you feel is missing from it?
[00:32:41]
Because a lot of things,
[00:32:43]
I look at the examples, I'm like, these examples are so wildly different.
[00:32:49]
I don't know what it can and when, especially what it cannot do.
[00:32:54]
So
[00:32:55]
Yeah, so it's not so much about can't do, you know, because you can just program stuff
[00:33:00]
yourself, but there's, are abstractions missing?
[00:33:02]
I mean, the big topic that we don't cover at all is like geospatial stuff, maps and
[00:33:09]
so on, which is a huge, huge world.
[00:33:13]
And it's very complicated.
[00:33:14]
I made some attempts in that direction.
[00:33:17]
But I think I ran into the limitations of what can be done on a sort of open source
[00:33:23]
budget.
[00:33:24]
So I think, at least for now, I'm not really intending to go there unless something miraculous
[00:33:34]
happens.
[00:33:35]
I can already just imagine having to draw a map of the world with all the borders.
[00:33:43]
And every time they change, you have to release a new version.
[00:33:46]
And just that would be a pain already in itself.
[00:33:49]
Yeah.
[00:33:50]
And like, I mean, I've worked in, you know, mapping and so on.
[00:33:56]
For some period of time, I was maintaining this other library called Elm Mapbox to do
[00:34:02]
kind of like zoomable maps and so on.
[00:34:05]
And so I've got some insight into the complexity there.
[00:34:09]
And it's just like agreeing on how to represent two numbers, i.e. a point on the earth.
[00:34:17]
There's like a very large number of ways people have decided to solve that problem.
[00:34:23]
So like just that, it's a really complicated problem.
[00:34:27]
And then it gets worse from there.
[00:34:29]
So can you explain that one?
[00:34:34]
So what you probably are mostly familiar with sort of people specifying points on the earth
[00:34:40]
as longitude or latitude pairs, right?
[00:34:43]
Have you heard those terms?
[00:34:44]
Yeah.
[00:34:45]
Yeah.
[00:34:46]
So that's what we call like, people call it the GPS coordinates or properly it's called
[00:34:51]
WSG 84 is the specification for that.
[00:34:55]
And essentially the idea is their angle.
[00:34:57]
So you can think of it as one circle is kind of goes through the poles of the earth and
[00:35:05]
the other one, other circle goes around the equator and you can kind of, you know, combining
[00:35:11]
the two angles on those circles, you can kind of come up with a coordinate system that more
[00:35:16]
or less specifies places on the earth.
[00:35:19]
So that's sort of one way you can do it.
[00:35:23]
But even there, you come into trouble because some people like to specify things as latitude
[00:35:28]
then longitude.
[00:35:29]
Other people like to first do longitude then longitude.
[00:35:32]
So like, even though you're not totally out of the weeds, but then there's like lots of
[00:35:38]
other ways you can specify.
[00:35:40]
If you can't agree just on that, then like there are 13 standards on just the ordering.
[00:35:48]
Well, there's only two ways you can do it.
[00:35:55]
But you know, it's, yeah.
[00:35:58]
But like, then you can, you know, part of the problem with that system is that the earth
[00:36:04]
isn't a perfect sphere.
[00:36:06]
So you get some inaccuracy in that system.
[00:36:08]
So there's other systems that try to fix that.
[00:36:11]
Then there's a lot of ways, well, you know, that doesn't allow you to draw a map per se
[00:36:16]
because, you know, that's a sphere, but a map is a rectangle.
[00:36:23]
So then if you try to unwrap a sphere into rectangle, you're always introducing distortion
[00:36:27]
and then you have different systems that can deal with that distortion in different ways.
[00:36:32]
And I could talk about this literally for like days.
[00:36:38]
But yeah, it just goes into, there's a lot of pain in the GIS world.
[00:36:45]
So solving a lot of that in a nice way is tough.
[00:36:49]
Did you also happen to try and solve time zones at the same time?
[00:36:54]
I'm not that suicidal.
[00:36:56]
Which one do you think is more complicated?
[00:37:00]
The maps one or the time zones?
[00:37:02]
I don't know.
[00:37:03]
Time zones are also just horrible.
[00:37:05]
I mean, I think I don't, yeah, I know enough about time zones not to want to know anymore.
[00:37:12]
Fair, fair.
[00:37:15]
No, no, but yeah, I mean, then you have a bunch of other things that are complex layout
[00:37:23]
wise.
[00:37:24]
One thing I'd like to do some point in the near future is what are called Sankey diagrams,
[00:37:31]
which kind of visualize flows between different things.
[00:37:37]
So you could say like, you could think of saying like, if you want to do a chart between
[00:37:42]
countries and some import and other export different commodities between them, you can
[00:37:45]
visualize this in this chart, kind that shows you the quantities of stuff flowing between
[00:37:51]
these different things.
[00:37:52]
It's a really nice, nice way of visualizing stuff.
[00:37:56]
And it's sort of non trivial to compute that layout.
[00:37:59]
So I'd like to do that one.
[00:38:01]
Is it non trivial because every flow impacts how the other flows will show or the order
[00:38:08]
of those things?
[00:38:09]
Yeah, I think that's generally the problem you get with most like complex layout algorithms
[00:38:14]
is that it's just everything affects everything and you have only so much space to put it
[00:38:18]
all into.
[00:38:19]
And so you end up having to shuffle everything around a lot.
[00:38:24]
Actually, you know, so one of the things we had a pretty major release recently, which
[00:38:32]
added this new module that deals with we call it hierarchy, but essentially, you can think
[00:38:37]
of it as dealing mostly with things you could represent in a tree, tree like data structure.
[00:38:42]
And that's all just layout, we don't really do any, as usual, we don't only do any drawing,
[00:38:47]
we just compute where in where would you put stuff if you wanted to do some kind of layout.
[00:38:53]
And so that's been a bunch of layout algorithms I've been working on.
[00:38:58]
So they're, yeah, they're just tend to be pretty complex.
[00:39:01]
Yeah, it's kind of a funny one, because Elm visualization is structured internally by,
[00:39:06]
you know, you often see as the on the API surface, it's like a single function.
[00:39:12]
And usually, that module is just documentation and, and the function, like I almost use like
[00:39:19]
a C like header pattern, where you have like a header file, which has the function signatures
[00:39:26]
and the documentation, and each function is implemented in its own entire module, because
[00:39:31]
that function implementation is probably like 3000 lines.
[00:39:37]
So it's also a little bit atypical, I think, in that regard, is that some of these things
[00:39:42]
are just inherently pretty complicated.
[00:39:46]
So this package only gives small helpers, but each one of those helpers is very complex
[00:39:53]
to compute and takes a lot of most of that some of them are pretty simple, but most of
[00:39:58]
them.
[00:39:59]
So could you walk us through some of these sort of ecosystem of supporting packages that
[00:40:09]
you mentioned in the readme there in the getting started, so there are a few things that come
[00:40:13]
up while using this package.
[00:40:18]
Elm color is a pretty straightforward one.
[00:40:21]
It's just a kind of community standard package for describing a color.
[00:40:27]
But so like typed SVG, I actually wasn't familiar with typed SVG.
[00:40:31]
What is that package for?
[00:40:33]
Yeah, so most people probably are familiar with Elm slash SVG, the sort of, I guess,
[00:40:41]
standard library.
[00:40:42]
But it's, at least in my opinion, not a great package.
[00:40:47]
It has it basically copies is designed from Elm HTML in the sense that every element takes
[00:40:55]
two lists, and every attribute basically takes a string as its one input.
[00:41:00]
And that works pretty okay for HTML.
[00:41:03]
And it's kind of beginner friendly in the sense that, you know, if you know how to type
[00:41:07]
HTML, you probably know how to type Elm HTML, it's, you know, very consistent, which is
[00:41:13]
good.
[00:41:14]
But it's not a great package if you want to actually dynamically compute most of the attributes,
[00:41:19]
because most of the attributes in SVG are just not strings at all.
[00:41:24]
They're either they're usually floating point numbers, typically, or they're just complex
[00:41:30]
structures like things like paths are, it's a fairly complex data structure that ends
[00:41:35]
up being stringified into a string.
[00:41:38]
But if you want to actually compute it, you don't, you know, stringifying it isn't isn't
[00:41:43]
really a core concern, you know, and then you have a bunch of things that are basically
[00:41:47]
just enums.
[00:41:48]
So you can say like, I want, you know, if I make a if I bend a line, like imagine 90
[00:41:54]
degrees, you can draw the corner there in like three different ways, you can get it
[00:41:59]
kind of like to overshoot, you can kind of rounded a bit or you can kind of do like a
[00:42:03]
45 degree bend at the edge, right.
[00:42:07]
And so those are like your three options.
[00:42:08]
And, you know, you can specify an attribute that's going to be one of those three.
[00:42:13]
So like, taking an arbitrary string is just a way to shoot yourself in the foot.
[00:42:18]
Because you probably don't remember how to spell I don't know what it's called.
[00:42:22]
Well, and yeah, you don't remember what it's called.
[00:42:25]
So good luck with autocomplete with a string.
[00:42:29]
So
[00:42:30]
doubts and then hope for the editor.
[00:42:35]
Because it's a string, you're not going to get any help from your ID.
[00:42:40]
So you're gonna have to go and Google it.
[00:42:42]
And you know, it's annoying.
[00:42:44]
So type SVG is an attempt to solve some of these problems.
[00:42:49]
I personally am not super happy with that library either.
[00:42:54]
I think it's a move in a better direction, but I still think that like, as the ultimate
[00:43:00]
Elm SVG rendering packages is still waiting to happen.
[00:43:05]
Well, you have a choice between writing a new book and making that the library.
[00:43:10]
So yeah, I started on it once.
[00:43:14]
And then I sort of quickly just looked at the size of the SVG spec.
[00:43:18]
And I was like, yeah, no.
[00:43:21]
Okay, let me let me find a way to generate this from the spec.
[00:43:25]
Yeah, but there's, you could try that.
[00:43:28]
But then then you're not going to end up with a, you know, I think that's a little bit like
[00:43:33]
where type SVG also like falls is that, you know, some of the ergonomics end up not being
[00:43:38]
all that ergonomical, because, like, to give you an example, right, there's certain attributes
[00:43:44]
that like 95% of the time you use them, you use them with, like a number, let's say as
[00:43:50]
an input.
[00:43:51]
But they can also technically take like a straight other value, like something like
[00:43:57]
none, or, you know, something like that, or, you know, so if you just model it as like,
[00:44:04]
oh, well, then we have to wrap the number in, like one tag, so that we can have the
[00:44:09]
other tag, you end up with this spare tag, like literally, or called all over the place,
[00:44:15]
you know, so like, a better API design would be just to make this attribute just take the
[00:44:20]
number and then maybe add an extra attribute that you're going to use in that one situation
[00:44:24]
you needed that has some more awkward name.
[00:44:28]
But you know, it makes the 95% case way nicer.
[00:44:34]
You know, and it's the sort of thing which needs some experience and quite a bit of thought
[00:44:37]
to to really get the sort of developer experience to that level.
[00:44:43]
That's quite a lot of work.
[00:44:45]
Yeah, so it sounds like Elm SVG is similar to Elm HTML, where typed SVG is similar to
[00:44:53]
Elm CSS.
[00:44:54]
But you want Elm UI for SVG?
[00:44:57]
Maybe, yeah.
[00:44:59]
Something, something, something like that.
[00:45:03]
I think as a metaphor, I think that works.
[00:45:05]
Yeah.
[00:45:06]
I think also, because like, Elm CSS has the same some of the same issues you mentioned,
[00:45:10]
like, oh, none can be specified as an attribute to anything, almost.
[00:45:16]
And it also had like, needed to go through some type trickery to make it work.
[00:45:22]
Okay, so one true path, that one, I had also not heard about.
[00:45:27]
And I'm very curious, like, what is the one true path package solving?
[00:45:34]
The one true path, actually, it's funny, because that actually happened at that first Elm Europe
[00:45:43]
conference, where I think we might have met there, I don't know.
[00:45:47]
And I think a bunch of people like myself, Matt Griffith, I think was there, I don't
[00:45:54]
know, Fulgert, who ended up writing this, maybe one or two other people.
[00:45:57]
And we were all like saying, like, well, we all want to do stuff with SVG paths.
[00:46:03]
Like I wanted to generate them from various helpers.
[00:46:08]
And Matt was interested in using them for animation, because he wanted to do animation,
[00:46:13]
you know, on a path.
[00:46:15]
And I'm not sure what Fulgert was trying to do at that time.
[00:46:19]
And so we were like, well, you know, one of the I guess one of the so this goes back to
[00:46:23]
Elm's design, right?
[00:46:24]
And Elm, it's strictly typed with nominal types, which means if I produce a type that's,
[00:46:31]
you know, called something, say, the path, and you want to consume that type path, you
[00:46:37]
have to take me on as a dependency, you know, but you might have nothing at all to do with
[00:46:42]
my package.
[00:46:43]
Like, if you want to do animation, you probably don't need to, you know, depend on a data
[00:46:47]
visualization package, like it doesn't make much sense.
[00:46:51]
And so it's kind of beneficial if the community can organize around, around some of these
[00:46:57]
core types that it would be beneficial to share between a bunch of packages and produce
[00:47:03]
a single package.
[00:47:04]
And so that's how ElmColor was born, for instance, and one true path was supposed to be that
[00:47:09]
for path information.
[00:47:12]
Now I don't think in that case, that totally materialized.
[00:47:15]
I don't think there's other packages that really use it.
[00:47:19]
But that was the idea.
[00:47:20]
There was a way it's called one true path, because it was meant to be the one path package
[00:47:25]
that was going to unite them all.
[00:47:29]
And so that was the intention there to make the ability to take path data from one package
[00:47:33]
to another and, and, and share them.
[00:47:37]
And path data as opposed to like the D element in SVG, which is like, doesn't describe the
[00:47:45]
data, it describes the element directly.
[00:47:49]
So in SVG, you have what's called a path element that takes has an attribute called D, which
[00:47:56]
is super intuitive, which is this, you know, if you look at it, it just looks like a long
[00:48:02]
string of mumbo jumbo.
[00:48:04]
But it's that string is essentially a list, you can think about it as a list of commands.
[00:48:11]
And each command is like, move over to those coordinates, and then move to those other
[00:48:16]
coordinates, but as you move, draw a line, like you can think about it as almost like
[00:48:19]
a logo drawing program, you know, then go in a circular fashion to this other point,
[00:48:25]
and then like, maybe just complete the shape.
[00:48:29]
And so you get these these commands.
[00:48:31]
And so they describe what we call a path.
[00:48:34]
But essentially, it's sort of a generalized geometry.
[00:48:37]
And you can use that for drawing stuff, for instance, but you can also use it as just
[00:48:42]
a path that someone could take, for instance, in an animation.
[00:48:45]
So there's different ways you can interpret it.
[00:48:48]
But conceptually, or mathematical calculation or something.
[00:48:52]
Yeah, you know, and so that's, that's what we call path data.
[00:48:55]
And so Elm visualization has a bunch of different helpers that produce these sort of paths based
[00:49:01]
on, let's say, you have some abstract data, again, when you can use some scales, and you
[00:49:06]
can turn it into path data.
[00:49:08]
And then you can either just render it, but you can also potentially animate up, you know,
[00:49:13]
create something based on that data path.
[00:49:16]
So you know, it's one of the things you, there's a lot of data visualization libraries that
[00:49:20]
have like animation, but it's really like what I would call spurious animation, right?
[00:49:25]
It's like, you open the page and the bars in the bar chart is like, zoom in.
[00:49:31]
And it's like, Oh, like, okay, it's, I guess, cool.
[00:49:34]
But I've seen animations before, like, it doesn't, but it's, it doesn't tell you anything
[00:49:39]
about the data, you didn't wouldn't know if the animation wasn't there.
[00:49:44]
But I think there's a lot of opportunities animation in a way that's much more explanatory
[00:49:50]
and tells you stuff about the data.
[00:49:52]
So I think we have a really cool example about that.
[00:49:54]
If you look at the bar chart race example on visualization, you know, that's an example
[00:50:00]
where it's a bar chart, but it's, it's, it grows as time progresses, and then it reorders
[00:50:07]
itself.
[00:50:08]
And then kind of the motion tells you how the situation changed over time, you know,
[00:50:15]
and so it's the animation and the motion is actually telling you things that you couldn't
[00:50:19]
understand if it was just a picture.
[00:50:22]
And so I think there's a lot of like opportunity to use these sort of techniques to come up
[00:50:26]
with really intuitive ways to explain data that wouldn't be, you know, wouldn't be possible
[00:50:32]
if you just didn't have those animation permitted.
[00:50:35]
So that's my hope with that.
[00:50:36]
It didn't, it didn't totally pan out in the sense that I don't think other packages totally
[00:50:40]
adopted it.
[00:50:41]
But, but, hey, it's still there.
[00:50:44]
So yeah, no, that's, that's great.
[00:50:47]
That's great context.
[00:50:48]
I think, for me, at least it helps.
[00:50:50]
It helps me when I understand like the motivation for why a package came into existence.
[00:50:54]
It helps me when I'm trying to use it to understand that context.
[00:50:58]
So other philosophy we have in on visualization is that, well, you might have noticed it's
[00:51:04]
still on version 2.4 and the major version is only two.
[00:51:10]
And the only reason we made the second major version was that Elm 0.19 came out and broke
[00:51:17]
pretty much everything.
[00:51:20]
And so we had really no choice but to just, you know, redesign a bunch of stuff.
[00:51:25]
Like for instance, you might not remember this, but color used to be in Elm core, you
[00:51:31]
know?
[00:51:32]
And then time worked completely differently.
[00:51:35]
So Elm visualization, those are pretty important types for us.
[00:51:38]
We do a lot with times and colors.
[00:51:40]
So that was, yeah, that was, so that was, and while we're going to do a big breaking
[00:51:45]
change, I fixed a bunch of like design flaws and so on.
[00:51:48]
But you know, the, the main aim here is to keep it as backward compatible as we can.
[00:51:54]
So some of these things, like, I think if I was designing it today, maybe I would have
[00:51:59]
come up with a slightly, maybe it would have made a different package for path or something
[00:52:03]
like that.
[00:52:04]
But, but it's, it works well and it's, it doesn't, I don't feel like we need to break.
[00:52:10]
It's not bad in a way that we should break anyone's code for it.
[00:52:14]
Like it works really well, actually.
[00:52:16]
So.
[00:52:17]
Right.
[00:52:18]
Yeah.
[00:52:19]
And, and you recently released a new version.
[00:52:21]
What are, what are the highlights from the new version?
[00:52:23]
So the main highlight, as I mentioned, is the ability to do these kinds of tree visualizations.
[00:52:29]
So you can really, there's three ways you can lay out trees that we support now.
[00:52:35]
So one is allows you to do kind of what we call sometimes node link diagrams, but you
[00:52:41]
can think of it as somebody told you, like, can you draw me a tree on a, on a whiteboard?
[00:52:47]
That's what you would probably produce.
[00:52:49]
Like you would draw boxes and you would draw lines between them.
[00:52:52]
And that would be how you would visualize the tree.
[00:52:54]
Now to do that, to look nice is actually tricky and there are some aesthetic rules that you
[00:52:59]
can apply to make things, you know, look nice.
[00:53:02]
Like the tree shouldn't be, should be kind of look kind of balanced.
[00:53:06]
Like ideally the root of the tree should sort of be in the middle-ish and so on.
[00:53:11]
And things should be kind of neatly done.
[00:53:15]
One of the cool things we support is there's distinction between layered and non-layered
[00:53:21]
trees.
[00:53:22]
So what that means is if you have the nodes in the trees, I can have different sizes.
[00:53:30]
And so if, if you have, if you have that property, then you have to make a decision.
[00:53:34]
Are you going to make the tree such that every layer of the tree by layer, I mean here, like
[00:53:41]
think of like a rank in an army, right?
[00:53:43]
Like if you have units, then like all the generals, you would want to line them up and
[00:53:46]
all the lieutenants you want to line them up and colonels.
[00:53:49]
And I don't know, I have no actually idea how ranks work.
[00:53:52]
You would want to draw it in that sort of way where they all like end up being, you
[00:53:59]
know, at the same level to show that they're the same rank.
[00:54:02]
But like if you, so then you would say like, I want to draw it layered and that's going
[00:54:06]
to take you more space because you actually have to, you can't squeeze stuff into the
[00:54:10]
gaps otherwise.
[00:54:11]
But if you don't care about this property, then we support the non-layered, which is
[00:54:15]
much more computationally tricky to do, but it allows you to, to, to kind of take, you
[00:54:21]
know, if you have a really tall element, we can squeeze a whole sub tree in the space
[00:54:24]
that it leaves.
[00:54:25]
So you end up with these really compact, but quite nice looking layouts.
[00:54:29]
So that was a lot of fun to build.
[00:54:33]
Then tree maps, tree maps.
[00:54:37]
If you're not familiar with that is basically you take some sort of space, like a rectangle
[00:54:43]
and you start dividing it based on the structure of the tree and some quantitative variables.
[00:54:48]
So like that's great way how to use that is there's tools and there's tools out there
[00:54:53]
that do this.
[00:54:54]
If you are running out of space on your computer, you can use a tool that will produce a tree
[00:54:59]
map of your hard drive.
[00:55:01]
And then you can see which directory is which size.
[00:55:04]
And you immediately see, Oh, there's that weird directory in my downloads file that
[00:55:08]
has like 10, 10 gig films in it that I'm never going to watch.
[00:55:13]
You can immediately see this is, I'm going to like save space.
[00:55:17]
Whereas if you were just looking through some other way of showing your file system, you
[00:55:21]
would never find that.
[00:55:24]
Or JavaScript bundle sizes as well.
[00:55:26]
Yes, that's a perfect, perfect example as well.
[00:55:32]
Yeah.
[00:55:33]
And then the last one is kind of what we call a partition layout, which is kind of like
[00:55:39]
a one dimensional version of the tree map.
[00:55:41]
So it just divides each layer successively into smaller pieces in kind of like a rectangular
[00:55:48]
fashion.
[00:55:49]
And you can like one of the really attractive things you can do with that is what's called
[00:55:53]
a sunburst visualization.
[00:55:55]
So you do that, but you arrange them in a circular fashion.
[00:55:58]
And so the circle is kind of split up and you kind of go into the little branches of
[00:56:03]
the tree going from the center outwards.
[00:56:07]
And so that's quite an attractive layout, I think personally.
[00:56:11]
So you can do stuff like that.
[00:56:13]
And by the way, we'll link to the release notes, which have really good visuals of all
[00:56:17]
these.
[00:56:18]
Yeah, I mean, the other big thing is, is the tutorial that we mentioned that for me, at
[00:56:23]
least personally was the hardest game about this release.
[00:56:29]
And then, yeah, then there's actually some really nice, just new examples.
[00:56:33]
So I always try to release a couple more examples to do some stuff.
[00:56:37]
I really recommend people looking at the weather radio one, which shows you the weather pattern
[00:56:46]
for a whole year in a particular location.
[00:56:48]
And the really fun bit is you can change the location.
[00:56:52]
And so I think when I showed it to my wife, we spent like two hours just looking at different
[00:56:56]
places.
[00:56:57]
I mean, like, oh, what does it look like in Iceland?
[00:57:00]
Oh, what does it look in that desert?
[00:57:02]
Oh, what does it look like in, you know, Siberia?
[00:57:07]
And so it's a really fun example to play with.
[00:57:10]
So if you want to waste some time, I'd recommend that.
[00:57:14]
Yeah, that one looks amazing.
[00:57:17]
So it's actually based on a really famous, really famous poster.
[00:57:22]
And I love that poster so much, but it just has, it's a poster you buy.
[00:57:25]
And so they only pick 30 places.
[00:57:27]
And if you have no relation to those places, it's not that meaningful of a poster.
[00:57:32]
So I always wanted to make this tool to be able to make that poster.
[00:57:36]
But in the places I've like lived to or been, lived in or been to, or, you know, that sort
[00:57:41]
of thing where you have some personal relationship to it.
[00:57:44]
So you can kind of relate to those places specifically.
[00:57:48]
So I'm curious, like, how do you even approach building these visualizations?
[00:57:54]
Like I want to take the example of the weather radial, but I don't know if that one is too
[00:57:59]
complex to ask you, like, how do you go about approaching it?
[00:58:03]
Yeah, so usually you start with some sort of idea, you want to build something.
[00:58:08]
For a lot of these examples, a lot of these are like famous stuff that, you know, people
[00:58:14]
have built or, or like are in newspapers or stuff like that.
[00:58:18]
I'm thinking mostly in terms of implementation rather than designing the visualization.
[00:58:22]
Yeah, so you always start with, you know, on one side, you have your data.
[00:58:29]
And on one hand is what the pixels you want to look like, right.
[00:58:33]
And so fundamentally, you're going to end up with some form of transformation between
[00:58:38]
the two.
[00:58:39]
You know, like we talked earlier with the scales, that's the simplest case.
[00:58:43]
But you know, it usually gets a bit more involved than that.
[00:58:46]
But, but fundamentally, the workflow is pretty similar.
[00:58:49]
Like you come up with, you know, ways to, to do that.
[00:58:53]
And then you, you know, and it's, it's fun, because it's visual programming, right?
[00:58:58]
You're constantly getting visual feedback, like you put something and it just all looks
[00:59:02]
completely horrible.
[00:59:03]
And then you change the parameter, and it rotates the right way around.
[00:59:06]
And you're like, Oh, yeah, that's great.
[00:59:08]
You know, and, and so it's, I find it really like rewarding in that way that front end
[00:59:14]
engineering can be rewarding, where like, you're constantly getting this really nice
[00:59:19]
visual feedback.
[00:59:21]
So it's, it's definitely fun.
[00:59:24]
Sometimes it can be tricky when you don't know how to proceed.
[00:59:26]
But yeah, I would say like, when you have this kind of visual feedback, it's really
[00:59:32]
easy to, to iterate.
[00:59:36]
But when it's visual, then it's really hard to write tests for.
[00:59:41]
And that's, that's going into another tangent that I'm sure that Dillon has a lot of thoughts
[00:59:46]
about.
[00:59:47]
The less visual something is, the easier to test it is.
[00:59:51]
Yeah, well, that's, yeah.
[00:59:53]
Like, so for instance, what I was really pleased about with the, with the tree work in the
[01:00:00]
latest release was that the actual papers that describe the layouts, the sort of aesthetically
[01:00:07]
pleasing layouts that trees should have, they codify them as seven rules.
[01:00:16]
And you hear like, oh, rules, fuss tests, and then something clicks in your head and
[01:00:22]
you're like, oh, I can write fuss tests.
[01:00:24]
So I think I have fuss tests for four of these rules, which were kind of sufficient enough
[01:00:30]
to really like shake up all the bugs I could, I could find.
[01:00:35]
So yeah, it's actually very nice when you end up with this situation where you get this
[01:00:40]
really powerful way to do, you know, something quite abstract.
[01:00:46]
So sometimes, sometimes it isn't like that.
[01:00:50]
Sometimes you end up with a situation where actually you get really nice properties.
[01:00:54]
And it might be hard to test the visualization itself, but the, the data transformations
[01:01:02]
that are, you know, show showing up as the final result of the visualization are easier
[01:01:08]
to test.
[01:01:09]
So that's when the unit tests come in and.
[01:01:12]
It's also like an implementation detail, but yeah, like if that's the closest you get to
[01:01:17]
be able to test something and sure.
[01:01:20]
Right.
[01:01:21]
Which is why it's harder.
[01:01:22]
It's harder to test the final full thing.
[01:01:26]
It's, but it might be pretty easy to just test some of the number crunching along the
[01:01:30]
way.
[01:01:31]
Do you have like, when you make a visualization, do you have tests for it and not for the underlying
[01:01:39]
API?
[01:01:40]
I mean, really for like, Oh, I have a weather radio.
[01:01:43]
I have some tests for them for that.
[01:01:48]
At work sometimes for it, for the example galleries, there's no, no tests.
[01:01:53]
I it's, they're supposed to be kind of like very self-contained examples.
[01:01:58]
So I, you know, it's slightly different emphasis, but at work we've done some, some, but yeah,
[01:02:05]
as you say, it's sometimes it's pretty challenging and just doesn't feel worth it.
[01:02:10]
Totally.
[01:02:11]
You get, you know, you can test it a lot, just manually you get, because it's visual,
[01:02:16]
you can kind of, your eye can notice the defects super fast in a way that I've done.
[01:02:23]
I've done a lot of tests during development when I was doing like data visualization with
[01:02:29]
some map stuff and WebGL just because the development workflow is just really awful.
[01:02:38]
Like the WebGL tooling, at least back then was, was not great.
[01:02:44]
And so I built a bunch of like test stuff and I did a lot of, you know, you can do image
[01:02:50]
comparisons or I would, you know, render to a buffer and then do like an image diff against
[01:02:55]
the reference image and so on, which was quite nice, but it was a lot of work to get that
[01:03:01]
set up.
[01:03:02]
So it depends on whether you feel like that's worth it or not.
[01:03:05]
So in your guide, you, you mentioned like some of the important skills being, you know,
[01:03:12]
understanding statistics and, you know, sort of data modeling and like cleaning your data.
[01:03:21]
Can you talk a little bit about, you know, for somebody maybe who is not super experienced
[01:03:27]
with some of these statistical techniques, like what are the important things to look
[01:03:33]
into and like where might somebody learn more about that?
[01:03:36]
Yeah, it's kind of a good question.
[01:03:39]
I don't think it's like necessary to get like a university degree in statistics or something
[01:03:43]
like that.
[01:03:44]
But like it's, and where exactly to learn everything, I don't really know.
[01:03:51]
Part of what I just mean by that is that like fundamentally, a lot of times your work is
[01:03:55]
going to be understanding things like sometimes a terminology, honestly.
[01:04:01]
So things like what's a dependent and independent variable, you'll hear that a lot.
[01:04:05]
If you don't know what that means, it's not the same thing as in programming, you know,
[01:04:11]
and, you know, or you're going to get things like a quantitative dimension versus, you
[01:04:17]
know, ordinal dimension, for instance.
[01:04:20]
And you know, these things just mean a quantity dimension is like a number and ordinal dimension
[01:04:25]
is something that you can, has a defined order, but doesn't have like a value, let's say.
[01:04:31]
So like, you know, like for instance, if you're doing a count of each, how many times a letter
[01:04:38]
appears in a piece of text, you want to visualize like a histogram of letter frequencies, like
[01:04:43]
letters would be an ordinal thing because they have an order.
[01:04:47]
Like it doesn't make sense to visualize them as like D, Z, X, and V. Like you're going
[01:04:53]
to visualize them A, B, C, D, E, F, G, right.
[01:04:56]
They don't have like, A is not any bigger than C in that sense.
[01:05:01]
So that's what like, you know, quantitative ordinal.
[01:05:03]
And then you have nominal is the like third category, which are just things that are distinct
[01:05:07]
from each other, but don't have any intrinsic order.
[01:05:11]
So that would be like your typical categories, blue and red and green, something like that.
[01:05:18]
So you have a lot of this jargon that it's helpful to understand, and kind of not just
[01:05:24]
the jargon, but some of the concepts, you know, like you, if you understand that, like,
[01:05:28]
look, this is a nominal variable, then you're going to think of like, okay, I'm going to
[01:05:34]
visualize it maybe with this kind of scale rather than some other kind of scale.
[01:05:38]
So it just helps you click these things.
[01:05:40]
You know, there's no point trying to do it in a quantitative way.
[01:05:45]
Data cleaning is just, that's like almost every place I've worked in has had, you know,
[01:05:51]
you get data to visualize and the data is just rubbish one way or the other.
[01:05:57]
You know, like there's just, I don't know, there's duplicates, there's the data isn't
[01:06:02]
adequately sorted, stuff like that.
[01:06:04]
So you're always going to need to do some data transformation work.
[01:06:07]
In Elm particularly, like you want to end up with nice types, it's going to make everything
[01:06:12]
else work better for you, right?
[01:06:15]
So there's always going to be work taking these data sets and making sure that they
[01:06:18]
end up neatly typed.
[01:06:20]
And maybe that's not, you know, it's not necessarily the case for everyone.
[01:06:24]
Like a lot of, if you work at a good software company and you're just trying to write a
[01:06:28]
visualization for what some nice backend API gives you, you might not need to do much of
[01:06:33]
that.
[01:06:34]
If you're working in a lot of other kinds of companies and somebody drops a CSV file
[01:06:38]
on you, you're going to need to do a lot of that.
[01:06:42]
So it depends on your use case.
[01:06:45]
Yeah, I could imagine like the way that you structure your data being important for both
[01:06:53]
being able to visualize something the way you want to and for performance reasons too.
[01:06:58]
Like sometimes the way you order things one way or the other can completely change that.
[01:07:05]
Cool.
[01:07:06]
And you talk about the Rose Tree data structure in the new release, which I have to admit,
[01:07:13]
it sounds really cool, but I don't know what that data structure is.
[01:07:16]
Could you give us an intro to that?
[01:07:19]
It sounds pretty at least.
[01:07:21]
Yeah, I should have.
[01:07:23]
Yeah, it's again, I mean, jargon is just, it's a trap that's hard to escape, isn't it?
[01:07:28]
But a Rose Tree is nothing very fancy.
[01:07:32]
It's just a tree that each node can have any number of children.
[01:07:36]
So like a binary tree is just a tree where each node has exactly two children or it's
[01:07:42]
a leaf, so two or zero, but like in a Rose Tree, you can have any number.
[01:07:46]
That's it.
[01:07:47]
Oh cool.
[01:07:48]
And it has a zipper so you can traverse it.
[01:07:51]
So in some sense, it's just kind of the, I guess the most general kind of tree that gives
[01:07:56]
you the least kind of guarantees in terms of like things like performance of searches
[01:08:01]
or stuff like that.
[01:08:02]
Like it doesn't give you computational benefits, but it can represent sort of any kind of tree
[01:08:06]
you want, as long as you would call it a tree.
[01:08:09]
Yeah, it makes sense.
[01:08:10]
I mean, in Elm, we often, I feel like try to use really high level intuitive terms for
[01:08:17]
things.
[01:08:18]
But then at the same time, when you get into like mathematical things and statistical things
[01:08:22]
and data structures, you sort of, there are certain properties that you convey a lot of
[01:08:28]
information with when you use a particular term, when you use the jargon.
[01:08:33]
So you kind of have to use the jargon in some of these things.
[01:08:39]
But it's good to know.
[01:08:40]
It's just like, it's a good tree.
[01:08:41]
It's a good tree data structure.
[01:08:43]
I don't think I mentioned in the release, but in the docs, I do actually provide the
[01:08:46]
type alias precisely to just show that like, look, this is, it's a pretty mundane data
[01:08:52]
structure.
[01:08:53]
Like there's, you know, it's, but yeah, I guess the main idea of it is like, if you
[01:08:58]
have any other kind of tree, you should be able to fairly trivially transform it into
[01:09:03]
a Roast tree and then be able to visualize it, you know.
[01:09:07]
Right.
[01:09:08]
So, so yeah, that was, that was also one of the recent things we released is a library
[01:09:14]
to deal with those.
[01:09:15]
So that's been, there's been a lot of open source activity lately on that front.
[01:09:21]
Yeah.
[01:09:22]
Amazing.
[01:09:23]
Well, that's great information.
[01:09:25]
And so Jakob, if people want to learn more, what are some good resources?
[01:09:31]
We mentioned the tutorial, which I would highly recommend.
[01:09:34]
Are there any other good resources for people to dive in to Elm visualization?
[01:09:38]
I think basically it's, there's a, the tutorial example gallery, which we mentioned the documentation
[01:09:46]
is also fairly extensive.
[01:09:49]
And then finally there's a Slack channel on the Elm Slack called hashtag visualization,
[01:09:56]
which is one of the perks of being old because back then you could still get channels for
[01:10:00]
your projects.
[01:10:04]
So yeah, so you can ask questions there and I tend to respond reasonably promptly.
[01:10:11]
So that's, that's basically it so far.
[01:10:14]
If somebody wants to write a book, as I said, please, please, you're very welcome to.
[01:10:19]
Is there anything that you would like to see Elm visualization be used for that would get
[01:10:25]
you excited or you just, that would be nice to have somewhere out there?
[01:10:30]
I think one of the things that somebody actually started on, and I think it's fairly productive
[01:10:35]
is you can use Elm visualization as a library to build the other kind of visualization library,
[01:10:42]
right?
[01:10:43]
You can build an explanatory data visualization library, which under the hood is powered by
[01:10:48]
Elm visualization primitives.
[01:10:50]
And so I think that already exists, but what would be really cool, I think in my mind is
[01:10:56]
if you could couple that with some code gen and you would have like, you could have like
[01:11:00]
an eject button where like, you could start with that high level one and then you'd be
[01:11:06]
like, you know what, I just want to go hardcore.
[01:11:09]
You would hit that eject button and it would transform that into like Elm visualization
[01:11:13]
code and then you could, you know, fiddle with it.
[01:11:16]
That would be really cool.
[01:11:17]
Elm visualization land or something like that.
[01:11:24]
Something like that.
[01:11:26]
So that would be pretty fun.
[01:11:28]
Maybe the ejection could be an Elm review rule that automatically scoops out the code.
[01:11:35]
Great stuff.
[01:11:36]
Well, Jakob, it was a pleasure having you on.
[01:11:38]
Thanks so much for coming on.
[01:11:39]
Yeah, thank you.
[01:11:40]
Yeah.
[01:11:41]
Thanks for having me.
[01:11:42]
It was really nice.
[01:11:43]
And Jeroen, until next time.
[01:11:44]
Until next time.