TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Clojure Interactive Development 101

54 pointsby refset9 months ago

2 comments

dmichulke9 months ago
I&#x27;d love to use all this but the fact that you have to substitute in variables just makes this very not-useful.<p>Ideally in functional programming everything is a (pure) function (and this is how I program), so you never have your variables defined.<p>Instead, my standard setup is to debug a function by saving its arguments in a vector, e.g.<p><pre><code> (defn buggy-function [a b c] (def test-bf [a b c]) ;; &lt;- add this ... function body ... ) </code></pre> Then I can call buggy-function with<p><pre><code> (apply buggy-function test-bf) </code></pre> and modify the code until it behaves as expected.<p>This is also where immutability has its grand appearance.
评论 #41425168 未加载
mjdiloreto9 months ago
&gt; Note that def we have inserted, to define a global variable request. This is a powerful debug mechanism, but a better way to use it is a tool like [snitch](<a href="https:&#x2F;&#x2F;github.com&#x2F;AbhinavOmprakash&#x2F;snitch">https:&#x2F;&#x2F;github.com&#x2F;AbhinavOmprakash&#x2F;snitch</a>).<p>Wow, wish I knew about snitch earlier! I have been using a similar, much less powerful, set of macros for this: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;mjdiloreto&#x2F;9e7c65023fff691b5ab7d297d9b97502" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;mjdiloreto&#x2F;9e7c65023fff691b5ab7d297d...</a><p>In my experience, this is a phenomenal way to develop. You just replace whatever `defn` or `let` you are working on with `defn<i>` and `let</i>`, and interact with your app normally (click around in the UI, trigger the frontend or backend functions you are examining). Combined with a tool like portal (<a href="https:&#x2F;&#x2F;github.com&#x2F;djblue&#x2F;portal">https:&#x2F;&#x2F;github.com&#x2F;djblue&#x2F;portal</a>) you can quickly get an overview of your system <i>while it is running</i>!