Arc Forumnew | comments | leaders | submit | shader's commentslogin

What version of mzscheme does anarki currently require/support?

And is the anarki repo still live, or does it need forking? i.e. is there public commit access?

-----

1 point by shader 6129 days ago | link | parent | on: Ask Arc: does code have to be text?

Interesting. Code as data -> Data as Code. Pictures as data; pictures as code? That reminds me of some "graphical" programming language I saw a while ago. It used blocks of color to control the interpreter much like a Turing tape. The head would "move" up down, left or right depending on color, and perform various other operations.

How would you use images as code?

-----

2 points by shader 6141 days ago | link | parent | on: Where are we going?

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 6139 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 6138 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 6137 days ago | link

Have you thought about interop with Clojure?

-----

1 point by conanite 6137 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 6138 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 6137 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 6137 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/).

-----

5 points by shader 6151 days ago | link | parent | on: Block Inclusion Syntax

If it has to be a single character, here are some other choices:

(with (a 1 b 2) &) (with (a 1 b 2) *) (with (a 1 b 2) @)

There might be more possibilities, but I think the first two make the most sense.

Here's an interesting way to come up with syntax features for a language: Write out some code with a random symbol, syntax, or function name. Either read it yourself, or have a disinterested third party read it, and see what they think it means. If it doesn't make any sense, it might not be the best choice. On the other hand, if it means what you think it should mean, it's probably a step in the right direction.

However, I worry sometimes about some of arc's attempts to shorten code. Coming up with a powerful set of axioms and basic functions that allow you to express your self with a limited number of syntactic objects is probably a good thing, but abbreviating everything so that it looks like perl line noise without actually reducing the amount of code you have to write, just letters, is actually going in the wrong direction. This is because you actually have more to think about. Not only do you have to think about the same number of objects, but they are in a relatively unintelligible form. I'm not saying that this particular symbol, or any other, is necessarily bad; I'm just saying that we should be careful about abbreviating all of our English to vowel-less words and funny symbols. Lisp has the distinction of being able to abstract away most repetitive coding via macros; let's not waste it by making the code involved unintelligible to begin with.

-----

1 point by shader 6154 days ago | link | parent | on: hosting for arc web app

Sorry to dredge up an old post, but I was wondering pretty much the same thing. Is it possible to use arc on a shared host? Has anyone here done so? Python is already supported by many such hosts, and it doesn't seem like it should be too hard to do the same with arc.

-----

1 point by CatDancer 6153 days ago | link

What part of your question hasn't already been answered in the earlier comments?

-----

1 point by shader 6153 days ago | link

All of the previous comments presumed virtual private servers, as far as I could tell. I am basically wondering if arc (or another lisp) could be run on a host such as DreamHost via fastcgi, or a similar method. Since python and ruby are run on DreamHost this way, it seems feasible, and I was wondering if anyone else had done this with arc or another lisp.

-----

1 point by cchooper 6153 days ago | link

Poking around the DreamHost support wiki and terms of service, I can't see anything stopping you. You can run an Arc interpreter in the background, so long as it doesn't eat too many resources, and I can't see anything stopping you from forwarding requests to it.

However, it will not be officially supported in the same way that Ruby and Python are, so you'll be on your own when it comes to fixing problems. It might be better to use their private hosting service so that they don't complain about your Arc process (which they may do if a bug causes it to behave badly). Although this means it runs on a private virtual server, you still get all the same support and software as with the shared service.

-----

1 point by CatDancer 6152 days ago | link

Another option is if your provider will forward web requests that come in on the standard HTTP port 80 for your domain to your Arc process listening on a port such as 8080.

For example, here's my Apache configuration:

  <VirtualHost *:80>
    ServerName desiremenu.net
    ProxyPass / http://localhost:9002/
  </VirtualHost>
Arc runs and listens on port 9002 (serve 9002). Web requests that come in to http://desiremenu.net/ are forwarded by Apache to port 9002.

