Arc Forumnew | comments | leaders | submitlogin
2 points by shader 3166 days ago | link | parent

Nice to see that someone is still here ;)

So, how much of the java libs does rainbow have access to? And do you think that it could be used for web serving on a shared host? (I know, I've been asking that question too much lately)



3 points by conanite 3165 days ago | link

rainbow has various low-level functions for interfacing with java, including

  java-new (class . args)
  java-invoke (obj method . args)
  java-implement (class strict . functions)
so technically you can access any java library you want from your arc code as long as it's in your classpath. Ultimately though it's prettier to hide these calls behind macros or functions in arc so your code is more expressive. I've done this a little for swing (java's desktop UI library) - for example there are event handler macros like

  on-key (component (var) . body)
  on-scroll (component (var) . body)
where "body" is event handler code. From the perspective of the calling code, there's no way to tell it relies on java behind the scenes.

Java objects have the arc type 'java-object

  (type some-big-java-object)
  -> java-object
so defcall is defined to invoke 'java-invoke - you should almost never need to use 'java-invoke directly. In other words,

  (some-big-java-object 'equals another-big-java-object)
results in the call

  (java-invoke some-big-java-object 'equals another-big-java-object)
which, naturally, results in a call equivalent to

  someBigJavaObject.equals(anotherBigJavaObject);
Strings, numbers, booleans and lists automatically convert to and from arc types. Here's a longer example:

  arc> (set foo (java-new "java.util.HashMap"))
  {}
  arc> foo
  {}
  arc> (type foo)
  java-object
  arc> (foo 'put 'bar "toto")
  nil
  arc> foo
  {bar=toto}
  arc> (foo 'keySet)
  [bar]
  arc> (type (foo 'keySet))
  java-object
  arc> (foo 'getClass)   
  class java.util.HashMap
  arc> 

As for serving on a shared host - I switched from java to ruby a while ago precisely because it's a pain to use java on a shared host - and most java hosting plans offer a shared tomcat (tomcat: popular java app server) instance, so even then you couldn't use arc's webserver natively. You could implement the necessary servlet interfaces in arc and then package it like a java web app and tomcat would deploy it. So at least the logic of your app would be written in arc. If you want to try this, I'll be happy to help.

-----

1 point by shader 3163 days ago | link

Nice to know that java isn't too hard to access, not that I expected it to be.

As for hosting, I'm currently using dreamhost. They provide support for python and perl via fastcgi, so I've been looking for a lisp option that could leverage that. Most of them don't have much in the way of libraries. And I like arc. So the option of using arc with java libs seems like a plus. How hard do you think it would be to write arc's web tools based off of fcgi? Unfortunately I don't even know what it takes to run rainbow via the jvm on a server, but I would presume that it's possible.

-----

1 point by rincewind 3163 days ago | link

Have you thought about interop with Clojure?

-----

1 point by conanite 3163 days ago | link

Not yet :)

but theoretically you could host a bunch of languages in a single jvm instance - and have arc, clojure, jruby, jython, and javascript (via rhino) all calling each other in a big polyglotfest. Java 6 includes a scripting framework ( https://scripting.dev.java.net/ ) that standardises the way a jvm hosts a ScriptEngine. I haven't looked at this yet at all but it's on my todo list.

-----

1 point by CatDancer 3163 days ago | link

web serving on a shared host

what's your project?

how much do you want to pay for hosting?

-----

1 point by shader 3162 days ago | link

Nothing too complicated or high volume. Our church website and a realtor's website, currently in php. We've been working on a design for a quasi-framework, and were hoping to do it in lisp. Currently my host is dreamhost, which pretty much permits anything, and has shell access. If I could use an fcgi interface, I'm pretty sure it would work. Which lisp / web framework do you recommend?

-----

3 points by CatDancer 3162 days ago | link

How much are you paying for DreamHost? The cheapest Linode (http://www.linode.com/) plan is $20/month. Download and unpack MzScheme, fire up Arc, and you're up and running. Sounds to me quicker and easier than messing around with fcgi, unless there's something about your situation that I'm not realizing.

If you want your two web sites to be running with different domain names (www.mychurch.org, www.terrificrealtor.com), you have a couple options: you can run Apache (or any other HTTP server that can forward requests) in front of Arc, and be running two Arc processes, one for each site. Or you could hack Arc (or ask a hacker here to hack Arc for you) to look at the "Host" header.

Which lisp / web framework do you recommend?

Well, I use Arc myself, simply because I can use any language I want, and I like Arc. What I'd recommend for you would depend on what your goal was. If you want a powerful programming environment that will enable you to implement your two sites quickly and easily without having to do any Linux system administration, I'd recommend taking a look at AppJet (http://appjet.com/).

-----