<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>ophy.eth</title>
        <link>https://paragraph.com/@ophy</link>
        <description>undefined</description>
        <lastBuildDate>Thu, 21 May 2026 18:55:37 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Writing Web3 Apps with Clojurescript]]></title>
            <link>https://paragraph.com/@ophy/writing-web3-apps-with-clojurescript</link>
            <guid>5ijd510Mwafj1veJProT</guid>
            <pubDate>Fri, 10 Dec 2021 22:36:10 GMT</pubDate>
            <description><![CDATA[Clojure has been my favorite language for a long time. It is not without its faults, but it is the language in which I can express my ideas in the most efficient way. It has a powerful macro system that lets you mold the language to your needs. Most Clojure code can run on the JVM as well as in a Javascript runtime (as Clojurescript). This lets us leverage two rich package ecosystems with a convenient lisp syntax. While much of the code will be self-explanatory, a familiarity with Clojure (or...]]></description>
            <content:encoded><![CDATA[<p>Clojure has been my favorite language for a long time. It is not without its faults, but it is the language in which I can express my ideas in the most efficient way. It has a powerful macro system that lets you mold the language to your needs. Most Clojure code can run on the JVM as well as in a Javascript runtime (as Clojurescript). This lets us leverage two rich package ecosystems with a convenient lisp syntax.</p><p>While much of the code will be self-explanatory, a familiarity with Clojure (or other lisps) will be helpful.</p><h2 id="h-getting-started" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Getting Started</h2><p>Writing Clojure code is pretty simple and doesn’t require much boilerplate. We will need a few dependencies though.</p><h3 id="h-installing-dependencies" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Installing Dependencies</h3><p>Install Clojure by following this guide:</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://clojure.org/guides/getting_started">https://clojure.org/guides/getting_started</a></p><p>Then install shadow-cljs:</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/thheller/shadow-cljs">https://github.com/thheller/shadow-cljs</a></p><h3 id="h-initialize-project" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Initialize Project</h3><p>I like to keep all my projects under <code>~/Developer</code>, so I run this from there, but from whichever directory you want to create your project in, run the following code in your terminal:</p><pre data-type="codeBlock" text="npx create-cljs-project hello-web3
"><code>npx create<span class="hljs-operator">-</span>cljs<span class="hljs-operator">-</span>project hello<span class="hljs-operator">-</span>web3
</code></pre><p>This will create a new directory called <code>hello-web3</code> and within it create some of the files we need to get started.</p><p>One of the quirks Clojurescript inherited from Java is namespacing and directory structure.</p><p>Create the following file: <code>src/main/helloweb3/frontend/app.js</code> and put this in it:</p><pre data-type="codeBlock" text="(ns helloweb3.frontend.app)

(defn init []
  (println &quot;Hello Web3&quot;))
"><code>(ns helloweb3.frontend.app)

(defn init []
  (println <span class="hljs-string">"Hello Web3"</span>))
</code></pre><p>In <code>shadow-cljs.edn</code>, replace the empty <code>:builds</code> map with the following:</p><pre data-type="codeBlock" text="{
...
  :builds
  {:frontend
   {:target :browser
    :modules {:main {:init-fn helloweb3.frontend.app/init}}
    }}}
"><code>{
...
  <span class="hljs-symbol">:builds</span>
  {<span class="hljs-symbol">:frontend</span>
   {<span class="hljs-symbol">:target</span> <span class="hljs-symbol">:browser</span>
    <span class="hljs-symbol">:modules</span> {<span class="hljs-symbol">:main</span> {<span class="hljs-symbol">:init-fn</span> helloweb3.frontend.app/init}}
    }}}
</code></pre><p>Create the file <code>public/index.html</code></p><pre data-type="codeBlock" text="&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;title&gt;hello web3&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;
    &lt;script src=&quot;/js/main.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
"><code><span class="hljs-operator">&#x3C;</span><span class="hljs-operator">!</span>doctype html<span class="hljs-operator">></span>
<span class="hljs-operator">&#x3C;</span>html<span class="hljs-operator">></span>
  <span class="hljs-operator">&#x3C;</span>head<span class="hljs-operator">></span>
    <span class="hljs-operator">&#x3C;</span>meta charset<span class="hljs-operator">=</span><span class="hljs-string">"utf-8"</span> <span class="hljs-operator">/</span><span class="hljs-operator">></span>
    <span class="hljs-operator">&#x3C;</span>title<span class="hljs-operator">></span>hello web3<span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>title<span class="hljs-operator">></span>
  <span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>head<span class="hljs-operator">></span>
  <span class="hljs-operator">&#x3C;</span>body<span class="hljs-operator">></span>
    <span class="hljs-operator">&#x3C;</span>div id<span class="hljs-operator">=</span><span class="hljs-string">"root"</span><span class="hljs-operator">></span><span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">></span>
    <span class="hljs-operator">&#x3C;</span>script src<span class="hljs-operator">=</span><span class="hljs-string">"/js/main.js"</span><span class="hljs-operator">></span><span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>script<span class="hljs-operator">></span>
  <span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>body<span class="hljs-operator">></span>
<span class="hljs-operator">&#x3C;</span><span class="hljs-operator">/</span>html<span class="hljs-operator">></span>
</code></pre>]]></content:encoded>
            <author>ophy@newsletter.paragraph.com (ophy.eth)</author>
        </item>
    </channel>
</rss>