4 ms·
The trick is to "package" the code you write from the very beginning For instance programming in Clojure it's incredibly easy to write your own libraries. It's
by geokon 2y ago
The trick is to "package" the code you write from the very beginning
For instance programming in Clojure it's incredibly easy to write your own libraries. It's just a separate namespace in a separate directory on disk. If you work on projects and push most of your work into mini-libs not only is it more maintainable but it makes it very easy to then reuse code in subsequent projects. So even if you don't wrap up the "main" project, most of the work is in a reusable format
- mr_mitm 2y agoHow do you resist the urge to generalize every little function you need? Doesn't it become overwhelming to make a library out of everything?
- geokon 2y agoYou do generalize everything but its not overwhelming bc there is nearly zero friction to writing and using a library. It has to do with the ergonomics of the language you're using though. In Clojure you just point to the lib directory in your 'deps.edn' and then use the namespace locally. It essentially doesn't require any additional work - except you do need to decouple the code (which is good anyway) The only extra work is you need to write a 'deps.edn' file for each mini-libs to specify its dependencies, but that take 5 seconds to do. Lots of your mini libraries end up being just a handful of "helper" functions that for instance wrap some 3rd party lib. I find I reuse them later in other projects all the time
- perrygeo 2y agoLibrary/namespace is so low level as to be obvious. Breaking up code by internal boundaries is fairly well-explored territory - every language gives you a way to modularize. Clojure namespaces aren't unique here, though functional programming with immutable data makes it WAY easier to do so, it's not improssible in other languages.. The barriers to finishing most projects are the "final mile" - taking it to production. So in general I agree - package from the beginning. I advocate for making that the first mile. If you think you might need tests, a website, a library, and a mobile app - set up CI, a VPS with an IPv4 address, and apply for a dev account on CentralizedLangRepo and ProprietaryAppPlatform from day 1. Make it a habit to release early and often. That's the only way to earn the muscle memory for rapid iteration in any language.
- geokon 2y agowith the move from `lein` to `deps.edn` it made local libs much easier to use. You can also push to your own github or pin to git hashes. It's all just incredibly easy - in a way that I haven't seen as smooth in a lot of languages (where there is more boilerplate involved). In effect it's just a extra namespace - but it's an namespace that's automatically shared across projects You're probably right about websites etc, but working this way I just don't feel too concerned about dropping a project b/c the code will live on and get reused