<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Edmund Miller</title>
    <description>The latest articles on DEV Community by Edmund Miller (@emiller).</description>
    <link>https://dev.to/emiller</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F871168%2F839f7a50-f2d2-4a85-b749-fed587708578.jpeg</url>
      <title>DEV Community: Edmund Miller</title>
      <link>https://dev.to/emiller</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emiller"/>
    <language>en</language>
    <item>
      <title>Setting up Doom Emacs for Astro Development</title>
      <dc:creator>Edmund Miller</dc:creator>
      <pubDate>Tue, 23 Apr 2024 13:00:00 +0000</pubDate>
      <link>https://dev.to/emiller/setting-up-doom-emacs-for-astro-development-2b4g</link>
      <guid>https://dev.to/emiller/setting-up-doom-emacs-for-astro-development-2b4g</guid>
      <description>&lt;p&gt;&lt;a href="https://astro.build/"&gt;Astro&lt;/a&gt; is the new hot new web framework on the block. All the cool kids are using it. I've recently given up, drank the Kool-Aid, and gone all in on it.&lt;/p&gt;

&lt;p&gt;I've rewritten this website, &lt;a href="https://monimiller.com/"&gt;my partner's website&lt;/a&gt;, my university rugby club's website. I'm moving my &lt;em&gt;Applied Genomics&lt;/em&gt; course website to &lt;a href="https://starlight.astro.build/"&gt;Starlight&lt;/a&gt;, the Astro team's documentation framework. The &lt;a href="https://github.com/nf-core/website"&gt;nf-core site&lt;/a&gt; has been rewritten in Astro and Svelte from PHP. &lt;em&gt;I'm all in&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The beauty of Astro is it's the &lt;a href="https://www.nextflow.io"&gt;Nextflow&lt;/a&gt; of web frameworks.&lt;sup id="fnref1"&gt;1&lt;/sup&gt; It allows you to wrap other UI Frameworks in a web framework rather than forcing you to pick one, so you don't just have to pick React, Vue, or Svelte. You can have them all in the same application. You can just use &lt;a href="https://docs.astro.build/en/basics/astro-components/#html-components"&gt;HTML components&lt;/a&gt;. That's the beauty. That's why it's exciting. That's why I think it'll stick around.&lt;/p&gt;

&lt;p&gt;So anyways, I wanted to hook up Emacs with Astro support. For now, I've just been roughing it out there and running &lt;a href="https://prettier.io/"&gt;Prettier&lt;/a&gt; by itself and turning off save on format and auto-complete. It's been scary.&lt;/p&gt;

&lt;p&gt;What I'm seeking from Emacs is multifaceted: Tree-sitter support, LSP (Language Server Protocol) support—to alert me of any missteps—and a fully functional formatter. A frustrating hour was lost to Prettier mangling my Astro templates by wrapping them in quotes—a bug I could have done without. And while we're at it, add Tailwind CSS LSP support into the mix for good measure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Astro Tree-sitter Support
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Tree-sitter is an incremental parsing system for programming tools.&lt;br&gt;
Find out more about it on the &lt;a href="https://tree-sitter.github.io/tree-sitter/"&gt;project's website&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As the old saying goes, there's an Emacs package for everything. So, of course, someone's already written one for Astro and Tree-sitter.&lt;/p&gt;

&lt;p&gt;Setup for &lt;code&gt;astro-ts-mode&lt;/code&gt; appears simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;package!&lt;/span&gt; &lt;span class="nv"&gt;astro-ts-mode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;use-package!&lt;/span&gt; &lt;span class="nv"&gt;astro-ts-mode&lt;/span&gt;
  &lt;span class="ss"&gt;:after&lt;/span&gt; &lt;span class="nv"&gt;treesit-auto&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But wait, there's &lt;a href="https://github.com/Sorixelle/astro-ts-mode?tab=readme-ov-file#setup"&gt;more&lt;/a&gt;!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because this major mode is powered by Tree-sitter, it depends on an external grammar to provide a syntax tree for Astro templates. To set it up, you’ll need to set treesit-language-source-alist to point to the correct repositories for each language.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can choose to set it up and run &lt;code&gt;treesit-install-language-grammar&lt;/code&gt; for astro tsx and css.&lt;/p&gt;

