Everyone in the Python space is familiar with notebooks these days.
One of the original notebook environments was SageMath.
Created by William Stein and collaborators, it began as an open-source,
Python-based computational environment focused on mathematicians.
It has since grown into a full-blown company and has become a proper collaborative environment
for things like Jupyter Notebooks, Linux-backed Bash shells, and much more.
Think Google Docs, but across all these facets of development in your browser.
We welcome back William Stein to give us an update on his journey from professor to entrepreneur
building CoCalc along the way.
This is Talk Python to Me, episode 273, recorded July 7th, 2020.
Welcome to Talk Python to Me, a weekly podcast on Python,
the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy.
Follow me on Twitter where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm.
And follow the show on Twitter via at Talk Python.
This episode is brought to you by Linode and Talk Python Training.
Be sure to check out what the offers are for both of these segments.
It really helps support the show.
Speaking of Talk Python Training, have you been thinking about taking one of our courses?
We're participating in the latest Humble Bundle deal for Python developers along with a bunch of other great educators and tool developers.
Until July 22nd, you can get $1,400 worth of Python goodies, including three of our popular courses, for just $25.
Yeah, Humble Bundles are crazy.
That's $25 for our three courses and all those other things combined.
Just visit talkpython.fm/humble2020.
That's talkpython.fm/humble2020 altogether before July 22nd to take advantage of this offer.
Now, let's get to that interview.
William, welcome back to Talk Python to Me.
Thanks for having me back.
It's really great to have you back.
Your story is one that I've thought about a couple times over the years because it's really inspiring.
And it's quite interesting how you created SageMath and you went on this journey.
And it sounds like the journey is still going strong and you've come a long ways.
Yeah, it's been a very intense and exciting couple of years.
I started SageMath way back in 2004, worked on it an enormous amount until about 2013.
And for the last few years, I've been working on CoCalc, which is a web application whose goal partly is to make it really easy to use Sage without having to install anything, but also a lot of other open source software.
Right, absolutely.
So kind of notebooks before notebooks were cool, huh?
Yeah, so in Sage, we needed some sort of notebook interface.
So we wrote something called the Sage notebook back in 2006 through 2008, which back then, it looked a lot like it was the first sort of web-based computational notebook.
And we had to make a lot of interesting design decisions at the time.
And we put a lot of work into it over many years.
And then eventually, the whole Sage project, we switched to using Jupyter, using their file format and using Jupyter notebooks with a Sage kernel, rather than having to maintain our own completely separate notebook just for Sage.
Yeah, I guess before we get too far into it, maybe just tell folks what Sage is.
It has been almost four years since you were on episode 59 talking about Sage math and what it was.
So a lot's happened since then.
Yeah, so Sage is a big piece of software that's open source and free.
And the goal is to provide an alternative to Mathematica and Maple and Magma and various mathematical software systems.
But technically, what it is, is basically a Python library for mathematics.
And main things that distinguishes it from, say, SimPy is that we really, really focus on advanced research mathematics applications.
So things in pure mathematics like number theory, topology, differential geometry, etc.
So it gets used in physics and mathematical research.
But it also has a lot of functionality related to undergraduate mathematics teaching.
Oh, nice.
Yeah, that's a very interesting angle that we're going to talk about.
And your background's in number theory, right?
Yes.
Yeah.
I did my PhD in number theory in 2020 years ago at UC Berkeley.
Number theory.
So interesting.
That's one of the things I didn't study that much when I was working on my math PhD, which, to be clear, I didn't finish.
I dropped out halfway through and went and did computer stuff, which is fine.
But yeah, I was more on the analysis side.
But very, very cool.
Number theory is quite an interesting topic.
Now, I think, you know, let's just get straight into a little bit of the history.
So back in 2006, you, some of your grad students, you had some other students helping out sort of along the way, right, to build out SageMath.
At the time, you were a professor at University of Washington in the math department, right?
Yeah.
And then you built this up to be used in the classroom and to be used in the research, also with this undergraduate focus that you talked about.
Yeah?
Yes, that's right.
Probably 20 different students at University of Washington worked on Sage over the years and then hundreds and hundreds of people around the world.
And I taught frequently a class to about 20 to 50 undergraduates really about how to use software in mathematics.
So I guess nowadays it might be called a data science class.
Yeah, exactly.
Right.
It's sort of like, remember back when engineering, like you would go get an electrical engineering degree to actually do computer science or like programming, right?
Like you, there wasn't really a fit.
So like it would kind of go there.
Interesting.
Okay.
The course covered a bunch of topics like how to use R, how to use Pandas, which is a Python library, how to use LaTeX.
So we'd spend a week or two on just how to use LaTeX.
And I mean, it was really kind of a whirlwind and it was difficult to coordinate all this software with the students to get them to install something on their computer.
It was just, I mean, not really an option.
Right.
And you have all these different platforms, right?
Yeah.
And I liked having a part of class every meeting where I would give them something to work on and then walk around and help them and just see what was happening live.
So it was, you know, more interactive.
And so I ended up writing, well, first using the Sage notebook and then later use writing CoCalc specifically to make teaching that class more effective.
So they could do LaTeX, they could use R, they could use Python libraries, they could use Sage, everything in the course of the class.
And moreover, I did it in a way that was collaborative.
So absolutely all the functionality of CoCalc is collaborative.
So you have multiple people simultaneously using a Linux terminal, editing a Python script, editing a Jupyter notebook, editing a LaTeX document, whatever.
That's sort of built, baked in from the ground up in CoCalc.
Yeah.
So CoCalc is, I guess the way I see it is like Sage math as a service plus a bunch more.
Is that like a fair representation of it?
Yeah.
Okay.
We'll talk about what those things are, but there's a lot of things going on there.
And this collaborative side, I think is super interesting.
I mean, we're just starting to see that in a lot of other areas.
For example, you know, with VS Code having like the live share stuff, right?
You know, Jupyter Notebook still doesn't have, that I'm aware of, this rich, like Google Doc level of back and forth that you can actually have, right?
There's some online systems that have it.
I think maybe Datalore maybe has it, but it synchronizes a sentence or a cell, right?
It's not like you see it going.
And what's really interesting about the collaborative stuff, which is why I think this is really valuable.
So I'm diving into it a lot here right at the beginning is you can even do like a collaborative bash shell and stuff, right?
Yes.
There's more than just, I can work on the notebook and then there's other stuff.
It's like all that is collaborative.
Every single thing is collaborative.
So you can have a collaborative bash shell with a little chat on the side where you can chat back and forth to each other.
And it's nicely integrated.
You see the other person as they're typing.
And we actually, it's kind of funny, we were looking at different terms to, you know, kind of do SEO for.
So just for fun, we played around with Linux online and online terminal.
And strangely, we're the top, we've been the top hit for both of those search terms for quite a while now.
And we're getting a lot of users for learning Linux online.
They use CoCalc, they use the terminal and they learn Linux.
Right, right, right.
Sure.
Because you get basically a synchronized interactive bash shell.
Exactly.
Oh, I hadn't thought about that.
But of course, that makes a lot of sense.
And there's also a code editor.
So you can edit a .sh file and then run it in the bash shell.
Okay, very cool.
You know, you mentioned the chat.
And one of the things on the website that I thought was cool.
So you've got cocalc.com, pretty straightforward.
That's awesome.
One of the things you mentioned, which I recently ran into in a programming variant, is you have math friendly chat.
Tell us what math friendly chat is.
Okay, so first, anytime you write, so the chat is marked down, but you can use dollar signs.
And it will typeset using LaTeX, whatever's between dollar signs.
So in that sense, it's kind of like you're writing in LaTeX.
So that basically makes it math friendly.
One other thing that I think makes it math friendly is you can look at any message in the past and double click on it and edit it in order to fix something that's wrong.
Mathematicians like everything to be exactly right always.
So whenever you see something that's wrong, you really want to be able to fix it.
Exactly.
You can edit other people's chats, not just your own.
So if somebody else writes a chat and you see a typo or something that's wrong, you can make an edit to their chat.
And it's recorded.
So there's a history of the changes.
And you can see, you can click a button to see what's the history of edits to a particular chat cell.
Wow.
That's really, really interesting.
Yeah.
You know, I slight diversion.
I think that that would fix so many problems with social media like Twitter, for example.
They say, you know, we're not going to let you edit chats because we want to have an authoritative view.
We don't want people to twist what it means.
Like, why isn't there just a history?
Like, show original.
You know what I mean?
Yeah.
It's so bad.
I just recently tweeted and tried to amplify this message as much as I can.
And I'm like, oh, no, there's a bad grammatical error in that.
But I can't fix it.
I just got to live with it.
Right.
And so I think that's a super cool feature.
The scenario where I ran into the equivalent of this is I was in a Zoom meeting.
I have office hours for my online courses.
And I wanted to share some bit of code.
I'm like, this little fragment of Python is what you need to fix it.
And I paste it into Zoom.
No indentation.
Right.
Not even indentation.
The person's got to go through and like rebuild it.
And it's obviously not a fixed width font and all those things, which I guess doesn't matter if you take away the indentation.
But still, just having those little touches, I think, is actually really nice.
And the co in co-calc stands for collaborative.
Am I guessing that right?
Yes, that's right.
Yeah.
So really focusing on that rich exchange, that sort of interactive bits there seems valuable.
Yeah.
For a long time, it was called SageMath Cloud.
And that really made you think it was just a cloud-based way to run SageMath.
And we ended up really, really supporting pretty much everything in the open source math-related ecosystem equally.
And so focusing just on Sage was really kind of not really what we were about.
And we also put so much effort into collaboration.
So we ended up coming up with a name that really focused on collaboration and just general calculation, not just Sage.
Yeah.
It's a great name.
I really like it.
I think it's the right move.
So one thing I do want to touch on, I think, is probably interesting for a lot of people out there listening.
We've got a lot of academics in the audience.
You started out as a professor at University of Washington in the math department, which is a very coveted and challenging position to get.
You worked on this project, and I'm sure it was not easy, but you decided to leave the professor position, leave the department, and then focus exactly on this.
Could you talk just a little bit about that for folks out there who may be wondering how it went or in similar situations?
I went to graduate school and was terrified would I ever be able to get a job at all in academia as a postdoc and didn't expect to.
But then amazingly, I did.
And I had a job as a postdoc for a while, and then I got a job at UC San Diego.
And surprisingly, I got hired with tenure out of my postdoc, which was not at all what I expected to have happen.
And so the job at University of Washington was fantastic.
It's a great department.
The chair of the department is a very active Sage developer.
So it's a very supportive environment.
I have no issues with the department at all.
I didn't leave for reasons like that.
But I just really, really felt it was the right time to focus full time on making CoCalc better.
And, you know, we have a critical mass of users, so it's worth it to do so.
We have three full time employees of the company, including myself.
So, you know, we can support.
There are enough users to at least support significant full time development.
But, yeah, it was a terrifying choice to leave a tenure job, take a salary cut, significant salary cut to work on CoCalc all the time.
So I really had to be very, very confident that this is going to work.
I know exactly how you feel.
It's quite a stressful thing to have a really good job in hand and say, I have this theory that this thing is going to work out amazing.
Let me, you know, with bills to pay and responsibilities, let me just jump in and try the thing.
And also my wife is faculty at University of Washington.
So we had solved the two body problem.
Oh, my gosh.
Yeah, that's really hard to solve a second time.
And I'm also very aware of how hard it is to get an academic position or to go back because half the time I was at University of Washington, there was very, very little hiring due to the 2008 financial crisis.
Yeah.
And it was around that time.
So now looking back, now that you're on the other side of that fence, how do you feel about it?
I really, really like my current job a lot working on CoCalc.
I love it.
You get pulled in a lot of directions as a professor or as an academic, right?
It's hard to focus on any one thing.
You have the, you know, the Monday, Wednesday, Friday, you end up with a full schedule, basically.
So I would basically Monday, Wednesday, Friday, all about teaching and then Tuesday and Thursday, all about meeting with students from, you know, 9 a.m. to 6 p.m.
I would just schedule in a, you know, an hour per student or per pair of students and just fill up my days.
And so we just get an incredibly end up with a very rigid schedule.
So instead of waking up and thinking, OK, what is the best possible thing that I could spend my time on today?
It was sort of already decided what I would be doing for the next, you know, 10 weeks.
You've got that 30-minute gap in there where maybe you could squeeze it in for the day and the rest is already booked, right?
I do like the freedom a lot of being able to iteratively decide on what's the best thing to work on.
And I feel like I still have a positive impact on education with CoCalc because a lot of educators use it in their classes.
And I'm still contributing to the education of students just in a slightly less direct way.
Maybe more so in some senses, right?
Hopefully.
Yeah.
At least in terms of numbers and maybe, you know, average out the impact, right?
Like what I was doing before is I was doing developer training and I would go and work for a week with 20 people or something like that.
And that was, I had a big impact with those 20 people.
But, you know, I had to leave that world to go do the podcast and do the online courses, which, you know, you work with thousands of people.
It's a really interesting trade-off to make.
It's very difficult to scale teaching in certain contexts.
Like as a university professor, there's various limits to how much you can scale up due to it.
Yeah.
Sort of being all owned by the university system.
Yeah.
We're both running into similar things.
So, yeah, it's nice that CoCal can scale up a lot more in your online courses as well than something in the context.
It's basically a matter of awareness rather than, you know, making more of you or whatever.
This portion of Talk Python to Me is brought to you by Linode.
Whether you're working on a personal project or managing your enterprise's infrastructure, Linode has the pricing, support, and scale that you need to take your project to the next level.
With 11 data centers worldwide, including their newest data center in Sydney, Australia, enterprise-grade hardware, S3-compatible storage, and the next-generation network, Linode delivers the performance that you expect at a price that you don't.
Get started on Linode today with a $20 credit and you get access to native SSD storage, a 40-gigabit network, industry-leading processors, their revamped cloud manager, cloud.linode.com, root access to your server, along with their newest API, and a Python CLI.
Just visit talkpython.fm/Linode when creating a new Linode account and you'll automatically get $20 credit for your next project.
Oh, and one last thing.
They're hiring.
Go to linode.com slash careers to find out more.
Let them know that we sent you.
Before we move off this whole academic side of things, let me just ask you really quick.
With all this COVID stuff going on and everything around universities and online education and Zoom education and whatnot, what's going to happen to universities?
Are they going to get a massive transformation?
Is it going to be hard for them to fill up their courses?
Do you think it's just going to go back to the way it was?
What's your view of the next five years of universities quickly?
Wow.
I really wish I had a good answer to that question.
I really want to know the answer to that because it has a big impact on how I should develop co-calc and my wife's job and many other things.
There are people who you'll see a lot of comments online by people who kind of think they know the answer to that question and have a pretty dire predictions.
They often are not seeing the whole picture of what a university is because a lot of research.
I mean, a really important part of the university is the research aspect of it.
Right.
Also, the social aspects of people meeting.
And it is definitely possible to have an online course, as long as it isn't too large, where I think you get a lot of the value of an in-person course.
If you conduct it over Zoom in real time, where you don't just record the lectures and play them back, you actually have real-time discussion between the students.
So I think the traditional value of the university can still be propagated via web-based mechanisms, via the web.
So I think that doesn't go away with COVID.
But yeah, I really, I think things aren't going to change dramatically, but evolution in a more of an evolutionary way.
So there'll be some changes, but it's not going to all come crumbling down.
Yeah, and that probably speaks good things for co-calc, which we'll get into in just a second.
Or just like the real value of the universities is the professors and the students could have a meeting.
And you still have that.
And the professors still exist, and the students still want to talk with them and learn a lot from them.
And I guess the research side of things, I hadn't really considered how much money grants bring into the university, right?
Like if you get a million-dollar grant, half a million or something in that scale goes to the university just straight out of pocket, right?
And so I think the whole research side of the university is still going to have an interesting story there.
We can have a massive-
Supporting them, yeah.
Yeah, it brings in, like at University of Washington, it's well over a billion dollars of their budget every year.
It's just research money that comes in.
How interesting.
All right, so let's dive into some of the features of co-calc.
I mean, we've been bouncing around a couple of them.
And maybe with this conversation, like let's start with talking about teaching a course.
So one of the things that you focused on with co-calc and its origins were helping teach a scientific or mathematical class, either in a classroom or potentially remotely these days, which I don't know how much you envisioned that before, but now it's pretty easy to do.
When I would teach classes, I would usually put all the content for the class on GitHub or on my website and then tell the students, hey, here's the website for the course.
Grab the content, download it, upload it, you know, whatever.
But as soon as other people started using co-calc and I made it available more generally, instructors would just write, I need a functionality in co-calc that does the following.
It takes a directory of files and assignment, pushes it out to all the students, lets them work on it in a way where I can see what they're doing.
And then at a certain point, I can collect the assignment, grade it and return it to them.
And I want that to all be integrated in the system.
So we implemented that and then in 2014 and then iterated on it and polished that kind of functionality over the years.
So now co-calc has its own integrated course management system where you, you know, paste in a list of email addresses of all of your students.
They get invited and they have their own little private workspace, a Docker container where they work on content for the course.
And they periodically receive assignments.
The assignments just appear in their project and they work on it.
And they don't have to do anything to submit the result.
It's just when it's due, it gets collected.
So that functionality is integrated into co-calc.
And it's done in a way where while the students are working, you can see their cursor moving.
You can like, basically you can look over their shoulder and see how they're doing.
See if they're running into errors.
See if things are working well.
Right.
Get a report of when they were working.
If you wonder how their notebook got to a particular state, we have this time travel feature.
It's kind of like a track changes.
You click a button and you get a slider and it shows you.
Exactly what the notebook was at about every three seconds as it's being edited actively.
That's pretty fine grained.
Yeah.
It's very, very fine grained.
And the students also have access to it.
And so I often notice students when I would walk around in a physical classroom with them,
they'd be working.
They'd say, I had this figured out five minutes ago and I messed it up.
And it's really hard to just undo, you know, back five minutes in time in a Jupyter notebook,
especially, which doesn't even have a global undo.
So with time travel, they just have a separate panel right next to the notebook, which is every version of the notebook every three seconds.
And so they can just look and see exactly what they had five minutes ago, copy, paste it back over, and they're back in business.
So it's a kind of reproducibility in a really practical sense.
It's super interesting.
I did notice that that jumped out at me, that the time travel story was pretty cool.
I didn't realize it was every three seconds.
That's great.
And I suspect you're already exchanging that data with the server for the collaborative side.
So just save it, right?
How this came about was I implemented an algorithm in 2014 for real-time collaboration called Differential Sync, which just passes around lots of messages.
It's this really weird, complicated algorithm, and it doesn't record any history of what happened.
And then an undergraduate, Jonathan Lee, who was working on CoCal as a student project, he added in some sort of time travel history feature because I think maybe some like online hackpad type program had it.
I looked at what he was doing, and I realized that you could basically rewrite our whole sync algorithm or come up with a different sync algorithm that automatically recorded the history.
And that was sort of the basis for the real-time sync as well.
So I threw out the old algorithm we were using, wrote a new one, and it made the thing he was implementing a lot easier to implement.
And then I started using it just in coding.
Like I'm editing a Python file or a TypeScript file or something, and I realized, hey, five minutes ago I had some code that I wanted, and I don't want to undo to get it.
It was not put in Git yet.
It's gone.
But with time travel, I just have it there.
So now whenever I'm coding, it's like a critical, I don't know, tool for me.
I can't imagine writing code without having this slider that gives me all past states in my code.
Well, it's a little bit like writing a document in Google Docs or Sheets or something like that, right?
Yeah.
I don't envision that I ever have to save or anything.
It doesn't quite have that fine-grained slider feel to it.
But I was watching a show yesterday.
It was like a sitcom type thing.
And the joke was these college or high school age kids were working on some – it was actually advanced math – on their laptop.
And there was a power surge, and their laptop died.
And they lost all their work.
I'm just like, what do you mean you lost all your work, right?
Like, this is such an outdated show from – I think it was really recent, actually.
But still, like, the concept of my work is not being saved is kind of wild.
With CoCalc, also with development, I've always assumed that for a while we had a lot of bugs, and you'd have to refresh your browser a lot because, you know, memory leaks or it just crashes.
So I've always designed kind of assuming that you're going to have to refresh your browser frequently or your network connection is really flaky.
And so a second or two after you type something, it goes to the server, and that's it.
That's all this – like, after that happens, you can refresh your browser, and you'll be exactly where you were.
And so that's just the assumption with the system that your browser is going to be crashing all the time.
Your network's terrible.
It's not true nowadays, but –
It's a little bit like the chaos engineering from Netflix, right?
Like, let's just throw monkeys into the – you know, wrenches into the mix or whatever analogy you want and say, let's design assuming that it's going to be wrecked.
That's also a fundamental design constraint with collaboration, I think.
With CoCalc, you make a project which is a Docker container, you use Jupyter Notebooks in it, and you invite collaborators to work on it.
And the collaborators could easily, in a few keystrokes, cause all kinds of damage.
And so you want to be able to trust adding collaborators.
And so with CoCalc, as they edit your files, all the changes are saved.
And if you want to revert back to before they messed it up, you just do that, and you won't have to worry about anything being lost.
Also, the files on disk are snapshotted every 20 minutes, like the complete state of all the files.
So if they accidentally delete all the files, you can – I mean, you might lose a few minutes, but you're not going to lose very much.
And there's no way for collaborators that you add to delete the history of editing.
So it's really immutable.
It just is a moving forward immutable thing.
The only way to delete it is to create a support request and ask us to delete it.
At least that person.
That's great.
In a teaching context, that's really good.
Look, if you want to have like a scientific paper you published where you have no history of it, copy, paste.
Here's the new version, right?
I mean, same thing with Google Docs.
Exactly.
If I work on something and I share the Google Doc with someone else, you know, say it's like a business proposal or something,
I assume that what I've typed, they're going to potentially go and look at.
So either export it as a PDF or just, you know, just know when you go in that that's how it's going to be and it's just – that's fine, right?
Yes.
So let's round out this teaching side of things, I guess, really quick.
So probably in the fall, I don't know what the world is going to look like.
Fingers crossed, it's vaccines.
Everything's well, but, you know, that's not necessarily the likely outcome.
So there's probably a lot of teachers, both middle, high, college, and even grad school level teachers thinking,
right, well, I'm going to have to do this online.
One option is I get a whiteboard and I write on it with a pen, you know, like a digital pen to teach something.
It sounds like this might be a better option for certain types of classes, at least as a side-by-side with a video call or something.
What do you say to those people, like, how could they use it?
What role would it fill there?
If you ever had like a computer lab part-tier class where you wanted all the students to work on a Jupyter notebook or something like that,
like, CoCalc basically just puts that in the cloud in a way where you really can walk around and look at students' work and, you know, jump in and start editing and see when they're active.
So it solves that.
And it makes it a lot easier to have homework assignments that involve Jupyter.
Could I have like 20 students and just open 20 tabs and just, you know, command alt arrow between my students?
Yeah.
And you also, whenever they have an issue, they can type a chat in the side and you'll see a notification and you can click on that notification and you'll open exactly their document.
But yeah, absolutely.
You could just command, you can just tab through all the students.
Or if you had a really big monitor, watch them all at once.
Exactly.
Yeah.
With that 55-inch 4K TV to good use.
We are constantly being contacted by instructors who are basically being forced to move classes online and looking into options.
They find CoCalc.
They think it might work, maybe not.
They ask us a bunch of questions.
The answers are all yes.
And then they're amazed and they start using it.
So people often assume, I think, some of the things that we can do well, probably nothing can do them yet.
But we can do them now.
Very cool.
Now, I was going to save this question for a little bit later, but let me jump it ahead because it might be more relevant here.
What does this cost?
Is it, I know there's a free tier and you can go over to CoCalc.com and do stuff for free.
But is this teaching a course free or what's the story there?
You can use CoCalc for free in a couple of ways.
But if you really want to teach a course and have the students have a good experience, etc., then it's basically, I mean, there's a range of different costs.
But basically, think $15 per student.
That's roughly, on average, what it comes out to.
There's a fee the students can pay directly or you can have your university pay us or something else.
Yeah.
I mean, it seems like maybe in a high school scenario, you might have the school district pay.
But in a college scenario, man, students are used to just paying and paying.
I remember when I went to my first, I first started out in community college and I paid my tuition and it was like $400.
Like imagine that, right?
For a full 15 hours course.
And then I went to the bookstore and it was like $600.
I'm like, how can the books cost more than the entire tuition of all the courses?
Like this doesn't make any, like $200 for a chemistry book or something like that.
So I think $15 to take a math course is probably a drop in the bucket.
It's probably easy enough.
If there's a textbook, it's about the sales tax on the textbook.
It's about the cost of the sales tax on the textbook.
Yeah.
It's interesting when, you know, from a starting a business side of things, some universities, it's the culture that all the students pay directly.
And other universities, that would be, it's considered unethical and crazy to have the students pay directly.
It's kind of like random which one it is.
Like University of Washington, the students pay.
That's just how it is.
Whereas various universities and other places, it would be considered just crazy to do that.
Right, right.
How interesting.
Well, if you're talking Mathematica or MATLAB or Maple, like student pay is like a lot of money.
Yeah.
Whereas there's the base rate, but oh, I also need the wavelet decomposition toolbox and I need this other toolbox.
And now all of a sudden it is legitimately really expensive.
All right, cool.
So the teaching side, I think it's really interesting.
And maybe let's talk about some of the other things that it does.
So you talked about the time machine thing, and that's a form of version control.
It's a little less structured than I'm saving a point in time actively.
Is there a way to integrate this with a GitHub like a thing or external source control?
Can I export it?
How does that happen?
A CoCalc project is literally just a Docker container running Ubuntu, currently 1804, but it seemed to be 2004.
And you can use the terminal and any Git commands in the terminal.
That's what people frequently do.
So there's like in the Docker, the shared Docker collaborative space, there's a Sage workbook or something to that effect, plus the other files.
And I can just get add those things, get in it and then get push and get add and so on.
Yeah, you just have a home directory.
It's a file system.
The default free quota is three gigabytes per project.
You can create as many projects as you want.
And within a project, you can say, you know, get clone, get pull, get push, get add, and just use all the Git commands, which usually is pretty easy.
Because anything you could possibly imagine wanting to do with Git, you just Google it and you find it pretty quickly.
And there's like 10 examples.
Yeah, for sure.
For sure.
But there's no graphical integration yet.
It's all like you use the terminal.
Sure.
What about file exchange?
Is there like a draggy droppy in the tool or do I have to use SCP or anything like that?
There's a pretty nice, I guess, file explorer application inside of CoCalc.
And it has drag and drop functionality in that you can just drag a file or directory from your desktop.
onto the file listing and it just gets uploaded automatically.
And next to any file, there's a download button.
So you can download files back.
You can also set up an SSH key, just like in GitHub, either for an individual project or across all projects you're using.
And once you upload an SSH key, your public key, then you can SSH to any of your projects.
And then you could use SCOPPY or R-Sync or some graphical tool on your desktop to sync files back and forth.
Yeah.
It's really just like a remote Linux server, basically.
Yeah.
Cool.
So you say Docker.
A lot of people hear Docker, they think transient.
Is there like a persistent map volume or something like that where it's kind of permanent?
We have a really cool thing.
What we do is we have this, it feels like you're running a Docker container that's about where the image is about 300 gigabytes.
Because we install every Python, like 9,500 Python packages, like 10 different versions of Sage and a whole bunch of versions of Anaconda.
We install everything and we install everything and the Docker container.
When the Docker container when the Docker container spins up.
And we also plug a home directory into that Docker container.
And so you have a fairly lightweight little Docker container that via remote file systems has a huge amount of useful information inside of it.
Yeah.
That's cool.
It's important because we want to be able to start the thing fairly quickly.
Yeah.
Every little bit of computational resource, you want to keep that, right?
Yeah.
Speaking of which, where are you running this?
When I go to CoCal, can I calculate?
Where do I calculate?
It's on Google Cloud Platform and Google Compute Engine.
And physically, it's on the East Coast currently.
That seems like one of the best choices, right?
Yeah.
That's where my servers are.
They're New York City, actually, right now.
But you've got to pick somewhere.
It's good for the US.
It's good for Europe.
It's less good for other folks.
But if you've got to pinpoint somewhere in the globe, that's probably, as terms of user, at least from what I experience, that's a good place.
We have a lot of users in Europe.
And so it makes sense time-wise.
We do plan to expand to other data centers when we have more users.
And also, one of our main developers, Harold Schilly, lives in Austria.
And so he wants it to be at least not ridiculously far from him.
Yeah.
No, that makes perfect sense.
I agree.
I think it's a good spot.
You talked about running graphical software.
I guess let me go back and touch on one other thing.
You talked about all these packages.
So it sounds like if I can SSH in or I can go to the Bash shell through cocalc.com's live interactive bits, I can pip install whatever I want when I get in there?
Yes.
Yeah, you can pip through your pip install.
And it just installs it into tilde slash dot local.
And yeah, so you can install any packages.
You might find that almost anything you want to install has already been installed because our Python environments have basically everything anybody's ever requested.
since 2014.
Is it standard Python?
Is it Anaconda?
What do I get when I drop it?
Yes, in the sense that there's a Python 2 system-wide, a Python 3 system-wide.
There's several versions of Anaconda.
There's each version of Sage has its own Python install inside of it.
So there are many, many different Pythons available.
If you look at the list of Jupyter kernels that we have there, it takes up the whole page.
Interesting.
So speaking of Jupyter and Jupyter kernels, it sounds like SageMath is slightly different than Jupyter itself, Jupyter Notebooks.
But also that there's some compatibility between, like, could I take a Jupyter notebook, IPYNB, whatever the extension is, and drop it up there and work on it?
In CoCalc, you can use Jupyter Notebooks.
We have a reimplementation of the Jupyter stack, but it uses standard Jupyter kernels.
And it's designed to be as compatible as we can possibly make it with, you know, the official upstream Jupyter project.
And that's a big difference, I think, from some of the other Jupyter-ish implementations, like CoLab and Kaggle.
Like, we have all the same menu options as Jupyter Classic.
And we really, I put, you know, basically my to-do list when implementing the new version of Jupyter for CoCalc was to implement every single feature that Jupyter Classic has.
Maybe we're at 99%, but our goal is to be 100% compatible.
That's cool.
So it sounds like if you have students and you're talking to them about, here's, they know Jupyter or they're looking at Jupyter documentation, it'll pretty much just work.
Yeah.
Not only that, in CoCalc, we have our built-in Jupyter client, but we also have a button that you can click, which runs a Jupyter Classic server from the project.
And then it's, you're looking at exactly the same.
It literally is.
Yeah.
It is Jupyter Classic.
And we have another button that runs Jupyter Lab.
So you can fully just use Jupyter Lab or Jupyter Classic to interact with your project instead of CoCalc's view of the project.
Do you probably lose the collaboration at that point?
Yeah.
Because those don't have collaboration.
So you lose the collaboration, but at least you can, you get 100% compatibility with those programs.
Right, right.
That's a good escape hatch.
One thing that I thought was pretty interesting that I didn't necessarily expect was I saw on the documentation, X11.
Yes.
That's like a remote windowing system for a full-on Linux applications that are Windows-based.
So you can do that in here as well?
Yes.
This is kind of weird, but there's a couple of HTML5-based X11 servers out there like Apache, Guacamole, and Xpra.
And people, every once in a while, people requested that we add something like that to CoCalc.
And it was always like, you know, they can do 99% of what they need to teach this class, but there's this 1% where they want to use an old Java application with a graphical interface for a few days in the class to look at some data or, you know, something like that.
And so I decided to finally try to figure out how to do it and ended up writing an Xpra client.
So I took, so Xpra, Xpra is some X11 server that runs under Linux, and it has an HTML5 client that they have.
And I took their code, and I basically rewrote it.
In a way, basically like paint the screen on an HTML canvas or something like that.
It sends you a bunch of data and then use an HTML5 canvas to display that data, and you handle clicks and so on.
So I just rewrote their client to fit into CoCalc collaboratively.
Like you can have multiple people looking at the same X11 application, and when somebody moves their cursor, you'll see the cursor move around.
So that's actually collaborative.
That sounds really cool, actually.
The gotcha is just, you know, it's over the network, so it's slow.
There can be latency, which is really annoying for a graphical application.
Yeah, but it exists.
It's better than nothing.
There are a few, like if you want to play around with Tickle TK to do some old school Python graphical user interface development for like, you know, an assignment in a class, you can totally do that in CoCalc.
You can fire up Idle, which is the official Python, you know, graphical interface that nobody uses, but it's official.
Yeah.
And you can type in some commands to pop up graphics and they'll work.
Yeah, it's pretty neat.
Or you can run GIMP or Inkscape or something.
Yeah.
So I don't think it gets used a lot, but again, it was really aiming at the very edge case that would be something that stops somebody from teaching a course or otherwise using CoCalc.
Right. Or they have this one GUI interface that they did for this research project and they want to move the research project there.
Yeah.
And if they're going to do that, they need it to work or something, right?
Yeah.
Very interesting.
All right.
Well, what else is notable?
You know, something that jumps out at me is you kind of have like MATLAB support in a bit.
Yeah, Octave.
In a sense, right?
Through Octave.
Tell people about that.
The Octave Jupyter kernel, we, you know, make sure that graphics work nicely.
And yeah, so you can use Octave.
Octave is very similar to MATLAB, at least for the basic language.
And yeah, Jupyter.
And in the graphical interface we just talked about, there's also an Octave client, which, you know, shows Octave graphics.
And kind of looks like MATLAB.
I don't know much about Octave.
I haven't, I used to do some MATLAB stuff, but I never do think of Octave.
How close are those two things?
Very close, but there's deep functionality for certain special domains that aren't implemented in Octave, but are available in MATLAB.
So like, there's various toolboxes and so on that aren't there.
But I think the language is nearly compatible.
Cool.
So that's a pretty good option.
And again, online as part of this thing?
Yeah.
And other things to note about CoCalc, you can run CoCalc yourself.
There's a Docker image that we regularly update.
And so you just type a command in Docker and you're running your own CoCalc server on your laptop or on a remote server.
It's like a mini version of CoCalc with all the same functionality that you run locally or anywhere you want.
Yeah.
Very cool.
Okay.
Nice.
LaTeX.
We already talked about LaTeX in chat.
And for those who don't know, LaTeX is a markup language, kind of like HTML, but for visually accurate mathematical representation.
So if you want to do a sum from N equals one to a thousand, it has the little N equals one at the bottom and a thousand.
Like it's the representation that you would write in, you know, proper math class.
Right.
So it's kind of a markup for that.
And you, you all have some pretty good support for that there as well.
Yeah.
So it's what everybody who writes papers and math and physics and probably some other areas in academia will use for sure, because it looks very, very professional.
It has excellent support for cross-referencing between different sections and splitting your document up into different files and so on.
So we fully support that.
Also, there's a package called, I think, PyTech, like use package, P-Y, and then you go backslash P-Y, and then right in your LaTeX document, you can type a Python, a bit of Python code, and it gets evaluated whenever the document gets updated.
So that's pretty cool.
And there's something similar for Sage called SageTech, which lets you embed plots and arbitrary Sage code in your document, which automatically get updated when the document gets compiled.
And we make that very easy to use inside of CoCalc.
So you don't have to install anything or mess with anything.
It just works.
Yeah.
And one of the things I thought was pretty cool there was right on the home screen, you've got a representation of some nice, it's not that fancy, but it is, you know, proper LaTeX representation of, you know, fractions and square roots and stuff.
So you say, show LaTeX.
So you've got a solver that solves an equation.
And then you say, just show LaTeX of the solution.
And boom, there it is.
That's pretty cool.
If you just say LaTeX of the solution, then it shows you the code that you would put into a LaTeX document or a markdown file to get that beautiful formula.
Cool.
So it shows you that like the LaTeX markup, the dollar or whatever.
Yeah, exactly.
Yeah.
Okay.
That's basically a feature of Sage and other systems.
Like SimPy has something similar.
So you build up some complicated answer and then you just say, give me the LaTeX so that I don't have to try to convert this ASCII looking thing into something nice.
You'll make a mistake or a typo.
Yeah.
You definitely don't want that.
Yeah.
So another thing that stood out to me was that you have database support for things like Postgres and whatnot.
You know, again, it's just Ubuntu Linux.
So we have a lot of things pre-installed that people requested.
And it's just sitting there and you can use it from using Python or other languages.
Yeah, sure.
So maybe you analyze some data, throw it in there, put some indexes on it and let you ask a bunch of questions quick and fast.
And the nice thing is it's all in one place, like all in the same site, all in the same container.
You can work with some Python code.
You can use it in a Jupyter notebook.
You can play around with the data from a database and then write a paper in LaTeX all in the same place with collaborators.
Yeah, that's really cool.
And it's all saved there.
Very nice.
So there's a bunch of other features that we're not talking about, but these all seem really, really cool.
And the collaborative bits are really neat.
Like there's our support and other stuff.
I guess maybe we could talk a little bit, getting shorter on time here, I guess, but talk a little bit about some of the internals.
You already mentioned that it's basically your own re-implementation of the Jupyter stack because the way Jupyter worked, it didn't really support real-time collaboration, right?
Yeah.
Basically, Jupyter has a front-end client that receives a bunch of messages from the kernel.
They just kind of get proxied from the back end to the front-end client.
And the front-end client decides what to do with all that information.
So a huge amount of processing goes on on the front-end.
And with CoCalc, that kind of model really doesn't make sense for us.
So instead what happens is back on our servers, we process all the messages from the Jupyter kernel and then figure out how that should make the document evolve.
And then we just synchronize the document between the front-end and the back-end.
And it's a very different architecture than Jupyter currently has.
And so it made real-time sync difficult.
I did implement real-time sync directly on top of Jupyter Classic for a couple of years.
But it mostly worked.
But every once in a while, things would go wrong.
And we kept getting complaints from users.
And I really wanted that last 1% to work.
And I kept trying to figure out how to do it.
And I couldn't find any way to do it besides just rewriting the whole thing, which took months and months of effort.
It's one of those things that doesn't seem so...
It's a tough decision, right?
You're like, oh, no, we're going to have to do this.
Here we go.
You have to underestimate the difficulty in order to start.
Otherwise, you wouldn't do it.
Exactly.
I bet we could pull this off two months later.
You're like, boy, this was more than I bargained for.
Exactly.
Now you're committed, right?
Yep.
Yeah.
And we continue to be committed.
So we have to implement every extension as well.
We have to re-implement all the extensions.
So we prioritize that based on what is most in demand.
So people want the table of contents extension to Jupyter.
So we have to re-implement that so we don't get anything for free.
Do you have telemetry and stuff like that that tells you what's going on?
Or is it sort of support requests coming in?
We have a lot of telemetry because of this time travel.
We're recording everything that's happening and so on.
But we basically ignore it for the most part and make our development decisions and our direction based almost entirely on support requests from users.
We make it very easy for users to ask us questions.
Just click a button help in the top of the screen, type something, and then we get the support request.
And so that really drives our development.
It's just what people are wanting and people are willing to share.
We also have a Discord chat room where people often tell us what they want.
So there's probably a lot of Python going on here.
But there's also probably a lot of JavaScript being basically a very fancy single page application.
Exactly.
Right.
Yeah.
It's lots and lots of TypeScript code.
Both the front end and the back end is mostly JavaScript.
We use Python mostly for managing the complicated back end stuff, like getting projects to run and moving data around.
And there's just a lot of tasks that periodically happen on a Kubernetes cluster and monitoring tasks.
But CodeCalc is mostly a TypeScript application.
Because a lot of it runs in the web browser and that's just the canonical language these days.
It sadly is.
I wish that the story could be a little bit different.
I mean, on one hand, I lament it for Python.
On the other, what other environment is there only one language?
Yeah.
It's pretty amazing how JavaScript has been dominant.
Other things haven't really picked up in the browser.
Yeah.
It's really surprising.
Things like Dart and other things just haven't caught on.
Yeah.
And a lot of the foundations we might have with WebAssembly and so on.
I guess I'll take us on a slight diversion.
I really wish that there was a way to have more runtimes running as WebAssembly in the browsers.
Right.
I mean, on one hand, you say, well, it's C, so you compile it to WebAssembly and then you can just link it and download it.
But no app is going to say it's acceptable to have a 10 megabyte download to get my page to show.
Right.
Yeah.
I mean, maybe if it's something like CodeCalc where you're there for a while, but like not in the general sense.
But, you know, if you had a set of canonical, like here's the Java runtime, here's the .NET, here's the CPython, here's the.
And those just got shipped as part of Firefox, Chrome, Edge, and that you didn't have to download them.
All of a sudden, you know, we would be free from JavaScript.
But that's a world I see in the future.
It doesn't sound like Python on the front end has a lot of value to you guys at this moment.
We don't get any requests for that from our users ever.
I don't know if that's because there aren't lots.
I'm not saying that there isn't a huge demand for it.
It's just that I think maybe other sites like Replete and just other things already solved that problem.
So people don't come to us because they don't need us for that, to solve that problem.
You already have a way for them to execute Python.
Yeah.
Right.
It happens back there on the server in a totally fine way.
It would really be just for you guys so that you could say we'd rather write Python if that were the case.
I don't even know if that necessarily makes sense.
Right.
Because you probably have nice front end frameworks.
Yeah.
We just type it.
We use TypeScript and React.js.
Exactly.
TypeScript's pretty good and provides a lot of value and it kind of fits into the browser ecosystem.
So there's that.
I mean, Python's somehow developed as a language that's super good for data science and scripting
and a lot of types of applications.
But I think TypeScript and JavaScript have developed to be really good for asynchronous applications
where you're often responding to a flow of events and where everything is not as non-blocking as
possible.
And most code, individual code runs very quickly and is responding to things.
So it's, they kind of tend to be solving different problems well or differently.
Right.
Well, that's what you get when you write a language that has no mechanism for synchronous calls.
Yeah.
Right.
It has to be callback or async and await, depending on how modern it is.
Interesting.
All right.
Well, it sounds like a pretty cool project.
I mean, it's, I love the collaborative side of this thing.
And when I heard CoCalc and I thought about it, I envisioned the notebook thing to be very
collaborative, but I didn't expect, you know, collaborative GUIs, collaborative Linux terminals,
collaborative, all these things.
I think this is, you know, at a higher level of collaboration than I realized, which is,
you know, a real testament to what you guys built.
Cool.
Yeah.
All right, William, before I let you out here though, I've got to ask you the two questions
and I'm looking forward to the answer to this one.
First of all, if you're going to write some code, what editor do you use?
So CoCalc itself, when I started writing it, I also bought one of the original Chromebooks
from Google.
I can't remember what it was called, but it was...
One of the nice ones.
Yeah.
But it was really running Chrome OS, which was very limited back in 2013, 2014.
And I decided to write CoCalc entirely from within CoCalc.
And, you know, I bootstrapped it a little bit to get going, but then after that,
all the development since then has been from within CoCalc.
So really the editor under the hood is Codemirror.
I've developed, you know, added a ton of extensions to Codemirror and functionality to...
For example, if you're editing a page of code, you can split it horizontally,
vertically as many times as you want and look at lots of different points in the document.
There's code folding, syntax highlighting.
The time travel feature just...
I kind of consider that a basic need for editing code now.
I find it impossible to imagine editing code without that.
So the one thing that is really lacking from CoCalc for being a full IDE is VS Code-style
language server protocol support, where you get extensive information about typing and other
sort of static analysis of your code.
And there's no reason that I can't add it.
It's just hard and I haven't done it yet.
And I'm working on that.
For sure.
But before CoCalc, I used Emacs for a very, you know, for like 20 years.
Well, you always think about, you know, when as a language, a proper language, when it can
build itself, you know, when it can compile its own runtimes and when it's creating itself.
And this is an interesting thing for the editor as well, right?
When can you create this tool with this tool itself?
And I think that's a pretty awesome thing.
It's got to help make it better, right?
Because it's one thing to say, well, students get to type in here and they're a little annoyed
with that thing, the way it works, but whatever.
Yeah.
Versus I got to live in this thing day to day.
No, we're fixing that problem all of a sudden, right?
Is there some of that?
Oh, yeah.
Yeah.
Like we've had a million problems over the years and they hit me all day long every
day.
So it definitely helps me prioritize them.
Not taking this paper cut anymore.
Exactly.
Tomorrow I'm fixing this or whatever.
All right.
And then a notable PyPI package.
So there is a package for SageMath.
You can do pip install SageMath, but it's a kind of silly package because all it does is
check that you have Sage installed somewhere on your computer.
It doesn't actually install anything except this sort of like tiny little five lines of code.
code.
And in the future, though, I hope someday, maybe in five years, when you do pip install
SageMath, it will actually install Sage into whatever Python environment you're using.
So that's a major challenge because Sage is like a million lines of code.
That's new code written for Sage plus a bunch of dependencies, which are themselves, you know,
hundreds of thousands of lines of C code and assembly and other things.
But, you know, that's if I had a million dollars to spend on Sage development, that would be what
I would want to do.
I would want to break up Sage into smaller pieces.
Take like the really cool Python functionality we've written for Sage, break it out of Sage
and make it lots of Python packages.
So my favorite PyPI package is the many non-existent packages that exist only in my head, which together
someday would make pip install SageMath install SageMath.
There you go.
That's like calling your shots, right?
Yeah.
We're going to do this.
Here it comes.
Awesome.
It's from 2030.
Exactly.
Put it on the calendar.
All right.
Final call to action.
People want to get started with CoCalc.
Maybe try it in their classroom or try it in one of their research projects.
What do they do?
Just type CoCalc.com into your browser and you'll get to the website and there's lots
of information right on the website about how to use it.
You can also be type share.coCalc.com.
You can browse through like tens of thousands of documents people have publicly shared from
CoCalc.
So they're like Jupyter notebooks, markdown files, all kinds of different things.
And when you're looking at any one of those documents, there's a big green button at the
top, which is called open and run or run now.
And when you click it, it will start up CoCalc and interactively run that thing.
And you don't have to make an account.
You don't have to do anything at all.
Just sit back for a few seconds and then you'll be using CoCalc.
And it's completely anonymous and free to do that.
Yeah.
Very, very cool.
All right.
Well, great work on this project.
It's so nice to check in with you.
You know, we last spoke in 2016 and I think at the time you were still in your professor
role, but working on SageMath.
So what a long journey you've been on and well done.
Thank you very much for having me on the podcast.
Yeah, you bet.
Bye.
This has been another episode of Talk Python to Me.
Our guest on this episode was William Stein, and it's been brought to you by Linode and us
over at Talk Python Training.
Start your next Python project on Linode's state-of-the-art cloud service.
Just visit talkpython.fm/Linode.
L-I-N-O-D-E.
You'll automatically get a $20 credit when you create a new account.
Want to level up your Python?
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
Or if you're looking for something more advanced, check out our new async course that digs into
all the different types of async programming you can do in Python.
And of course, if you're interested in more than one of these, be sure to check out our
Everything Bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, the Google Play feed at /play,
and the direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
I'll see you next time.
Bye.
you
Thank you.