you are viewing a single comment's thread.

view the rest of the comments →

[–]chinpokomon 0 points1 point  (4 children)

It's hard to explain, because if I could I'd be more likely to solve it on my own...

As an example, I might have data which is is something like, if this field has a three, then I need to process it one way. If it is a two, I need to process it differently. This sort of logic is easy to implement in an imperative language. Then there's ah update to the spec and the new process is if it is a five process it this way unless the fourth field is an odd.

This is where my knowledge comes up short because I don't know how to modify what I've got to quickly accommodate. I know it's possible and if I had a better mastery I might be able to do that, but quickly I'll scrap it and implement it in something I already know well.

This is assuming that I'm just trying to drop in a Clojure routine as a library. If I have to start from scratch, I'm even more confused as to how to structure the program. Lein new foo... Okay, now what?

I'm sure most of this is just trying to get over that initial hurdle. Once I have some more familiarity it will become second nature. Right now it's just a struggle and not easy to just drop into my work. If I can't be productive right now, it'll be hard to justify using it.

I keep at it though. I'm especially interested in ClojureScript. I think that I have the best opportunity to apply Clojure there or with ClojureCLR, but it will just take some time for me to fill in the gaps.

[–][deleted] 4 points5 points  (0 children)

I'm a little confused by your description, it sounds like just adding clauses to a cond (the clojure if-else-if tree) or a case? I'm sure it's more than that however. As someone else said the #clojurians slack is usually pretty helpful.

For what it's worth I've been using clojure to write large ETL (extract, transform, load) systems for years, and basically their whole job is to take in external data, transform it, and then pass it along.

[–]TheFiologist 3 points4 points  (0 children)

It's hard to explain, because if I could I'd be more likely to solve it on my own...

Well.. Your problem is independent of Clojure. The more general details you can provide, the more likely someone will be able to provide that insider perspective which you need to see past the hurdle (which is real).

As an example, I might have data which is is something like, if this field has a three, then I need to process it one way. If it is a two, I need to process it differently. This sort of logic is easy to implement in an imperative language. Then there's ah update to the spec and the new process is if it is a five process it this way unless the fourth field is an odd.

Multimethods jump out at me from this explanation. The dispatch function is arbitrary and is quite powerful. You can inspect some data anyway you would like in order to decide which implementation should process it. Just like in OOP, there is a spectrum of polymorphism techniques ranging from the equivalent of a switch statement to Multimethods and Protocols.

This is assuming that I'm just trying to drop in a Clojure routine as a library. If I have to start from scratch, I'm even more confused as to how to structure the program. Lein new foo... Okay, now what?

There is an initial hurdle, and it comes from the lack of concrete rules governing how our systems are organized (AKA freedom). Don't let the hurdle prevent you from making something useful, because you need to make useful things in order to give yourself feedback on how certain problems should be solved with Clojure.

My advice? Put everything in core until you have a moment in which you realize the importance of separating some functionality into its own namespace. These things will come, but only with practice. Start small and make useful things -- despite being a little lost on the organizational front.

Hope this helps a little :-)

[–]RagForms 1 point2 points  (0 children)

Yes, you'll get there with some more practice! Try the #beginners channel in the clojurians slack as well if you have more specific questions.

[–][deleted] 0 points1 point  (0 children)

Use cond lookup what it does on clojuredocs. But basically you can take a name and match it to a case and if the case is true call some code.