Re: Simulations in Clojure/Clojurescript
Hi, Have a look at Vega and Vega lite for visualization... Amazing chart library On Jan 27, 2018 11:48 AM, "Michael Nardell"wrote: > Tiago ::Thanks, for your input. Worth more considerably more than $00.02 > for me right now. Since the last week or so, I have been diving into > ClojureScript. In particular I am loving exploring D3.js, with an > interactive, live coding experience. I am not sure if I should admit this > in public.. but I actually really miss Macromedia Director + Lingo. Offered > an interactive environment for building highly visual simulations and then > distributing on the web. I am seeing ClojureScript + FigWheel + D3.js > (and/or other viz libraries) as a way to get that experience back. > > MIke > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Simulations in Clojure/Clojurescript
My $0.02, I was a very early Clojure adopter, but I stopped using it when Oracle bought Sun (I left the JVM completely at that time). I am currently using ClojureScript a lot - for the last 6 months or so, thus not the most experienced programmer. Most of my usage is doing scientific simulations (genetics and epidemiology in my case). I published one simulator in Scala and Java. Done quite a few in Python+C and currently working in JavaScript + ClojureScript. My observations here come mostly from my Scala work and my current work in JS+CLJS. First observation is that a lot of scientific simulation code is highly imperative (not saying if that is good or bad), so lots of the mentality in the field is geared towards that. Still lots of Fortran floating around, for example. In many cases performance is really really important. This tends to be CPU bound, rarely disk or network. Sometimes memory might be a consideration. My general strategy is to do the computationally expensive core in a lower level language. For example, my Scala simulator had the core written in Java. My ClojureScript stuff has a JS core (and in the future will have parts in C). The Python stuff had C/C++ code. The higher level language (Scala or ClojureScript) provided the interfaces to manipulate the lower level code in a declarative, elegant and functional way (actually DSLish way). Tiago On 10 January 2018 at 16:08, Michael Nardellwrote: > Greetings :: I am new to Clojure and have not really gotten my feet wet > with Clojurescript yet. The advice I always give someone when leaning > programming or a new language is to pick a project that they are interested > in and dive in. For me, that project would be creating educational > simulations that model complex systems. > > Part of my challenge with this as a project is that it is leading me > towards programming (at least partially) with objects to model the discrete > components in these systems. Arguably simulations are one of the domains > where objects are the right paradigm. The question I pose to the group is > how to work with objects in Clojure, in a manner that "goes with the grain" > of the language. Perhaps best to ground my question in a concrete example: > > I had created simulations / visualizations of Hubel and Wiesel's model of > the center-surround receptive fields in the retina. My past simulations I > used a collection of objects to model photo receptors (i.e. rods/cones), > horizontal, bi-polar cells, connected together to represent the behavior of > either on-center or off-center receptive fields. Kind of a simple neural > network. Would like to preserve the object nature of nodes in the network, > since the nodes have state and should be represented by graphics in a gui. > Ultimately I would like to move toward a "constructor kit" approach that > would allow students and teachers to model and simulate a whole variety of > various systems that can be represented as a network of processes with > feed-forward and feed-back connections. > > Interested to know of any useful examples and guidance for doing objects > the Clojure/Clojurescript way. Certainly one of the examples I want to look > at closely is the Ant Hill that Rich Hickey demonstrated. > > As is the case with a neophyte - any advice is well appreciated. > > Mike > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Tiago Antao Scientific and HPC programmer http://tiago.org https://github.com/tiagoantao/ -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Consistency of the API
On Mon, Nov 9, 2009 at 8:08 PM, Kevin Downey redc...@gmail.com wrote: I don't understand, the error message you get is the error that occurred. Both of them honor their documentation - no doubt. My point is not that, my point is that the behavior is different between the 2 functions for the same kind of issue: What is the rationale for even? and contains? having different behaviors for the exact same error (ie, one throws the other works fine and just returns false on a type error)? From a design perspective this seems to increase the cognitive load to programmers without any (apparent) reason. One would imagine that both functions should have the same behavior for the same kind of error... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Consistency of the API
On Mon, Nov 9, 2009 at 8:31 PM, Mark Engelberg mark.engelb...@gmail.com wrote: I imagine the rationale is efficiency. Every core function could conceivably do a number of runtime checks to make sure that each input is the right kind of type, and then Clojure might feel more sluggish. So instead, the core functions just worry about what to do for the appropriate inputs. If you pass a bogus input, the consequence depends entirely on how that particular function was coded. It might return a spurious result, or it might error. There are numerous examples of this in the Clojure API. I understand this, but it creates another kind of problem: When programmers make mistakes (and I, being not a perfect human being, make lots of mistakes) the system behaves inconsistently in a place where one would expect consistency (type checking): sometimes it blows in your face (like even?), sometimes it does that silently (like contains?). From a software engineering perspective is seems a bit dangerous. Unless of course, programmers are perfect and never make mistakes, for those kind, this discussion might seem ridiculous. I, for one, prefer the blow in your face (ie, like even?) design approach than the silent one. But above all, consistency would be nice to have. But I understand the rationale for efficiency. Tough I question if there is really a rationale of efficiency or this issue was really never really thought about (considering that Clojure is such a fast moving target, that would be normal). Peace, Tiago --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Consistency of the API
On Mon, Nov 9, 2009 at 10:20 PM, John Harrop jharrop...@gmail.com wrote: It seems to treat strings as it does vectors, seeing if an index is in bounds or not. It doesn't treat symbols as anything though. The clojure.contrib.seq-utils/includes? function gives true for foo and I did not want to make this a discussion about contains? per se, but about the general design philosophy about dealing with type erros (which I think is a bigger issue, IMHO). But it is a bit difficult to avoid noticing that contains? is a bit unintuitive, so to say. Even with vectors (contains? [1 5] 5) being false sounds somewhat strange. I understand the initial intent, like this: (contains? {'a 5} 5) being false But the end result with strings and vectors is a tad unintuitive... Tiago --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Constructing Java Interop calls
On Thu, Oct 29, 2009 at 1:38 PM, Meikel Brandmeyer m...@kotka.de wrote: All good here, but, if I do the eval variation, user= (eval (list (symbol .setFileSelectionMode) jfc 1)) Another example which shows that eval is not worth the trouble. It is better to use reflection. You cannot embed the JFileChooser as a object into the code. You have to construct it in your eval. (eval ` (let [chooser# (JFileChooser.)] (~(symbol .setFileSelectionMode) chooser# 1) chosser#)). Thanks for all the people that helped. But I just wonder, why? I mean, why one cannot embed an object in the eval code? Tiago --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Constructing Java Interop calls
On Thu, Oct 29, 2009 at 2:15 AM, Alex Osborne a...@meshy.org wrote: Using eval (which will also work for dynamically calling Clojure functions): (let [obj some string fname .substring] (eval (list (symbol fname) obj 2))) Thanks a lot. I was trying to avoid reflection (ie, looking for a clojure idiom), especially to get an understanding on what are clojure limitations. The eval form still shows some problems, if I do this preparation: (import javax.swing.JFileChooser) (def jfc (new JFileChooser)) And then do: user= (.setFileSelectionMode jfc 1) nil All good here, but, if I do the eval variation, user= (eval (list (symbol .setFileSelectionMode) jfc 1)) I get: #CompilerException java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined In theory it should work? What basic mistake am I doing here? BTW: user= (println (list (symbol .setFileSelectionMode) jfc 1)) (.setFileSelectionMode #JFileChooser javax.swing.JFileChooser[,0,0,0x0,invalid,layout=ja...] 1) So the list for the eval looks good... Many thanks, Tiago -- The hottest places in hell are reserved for those who, in times of moral crisis, maintain a neutrality. - Dante --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Constructing Java Interop calls
Hi, Sorry for the newbie question, but I am trying to understand how to construct and call java dynamically from clojure. As an example, imagine that there is a bean property called Bla and one wants to set Bla to 1 on object x, which has that property. So, the objective would be to construct, the following java equivalent x.setBla(1); I defined a macro called setProperty like this: (setProperty Bla x 1) And the definition is (very wrong): (defmacro setProperty [field obj value] `(let [cct# (symbol (.concat .set ~field))] (cct# ~obj ~value) ) ) If I do (println (setProperty Bla x 1)) I get 1 (the setBla is a void, so I should not get 1). bla is never set to 1, by the way :( Note that I am not trying to sort the particular case of beans. I am trying to understand the general mechanism to construct symbols (java interop) and execute them with a set of parameters over a java object. Thanks a lot and sorry for the newbie question, T -- The hottest places in hell are reserved for those who, in times of moral crisis, maintain a neutrality. - Dante --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Constructing Java Interop calls
On Wed, Oct 28, 2009 at 7:34 PM, Wilson MacGyver wmacgy...@gmail.com wrote: Is there a reason you don't want to use doto? http://clojure.org/java_interop#toc15 ie (doto Bla (.setProperty x 1)) I really want to do something different: (def x (new StringBuffer )) (doto x (.setLength 2)) But my point is to be able to construct the method name in runtime. Using doto, I still have the same problem: (defmacro setProperty [field obj value] `(let [cct# (symbol (.concat .set ~field))] (doto ~obj (cct# ~value)) ) ) If I do: (def sb (new StringBuffer )) (setProperty Length sb 2) sb I get (It should be aa). Again, the point here is to be able to construct method names (full call signatures, really) on runtime. I am lost. As in newbie clueless :( Thanks a lot, T --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---