Programming

I create free and open-source software with scientific and technical applications.

One of my objectives is making it easier to write scientific and technical documents. I like to include executable code in my documents, so that things like plots and tables can be generated automatically. Documents can write themselves – at least in part. You may be familiar with this approach from software like Jupyter notebooks, knitr, or Org-mode Babel. My own contributions are Codebraid (along with Codebraid Preview) and PythonTeX.

I use Python and LaTeX daily. LaTeX is not just for writing – I have extensive experience with macro programming in LaTeX and plain TeX. Before I started using Python in 2010, I primarily worked with MATLAB, C++, and Perl. At times, I have also used Bash, Fortran, Go, HTML + CSS, JavaScript, Julia, Lua, Mathematica, Octave, R, Ruby, Rust, and TypeScript.

  • Codebraid makes inline code and code blocks executable in Pandoc Markdown. Codebraid documents are pure Pandoc Markdown; there is no custom syntax or Markdown extensions. This allows everything Markdown-related to be handled by Pandoc. Codebraid supports Bash, JavaScript, Julia, Python, R, and Rust. It can also use Jupyter kernels, in which case rich output like plots, images, and LaTeX math are included automatically.

  • Codebraid Preview is a VS Code extension that provides a live Markdown preview generated with Pandoc. Because the preview is generated with Pandoc itself, all Pandoc extensions to Markdown syntax are fully supported. For a good overview, see the presentation for SciPy 2022.

  • PythonTeX executes code in LaTeX documents and includes the results. It supports Python plus Bash, JavaScript, Julia, Octave, Perl, R, Raku (Perl 6), Ruby, SageMath, and Rust. Unlike some similar software, PythonTeX is not a preprocessor. Code is passed to Python only after being processed by LaTeX. As a result, it is possible to write LaTeX macros that internally run Python or other code. This was my first real programming experience with both Python and LaTeX, starting in 2011.

  • BespON is my experiment in creating a configuration language similar to YAML or TOML. It is designed for lossless round-tripping: a configuration file can be loaded, programatically modified, and then saved while retaining all original layout and comments. BespON provides concise syntax for deeply nested data structures and supports inheritance, aliases, and circular references. The pure Python performance is surprisingly good – I haven't yet tried any serious optimizations. BespON is currently used in Codebraid and some other projects.

  • unicodetools is a library I wrote for working with the Unicode Character Database. In creating BespON, I needed regular expressions based on code point properties, and wanted to use a more recent version of Unicode even under older versions of Python.

Typography

listings and minted are the two major LaTeX packages for typesetting computer code with syntax highlighting. I have been maintaining and developing minted since 2013. PythonTeX and minted both use Pygments for syntax highlighting, so there is some overlap. I have made many improvements to minted (and PythonTeX) code typesetting. Several of these are implemented in my fvextra LaTeX package.

  • fvextra builds on the earlier fancyvrb package that is commonly used for working with verbatim text. It fixes a number of issues with LaTeX math embedded in a verbatim context, so that math within code comments can be typeset exactly like math anywhere else in a LaTeX document. Other fvextra features include improved line numbering options and the ability to highlight individual lines of code or line ranges.

  • The most important feature of fvextra is probably automatic line breaking for long lines of code, with automatic indentation to the correct level. Previously, such line breaking was only available in the listings package. fvextra provides fine-grained control over break locations: breaks can be enabled anywhere, at spaces, or only before or after specified characters. If breaks are allowed before or after a specified character, it is possible to group runs of identical characters. Breaks can also be disabled within a programming language's tokens, so that for example there are not breaks in the middle of strings.

Physics

I teach undergraduate physics at all levels. I frequently use PythonTeX to generate randomized assignments for my students (typically with automatically generated solutions for me). RandAssign is a Python package I created to automate this process. More recently, I created text2qti for generating quizzes in QTI format.

I also incorporate Python programming in my upper-division classes, especially Mechanics and Mathematical Methods for Physics. Programming exercises are common during class and as part of homework, typically using Jupyter notebooks.