&lt;p&gt;Or you can take the red pill and use &lt;a href="https://github.com/renzmann/treesit-auto"&gt;treesit-auto&lt;/a&gt; and automatically install the language grammar.&lt;/p&gt;

&lt;p&gt;In case this your first Edmund experience, two things you should know. I love to automate things, and I love a good rabbit hole.&lt;/p&gt;

&lt;h3&gt;
  
  
  treesit-auto
&lt;/h3&gt;

&lt;p&gt;There was &lt;a href="https://github.com/Sorixelle/astro-ts-mode/issues/5"&gt;a tip&lt;/a&gt; from &lt;a href="https://github.com/ispringle"&gt;Ian S. Pringle&lt;/a&gt;(Who owns both a farm and a digital garden!).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Sorixelle/astro-ts-mode"&gt;Ruby Juric&lt;/a&gt;(the author of &lt;code&gt;astro-ts-mode&lt;/code&gt;) converted the snippet to use &lt;code&gt;let&lt;/code&gt; to avoid creating a global variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;use-package!&lt;/span&gt; &lt;span class="nv"&gt;astro-ts-mode&lt;/span&gt;
  &lt;span class="ss"&gt;:config&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;global-treesit-auto-mode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;astro-recipe&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;make-treesit-auto-recipe&lt;/span&gt;
                       &lt;span class="ss"&gt;:lang&lt;/span&gt; &lt;span class="ss"&gt;'astro&lt;/span&gt;
                       &lt;span class="ss"&gt;:ts-mode&lt;/span&gt; &lt;span class="ss"&gt;'astro-ts-mode&lt;/span&gt;
                       &lt;span class="ss"&gt;:url&lt;/span&gt; &lt;span class="s"&gt;"https://github.com/virchau13/tree-sitter-astro"&lt;/span&gt;
                       &lt;span class="ss"&gt;:revision&lt;/span&gt; &lt;span class="s"&gt;"master"&lt;/span&gt;
                       &lt;span class="ss"&gt;:source-dir&lt;/span&gt; &lt;span class="s"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;add-to-list&lt;/span&gt; &lt;span class="ss"&gt;'treesit-auto-recipe-list&lt;/span&gt; &lt;span class="nv"&gt;astro-recipe&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think this worked for me. I had built it manually with &lt;code&gt;treesit-auto&lt;/code&gt; before.&lt;/p&gt;

&lt;p&gt;Oh, by the way&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;!NOTE&lt;br&gt;
Make sure you have a working C compiler as cc in your PATH, since this needs to compile the grammars.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Emacs lsp-mode and Astro Language-server
&lt;/h2&gt;

&lt;p&gt;The official Astro editor docs link to &lt;a href="https://medium.com/@jrmjrm/configuring-emacs-and-eglot-to-work-with-astro-language-server-9408eb709ab0"&gt;an article&lt;/a&gt; with instructions to configure eglot, but there's no equivalent one for lsp-mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; @astrojs/language-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I just had to add a hook to &lt;code&gt;astro-ts-mode&lt;/code&gt; and it pulled right up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;use-package!&lt;/span&gt; &lt;span class="nv"&gt;astro-ts-mode&lt;/span&gt;
  &lt;span class="ss"&gt;:after&lt;/span&gt; &lt;span class="nv"&gt;treesit-auto&lt;/span&gt;
  &lt;span class="ss"&gt;:init&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;modulep!&lt;/span&gt; &lt;span class="nv"&gt;+lsp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;add-hook&lt;/span&gt; &lt;span class="ss"&gt;'astro-ts-mode-hook&lt;/span&gt; &lt;span class="nf"&gt;#'&lt;/span&gt;&lt;span class="nv"&gt;lsp!&lt;/span&gt; &lt;span class="ss"&gt;'append&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="ss"&gt;:config&lt;/span&gt;
