Re: Impact of gen-class on clojure-ness
On Mar 29, 8:56 am, Steven Devijver wrote: > Thanks for your reply. I understand there are more clojure-ish ways > then to use Java interfaces, but I take from your answer that using > Java interface with gen-class won't introduce technical issues. It's possible, but Clojure isn't designed to work that way. Put it another way: let's say I plan to make a Java program using nothing but static methods, and instead of using types I wanted to make everything an Object, and then cast it as needed. This is technically possible, but in your opinion, would it be a good idea? - James -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: Impact of gen-class on clojure-ness
On 29 mrt, 09:43, Jarkko Oranen wrote: > Interfaces are good, but defining your own is mainly reserved for Java > interop. You should strive to use plain old untyped data structures > for your data, ie. just put things in maps, vectors, sets andl lists. > Write (pure) functions to transform the data, and some logic to handle > program state. Try to keep a clear separation between state-handling > or "interactive" code and data-handling logic. Also make use of > Clojure's sequence abstraction. The core libraries have many functions > for processing sequences. > > The core abstraction in Clojure is a function. There is a feature > called "protocols" in git master that will become the Clojure way of > defining interfaces, but even if it is a protocol, the interface is > simply a collection of functions. If you're used to object oriented > programming, you need to invert your thought process from "What > methods does this object have?" to "What data can this function > process?" Thanks for your reply. I understand there are more clojure-ish ways then to use Java interfaces, but I take from your answer that using Java interface with gen-class won't introduce technical issues. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: [Noob] Impact of gen-class on clojure-ness
Hi Steven, Skip interfaces and gen-class, and look instead at protocols and types. There is a simple example [1] in the labrepl [2]. (You will need to be on Clojure 1.2 bits, which labrepl does for you, and you should do in any case.) I think people will use protocols less frequently than interfaces, but with greater leverage. Stu [1] http://github.com/relevance/labrepl/blob/master/src/solutions/rock_paper_scissors.clj [2] http://github.com/relevance/labrepl Hi, I'm thinking about writing some piece of software completely in clojure (yeah!) However, it is my first time so I want to make sure I know what I'm doing. Specifically, I prefer to define the important components of my software as Java interfaces. Partly to see myself think, partly because it just makes more sense to me. I then want to implement these interfaces using gen-class and clojure functions and pass resulting objects as function arguments. My question is: does this combination of Java interfaces and gen-class impact clojure-ness in any way? In other words, would I be living in a different world if I would just implement my functions and pass those functions around as function arguments without using Java interfaces and gen-class? Thanks Steven Devijver -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure +unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: Impact of gen-class on clojure-ness
> Specifically, I prefer to define the important components of my > software as Java interfaces. Partly to see myself think, partly > because it just makes more sense to me. I then want to implement these > interfaces using gen-class and clojure functions and pass resulting > objects as function arguments. > > My question is: does this combination of Java interfaces and gen-class > impact clojure-ness in any way? In other words, would I be living in a > different world if I would just implement my functions and pass those > functions around as function arguments without using Java interfaces > and gen-class? It sounds like you're thinking of an object-oriented design. Clojure is not particularly object-oriented. Interfaces are good, but defining your own is mainly reserved for Java interop. You should strive to use plain old untyped data structures for your data, ie. just put things in maps, vectors, sets andl lists. Write (pure) functions to transform the data, and some logic to handle program state. Try to keep a clear separation between state-handling or "interactive" code and data-handling logic. Also make use of Clojure's sequence abstraction. The core libraries have many functions for processing sequences. The core abstraction in Clojure is a function. There is a feature called "protocols" in git master that will become the Clojure way of defining interfaces, but even if it is a protocol, the interface is simply a collection of functions. If you're used to object oriented programming, you need to invert your thought process from "What methods does this object have?" to "What data can this function process?" -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
[Noob] Impact of gen-class on clojure-ness
Hi, I'm thinking about writing some piece of software completely in clojure (yeah!) However, it is my first time so I want to make sure I know what I'm doing. Specifically, I prefer to define the important components of my software as Java interfaces. Partly to see myself think, partly because it just makes more sense to me. I then want to implement these interfaces using gen-class and clojure functions and pass resulting objects as function arguments. My question is: does this combination of Java interfaces and gen-class impact clojure-ness in any way? In other words, would I be living in a different world if I would just implement my functions and pass those functions around as function arguments without using Java interfaces and gen-class? Thanks Steven Devijver -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.