Arc Forumnew | comments | leaders | submitlogin
ASK: Is arc better than clojure?
2 points by kinnard 2969 days ago | 19 comments
Is arc better than clojure? If so, why? What sort of things is arc better suited for?


2 points by akkartik 2969 days ago | link

Clojure is definitely more mature, but Arc has some features a minority want, like unhygienic macros atop a small Scheme core.

-----

3 points by rocketnia 2968 days ago | link

Well, Clojure has unhygienic macros too.

I think Clojure fits most of the criteria that would lead someone to choose Arc. I think Clojure's main flaw compared to Arc is that it's a bit cumbersome to do iteration, because there's no general support for tail call optimization.

Arc has a few things positively going for it:

* Arc's implementation doesn't implement the whole language from scratch. Instead, syntaxes, data representations, and primitive operations are inherited from Racket, and most of the high-level tools are implemented in Arc itself as a library. What remains in the Arc implementation is a small, unintimidating core focused on some compilation and pattern-matching features. Since the core is small, it's easy to make certain modifications if needed. (Modifications to things inherited from Racket, like changing the reader syntax, are more challenging.)

* It extends s-expression syntax in a few minor ways. I think one of these extensions, the (a:b:c d) shortcut for (a (b (c d))), is particularly compelling. It tends to reduce lines of code, indentation, and parentheses all at once:

  (blah-blah-foo
    (blah-blah-bar
      blah-blah-baz))
  -->
  (blah-blah-foo:blah-blah-bar
    blah-blah-baz)
* Paul Graham wrote influential essays about language design that led to the release of Arc. Some people, including me, came to Arc because they read those essays and liked the high-level goals and priorities they expressed. Arc probably isn't even the best existing manifestation of those goals, but it is a Schelling point at least.

-----

2 points by akkartik 2968 days ago | link

> Well, Clojure has unhygienic macros too.

Huh, I didn't know that about Clojure!

Yeah, I agree with everything you wrote. It was an unprecedented experience to hack on programs with the compiler for them open in a split window.

-----

2 points by rocketnia 2968 days ago | link

I'm drifting off topic, but imagine this: When you call (eval ...), imagine you pass in the global namespace that the code will run in. (Maybe we're using aw's extension for this purpose.) When you pass in a namespace that contains your own implementation of (eval ...) itself, you've effectively modified the compiler, but only as far as that specific code is concerned! As long as our custom compilers are written in Arc, we can treat them like we treat Arc libraries, and we can mix code that uses different compilers. We can have all kinds of compilers open in split windows at the same time. :-p

We already have plenty of examples of first-class namespaces, like aw's implementation posted recently. So all this would take is an implementation of Arc in Arc. Do we have one of those? I thought I heard of one at some point.

My excitement is not because I think a pileup of various compilers in a single codebase is a great idea, but because I think it's easier to share code this way. Compiler hacks are prone to merge conflicts that inhibit code sharing, but sharing libraries is... well, not perfect in Arc either, but it's at least ameliorable by doing some simple search-and-replace renaming or by agreeing on a namespacing framework (like my framework in Lathe).

This came to mind because I was recently realizing that in my language Staccato, my Staccato self-compiler was approximating a style of programming much like that split window of yours, without sacrificing modularity.

-----

2 points by akkartik 2968 days ago | link

By an odd coincidence, somebody just pointed me at Expansion-passing style today: http://lambda-the-ultimate.org/node/4588

-----

2 points by zck 2967 days ago | link

Clojure also has a pretty cool way to not have to call (uniq) by hand. If, inside a backquote, you append a # to a symbol, clojure will replace that variable with a gensym. And it'll use the same gensym every time you use that variable in the backquoted form.