&lt;span class="c1"&gt;;; ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;prettier-plugin-astro&lt;/code&gt; in Emacs with Apheleia
&lt;/h2&gt;

&lt;p&gt;From &lt;a href="https://github.com/Sorixelle/dotfiles/blob/main/config/emacs-config.org#astro"&gt;Sorixelle's Emacs config&lt;/a&gt; I found the magic snippet that had prettier use &lt;code&gt;--parser=astro&lt;/code&gt; in &lt;code&gt;.astro&lt;/code&gt; files. ✨&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(set-formatter! 'prettier-astro
  '("npx" "prettier" "--parser=astro"
    (apheleia-formatters-indent "--use-tabs" "--tab-width" 'astro-ts-mode-indent-offset))
  :modes '(astro-ts-mode))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tailwind CSS IntelliSense in Emacs
&lt;/h2&gt;

&lt;p&gt;Of course, there's already a package for &lt;a href="https://github.com/merrickluo/lsp-tailwindcss"&gt;TailwindCSS using LSP&lt;/a&gt;. With Doom Emacs installation instructions as well!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;use-package!&lt;/span&gt; &lt;span class="nv"&gt;lsp-tailwindcss&lt;/span&gt;
  &lt;span class="ss"&gt;:when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;modulep!&lt;/span&gt; &lt;span class="nv"&gt;+lsp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="ss"&gt;:init&lt;/span&gt;

  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;setq!&lt;/span&gt; &lt;span class="nv"&gt;lsp-tailwindcss-add-on-mode&lt;/span&gt; &lt;span class="no"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="ss"&gt;:config&lt;/span&gt;

  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;add-to-list&lt;/span&gt; &lt;span class="ss"&gt;'lsp-tailwindcss-major-modes&lt;/span&gt; &lt;span class="ss"&gt;'astro-ts-mode&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You can find &lt;a href="https://github.com/edmundmiller/.doom.d/tree/main/modules/lang/astro"&gt;all of the code in my Doom Emacs config&lt;/a&gt;. It's got everything, Tree-sitter, LSP, Prettier, and Tailwind CSS IntelliSense.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;Did I really just compare a very niche DSL to describe a niche programming language? ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>emacs</category>
      <category>webdev</category>
      <category>astro</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Using age with org-journal</title>
      <dc:creator>Edmund Miller</dc:creator>
      <pubDate>Fri, 15 Dec 2023 19:04:51 +0000</pubDate>
      <link>https://dev.to/emiller/using-age-with-org-journal-oig</link>
      <guid>https://dev.to/emiller/using-age-with-org-journal-oig</guid>
      <description>&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Because &lt;a href="https://dev.gnupg.org/T6481"&gt;gpg 2.4.1 borked&lt;/a&gt; Emacs's EasyPG. It just hangs on saving.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why not just use gpg?
&lt;/h3&gt;

&lt;p&gt;There are some ways around it, and I was using the &lt;code&gt;fset&lt;/code&gt; hack until I read this &lt;a href="https://www.reddit.com/r/emacs/comments/18d6fmt/how_to_lock_yourself_out_of_a_gpg_encrypted_file/"&gt;post about the person who corrupted their encrypted files&lt;/a&gt;. I also had to run the elisp on every new Emacs instance.&lt;/p&gt;

&lt;p&gt;And then &lt;code&gt;lib-gcrypt&lt;/code&gt; is marked as broken in NixOS if you use the &lt;code&gt;gnupg22&lt;/code&gt; package(Version: 2.2.41), and a blowing past that stop sign sounded like a bad idea.&lt;/p&gt;

&lt;p&gt;So I started thinking outside the box.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why &lt;a href="https://github.com/FiloSottile/age"&gt;age&lt;/a&gt;?
&lt;/h3&gt;

&lt;p&gt;I started using it with &lt;a href="https://github.com/ryantm/agenix"&gt;agenix&lt;/a&gt;, just because &lt;a href="https://github.com/hlissner/"&gt;Henrik&lt;/a&gt; started using it in his dotfiles. The &lt;a href="https://github.com/onedr0p/flux-cluster-template"&gt;k8s@home template&lt;/a&gt; also eventually &lt;a href="https://github.com/onedr0p/flux-cluster-template/pull/153"&gt;switched from gpg to age&lt;/a&gt; so I was already pretty comfortable with using age.&lt;/p&gt;

&lt;p&gt;TL;DR &lt;a href="https://nixfaq.org/2021/01/age-the-modern-alternative-to-gpg.html"&gt;Age: the modern alternative to GPG — nixFAQ&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Age is presented as a modern alternative to GPG that solves many of its limitations while maintaining security.&lt;/li&gt;
&lt;li&gt;Age stands for "Actually Good Encryption" and has implementations in Go and
Rust for improved security compared to GPG's C implementation.&lt;/li&gt;
&lt;li&gt;Age uses smaller keys that are easier to store physically and has a simpler interface with no configuration options.&lt;/li&gt;
&lt;li&gt;Files can be encrypted for multiple recipients simultaneously using Age.&lt;/li&gt;
&lt;li&gt;Age supports encrypting for SSH public keys in addition to its own keys.&lt;/li&gt;
&lt;li&gt;Age allows encrypting files for GitHub users by using their SSH keys from their profile.&lt;/li&gt;
&lt;li&gt;Age offers a better user experience than GPG while maintaining an equally high level of security.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why still org-journal?
&lt;/h3&gt;

&lt;p&gt;I've considered using &lt;a href="https://www.orgroam.com/manual.html#org_002droam_002ddailies"&gt;org-roam-dailies&lt;/a&gt; instead of &lt;a href="https://github.com/bastibe/org-journal"&gt;org-journal&lt;/a&gt;. However, after some reflection, I'm not entirely sure why. &lt;a href="https://github.com/anticomputer/age.el#org-roam-support-for-age-encrypted-org-files"&gt;Org Roam supports Age encryption&lt;/a&gt;, and &lt;a href="https://github.com/bastibe/org-journal/issues/400"&gt;org-journal has several PR fixes&lt;/a&gt; for various issues that have been neglected (this is not a judgment of the maintainer, but problems like &lt;a href="https://github.com/bastibe/org-journal/issues/375"&gt;journal files being decrypted whenever the calendar is invoked&lt;/a&gt; are troublesome). I think I was just seeking a quick solution to resume journaling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Now that you've listened to me ramble on for a bit, here's the actual setup. This is using &lt;a href="https://github.com/doomemacs/doomemacs"&gt;Doom Emacs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;packages.el&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;package!&lt;/span&gt; &lt;span class="nv"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;config.el&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;use-package!&lt;/span&gt; &lt;span class="nv"&gt;age&lt;/span&gt;
  &lt;span class="ss"&gt;:init&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;setq!&lt;/span&gt; &lt;span class="nv"&gt;age-program&lt;/span&gt; &lt;span class="s"&gt;"rage"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="ss"&gt;:config&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;setq!&lt;/span&gt; &lt;span class="nv"&gt;age-default-identity&lt;/span&gt; &lt;span class="s"&gt;"~/.ssh/id_ed25519"&lt;/span&gt;
         &lt;span class="nv"&gt;age-default-recipient&lt;/span&gt; &lt;span class="s"&gt;"~/.ssh/id_ed25519.pub"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;age-file-enable&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Went with &lt;a href="https://github.com/str4d/rage"&gt;rage&lt;/a&gt;, because Rust. Also there's &lt;a href="https://github.com/anticomputer/age.el#workaround-pinentry-support-through-rage"&gt;pinentry support through rage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config.el&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;after!&lt;/span&gt; &lt;span class="nv"&gt;org&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;setq&lt;/span&gt; &lt;span class="nv"&gt;org-journal-encrypt-journal&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
        &lt;span class="nv"&gt;org-journal-file-format&lt;/span&gt; &lt;span class="s"&gt;"%Y%m%d.org.age"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only thing I had to do then was turn off the built-in gpg support on&lt;br&gt;
org-journal, and update the naming scheme to have age as the suffix and it just&lt;br&gt;
worked.™&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>age</category>
      <category>writing</category>
    </item>
    <item>
      <title>Why I'm hyped about Julia for Bioinformatics</title>
      <dc:creator>Edmund Miller</dc:creator>
      <pubDate>Wed, 01 Jun 2022 19:12:59 +0000</pubDate>
      <link>https://dev.to/emiller/why-im-hyped-about-julia-for-bioinformatics-21o6</link>
      <guid>https://dev.to/emiller/why-im-hyped-about-julia-for-bioinformatics-21o6</guid>
      <description>&lt;p&gt;Julia might just change the game for bioinformatics. Bioinformatics is starting to heat up as a field, and I think we have a lot of unique issues starting from the days of &lt;a href="https://bioperl.org/articles/How_Perl_saved_human_genome.html"&gt;perl and the Human Genome Project&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Based off a recent recommendation from my friend &lt;a href="https://github.com/tecosaur"&gt;Teco&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Language Problem
&lt;/h2&gt;

&lt;p&gt;Plenty of people have written about this with Julia. Lots of scientific communities may use a high-level "scripting" language to manage their business-logic and then drop into a low-level language such as C/Fortran/Rust to highly optimize the bottleneck.&lt;/p&gt;

&lt;p&gt;In bioinformatics, we have a 5 language problem. From the perl script written before the first generation of Next Generation Sequencing, to packages like DESeq2 that aren't going to leave anyone's toolbox anytime soon, but no one is going to rewrite, and instead are going to spend time teaching R to every incoming generation of bioinformaticians just so they can use these influential packages. That's not including python, Rust, and every bioinformatician's favorite, bash. That's not including if you want to contribute to any GATK CLI tools written in Java.&lt;/p&gt;

&lt;p&gt;Now, workflow managers such as &lt;a href="https://snakemake.readthedocs.io/en/stable/"&gt;Snakemake&lt;/a&gt; and &lt;a href="https://www.nextflow.io/"&gt;Nextflow&lt;/a&gt; have fixed the majority of those. Just stick those scripts in a container that acts as a time-capsule of versions long forgotten, and you can use them for just what you need and put them back in closet.&lt;/p&gt;

&lt;p&gt;But what about new scripts? When you're starting a new bioinformatics project in 2022, do you follow in the footsteps of the pioneers that came before you, and learn how to call C functions in an R package? Or would you rather just see this beauty.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NRtb48W4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://edmundmiller.dev/static/julia-100.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NRtb48W4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://edmundmiller.dev/static/julia-100.png" alt="img" width="594" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  But what about my C functions that are highly optimized?
&lt;/h3&gt;

&lt;p&gt;What about our in-house python library that interacts with all of our sample tracking and pulling files temporarily from s3? "I don't have time to figure out how to untangle that mess" you say. The Julia community wants to keep all of those import scientific scripts written. Packages such as &lt;a href="https://juliainterop.github.io/RCall.jl/"&gt;RCall.jl&lt;/a&gt;, &lt;a href="https://www.juliapackages.com/p/pycall"&gt;PyCall.jl&lt;/a&gt;, and plenty of others housed under &lt;a href="https://github.com/JuliaInterop"&gt;Julia Interop&lt;/a&gt; allow for legacy code to fit right into new code. As scientists, we are constantly standing on the shoulders of giants, and Julia is enabling that.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://biojulia.net/"&gt;BioJulia&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Julia has a wonderful open-source structure. Since it was created, only a decade ago there's not a lot of legacy things to maintain and everything can be fresh and inclusive. Take for example the heavy use of organizations to house these code repositories, which prevents packages from going unmaintained and orphaned when the creator moves on.&lt;/p&gt;

&lt;p&gt;While it's a relatively small community, they've covered a wide range of the various file types that we deal with on a daily basis. I hope to dog food most of the packages to fill in some missing pieces, and improve documentation and create some content for the community. The part that I found difficult was finding the people based on the website. I joined the Gitter to ask a question, but luckily someone saw the message and told me that most of the real-time chat happens in &lt;a href="https://julialang.slack.com/archives/CAKKFNYLD"&gt;the #biology channel in the Julia slack&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Designed for Scientific Computing
&lt;/h2&gt;

&lt;p&gt;It seems like bioinformaticians always want to do things in the most efficient path, but solving for a different variable than most. &lt;a href="https://www.lastweekinaws.com/podcast/screaming-in-the-cloud/quantum-leaps-in-bioinformatics-with-lynn-langit/"&gt;In a recent episode of screaming in the cloud&lt;/a&gt;, &lt;a href="https://lynnlangit.com/"&gt;Lynn Langit&lt;/a&gt; mentioned that in finance, they care about getting the results as quickly as possible. The cost of the computing isn't a factor. In bioinformatics, they're trying to solve for both time and cost, trying to find the local minimum between both. There are plenty of time results don't need to be instant, and waiting a few days to stretch a grant out is a necessary evil.&lt;/p&gt;

&lt;p&gt;Julia is fast, and that's been said numerous times, so you're probably guessing I'm going to say you can save money by decreasing your compute time. While that's true, the piece that I think people aren't solving for in that equation is developer time. Julia was designed from the ground up as a general programming language for scientists (&lt;a href="https://julialang.org/blog/2012/02/why-we-created-julia/"&gt;Why We Created Julia&lt;/a&gt;).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We want a language that's open source, with a liberal license. We want the speed&lt;br&gt;
of C with the dynamism of Ruby. We want a language that's homoiconic, with true&lt;br&gt;
macros like Lisp, but with obvious, familiar mathematical notation like Matlab.&lt;br&gt;
We want something as usable for general programming as Python, as easy for&lt;br&gt;
statistics as R, as natural for string processing as Perl, as powerful for&lt;br&gt;
linear algebra as Matlab, as good at gluing programs together as the shell.&lt;br&gt;
Something that is dirt simple to learn, yet keeps the most serious hackers&lt;br&gt;
happy. We want it interactive and we want it compiled.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That sounds like a bioinformatician's dream to me! Think of all the time we can save on developer experience, not trying to hack out some extra speed, or fixing broken dependencies (or a complete lack of specified dependencies!). Allowing legacy code to be treated like the crown jewel in our metaphorical software crown, and wrapping it in some gold Julia code like it deserves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Call to action
&lt;/h2&gt;

&lt;p&gt;I plan on working to increase the visibility into Julia, specifically for bioinformatics. I always love this Venn diagram to explain to people what bioinformatics is. I think it'll be natural to cover &lt;a href="https://github.com/JuliaData/"&gt;JuliaData&lt;/a&gt;, &lt;a href="https://juliastats.org/"&gt;JuliaStats&lt;/a&gt;, and &lt;a href="https://biojulia.net/"&gt;BioJulia&lt;/a&gt; to cover all three and show people how the three intersect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9AoGvmNT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://acm.na.edu/img/bioInfoLab/bioinformatics_venn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9AoGvmNT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://acm.na.edu/img/bioInfoLab/bioinformatics_venn.png" alt="img" width="880" height="841"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to get started with Julia
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://juliacon.org/2022/tickets/"&gt;Attend JuliaCon 2022&lt;/a&gt; (It's online and free to attend!)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.talkjulia.com/"&gt;Listen to the Talk Julia Podcast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://juliaacademy.com/"&gt;Go through some courses on JuliaAcademy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Check out the work by &lt;a href="https://www.logankilpatrick.com/"&gt;Logan Kilpatrick, the Julia Dev Community Advocate&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bioinformatics</category>
    </item>
  </channel>
</rss>