This doesn't need any additional code or implementation in Arc, since srv.arc already implements a web server.

-----

1 point by shader 6151 days ago | link

How well does that hold up under load? I.e. is it fast enough to run on a shared host?

Also, has anyone here tried any of the other lisp web frameworks, such as webolcks, ucw or plt? How do you think they compare to arc's?

-----

1 point by CatDancer 6150 days ago | link

is it fast enough to run on a shared host?

I would assume so. I've used Apache's ProxyPass frequently and haven't had a problem. There's no technical reason that I know of that it would be either faster or slower than fastcgi. In both cases Apache is passing on the request to a persistent process. I haven't measured it though.

-----

1 point by CatDancer 6153 days ago | link

You'd need to find a provider who allowed you to install executables, so that you could install MzScheme. Then, I haven't heard that anyone has implemented the fastcgi protocol for Arc, so you'd need to implement that.

-----

1 point by shader 6153 days ago | link

How hard would it be to pull the fcgi interface up from mzscheme?

-----

1 point by CatDancer 6152 days ago | link

I haven't tried it, so I don't know, but in general I've found it easy to call MzScheme code from inside of Arc.

You can add xdef's to ac.scm; Anarki has a $ macro to call into MzScheme if you use Anarki; and I describe my favorite way to call into MzScheme here: http://arclanguage.org/item?id=8719

-----


You could make your own number data type. Have a cons cell in which both halves are bignums, the car being the mantissa and the cdr being the exponent. You would have to overload the math functions for you datatype of course, or write your own set for use in this circumstance.

-----

1 point by shader 6194 days ago | link | parent | on: Arc for Arm

Neat idea. How would we go about starting said project? I suppose it would mean making some macros for arm assembly, and then implementing arc's primitives in those macros as opposed to scheme?

It sounds more like a compiler situation than an interpreted one.

-----

1 point by natarajsn 6162 days ago | link

Hi

Sure. It seems to be a compiler situation. How different are Arc and Scheme? Give me some tips to start off implementing arc's primitives.

-----

1 point by CatDancer 6162 days ago | link

The first step would be to read and understand arc2/ac.scm, which is an MzScheme program which translates Arc code into MzScheme.

Then you could look at if ac.scm is using any MzScheme features that Armpit Scheme doesn't have.

-----

3 points by shader 6208 days ago | link | parent | on: Brainstorm: syntax sugar for lambdas

Here's an idea: If you don't actually specify an order to your variables, unbound symols are bound in alphabetical order. That way you can have complex symbols you like, and you don't have to specify them either.

This would work with _1 _2 _3, and a b c.

-----

1 point by shader 6202 days ago | link

Any ideas on how to implement this? Is it worth it?

-----

2 points by Darmani 6200 days ago | link

Let's call these anonymous functions whose arguments are the unbound symbols within them in alphabetical order "ofn"'s.

The clearest way to implement ofns is to have a function on the outside of every block of code which does a tree-traversal, collecting all the symbols bound, and then, whenever it finds and ofn, just simply does (sort < (rem [mem _ bound-list] (get-list-of-symbols-used ofn-code)) to find the args list.

There are two major issues with this. The first is global variables -- it needs to determine which symbols will be bound in the global scope at runtime at compile time. Let's assume all global bindings will be done at the top layer or in a layer separated by nothing by calls to 'fn from the top (please, tell me you don't bind your globals in 'eval). (E.g.: (let a 1 (def b ...)) becomes ((fn (a) (= b (fn ...))) 1) and thus meets that criteria, but (def a (b) (= b 1)) becomes roughly (= a (fn (b) (= b 1))), and thus the call to (= b 1) has a call to = between it and the top, and thus will not be counted.) In a process very similar to the overall version, we can then go through the macro-expanded files, and find all the symbols bound by those = forms.

The second problem is nested ofn's (e.g.: [map [map [+ a b] c] d]). I'm still in search of a good solution. I've thought about finding the arity of each ofn (made impossible in the general case by higher-order functions like map which call functions with a variable amount of arguments); finding where each variable is used to determine its minimum scope, and having each symbol an argument of the ofn with that minimal scope; letting inner ofns each have one arg, determined by some alphabetical ordering, and letting the outer ofn have the rest. All those solutions fail some major elegance tests. Best way is probably to just ban nested ofns.

At first I would have said ofn's would be a great feature, but, if we can't have them nested, I can't be so sure -- it would be inelegant to have nested bracketed functions work differently that the outer one, or to have a different delimeter for ofns and normal square-bracketed functions.

Ironically, the difficulty in implementing this dynamic feature stems from the source code of dynamic languages being difficult to analyze.

-----

2 points by shader 6200 days ago | link

It seems to me that, however we do it, it would probably be slow. Maybe, as the source is being read in, the compiler/interpreter could somehow flag each symbol as bound or unbound? Then you could have your ofns just inspect all of the symbols below them, and check whether they're bound or not.

About nested ofns, how would you expect them to work? That should be the real test of what method to use in determining which ofns bind which vars. Obviously they're bound in alphabetical order. How about having the outer ofn bind as many vars as it has args, and leaving the rest unbound for the next layer? This would make it impossible to tell which ofn would bind which var at compile time (unless you know the arity of the outer function based on it's environment), but it would (I think) make the most sense. It does leave room for confusing circumstances though ;)

What would happen if there weren't enough arguments to fill in all of the vars? Return a fn? Even more fun!

If the ofns bind inwards, you would need to do your example backwards: [map [map (+ d c) b] a]

You could however try and bind outwards, so the inner ofn binds first, but I don't see how that would be a good idea.

What do you think? Any better ideas? Any glaring flaws with my idea? (I don't know lisp or arc that well)

-----

1 point by Darmani 6199 days ago | link

Source-code traversals are O(n), and compile-speed is not that important below a certain point. And finding all the globals only needs to be done once.

At first I thought it was important to have this conventionalize-ofns function run inside every def and every mac, so that, if I wished to use ofns inside a macro-expansion, which symbols are arguments would not depend on the context. I then realized this would break for virtually any method of generating macro-expansions other than quasiquote, and that, since, under the curretn implementation, two pseudo-gensyms have the same alphabetical ordering as the order they were created in unless they're of different length, it would still be workable (just do a (w/uniq (a b c) ...) and I'll hardly notice the difference -- saves fewer characters overall, but I find it a little more readable; plus, these can be reused if the macro-expansion contains multiple ofns).

If we are to do ofns at runtime, they would be much more workable, but also more unpredictable. I've said once before that a runtime-list of all bound symbols would be desirable for other reasons, but, if I'm testing code in the REPL and set a to some value, I don't want half the functions I call breaking for some mysterious reason. Especially considering I haven't found a way to unbind variables.

-----

1 point by shader 6199 days ago | link

Well, I think that the ofns should probably be closures, at which point the binding of the variables only matters when they are defined, after that defining a out of context wouldn't overwrite the a in the ofn. If not, we could have the ofn replace each symbol with a gensym tagged with 1st, 2nd, 3rd, etc. Then it wouldn't matter what you did with the original name. The gensym replacement only happens, of course, if the var is unbound during definition.

Here's a question: how does anarki's [ _1 _2 _3 ] form work when nested?

-----

1 point by shader 6210 days ago | link | parent | on: Brainstorm: syntax sugar for lambdas

Actually, I do think the _1, _2 .. syntax makes the most sense, if you aren't wanting to name parameters. Though maybe (as was mentioned above) in some cases, the first three should be a b c, or x y z? I don't know how you would set that up to work well with what already exists though.

-----


Interesting idea on using branches to keep development separate from the main trunk. After all that's what it's for ;)

Maybe more of our things should be done that way?

Besides, it's easy to see a list of branches with "git branches -r". If only each branch could have a description.

-----

More