top | item 3264341

The price of a messy codebase: No LaTeX on the iPad

328 points| steeleduncan | 14 years ago |vallettaventures.tumblr.com

242 comments

order
[+] atakan_gurkan|14 years ago|reply
The price of a LaTeX rewrite would be even higher: incompatibility. If one tries to rewrite TeX, the problem gets much much worse, since TeX is, for all intents and purposes, bug-free. A new implementation will certainly not be. Joel Spolsky said it very well http://www.joelonsoftware.com/articles/fog0000000069.html

I disagree that the current situation is LaTeX developers' fault. TeX and LaTeX are complex pieces of software, that are developed over time. They were extended as the capabilities of their platforms increased, to take advantage of those capabilities. This requires full access to the OS utilities, and naturally LaTeX environment does that. If anything, this is Apple's fault. For whatever reason, they cannot allow applications to use the existing capabilities of the underlying OS. This goes against the Unix mindset; of course there will be unpleasant consequences, but one cannot hold Unix mindset responsible for these.

[+] tolmasky|14 years ago|reply
Unless I'm forgetting something from the article, the author never said it was the LaTeX developer's fault -- he simply said Apple was right for not allowing it in its current state. Not all situations are someone's "fault", and thus just because Apple is not at fault doesn't mean the developers are. It's just as you declared it, an unfortunate result of many decisions which were right at the time.

That being said, I also think you have a low bar for definitions of "bugs". Terrible performance is very much a "bug" in my book. Even the things that aren't "bugs" in the strictest sense can still make for bad software. The executable described here is 4GB, that's 1/4 thte total space on a low end iPad! Also, if tomorrow someone does discover a bug, it sounds like this would be a mess to fix. The jumble of source simply won't be attracting many new developers (whether it be to fix existing bugs, add new features, or port to new platforms).

[+] nailer|14 years ago|reply
> For whatever reason, they cannot allow applications to use the existing capabilities of the underlying OS. This goes against the Unix mindset; of course there will be unpleasant consequences, but one cannot hold Unix mindset responsible for these.

Using the native capabilities of the OS in the sense you mean - allowing TeX to use its ancient, hideous bitmap font system, goes against:

- Unix philisophy - do one thing well, link against or pipe to other apps/libraries that do their thing well

- Simplicity. The user should not be forced to make an unnecessary choice where one option is almost always superor to the other.

Knuth's concept of 'bug free' is one of an academic computer scientist. TeX has many, many issues: unnecessary dependencies, a horrible build process, and many UX issues that stopped TeX from reaching TeX's original goal of 'allowing anyone to create typeset documents'. This is fine: Knuth is a mathematically focused computer scientist from a period where everyone who had access to a computer was a programmer. It was valid in this era.

[+] X-Istence|14 years ago|reply
The big problem on tablet devices is constraints in memory. Yes the unix way is to have various small utilities work together through pipes and interprocess communications. The big challenge at that point is how to do you manage memory? What if a single process in that huge chain uses up all of the memory and another process gets killed by the OS which was part of that chain (do note, no swap on mobile devices)... How is the calling program supposed to handle one of its subprocesses suddenly dying?

Do note that the same is true on Google's Android OS. You can run as many threads as you want, but no calling other executables to do work in the background ...

[+] pantaloons|14 years ago|reply
I'm curious where you get the idea that LaTeX is bug free. In my experience it is rare to find two packages that work together bug free, yet alone the collections of them needed to form even a respectable document.
[+] bh42222|14 years ago|reply
There's rewrites and there's rewrites. I think what Joel is against is the starting from scratch rewrite, I agree with him on this.

But I don't think Joel is against a slow, one line at a time, working on the old code base rewrite.

It is not clear what kind of re-write the OP is advocating. But I would be surprised if he is pro the start from scratch kind.

But it might be just my biased perception.

[+] idspispopd|14 years ago|reply
>This requires full access to the OS utilities, and naturally LaTeX environment does that. If anything, this is Apple's fault.

I'm interested to see how this could be justified, instead of "hit'n'run" style.

Noting here that other than the source problems, performance was a considerable issue.

[+] zerostar07|14 years ago|reply
The only think i 'd keep from old tex is part of the mathematical notation. Otherwise, it's bloated, quirky and doesn't handle international text well.
[+] dextorious|14 years ago|reply
"""The price of a LaTeX rewrite would be even higher: incompatibility."""

Yeah. The only benefit is a codebase that reflects current needs and can grow in new directions and follow current practices, that programmers of today are familiar with. And also be faster, and more flexible. But what are those compared to compatibility right?

