#clojure logs

2008-04-03

11:11cgrandIt seems that when calling a method on a type hinted value, the object is cast to the declaring class of the method not to the hinted class. Am I right? Can I rely on this behavior or is it an implementation detail?
11:12rhickeywhen does distinguishing it become important?
11:13cgrand*out* is tagged as an OutputStreamWriter and I bind it to a PrintWriter (in a servelt)
11:13cgrandRight now it works
11:14rhickeyhmm...
11:15rhickeyit probably should just be hinted Writer
11:16rhickeyI can't promise it will never cast to hinted type
11:16cgrandand I would not have to worry :-)
11:16Chousercgrand: are you using webjure?
11:18cgrandcasting to the hinted type can provide some performance gains (methods declared final... or final classes... hey does it means that actually Strings are cast to CarSequence?)
11:18cgrandchouser: no writing write a minimal servlet wrapper
11:19cgrandchouser: (delete "write")
11:20rhickeycgrand: the hints are just used to find resolve methods, the casts are based upon the methods themselves right now
11:22cgrandrhichey: ok
11:23rhickeycgrand: *out* type hint now Writer
11:23cgrandrhickey: thanks
11:29Chousercgrand: I'm currently writing a minimal webserver that may or may not be able to load and run servlets eventually.
11:30Chousercgrand: are you writing Java code to run clojure in a standard Java server, or some other piece?
11:33cgrandchouser: a simple servlet which setup clojure and delegates everything to clojure code with nearly no wrapping of java objects (request & response)
11:36cgrandchouser: are you building your webserver from scratch?
11:37Chousercgrand: yeah, I just want something that's super-easy to deploy, esp. in a development environment.
11:41Chouserso you're passing the servlet req and resp directly into clojure code?
11:42Chouserwill the clojure code register some kind of handler with the servlet, or will it be more hard-wired?
11:43cgrandchouser: yes, I bing them to servlet/*request* and *response* (and *in* and *out* to their reader/writer)
11:43cgrandchouser: s/bing/bind/
11:43rhickeycgrand: it's easy, right?
11:44Chouserok, cool.
11:44cgrandreally easy and I tak the name of the boot script for the app from a servlet parameter
11:44rhickeyI'll eventually put a servlet stub class in Clojure
11:44rhickeyto make even easier and standardize
11:47cgrandrhickey: how would you dispatch requests to clojure code? with a map (http-method => handler), with a single clojure function "service" or several functions (one by http method)?
11:47Chouserisn't the input stream already in the request? Sorry, I'm new to servlets.
11:49rhickeycgrand: probably a single service fn, to allow the most flexibility, since the advantages of overriding them separately on the Java side are lost once you override them all
11:50rhickeythe idea of the stub would be to get out of Java ASAP
11:51cgrandchouser: it is, I just think it's fairly common to want to bind *out* to the response outputstream so that print works.
11:51Chouseryeah, ok.
11:59cgrandchouser: did you consider Jetty? http://docs.codehaus.org/display/JETTY/Embedding+Jetty
11:59Chouseryes I did
12:01ChouserI started trying to install and configure Jetty. I got maven installed ok, but then it was pulling in all sorts of libraries to build Jetty. The binary installation of Jetty was over 20MB.
12:02cgrandlightweight :-)
12:02ChouserI don't mean to whine, but I don't really want all that just for playing around with development.
12:03ChouserI expect to have a minimal web server .clj file to weigh in at around 150 LOC. With minimal servlet support, maybe add another 100.
12:04ChouserSure, if I'm going to deploy a production server I can expect signicant installation work, and I can compare Jetty and TomCat and whatever, and do what makes sense.
12:05ChouserBut I've played with a few web "frameworks" in a few languages (python, C++/Qt, ruby (guess which one!)) and being able to install a small framework and run a command to get your sample site running in a little webserver is just really pleasant.
12:05ChouserI think it's a good way to help get a newbie hooked on any particular framework.
12:06Chouseror maybe my little webserver will be useless for anything but helping me learn Clojure and servlets. That's ok too. :-)
12:06rhickeyyeah, until people realize the built-in webservers for those frameworks are not so hot.
12:06rhickeyOnce you have a servlet host installed, everything else is easy
12:07rhickeybut you've built on an architecture that lets you swap in Tomcat/Jetty/Resin/GlassFish...
12:07rhickeygrows into authentication, JDBC connection pooling
12:07Chouserbut what if the code you write for the built-in webserver can be dropped directly into a standerd servlet host?
12:08rhickeyyour clients can get support for the servers from Sun/IBM/JBoss
12:08Chouserwhat's the downside then?
12:08rhickeyas I said before, you'd have to provide all of the features of servlets, accurately
12:09Chouserso you really think this is a dead end.
12:09rhickeyWhen Webjure was released, I was on a client site and had no servlet host on my laptop...
12:10rhickeyI downloaded Jetty into a directory, started it, dumped webjure into the deploy directory, fired up a browser and it worked - 10 minutes
12:11rhickeyChouser: yes, while J2EE is overkill, servlets are sweet, and all of those servlet containers are really nice open source tech - to good to ignore
12:11ChouserDo you have a recommendation for a low-cost hosting service that includes servlet support? Ususally that one feature seems to crank the monthly price up significantly.
12:13rhickeynot offhand - most of my clients are self-hosted/internal
12:13cgrandrhickey: would you mind making RT.loadResourceScript public?
12:13Chouseryeah. Makes sense for most businesses, I suppose.
12:15rhickeycgrand: done
12:15cgrandrhickey: thanks
12:25ChouserSo no love from the Java folks for FastCGI or SCGI. Makes me sad.
12:25ChouserI guess I'll try to find a work-around.
12:29Chousercgrand: do you plan on putting your wrapper in clojure-contrib?
13:15Chouserok, I seem to have tomcat running. I guess I'll use webjure until cgrand's wrapper is done, if he feels like sharing.
14:28cgrandChouser: sorry, I was away. I'll put in in the grop asap.
14:52Chousercgrand: cool! I'm stumbling along fine with webjure for now, but a more minimal solution will be great.
14:52ChouserUgh, I'm so bad at dealing with the Java libs.
15:33abrooksrhickey: Will you ever be open to having platform support code as part of a general Clojure distribution? (i.e. JNI via "(. posix.something (mumble...))") There are some generally useful OS interfaces and some more specific (RDMA / various hardware MPI assist for HPC for example) interfaces which would be interesting for various domains.
15:34rhickeyabrooks: I think the core should be pure Java
15:35abrooksAgreed. I was more asking about side libraries that could be bundled with the sources and be available on supported platforms. I wasn't imagining that this would in any way be in the core language implementation (however we're both defining "core" ;).
15:38rhickeyabrooks: I don't see it, at present
16:00abrooksrhickey: That's understandable. :) Just testing the waters.
16:00rhickeyabrooks: never say never :)
22:25ericthorwhat is the painless way to deal with the equivalent of function that takes Object[] ? Like new Object[] { new SomeType(),2,new SomOtherType()}
22:25ericthornevermind...i just thought of something