Here's the source for `and` (https://github.com/clojure/clojure/blob/clojure-1.7.0/src/cl...):

    (defmacro and
      "Evaluates exprs one at a time, from left to right. If a form
      returns logical false (nil or false), and returns that value and
      doesn't evaluate any of the other expressions, otherwise it returns
      the value of the last expr. (and) returns true."
      {:added "1.0"}
      ([] true)
      ([x] x)
      ([x & next]
       `(let [and# ~x]
          (if and# (and ~@next) and#))))
See how it uses and#, but it doesn't capture the variable and?

I'm not entirely sure how you would capture a variable (e.g., Arc's "aand"); if you try to, clojure errors by default. There's probably some way, but I don't know offhand.

-----

3 points by rocketnia 2964 days ago | link

This StackOverflow answer ends with "I'd recommend a real anaphoric macro" and gives an example: http://stackoverflow.com/questions/9764377/how-to-avoid-anap...

Based on that, I found this way to write aand, which seems to work at http://www.tutorialspoint.com/execute_clojure_online.php:

  (defmacro aand
    ([] true)
    ([x] x)
    ([x & next]
     `(let [~'it ~x]
        (if ~'it (aand ~@next) ~'it))))
  
  (prn (aand "woo" (list it it) (list it it it)))
It looks like Clojure macros can capture variables in the other direction too, like Arc:

  (defmacro capture-it
    ([] 'it))
  
  (prn (let [it "woo"] (capture-it)))

-----

2 points by kinnard 2969 days ago | link

• What do you mean when you say more mature?

• Who composes the minority that want those features?

• Why do people like unhygienic macros?

• What are some other reasons people prefer arc?

I'm completely new to Lisp, started exploring arc first but wondering if it's smart to actually build something using it.

-----

2 points by akkartik 2968 days ago | link

Mature: more people have used Clojure, kicked at the wheels, found bugs.

Who wants unhygienic macros? People here and those who like Common Lisp. Why? They're more flexible. They give you enough rope to hang yourself, but if you exercise taste in using them life can be quite good.

We often prefer arc because we want to poke under the hood and understand how interpreters and compilers work.

If your goal is to learn, it mostly doesn't matter what you use. Just build. The journey is what matters. Use something where you have someone to ask questions of. (Like here.)

(If your goal is something more specific, then Arc might well not be a good idea. But then neither will anything else, most likely. But you'll still have built something by the time you realize that you chose wrong.)

-----

1 point by kinnard 2968 days ago | link

I'm a starving hacker. I want my app to work and lots of people to use/love it and to get into YC so I can eat . . .

-----

5 points by aw 2967 days ago | link

Looks like Arc vs. Clojure has been pretty well covered by the other comments. To take a step back and look at your goals, in case you might find it useful... consider separating the need to eat from your other ambitions.

The demand for hackers is very high right now, so it's easy to find work.

Most people when they get a job and make more money, immediately raise their standard of living. I.e. they find a nicer place to live, they eat more expensive food, maybe buy a car or get a nicer one, etc. But you don't have to do that if you don't want to. You can, if you choose, keep your expenses low while working, and save a lot of money instead.

When your expenses are lower than your income, you don't need to work full time. For example, you could work part time. Or, you could work full time for part of a year and not work the rest of the year.

With "I need to eat" covered, then you have time to pursue your interests without fearing that you're going to starve if you don't get things going quickly enough.

YC has a less than 3% acceptance rate (https://blog.ycombinator.com/yc-portfolio-stats), so applying to YC isn't a great strategy for keeping from starving. (YC is great if what you want to do is build a world changing startup. For meeting your own basic income needs there are many far easier and much more certain ways to do that).

I don't mean to discourage you in any way from applying to YC if you want to do a startup. Just suggesting you have a plan B for the "so I can eat" part :)

I think you might find TripleByte's blog post on what kinds of programmers YC companies want to hire interesting for several reasons:

https://data.triplebyte.com/who-y-combinator-companies-want-...

First, if you want to do a startup, it's interesting to see what kinds of technical skills have turned out to be important for startups.

Second, if you want to create an app, it's interesting to see what kinds of technical skills have turned out to be important for startups creating apps.

And third, if you want to get a job, it's interesting to see what kinds of technical skills are most in demand.

A highlight is that the most demand is for product-focused programmers.

Thus, if I were looking for something to study for the purpose of starting a startup, or creating an app that lots of people use/love, or for finding work, I'd consider focusing on:

- UX (user experience design); I've heard that Design for Hackers http://www.amazon.com/gp/product/B005J578EW is popular

- user testing

- solid foundational skills in web technologies (JavaScript, CSS, HTML) and/or mobile (iOS or Android programming)

Now, that said, if you want to learn Lisp, Clojure is a good choice. There are books on Clojure available to learn from, and it's supported by platforms such as Heroku for example (https://devcenter.heroku.com/articles/getting-started-with-c...)

But keep in mind that for most apps, for most startups, you don't need Lisp. Reddit, for example, started in Lisp and switched to Python because the libraries were better. Nor are most of the YC companies using Lisp.

Of course, every startup is different, and every app is different. For a particular app, or for a particular startup, Lisp might be a strong advantage. For Paul Graham's original startup ViaWeb, for example, Lisp was a decisive advantage.

Lisp is a programmable programming language. When do you need to program your programming language? When your programming language isn't doing enough for you on its own.

As other programming languages have gotten better, there's less of a gap between them and Lisp. ViaWeb was using Lisp competing against companies writing in C++. Nowadays the mainstream languages are higher level.

Lisp is a useful skill to learn because if you ever do get into a situation where it would be helpful to be able to program your programming language you can say "aha! A macro would make this easier!"

And yet, to get into YC, or to write an app that lots of people use/love, most of the time, in most cases, that's not necessary. (Or else startups would be looking for Lisp programmers).

I hope this helps! :)

Andrew

-----

1 point by akkartik 2968 days ago | link

Yeah I wouldn't use Arc in your situation. It can still be good for prototyping new ideas, but I'm not sure the gap with other languages is large enough to take on the risk of painting yourself into a corner..

-----

2 points by kinnard 2968 days ago | link

Arc seems cool.

The idea of axiomatizing programming is very appealing to me.

But it's not clear to me what improvements arc makes over lisp. And it seems close to dead.

I'd like to invest the time in learning. But realistically it seems infeasible given my timeline and paucity of resources/size of the community.

-----

1 point by kinnard 2968 days ago | link

Does arc's community want it to be more popular?

-----

2 points by zck 2968 days ago | link

It would be nice, but I have a hard time recommending it to anyone with no releases since 2009.

Perhaps Anarki would be something to recommend. But that's not really being driven forwards either. Any changes are the result of design by committee, which doesn't tend to lead to great design.

-----

2 points by akkartik 2968 days ago | link

It doesn't seem fair to call Anarki design by committee. It's closer to a small number of scatterbrained people who periodically have a shiny new idea and add it in in anarchist fashion. Maybe design by Dory? http://www.imdb.com/character/ch0003708 :)

-----

1 point by zck 2967 days ago | link

You're right. Perhaps I'd be better off saying "no single vision motivating changes".

-----

1 point by kinnard 2968 days ago | link

I wonder why PG decided to go hands off.

-----

2 points by zck 2968 days ago | link

I really like Arc.

That said, Arc is probably a better language if you want to hack the language, and Clojure is better for almost everything else. This is especially true if you need libraries, or want something that Just Works^TM.

-----