(Of course people interested in pure compatibility could just continue to use the old version, until the new is compatible enough, or they don't need compatibility anymore).

"""If one tries to rewrite TeX, the problem gets much much worse, since TeX is, for all intents and purposes, bug-free."""

And your wrong assumption is a) that a problem has to be bug free to be useful or b) that a new effort can't produce a relatively bug free codebase?

[+] patrickg|14 years ago|reply
* First of all, the OP mixes up LaTeX and TeX. TeX is written in a very portable language and has been ported to more platforms than most other software, including PDP-10 and others.

* LaTeX is working on the iPad, see for example: http://meeting.contextgarden.net/2010/talks/2010-09-14-arthu...

* LuaTeX (http://luatex.org) is written in C, not WEB.

* You only need one binary to work with TeX. Either PDFTeX or LuaTeX. All other binaries are just glue code (for example to generate missing Metafont fonts, but who wants them these days anyway?

[+] JoachimSchipper|14 years ago|reply
"One binary" is a bit optimistic; even if you never do anything fancy with fonts, you'll want bibtex. And makeindex, if you're writing a large work. PSTricks does not work with PDFLaTeX (Tikz is arguably better than PSTricks, but PSTricks won't be dead anytime soon). XeLaTeX is required to use system fonts easily.

And that's before getting into anything truly gross.

[+] EdiX|14 years ago|reply
> * You only need one binary to work with TeX. Either PDFTeX or LuaTeX. All other binaries are just glue code (for example to generate missing Metafont fonts, but who wants them these days anyway?

A lot of TeX uses Computer Modern to typeset the body (a metafont font) and I don't think I have ever see a TeX document that doesn't use Computer Modern or Euler (another metafont font) for equation typesetting.

I also wonder whether it's possible to achieve the excellent equation typesetting capabilities of TeX without metafont.

[+] antihero|14 years ago|reply
I may be being dumb, but is there a good tutorial for LuaTeX?
[+] jen_h|14 years ago|reply
One real issue is that most users' LaTeX environments are highly customized and tweaked to our own liking. Even if it weren't absolutely nuts to put every-package-and-extension-known-to-man inside a iOS binary, it still wouldn't be right. Like, what if I want LaTeX2HTML (I've never not had to highly tweak this)? What about my snazzy custom fonts? That bibliography style that only one journal accepts and requires these crufty old stys from 2.09?

If I needed LaTeX on a daily, here's what I would do:

1. Install DropBox on my mobile device and a designated "build" box--maybe just your home computer or an EC2 micro.

2. Set up Jenkins on a box that's got your favorite LaTeX environment and create a job that takes your LaTeX source files, builds and outputs your desired formats and pops them into an output folder you created on DropBox.

3. Set a build trigger that runs a build every time you touch a specific "ready to build" file.

4. Edit and write LaTeX source files on your mobile device using an app that syncs with DropBox like PlainText.

5. Increment something in your "build trigger" file.

6. Et voila, check the DropBox app on your mobile device for output and log files. :)

[+] podperson|14 years ago|reply
Sounds to me like a LaTeX App for iPad that offloaded page rendering to a server which also handled configuration would be a nice product. I'm guessing the market might not be large enough.
[+] spitfire|14 years ago|reply
LaTeX as a service. LaaS has a nice ring to it.
[+] mbq|14 years ago|reply
Buying a real netbook is way easier... and you have a better keyboard (-;
[+] ajarmst|14 years ago|reply
Which is very similar to what I did. A simple cron job with a bash script is quite sufficient (assume a *nix environment), and you can use the make utility to add your build trigger support quite simply.
[+] rmc|14 years ago|reply
I don't think this is a problem with LaTeX & "messy codebase", I think this is a problem with restrictions on iOS from Apple.

The crux of the problems with porting it seem to be that everything has to be in 1 executable, that there can be no scripts, and it must be in an approved language. That's merely a problem from Apple.

A correct title would be "The price of restriction on apps: No LaTeX on iPad"

The author also thinks it's be easy to just switch licence to GPL. Unless LaTex & TeX required copyright assignment, you cannot switch to GPL without getting every contributor to agree. The author is also under the believe that you cannot have commerical software that's GPL. It's DRM software you cannot have with GPL, and that's why Apple doesn't allow it.

[+] dextorious|14 years ago|reply
"I don't think this is a problem with LaTeX & "messy codebase", I think this is a problem with restrictions on iOS from Apple."

No. It's a problem with LaTeX & messy codebase.

Take Apple out of the picture, for a minute: the messy codebase remains a problem with TeX/LaTeX.

It doesn't lead itself to easy extension, it doesn't lead itself to easy incorporation of features such as full Unicode support, Open Type font special capabilities, and much much more. There have been several attempts to fix this, namely LaTeX3e, Omega et al, but none has been that successful. We're stuck with a codebase that works, but is messy, too complicated (ever tried to set up a LaTex/Tex distro from scratch), and obsolete in many parts.

[+] ivansavz|14 years ago|reply
In this paper[1], they say that much of the latex running time is eaten up in the startup and shutdown of the program and the actual typesetting time is in the microseconds.

A long-running process (daemon) is therefore a much more efficient way to run (La)TeX.

[1] www.tug.org/TUGboat/tb27-0/fine.pdf

""" On my current 800 MHz PC, the command

  $ tex story \\end
takes about 0.137 seconds, while

  $ tex \\end
takes 0.133 seconds. The first command typesets a small page of material; the second does nothing but start TEX and then exit. Thus, typesetting the small page takes about 0.004 seconds. """
[+] wtallis|14 years ago|reply
It strikes me that TeX ought to take a page from Lisp interpreters and dump core after loading all the standard configuration files, so that future runs won't need to waste so much time on initialization.
[+] microtherion|14 years ago|reply
Having ported a TeX distribution to MacOS classic some 15 years ago, I feel that the author overstates some of the difficulties. In particular, it's not all that hard to get kpathsea to work without callouts to bash scripts (it's not like Mac OS classic supported system() or anything like it). Basically, kpathsea is an API, and the implementation can be switched out (e.g. I implemented a dbm based file name cache).

Admittedly, getting everything linked into a single binary might be fairly hard.

[+] jsilence|14 years ago|reply
"iPad is the most beautiful platform out there"

Sorry, but I fail to understand, why any serious TeX-Head would say that. The platform is crippled and your problem shows it. You are ranting in the wrong direction.

-jsl

[+] guywithabike|14 years ago|reply
"Beautiful" has nothing to do with whether it's crippled or not. In any case, how is a 4GB executable + several-second runtime for trivial documents Apple's fault? Is the iPad crippled because it can't run a crappy cross-compiled version of OpenOffice with a PS/2 mouse?
[+] joshu|14 years ago|reply
Please don't sign your comments here. Thanks.
[+] EdiX|14 years ago|reply
The author is not a TeX-head, or he wouldn't be surprised about WEB, Pascal and wouldn't confuse Plain TeX with LaTeX (the documentation of TeX is the former not the latter).
[+] tedunangst|14 years ago|reply
Beauty and function are measured on different axes.
[+] mbq|14 years ago|reply
Fully agree; computer is something on which you can write, compile and run a native program without using external machines. And TeX is a computer typesetting system.
[+] maximusprime|14 years ago|reply
I don't see any reason why LaTeX should be shelling out to bash. And having a mish-mash of loads of different languages creates unmaintainable bloatware.
[+] Loic|14 years ago|reply
I don't know, maybe the author is trying to do something with the iPad which is simply not supposed to do. The iPad is beautiful, pleasant to use etc. but writing a book on the iPad is maybe not the things one does.

I use my tablet to write — quite a lot — way slower than on my regular keyboard, but with time to think. Everything is in text files, synced to my desktop where the typesetting is really performed.

Writing publications or books is a long process where basically the final rendering is taken care at the end because the quality of the wording is more important.

So, just a text editor with hard work on the words, sentences, ideas are where 99% of the time is spent.

Maybe the author can provide an extremely pleasant way to write on the iPad and on the Mac with syncing of the work to have the feeling that the work is never lost, that one can always update a bit of the manuscript and just run "make" on the Mac some times to times. Everything in a smooth workflow.

[+] gphil|14 years ago|reply
Wouldn't it be possible to just write a front end for the iPad, and run a LaTeX service in the cloud? I think this would be by far the easiest way to do it, and I don't think it's really optimal to do all the LaTeX stuff client-side on limited hardware and battery anyway.
[+] gamble|14 years ago|reply
I was agog when I downloaded the LaTeX binary install for my new Mac a few years ago and discovered how massive it was. LaTeX is almost as big as the entire operating system disk!

What on earth is in there?

[+] Argorak|14 years ago|reply
The full TexLive distribution contains all officially accepted packages ever written (this includes fonts, iconography, compiled documentation and other heavy stuff), most of the compilers, the LaTeX and Context (MK II and IV) packages and a huge toolchain. For compatibility reasons, packages are (almost) never removed. Also for compatibility reasons, the LPPL (Latex Project Public License) discourages[1] the release of a modified package under the same name, so there are copies within the distribution.

So, the TexLive distribution is the "fire-and-forget"-package in the LaTeX world, thats why it is so big. I use it for around 10 years now and I never had to install an additional package.

[1] It even prohibited that for a while, see Wikipedia.

[+] einhverfr|14 years ago|reply
Vast numbers of packages to do just about anything you could possibly want.....

Things like inserting graphics with text flowing around them (picins), or document classes for resumes,or textpos (for absolute text positioning), or......

Basically you have nearly two thousand such packages in TexLive......

[+] smokinn|14 years ago|reply
I remember installing it a few weeks ago on ubuntu to update my cv.

The base system was 280+ mb along with 190+ mb of documentation. I found it mildly amusing that I had to download ~500 mb of stuff just to update my cv.

[+] chalst|14 years ago|reply
Uncompressed, it's about 50% documentation and 35% fonts.
[+] jka|14 years ago|reply
This article seems to advocate a huge amount of work to an existing, open, and highly stable software product - all to allow it to work on a proprietary device with heavy restrictions on software availability and installation.

Should we do all this work - mandated by business-driven 'app store guidelines' - simply to allow known good software to continue to work?

[+] magice|14 years ago|reply
This article is a proof of the stupidity, ignorance, and general jerkiness of an Apple user. It's like, the world must resolve around some standards set by Apple because it fails to deliver a system that actually works. Oh, and never mind that the stupid guy never understands the reason why the code base is set up as it is.

All in all, here is my opinion: who ever upvote this should feel ashame of yourself for wasting everyone's real-estate on this stupid rant.

[+] fadzlan|14 years ago|reply
Have you actually spent a little moment to at least really RTA?

The author states that even with the restriction lifted, it wouldn't make much sense, as with all the extension that it requires to meet the author's need it would take 4GB.

The situation would be pretty much the same in Android, despite it being rooted in Linux. The article is not so much about Apple as it is about LaTeX.

If you would like to make a point, at least read the article.

[+] jawaddeo|14 years ago|reply
Thanks for contributing nothing but personal insults to a very serious argument. LaTeX is extremely useful, while the computing is going more and more mobile. How do we reconcile the situation and enable people to use LaTeX going forward on devices they like is I believe I an important issue.
[+] ajarmst|14 years ago|reply
Wait a sec. "No LaTeX on the iPad" conflates "editing a LaTeX document" and "rendering and compiling LaTex to a final document.". Editing LaTeX on the iPad is already perfectly easy and really quite pleasant, especially with a bluetooth keyboard -- I do it most days (currently, Textastic is my preferred platform, supports syntax higlighting, DropBox and MobileMe).

Rendering to DVI or PDF is something else entirely. While other comments here indicate its doable, I have to ask why? I render my documents on another machine (I actually have a script that monitors dropbox and periodically re-pdflatex's if the timestamp changes -- redirecting error messages to a file is trivial if you need to troubleshoot remotely). If you're attempting to do LaTeX with a WYSIAYG interface or (worse) doing the edit-a-line-rerender-repeat cycle, I'd have to say that you're doing it wrong. The assertion that "doing LaTeX" (or, frankly, any platform that supports simple text editing) requires the native presence of the entire LaTex codebase is just misinformed.

Finally, the author of the post apparently started his project without knowing that the original TeX distribution was written using literate programming, what kpathsea was, or that there were other implementations of LaTeX. Perhaps they weren't quite prepared/qualified for the undertaking? This smells like a classic case of "this isn't how I would do it/use the tool, so it must be broken".

[+] retrogradeorbit|14 years ago|reply
This is a total 'Bed of Procrustes' argument. In order to deal with the problem of this ONE device and in particular the App Store guidelines, you want to cut off the legs of the source code.
[+] bitcracker|14 years ago|reply
Don't use an entertainment toy for TeX. iPad is a very nice piece of hardware but it is only a consumer (gamer) device - not a full featured Computer. Its good for games and ebooks but I would never use it as a developer engine.

Why do you want to hurt yourself typing TeX on a virtual keyboard? If you consider to add a real keyboard to your ipad then you should better get serious and use a Macbook, Linux or Windows.

[+] nhoss2|14 years ago|reply
how about making an app that just stores the .tex files, and to convert them to pdf or something, the .tex file gets sent to a server
[+] mgualt|14 years ago|reply
Hear, hear! This post provides a perfect example of the utter failure of software engineering in the real world. I am reminded of it every time I try to install software, with all the ridiculous dependencies and multiple versions. Instead of addressing the serious foundational issues facing software development and architecture, the geniuses are busy inventing the latest, greatest programming language, creating even more problems.

Computer science and engineering departments should use these situations to train their students.

[+] thefre|14 years ago|reply
> This dream lasted a few days until we discovered that TeX, the typesetting engine underlying LaTeX, isn’t written in C. TeX is written in WEB, Donald Knuth’s “literate” programming language.

Seriously, they discovered that after starting the project???

[+] einhverfr|14 years ago|reply
LaTeX can't be 4GB. I think it is being confused with TexLive? You don't need all of TexLive to make LaTeX documents....
[+] cullenking|14 years ago|reply
I think the salient question here is why would you want to work with LaTeX on a tablet?