#clojure log - Apr 03 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

11:11 cgrand: It 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:12 rhickey: when does distinguishing it become important?

11:13 cgrand: *out* is tagged as an OutputStreamWriter and I bind it to a PrintWriter (in a servelt)

11:13 Right now it works

11:14 rhickey: hmm...

11:15 it probably should just be hinted Writer

11:16 I can't promise it will never cast to hinted type

11:16 cgrand: and I would not have to worry :-)

11:16 Chouser: cgrand: are you using webjure?

11:18 cgrand: casting 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:18 chouser: no writing write a minimal servlet wrapper

11:19 chouser: (delete "write")

11:20 rhickey: cgrand: the hints are just used to find resolve methods, the casts are based upon the methods themselves right now

11:22 cgrand: rhichey: ok

11:23 rhickey: cgrand: *out* type hint now Writer

11:23 cgrand: rhickey: thanks

11:29 Chouser: cgrand: I'm currently writing a minimal webserver that may or may not be able to load and run servlets eventually.

11:30 cgrand: are you writing Java code to run clojure in a standard Java server, or some other piece?

11:33 cgrand: chouser: a simple servlet which setup clojure and delegates everything to clojure code with nearly no wrapping of java objects (request & response)

11:36 chouser: are you building your webserver from scratch?

11:37 Chouser: cgrand: yeah, I just want something that's super-easy to deploy, esp. in a development environment.

11:41 so you're passing the servlet req and resp directly into clojure code?

11:42 will the clojure code register some kind of handler with the servlet, or will it be more hard-wired?

11:43 cgrand: chouser: yes, I bing them to servlet/*request* and *response* (and *in* and *out* to their reader/writer)

11:43 chouser: s/bing/bind/

11:43 rhickey: cgrand: it's easy, right?

11:44 Chouser: ok, cool.

11:44 cgrand: really easy and I tak the name of the boot script for the app from a servlet parameter

11:44 rhickey: I'll eventually put a servlet stub class in Clojure

11:44 to make even easier and standardize

11:47 cgrand: rhickey: 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:47 Chouser: isn't the input stream already in the request? Sorry, I'm new to servlets.

11:49 rhickey: cgrand: 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:50 the idea of the stub would be to get out of Java ASAP

11:51 cgrand: chouser: it is, I just think it's fairly common to want to bind *out* to the response outputstream so that print works.

11:51 Chouser: yeah, ok.

11:59 cgrand: chouser: did you consider Jetty? http://docs.codehaus.org/display/JETTY/Embedding+Jetty

11:59 Chouser: yes I did

12:01 I 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:02 cgrand: lightweight :-)

12:02 Chouser: I don't mean to whine, but I don't really want all that just for playing around with development.

12:03 I 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:04 Sure, 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:05 But 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:05 I think it's a good way to help get a newbie hooked on any particular framework.

12:06 or maybe my little webserver will be useless for anything but helping me learn Clojure and servlets. That's ok too. :-)

12:06 rhickey: yeah, until people realize the built-in webservers for those frameworks are not so hot.

12:06 Once you have a servlet host installed, everything else is easy

12:07 but you've built on an architecture that lets you swap in Tomcat/Jetty/Resin/GlassFish...

12:07 grows into authentication, JDBC connection pooling

12:07 Chouser: but what if the code you write for the built-in webserver can be dropped directly into a standerd servlet host?

12:08 rhickey: your clients can get support for the servers from Sun/IBM/JBoss

12:08 Chouser: what's the downside then?

12:08 rhickey: as I said before, you'd have to provide all of the features of servlets, accurately

12:09 Chouser: so you really think this is a dead end.

12:09 rhickey: When Webjure was released, I was on a client site and had no servlet host on my laptop...

12:10 I downloaded Jetty into a directory, started it, dumped webjure into the deploy directory, fired up a browser and it worked - 10 minutes

12:11 Chouser: 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:11 Chouser: Do 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:13 rhickey: not offhand - most of my clients are self-hosted/internal

12:13 cgrand: rhickey: would you mind making RT.loadResourceScript public?

12:13 Chouser: yeah. Makes sense for most businesses, I suppose.

12:15 rhickey: cgrand: done

12:15 cgrand: rhickey: thanks

12:25 Chouser: So no love from the Java folks for FastCGI or SCGI. Makes me sad.

12:25 I guess I'll try to find a work-around.

12:27 * Chouser grumpily installs tomcat.

12:29 Chouser: cgrand: do you plan on putting your wrapper in clojure-contrib?

13:15 ok, I seem to have tomcat running. I guess I'll use webjure until cgrand's wrapper is done, if he feels like sharing.

14:28 cgrand: Chouser: sorry, I was away. I'll put in in the grop asap.

14:52 Chouser: cgrand: cool! I'm stumbling along fine with webjure for now, but a more minimal solution will be great.

14:52 Ugh, I'm so bad at dealing with the Java libs.

15:33 abrooks: rhickey: 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:34 rhickey: abrooks: I think the core should be pure Java

15:35 abrooks: Agreed. 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:38 rhickey: abrooks: I don't see it, at present

16:00 abrooks: rhickey: That's understandable. :) Just testing the waters.

16:00 rhickey: abrooks: never say never :)

22:25 ericthor: what is the painless way to deal with the equivalent of function that takes Object[] ? Like new Object[] { new SomeType(),2,new SomOtherType()}

22:25 nevermind...i just thought of something

Logging service provided by n01se.net