Tools for Scientist Workflows Part 4: Visual Studio Code – Code Development

Julio Morales is a second year PhD student in the Department of Astronomy at New Mexico State University, where he conducts research on the flow of plasma in the solar interior using the technique of time-distance helioseismology. This work is part of the COFFIES collaboration, whose goal is to successfully simulate the solar magnetic field cycle. In addition to his graduate research, Julio also co-leads NMSUs “Inclusive Astronomy”—a committee dedicated to rigorous discussion and solutions to a variety of issues pertaining to diversity, equity, and inclusion.

Visual Studio Code

In the previous installment of this series on “Tools for Scientist Workflows,” we explored Git and GitHub—invaluable tools for code management. Now, let’s delve into a personal favorite of mine for actual code development—Visual Studio Code (VS Code). While various Integrated Development Environments (IDEs) exist, VS Code stands out as a particularly versatile and user-friendly option (see the official VS Code Tutorial to get started).

Multiple Language Identification and Compilation

VS Code’s strength lies in its “extensions” feature—a library of downloadable tools crafted by a mix of developers, which act to expand the functionality of VS Code. For example, a powerful capability of extensions is to allow the user to compile code of any language all within VS Code—no need to have an individual software for each language!

Enhanced Code Documentation

Extensions also enhance the editing process. For instance, the “better comments” extension facilitates organized comments with customizable highlighting. You can tag notes such as “TODO:” in green for reminders or “FIXME:” in red for fixes, all neatly organized in a toggle-able tree within the editor.

 

In the theme of detailed documentation, there is also an extension that integrates Zotero with VS Code.  Citation Picker for Zotero allows you to cite references stored in your Zotero account right in the VS Code editor. With this extension, if part of your code uses ideas or equations from specific publications, you can document as such in your code.  If you ever want to open the publication you’re referencing, simply copy and paste the citation from VS Code into Zotero. I’m particularly enthusiastic about well-documented code, and these features significantly elevate this aspect.

 

Git and GitHub Integration

However, VS Code’s capabilities extend beyond language support and editing tools. Extensions integrate VS Code seamlessly with Git and GitHub, eliminating the need for confusing terminal commands. Upon integrating these extensions, you can access Git commands and even manage GitHub repositories directly within VS Code.

My workflow exemplifies this synergy—starting with coding in VS Code and seamlessly transitioning to using Git-integration to commit and push changes to GitHub repositories. An extension like “GitKraken” enhances this further, offering a comprehensive overview of commits, comparisons, and metadata, all within the VS Code environment.

LaTeX Integration

The power of VS Code doesn’t stop there. It even accommodates LaTeX, albeit with a somewhat more involved setup. This integration allows you to maintain a self-contained project workflow, housing code, figures, LaTeX, and PDFs in one location. This approach ensures automatic coherence among files and simplifies updates and recompilations.

As an illustration, consider a file structure where code generates a plot saved to a specific path. Using LaTeX, you can include and display this plot directly in your paper by specifying its path to be the same as the location where you saved it in your code. Any code updates automatically reflect in the paper, maintaining synchronization and eliminating the need for manually uploading and re-uploading.

While this system works wonders for single-author projects, collaborative efforts via platforms like Overleaf may introduce some problems. Collaborative papers may possibly still be managed through a combination of Overleaf and GitHub integration, albeit with potential merge conflicts. Nonetheless, for individual projects, this integrated workflow, coupled with version control, fosters a streamlined and well-documented process.

In the next entry of this series, we will discuss the research command-center Notion, and its most powerful functionalities for organizing your research.

0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *