Arc Forumnew | comments | leaders | submitlogin
7 points by conanite 5784 days ago | link | parent

I know, it's 87 days later, sometimes I take my time ... this article stirred me from some months of guilty inaction so I took another look at rainbow (arc in java).

The latest checkin supports complex numbers and a little bit of trigonometry, and it also goes faster, yippee! I was planning to use arc to play with fractals (ergo need for complex numbers) when I have a bit of spare time. This checkin makes rainbow a fairly complete implementation of arc, so if you're interested in trying out arc but need some of that ready-made java library goodness, rainbow might be your thing.

It's at http://github.com/conanite/rainbow/tree/master and I'll document the trig functions and other features if anyone's interested. Anyone? Hello?



2 points by shader 5784 days ago | link

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 5783 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 5781 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 5781 days ago | link

Have you thought about interop with Clojure?

-----

1 point by conanite 5781 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 5781 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 5780 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 5780 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/).

-----

2 points by revorad 5782 days ago | link

Hey thanks for that, conanite. I just posted the link on HN. Could you please answer this question? - http://news.ycombinator.com/item?id=446346

-----

1 point by conanite 5781 days ago | link

Hey, thanks for that, revorad! It looks like stefano got there before me ... but yes, it's a complete arc, with ccc and tail-call optimisation. Unfortunately the JVM doesn't do this stuff natively so there's a whole arc VM running inside the jvm which as you can imagine slows things down a bit.

-----

0 points by ltol 5777 days ago | link

Bug report: "Rainbow" poor name. Please fix.

-----

1 point by absz 5777 days ago | link

I have to say that I like the name; it's also a multilingual pun, which gives it major bonus points (http://arclanguage.org/item?id=5785).

-----

1 point by ltol 5777 days ago | link

Pun was clear. Merit of French less so. Problem with name: Hard to google.

-----

4 points by conanite 5777 days ago | link

> Hard to google

True. When I search for "rainbow lisp", google asks me did I mean "rainbow lips". Rainbow's github page is the 6th result for "arc rainbow", alone among many discussions of the shape of the multicoloured atmospheric phenomenon.

Once we've taken over the world, I think it will get better.

> Merit of French

I happen to live in france. It was a convenient pun. No other reason, especially not love of the language that I haven't got to grips with even after nine years of living here.

-----