Fork me on GitHub
#clojure-austin
<
2024-04-29
>
xtructure17:04:01

Hi folks---I have a Clojure contracting opportunity with some older Clojure code that needs to be updated to get running again. Also open to refactoring if you see some opportunities. I wrote the original PoC in Java years ago, then hired a Clojure dev to redo it in Clojure since the application lent itself to a functional, Lispy programming style. I've been playing with ChatGPT to comment the code and offer advice on updating it. Here's what it has to say about one of the core .clj files: "As of Clojure 1.11.3, there are some elements in the provided code snippet that may need attention due to updates in the Clojure language and libraries. Here's a rundown of potential compatibility issues and deprecated features: 1. *`defstruct` and struct*: The defstruct and struct constructs are deprecated in favor of using Clojure's more flexible and powerful maps and records. These were part of earlier versions of Clojure but have been superseded by maps for general use and records when a fixed set of fields is needed. You should consider migrating these to either maps or records depending on the need for performance and field constraints. For example:

clojure
   (defrecord Bundle [children segments attributes])
   
2. *Error Handling in logged-error*: The use of (throw (Exception. message)) is correct, but it's important to ensure that it aligns with how exceptions are intended to be handled in your broader application context. Clojure 1.11 continues to support this mechanism. 3. *Use of Namespaces and Libraries*: - Ensure all referenced libraries (`taoensso.timbre`, clojure.data.json, etc.) are up to date and compatible with Clojure 1.11.3. Library versions can often introduce breaking changes or deprecations that may affect your code. - The :refer :all in the namespace declaration (`:require [xbundle.bundle-util :refer :all]`) is generally discouraged as it can make the code harder to understand and maintain by obscuring where functions are defined. It's better practice to explicitly refer only the needed symbols or use aliases. 4. *General Code Practices*: - Ensure that the use of macros like update-bundle is correctly capturing the intended semantics, especially in the context of scoping and symbol resolution. - The idiomatic use of functions like map, nth, and concat is compatible with Clojure 1.11.3, but always ensure that their usage aligns with current performance recommendations, especially for large datasets or performance-critical applications. If you’re upgrading from a significantly older version of Clojure or if you're integrating with newer libraries or systems, you would benefit from a full code review to ensure compatibility and adherence to modern Clojure practices. Consider refactoring deprecated features and improving the clarity of namespace management as part of this upgrade process."

xtructure17:04:33

Let me know if you're interested (@mlimotte, this is the project I mentioned at the last meetup).

👍 1
norman19:04:06

@staypufd Do we have any leads on topic for this month's meeting?