4 ms·
Are these cases easy in ClojureScript - I change the property 'Part' to 'PartList' on my DTO and now I need to find all places that Part is referenced and upda
by pixie_ 10y ago
Are these cases easy in ClojureScript -
I change the property 'Part' to 'PartList' on my DTO and now I need to find all places that Part is referenced and update them.
I have a function that takes a 'User' as a parameter, but I don't know what the property is called for the display name. Is there an easy way of figuring it out without running the app? REPL wouldn't help because I dont even know how to create a User object (this is a very large code base that I didn't write myself)
I add a new parameter to a render() function and I need to find out all the places the function is called so I make sure to update them.
I make a spelling mistake calling a function or referencing a property. Do I get any instant alert to the error or do I have to run the app, or run REPL on it?
If I'm changing tons of code across many files I don't want to have to run/REPL for every little thing to validate that I didn't make a dumb mistake. Ideally the mistake is caught as soon as I type it. Does ClojureScript have this?
- yogthos 10y ago>I change the property 'Part' to 'PartList' on my DTO and now I need to find all places that Part is referenced and update them. Yup, I use Cursive IDE (https://cursive-ide.com/ https://cursive-ide.com/) and it provides precise symbol lookup using static analysis. >I have a function that takes a 'User' as a parameter, but I don't know what the property is called for the display name. Clojure is a functional language so I don't have a problem of dealing with a plethora of classes. The data model is defined using the schema and I can easily tell what it looks like. Furthermore, since it's a functional language, I don't have any global state to worry about. I can try any function in the REPL in isolation to see what it's doing and how it behaves with different inputs. Destructuring (http://clojure.org/guides/destructuring http://clojure.org/guides/destructuring) is alos commonly used for readability in Clojure. When a function takes a non-primitive type, it's idiomatic to destructure it to show what the shape of the data is right in the arguments. >I add a new parameter to a render() function and I need to find out all the places the function is called so I make sure to update them. Yup, absolutely. I can look up usages of a function in Cursive. >I make a spelling mistake calling a function or referencing a property. Do I get any instant alert to the error or do I have to run the app, or run REPL on it? Yes, Cursive will highlight undefined symbols as well is invalid function arity. I get immediate feedback if I mistype something, try to use a function that doesn't exist, or pass wrong number of arguments to a function. >Ideally the mistake is caught as soon as I type it. Does ClojureScript have this? That's generally exactly what happens in my experience, and in addition I also have the REPL that lets me run any code if I'm not sure about what it's doing.
- pixie_ 10y agoInteresting, thanks. It seems pretty 'statically' typed to me. Kind of like TypeScript on the surface, but underneath the tooling and transpilers it is not. What do you think?
- yogthos 10y agoClojureScript is dynamic, but it has completely different semantics from JavaScript. It just treats Js as a compile target. I think that Clojure has much cleaner language semantics than JavaScript, and this makes the code much easier for the IDE to analyze it. That said, there is optional static typing available with Typed Clojure, and it can even generate type annotations from tests as seen here: https://github.com/typedclojure/auto-annotation https://github.com/typedclojure/auto-annotation
- mpweiher 10y agoAll these cases are also easy to trivial in Smalltalk.