Posts

Showing posts with the label clojure

JVM Notebook: Basic Clojure, Java and JVM Language performance

Image
"Measure, don't guess. The primary goal of all performance tuning exercises should be maximize the end user experience given the resource constraints." [1] "It isn't so much a "farewell to the J" as an expansion of the platform opportunities Java provides. Sun's investment to power ongoing development of JRuby and Jython broadens the range and reach of Java, as a whole." -- Rick Ross Overview and JVM Languages    One of the exciting trends to recently emerge from the Java community is the concept of the JVM language. These technologies are all that you would expect them to be. They are implementations of languages that run on the Java Virtual Machine. Some are newly created and some are based on existing, more mature languages. JRuby, Jython are two JVM languages based on CRuby and CPython. Groovy, Scala, Clojure are three completely new JVM languages that were created to add new language features that weren't supported by the core Ja...

Doing it wrong, fun with Clojure

Image
I certainly take a liberal approach to programming, some may call it quantity over quality but I like to enjoy everything I do. This may include doing it wrong, but sometimes I like the end result. I am working on a SWT GUI tool and could not figure out a clean way to avoid SWT's illegal thread exceptions. When a user clicked a menu option on the gui, I needed to first take text from an edit box field and then use that data to pass to a long running thread. This is what I ended up with: ;; Define the clojure 'agent', save the state of our search box ( def *search-text-state* (agent nil)) ;; Define an implementation of 'SelectionAdapter/Interface' ;; SelectionAdapter requires one method 'widgetSelected' ;; With display.syncExec, pass an implementation of java.lang.Runnable ;; The thread updates the 'agent' search-text-state text. ;; After we get this text value, then launch another thread 'start-findgrep' ( def findgrep-listener (p...