2008-02-23
| 07:55 | baggles | oh :D this is a nice suprise, i was expecting to find noone here. |
| 07:55 | bgeron | :) |
| 07:56 | baggles | i was just wondering how i might make an applet, so i go looking for how to make a class. i see the implement macro, but ... defjavaclass (java/awt/Applet) .... ?? |
| 07:56 | baggles | also... maybe those of you who haven't seen this before will find it interesting: http://parleys.com/display/PARLEYS/The+future+will+be+about+programming+languages?showComments=true |
| 07:59 | baggles | hm. maybe i'm barking up the wrong tree with the applet thing, or it's simply not implemented yet. |
| 08:09 | bgeron | rhickey: thoughts about applets? :) |
| 08:10 | baggles | well, i guess a better questions is: can i create a .class file that has a public class compatible the rest of the java world ... |
| 08:13 | baggles | i did have a search through the mailing list, but there was only one passing mention to an applet. |
| 08:13 | rhickey | Right now you can't implement named classes in Clojure, nor can you store compiled Clojure code. But it is easy enough to write a stub in Java, then call Clojure. |
| 08:14 | baggles | ok that's doable. |
| 08:15 | rhickey | See also Repl.java |
| 08:16 | rhickey | Hosting Clojure isn't documented yet. |
| 08:17 | baggles | ok |
| 08:19 | baggles | hm. is the idea of providing some class-definition mechanism at all on the cards though? |
| 08:22 | rhickey | There will be a way to extend concrete classes anonymously and dynamically, a la implement, but probably not a way to define Java classes in Clojure syntax - by the time you add everything needed to specify field types, access levels, super et al, plus the new semantics of methods vs true fns, and what you get is Java w/parens, and a lot more complexity in the language. |
| 08:24 | rhickey | I could see auto-generating the Java stubs from Clojure, maybe. |
| 08:24 | baggles | hm. so basically, when it comes to this applet stuff, i'm looking at a stub applet with something like public void init() { Compiler.... load something? } public void start() { Compiler.eval("(start)") } |
| 08:24 | baggles | auto-generating the .java source files? |
| 08:24 | rhickey | after the compiler has loaded code, you can call it by: |
| 08:25 | rhickey | creating a var, say clojureFn, in Java with the same ns/name as a Clojure fn you want to call... |
| 08:26 | rhickey | clojureFn.invoke(args) |
| 08:26 | rhickey | no eval |
| 08:26 | baggles | ok |
| 08:27 | baggles | hm cool. that was easy enough |
| 08:27 | rhickey | There will eventually be JavaDoc for the Clojure Java API |
| 08:28 | baggles | but still it's good enough to give an idea... |
| 08:29 | rhickey | Yes, just no way right now to know what's ok to use and what's implementation details - try to stick to RT, Var, and the (many) interfaces |
| 08:30 | rhickey | the thing to know is that when you intern a var with the same ns/name, it is the _same_ var object, everywhere |
| 08:30 | baggles | hm. ok |
| 08:31 | baggles | well |
| 08:31 | baggles | i'll have a play with it and see how it goes |
| 08:36 | baggles | well actually, i'm just going to see if i can make a generic applet to start a clojure runtime, then load a file given as a parameter into it in init, then find symbols for start, stop and paint in ... (or (a namespace named by another param) 'applet') .... and invoke them then. |
| 08:37 | baggles | does this sound sensible? |
| 08:37 | baggles | i'll put it on the mailing list if it works |
| 08:37 | rhickey | definitely possible. make sure you call RT.init once, early |
| 08:37 | baggles | yes. i'll put it as the first thing in the init method |
| 08:38 | baggles | cool. this is quite exciting really. :) |
| 08:39 | rhickey | definitely post your progress on the group, I'm sure many would be interested. |
| 09:07 | baggles | maybe a stupid question. but clojure symbols case is preserved, right? |
| 09:36 | baggles | hm. |
| 09:36 | baggles | Couldn't initialize Clojure runtime: Pop without matching push |
| 09:37 | baggles | that's on starting RT.init()... as the first thing inside the applet's init |
| 09:52 | baggles | hm |
| 09:53 | baggles | ok i think i can safely say that i'm stuck now |
| 09:57 | rhickey | clojure symbols are case sensitive |
| 09:58 | rhickey | pop without matching push - stack trace? |
| 10:00 | baggles | ok. i'll include that with the mailing list post and all my code |
| 10:02 | baggles | ok sent |
| 10:06 | baggles | maybe all the clj and the java code is a bit wrong anyway... but I guess if i can't get the RT.init right.... |
| 10:16 | baggles | http://groups.google.com/group/clojure/browse_thread/thread/7c65108c1d864e2b if anyone has any clues i'd be much obliged |
| 10:16 | baggles | i'm going to try and implement the same thing in a frame now |
| 10:24 | rhickey | looking at it now. I'm trying to create an applet from scratch in netbeans 6, got through RT.init(), in AppletViewer at least |
| 10:24 | baggles | cool |
| 10:25 | baggles | yeah i was using appletviewer too |
| 10:25 | baggles | might updating to latest svn help ? |
| 10:25 | rhickey | It might help with the stacktrace - those line #s don't correspond to my source |
| 10:26 | baggles | ok i have an up to ate source |
| 10:26 | baggles | is ant the best way to build? |
| 10:27 | rhickey | doesn't matter much |
| 10:27 | rhickey | ant and maven scripts are there |
| 10:27 | baggles | well, i barely remember ant and i've never heard of maven |
| 10:28 | baggles | oh well |
| 10:28 | baggles | that was quick. 6 seconds |
| 10:28 | baggles | java.lang.IllegalStateException: Pop without matching push at clojure.lang.Var.popThreadBindings(Var.java:224) at clojure.lang.RT.init(RT.java:240) at ClojureAppletTest1.init(ClojureAppletTest1.java:22) |
| 10:29 | baggles | oh. it's looking for boot.clj and i've moved the jar |
| 10:30 | baggles | whoops |
| 10:30 | baggles | i see now |
| 10:30 | baggles | i was just trying to be convenient for myself really |
| 10:30 | baggles | so that boot.clj is fairly fundamental |
| 10:30 | rhickey | yeah most of Clojure is defined in itself, in that file |
| 10:31 | baggles | ok |
| 10:31 | baggles | i mean in that applet, i've just included clojure.jar in with that applet's tags... how is boot.clj going to fit in? |
| 10:32 | baggles | well, as it appears to only load boot.clj i guess i'll just load it through my own means then. |
| 10:32 | rhickey | boot.clj is in clojure.jar |
| 10:32 | baggles | oh |
| 10:32 | baggles | so it SHOULD be ok really... |
| 10:32 | rhickey | RT.init() loads it from the jar |
| 10:33 | baggles | so it's just not working with this setup then |
| 10:34 | rhickey | don't know - the error you are getting is not the one you get when there is a problem loading boot.clj |
| 10:35 | baggles | ok |
| 10:36 | baggles | what does your applet look like then? |
| 10:37 | rhickey | just the boilerplate spewed by NB for a JApplet |
| 10:37 | baggles | hm |
| 10:38 | rhickey | what platform are you on? |
| 10:38 | baggles | Linux bill-desktop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux |
| 10:38 | rhickey | and JVM? |
| 10:38 | baggles | java version "1.6.0_03" |
| 10:38 | baggles | Java(TM) SE Runtime Environment (build 1.6.0_03-b05) |
| 10:38 | baggles | Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing) |
| 10:39 | rhickey | It almost looks like ThreadLocal initialValue isn't working there |
| 10:40 | rhickey | the Var pushThreadBindings and popThreadBindings are matched up where you get the error |
| 10:40 | rhickey | but pop restores the prior frame... |
| 10:41 | baggles | hm. maybe i should initialize the runtime in start instead of init? |
| 10:41 | rhickey | which is setup by ThreadLocal.initialValue |
| 10:42 | rhickey | you could try that, but it shouldn't matter |
| 10:43 | baggles | ok |
| 10:43 | baggles | oh well |
| 10:43 | baggles | making it in a Frame it runs |
| 10:43 | baggles | i think its' that i have loaded the clojure.jar and not had it in the classpath somehow |
| 11:32 | baggles | aha |
| 11:32 | baggles | well. using eclipse i got it working |
| 11:33 | baggles | i must have just set up the classpath incorrectly or something |
| 11:44 | baggles | hm |
| 12:02 | rhickey | works in NB, after I figured out how to get the clojure script into the jar... |
| 12:02 | baggles | erm |
| 12:02 | baggles | what do you mean? boot.clj? |
| 12:02 | rhickey | no, the app script |
| 12:02 | baggles | oh. |
| 12:03 | rhickey | I added a helper to RT - var(ns,name), both strings |
| 12:03 | baggles | hm. yeah. i guess that would help. well, i was trying with eclipse and using its method of running the applet (by using some java invocation with the AppletViewer class) it works |
| 12:03 | baggles | but just trying to get the HTML to make it appear in the standalone appletviewer program |
| 12:03 | baggles | comes up with those "pop without push" errors |
| 12:04 | baggles | my latest attempt involves trying to make a jar with clojure.jar as part of the classpath as described in a manifest per these instructions: http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html |
| 12:10 | baggles | http://java.pastebin.com/m220e4856 anyway that's where my java is at at the moment if you're interested. |
| 12:15 | baggles | hm. svn update is a bit broken at the moment it seems. |
| 12:15 | rhickey | yeah, I can't commit either |
| 12:15 | baggles | bah |
| 12:16 | baggles | i think... i've been thinking about this for too many hours |
| 12:16 | baggles | well, i'd be interested to see your applet anyway. |
| 12:16 | baggles | if it was working in appletviewer and a browser. |
| 12:23 | baggles | oh cool about the RT.var aswell |
| 12:24 | baggles | oh well |
| 12:24 | baggles | i think it must be time for runescape now :P |
| 13:15 | hoeck | hi |