Oracle vs. Google
Today the media was all over Oracle suing Google over something Java related, and as very little people seem to like oracle the most crazy theories went through the ether. Let me start with the fact that I personally am very sad that Oracle bought Sun, working with Sun (or now Oracle) is my daily job and for me things have everything but improved since the purchase – still I try to be objective.
Now it seems that somewhere, someone posted ‘Oracle sues Google for using Java’ which is as far as I understand total nonsense, but of cause a great story for the (social)media since people can be outrageous about it. Now after whoever started this posted their HN, Slashdot, Blog or whatever post the uninformed masses went all in panic about who next might be sued – today I read a post on the Clojure mailing list saying (to sum it up) we should put effort to get away from the JVM because Oracle might so.
I’ve actually taken the time to read the Lawsuit, while I don’t claim to understand all the lawyerish jibber jabber I think I can say that Oracle is in fact not suing Google for using Java but much the opposite.
The problem Oracle seems to have, and I am not going to discuss if it is right or wrong, is that as they claim Google has taken ideas and code from Java to implement their own version which seems to be a competitor to Java and the JVM, if google had used the JVM for android there would not have been any problem here.
So to put people back to sleep I think I will give you a list of what might get you sued and what not (of cause I don’t claim it to be correct or am willing to take any responsibility if you actually get sued for something – otherwise Oracle might sue me next ;)
- Writing running some program in Java (as in starting netbeans)
- Writing some program in Java (as in writing a text editor in Java)
- Writing in a language based on the JVM (as in rails (running on Jruby), or Incanter or I don’t know waht)
- Writing a language based on the JVM (as in Scala or Clojure or JRuby or Jython)
So I think 99.9% of the Java developers out there are pretty save unless they plan to write their own VM with implementation details that are euqal to the JVM.
Have fun!
clj-sandbox 0.4.1-SNAPSHOT
clj-sandbox 0.4.1-SNAPSHOT is released, it fixesd a security bug in the whitelist tomj reported the other day.
In addition to that an :initial argument can be passed now. It holds a seq of s-exps that will be evaluated in order to allow predefining functions. This is handy to overwrite functions and macros like defn or whatever.
clojure swing in real world
I’m currently working on a little tool for my work, one that requires a little gui, a menu, a combo box, two tree views and a text field, most of them interconnected. I’m lucky that I can develop this on clojure since to me it’s a great joy to write in this language. Now I said GUI, and fortunately I’d had clj-swing in my back of tricks and this was a great oportunity for me to test it in real world conditions, now I figured that I share the few things I’ve learned during this last days and weeks.
It works
As absurd this sounds, I was positively surprised of how well it worked and that I had to jump trough little loops to get things working. Of cause it wasn’t all smooth and nice, a few times I had to fall back to java interop but I think it was forgivable in the whole picture. Also it showed me a few things that clj-swing could do better and allowed me to improve it, which will continue to happen :).
The REPL is tricky
I am coding in EMACS+slime and I noticed that swing and slime don’t go along to well, all the seperate treads lead to the point where the swing app locks up for no reason – runnig it with java works fine so.
clojuires mutables are great
We all know this already but I mean great in another sense, it is super easy to store the data in them and see how things automatically update the GUI once the data changes, weehee!
And here how the gui code looks, somet things will go away with in the next clj-swing version and the code for actual actions is in extra functions (as it should be) but this is how you can generate a window with two tree vriews a splitter a combo box and a text field all interacting in one way and another over refs:
(defn -main []
(let [matcher-cb (combo-box (keys @matchers)
:maximum-size (java.awt.Dimension. Short/MAX_VALUE 25)
:action ([e] (combo-box-change-action e)))
menubar (make-menubar
[{:name "File"
:mnemonic KeyEvent/VK_F
:items
[{:action (make-action
{:name "Open..."
:mnemonic KeyEvent/VK_O
:handler (fn [_] (open-action matcher-cb))})}
{:action (make-action
{:name "Compile..."
:mnemonic KeyEvent/VK_C
:handler (fn [_] (compile-action (selected-item matcher-cb)))})}]}])
text (text-field :editable false :str-ref tf :maximum-size (java.awt.Dimension. Short/MAX_VALUE 25))]
(frame :show true :menubar menubar
:default-close-operation :EXIT_ON_CLOSE
:title "Config Generator 2.0" :size [600 400]
[_ (split-horizontal
(tree :model (mapref-tree-model raw-data "Data"))
(stack
[_ (panel :name p
:layout (BoxLayout. p BoxLayout/PAGE_AXIS)
[_ matcher-cb
_ text])
tr (tree
:action ([old-path new-path]
(tree-change-action old-path new-path text))
:model (mapref-tree-model
data {:name "Data" :good (good-data? @data)}
:node-wrapper (fn [node path] (Pathed. node (str (:name node)) path)))
:cell-renderer renderer)]
(add-action-listener text ([e] (check-validity)))))])))