Readit News logoReadit News
avindroth commented on Tacit programming   en.wikipedia.org/wiki/Tac... · Posted by u/tosh
kjqgqkejbfefn · 2 years ago
I've been using tacit programming intensively to the extent I get rid of most variables. I use both syntactic threading macros and functional combinators to achieve this. It is a double-edged sword in that it can make code as ugly as the original code it is trying to improve upon, but working without variables isn't that difficult nor does it lead me to intense clusterfucks. Composing lambdas contribute to this a lot more though.

As for making things clearer for everyone, well, this is code I work on solo (hobby), but I think providing example inputs as well as debugging macros can help a lot. Consider the following:

    (defn parse-it [dependencies]
      (pp->> dependencies
             str
             str/split-lines
             (keep (|| re-matches #"- (\d+(?:\.\d+)?) -> \[((?:\d+(?:\.\d+)?(?:, ?)?)+)\]"))
             (>>- (map-> (juxt-> second
                                 (->> third (re-seq #"(?:\d+(?:\.\d+)?)")))))))
    
    (parse-it (str "- 4 -> [1, 2, 3]\n"
                   "- 5 -> [4, 2]\n"
                   "- 6 -> [1, 2, 5]"))
    
    ;; The use of pp->> will lead to this getting printed
    ;; ->> dependencies                              : "- 4 -> [1, 2, 3]
    ;;                                                  - 5 -> [4, 2]
    ;;                                                  - 6 -> [1, 2, 5]"
    ;;     str/split-lines                           : ["- 4 -> [1, 2, 3]"
    ;;                                                  "- 5 -> [4, 2]"
    ;;                                                  "- 6 -> [1, 2, 5]"]
    ;;     (keep (|| re-matches #"- (\d+(?:\.\d+)... : (["- 4 -> [1, 2, 3]" "4" "1, 2, 3"]
    ;;                                                  ["- 5 -> [4, 2]" "5" "4, 2"]
    ;;                                                  ["- 6 -> [1, 2, 5]" "6" "1, 2, 5"])
    ;;     (>>- (map-> (juxt-> second (->> third ... : (("4" ("1" "2" "3"))
    ;;                                                  ("5" ("4" "2"))
    ;;                                                  ("6" ("1" "2" "5")))
In the end I think it doesn't really bring a lot, but it's especially useful in making short piece of code more readable:

    (->> [1 2 3 4]
         (map (when| odd? inc)))
    ;; vs
    (->> [1 2 3 4]
         (map (fn [x]
                (if (odd? x)
                  (inc x)
                  x))))
    ;; result (2 2 4 4)
Or this:

    (-> k-or-ks (when-not-> coll? list)
        (map-> ...do-something))
    ;;vs
    (let [ks (if (coll? k-or-ks)
               k-or-ks
               (list k-or-ks))]
      (map ...do-something
           ks))
Or even this:

    (-> 1 (juxtm-> :incd inc :decd dec))
    ;; vs
    (let [n    1]
      {:incd (inc n)
       :decd (dec n)})
Granted I have insane shits like this teleport arrow (very useful though):

    (-> '(1 2)
        (•- (conj (-• first dec)))) ;; => (0 1 2)
Or this >-args "fletching"

    (-> {:a 1 :b 2}
        (•- (-> (>-args (-> (/ (-> :a) (-> :b))))
                (->> (assoc (-•) :result))))) ;; => {:a 1, :b 2, :result 1/2}
I actually write this kind of stuff in my code ahahaha (the right move is to implement assoc-> of course hahahaha). Now there are combinators I wrote I never use, like departializers, unappliers, argument shifters, etc

avindroth · 2 years ago
Could you share the code for some of the custom threading macros you created? Looks very useful.
avindroth commented on Tacit programming   en.wikipedia.org/wiki/Tac... · Posted by u/tosh
avindroth · 2 years ago
Tacit programming + llm control library (like LangChain) has a lot of untapped potential. Tacit programming shines when the control structures are simple (and functions/variables can be anonymized), and these patterns occur frequently in programming on top of llms.
avindroth commented on Reading "A Programmer's Guide to Common Lisp"   journal.paoloamoroso.com/... · Posted by u/Tomte
avindroth · 2 years ago
For those who have the book, what is contained in the "discussion of the interactive Lisp programming process" as mentioned by Paolo?

Deleted Comment

avindroth commented on bigFORTH (1997-)   bernd-paysan.de/bigforth.... · Posted by u/RalfWausE
avindroth · 2 years ago
Forth really changed the way I think. I now take notes in a Forth-like way. Very underexplored.
avindroth commented on Procrastination is connected to perfectionism   solvingprocrastination.co... · Posted by u/EndXA
avindroth · 2 years ago
In my experience, perfectionism is crafted post-procrastination. It probably makes no sense, but the mind often does this convoluted thing in order to protect procrastination.
cc_ashby commented on Emacs-copilot: Large language model code completion for Emacs   github.com/jart/emacs-cop... · Posted by u/yla92
osener · 2 years ago
On a related note, is there a Cursor.sh equivalent for Emacs?
cc_ashby · 2 years ago
No, but there should be. If interested in collaborating (I made ChatGPT.el), shoot me an email at [email-redacted].

[url-redacted].

avindroth commented on Text Editor: Data Structures   averylaird.com/programmin... · Posted by u/ibobev
userbinator · 2 years ago
The worst way to store and manipulate text is to use an array. Firstly, the entire file must be loaded into the array first, which raises issues with time and memory. Even worse still, every insertion and deletion requires each element in the array to be moved. There are more downsides, but already this method is clearly not practical. The array can be dismissed as an option rather quickly.

Someone has clearly not heard of Notepad nor used the prolific quantity of text editors for DOS that appeared in the 80s/early 90s, a time when memory bandwidths were in the low MB/s; or even before that, micros with CP/M where memory bandwidths were measured in KB/s (and the whole address space was only 64k). Modern systems have memory bandwidths of dozens of GB/s.

Or perhaps that old saying really applies: worse is better.

IMHO an array is all you need for a regular general-purpose text editor. I hate needless complexity in software, but unfortunately others seem to love it.

avindroth · 2 years ago
Agreed. Our computers are so powerful, do we really need this additional complexity?

And of course, if performance becomes an issue, we can make minor improvements then.

Deleted Comment

Deleted Comment

u/avindroth

KarmaCake day919May 10, 2016View Original