Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> show me an example of how having 'spec' is going to help me refactor the code that I got wrong the first time, as easily as what a proto-ML-like static type checker does. It's not a question of "types are bad vs types are good thing". It's a question of "this property was called 'name', but now I need it to be 'names', and I really need to know every possible place of my code base that uses it so that I can recursively change all code paths to handle the fact that it's a list, now." I read the spec doc a dozen times, and I don't think it does help in this simplest of simple case.

For this, I think the way to go is to use `fdef` to annotate the arguments to each function. This is a lot more explicit keyboard-typing on the programmer's part, but then so is a statically-typed language.

Where I think Clojure will still come up short is in tooling to support finding each reference in a better way than grepping your project for `:user/name`. All the information you need is in there, as you can see from this proof-of-concept tool[0], but it's not implemented seamlessly into the workflow.

[0]: https://github.com/clj-kondo/inspector



Refactoring is still hard and awfully manual. And like all dynamic languages, a wrong key (was it :user or :users or :username or :user_name?) will be a PITA to find.


Refactoring from a :user/name String to a :user/names Array is going to be manual in both static and dynamic languages until Github Copilot gets a lot better. All the compiler or Spec can do is show you the places in your code where you'll need to make updates.


More precisely, it can show you "all" the places where I have to rework. And, since it is very likely that other pieces of the software will need to be change, it's crucial that is does it recursively.

The compiler can do that ; I'm not aware of how spec could do that.

Framing it as "all the compiler can do" us a bit weird - that's _exactly_ the thing I need.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: