Arc Forumnew | comments | leaders | submitlogin
What I really dislike about arc...
4 points by thaddeus 5574 days ago | 14 comments
Not to be negative, but I have to say... Too many inconsistencies...

I understand all the reasons for why they exist, but surely these are not good for language adoption as they are counter intiutive. These could be fixed - correct?

examples:

   1. >(= x (string ...)) 
      >(type x) = 'string
      where as:
      >(= x (list ...)) 
      >(type x) = 'cons
      why does this not return type "list"?

    2. >(obj first "p" last "g")
       'first and 'last result in type symbols...
       Shouldn't it be: 
       >(obj 'first "p" 'last "g") ?
       They are symbols.
       "deftem" has the same problem. 
       Correct me if I am wrong, but this is a simliar situation 
       as point 4 below, where the ' is not put in 
       because in macro expansion "it" is not evaluated, 
       which also sux, ~ shouldn't we be able to have "it" 
       evaluate so we can pass in functions to obj & case options?

    3. >(= name (list "p" "g"))
       >(last name) = "g"
       >(car name) = "p"
       shouldn't this be >(first name) not car; as last does? 
       and shouldn't "cdr" should be "rest"?

    4. >(let x 'y (case x y (pr "YES")))
       Shouldn't this be 
       >(let x 'y (case x 'y (pr "YES")))
       y is a type symbol after all...

    5. Why can't we use the same syntax to access and change association list as we do tables?
       * being able to use "pull"
       * being able to use special syntax like alist!key or alist.key
    They are just key/value pairs only ordered unlike tables....
    shouldn't an association list be a type of it's own more like tables?
    ~ not just extra methods applied to list structures.

   6. Why is it named "deftem" and not just "tem" or "tmpl" 
      - we're not defining a template anymore so than we're
      defining a table using "obj". "defobj?" - which notes   
      - why doesn't the name "obj" liken tables when the name 
      deftem likens template?


As I said - not to be negative, but I just don't get why these are not dealt with.

Regards. T.



6 points by absz 5574 days ago | link

Just some thoughts on your thoughts:

(1) This one I think is the right decision. The real constructor is, after all, cons; and in fact, (is (type:cons 'a 'b) 'cons) but (isnt:alist:cons 'a 'b), since cons is more generic. Being a list is a property that certain sets of cons cells have, but it isn't their type.

(2) Again, I think this is the right decision. The point of obj is to be convenient in the simple case where you're building an object-like hash table: one with fixed fields and changing contents. I feel that table should probably take arguments like obj but without quoting (so that (obj a 1 b 2) would be (table 'a 1 'b 2)), but obj is still handy to have around.

(3) Ah, car/cdr versus first/rest. There's not really anything I have to add to this one, other than that I like the conciseness and composability. I've also seen fst and rst proposed, so that you can do frst for first:rest; make of that what you will.

(4) Yes, this is annoying. The rationale is the same as in the obj case, but I very often want to compare to non-symbols.

(5) If we accept that association lists are really just lists which have a certain structure, then we can't use special syntax, etc., as that already means something for lists. What if you have (= a '((1 a) (2 b))); would a.1 be a (since it's an association list) or b (since that's element 1 of the list)? I would also argue that the point of association lists is to be lists with special structure; if you want something like that that's its own type, that's what tables are for.

(6) I haven't really used deftem, but it does define a template; you create them using inst. On the other hand, obj creates the table right there.

I should say, by the way, that I don't think Arc is a perfect language by any means. Its bizarre naming conventions come to mind, for instance. But I happen to think many of these are non-issues (though I would be perfectly open to being convinced otherwise).

-----

3 points by thaddeus 5574 days ago | link

>(1)

Ok I can see this. Thank you for pointing this out, but I still don't see why it can't be type list.... list is more intuitive.

>(2)

I don't see how obj is convenient when you can't pass in functions, or when new users have to remember "use symbol here - oh but not here, or there when this case is true" - reminds me of i before e but not after c. Shouldn't a goal of language design be to prevent these kinds of things and focus on promoting language adoption / ease of use ?

>(5) "I would also argue that the point of association lists is to be lists with special structure; if you want something like that that's its own type, that's what tables are for."

The only use I can see for an association list is to have a key/val pairs structure that maintains order; Which tables do not. Otherwise I think alist would be dead. They don't have to be called "list" or "table" call them "directories", "catalogs" - whatever... I think there's an ease of use benefit having users being able to use the same tools in the "alist" as they do tables.

>(6) "I haven't really used deftem, but it does define a template; you create them using inst. On the other hand, obj creates the table right there."

makes sense. it's probably just related the other post... ie. why is it called obj? creates confusion.

===

Everything is a trade off. I'm not suggesting the justification as to "why" doesn't have merit, I'm suggesting Arc should try leaning more towards audience adoption and being more intiutive rather than being so strict that we care about each token, or having to be absolutely technically correct. Or to carry forward bad concepts from languages that are not well adopted even when more powerful.

IMHO T.

-----

3 points by zck 5574 days ago | link

>...I still don't see why [(cons 'a 'b)] can't be type list.... list is more intuitive.

Traditionally, there's a distinction -- if only in discussion, and not code -- made between nil-terminated conses and a cons with another terminator. If and only if a cons is nil-terminated, it's a list. Otherwise, it's simply a cons.

Making the distinction would be difficult. Right now, type just has to call pair? to check whether it's a 'cons. To have both list and cons types would require iterating down until you hit the end of the list every time type is called. I'm not sure having both types is useful. It might make things more complicated.

-----

1 point by thaddeus 5574 days ago | link

That makes sense. I just wonder if were living with the distinction because of the implementation or if the implementation could change so that distinction could go away?

Not to say I know how. :) T.

-----

1 point by zck 5574 days ago | link

Regarding car and cdr vs first and rest, how would you get the second element? What we have now gives us (cadr lst). Your suggestion gives us (first (rest lst)) or (first:rest lst). I guess you could argue that you could shorten them to fst and rst and compose them as frst, but that looks like first to a quick glance. In the end (I believe I'm reiterating one of pg's arguments here), all names are somewhat arbitrary, and it's ok to have names that don't relate to what they're doing if you use them enough. They become meaningful through repetition. There's nothing inherent about + that makes it mean "add" -- we've all seen it so often that we instinctively know it does.

-----

3 points by eds 5574 days ago | link

You could always go by way of Clojure:

  car -> first
  cdr -> next
  caar -> ffirst
  cadr -> fnext
  cdar -> nfirst
  cddr -> nnext
So you really can compose the names. They're still less concise, but only by a couple of characters. If you really wanted to save those characters, use fst/rst (and ffst, frst, etc).

EDIT: I failed to completely read your post; it seems you already mentioned ffst etc. Don't know that my comment adds much to the debate.

-----

1 point by zck 5573 days ago | link

Actually, those were new to me -- I was trying to use fst and rst, and failing at it. While the Clojure way works better than my example, there's something about it that I don't like. Maybe it's simply that it's new -- if that was the original way, I'd react similarly to introducing car and cdr.

-----

2 points by thaddeus 5573 days ago | link

How about this ?....

    (= x (list "One" "Two" "Three" "Four" "Five" "Six"))

    (def first (xl)
      (car xl)) 

    (def next (xl (o n 1))
      (withs (n (+ n 1)
              nxl (cut xl 1 n))
       (if (single nxl)
           (car nxl)
           nxl)))

    (def rest (xl)
      (cdr xl))
 
So ...

    arc> (first x)
    "One"
    arc> (next x)
    "Two"
    arc> (next x 3) ; the next three
    ("Two" "Three" "Four")
    arc> (rest x)
    ("Two" "Three" "Four" "Five" "Six")
    arc> (next:rest x)
    "Three"
    arc> (rest:next x 3) ; the rest of the next 3
    ("Three" "Four")
    arc> (last:next x 3) ; the last of the next 3
    "Four"
    arc> (first:next x 3) ; the first of the next 3
    "Two"
That's six or so functions replaced by 3, that look like english and make sense.

-----

1 point by thaddeus 5574 days ago | link

I had thought "next"...

    first = car
    last = last
    rest = cdr 
    next = cadr
    next:+1 
    next:+2 
    ....
Comparing "+"/"add" to "car"/"first" is not the same thing.

"+" does mean "add" to the majority of people on earth - as its common knowledge, and thus it's intiutive. Car means "something one drives" to almost everyone.

> "all names are somewhat arbitrary, and it's ok to have names that don't relate to what they're doing if you use them enough"

Just because one can learn something faulty and get used to it doesn't mean one should accept it's faults and decide to live with it. One should strive to make it better. If this were not true - arc wouldn't exist. So why not change it?

-----

4 points by palsecam 5569 days ago | link

> "+" does mean "add" to the majority of people on earth - as its common knowledge, and thus it's intiutive. Car means "something one drives" to almost everyone.

1. From the Arc FAQ (http://paulgraham.com/arcfaq.html):

> Why did you keep car and cdr?

Because we couldn't think of any better alternatives. It would have been misleading to use first and rest or head and tail, because conses are fundamentally pairs; lists are one thing you can build with them, but not the only thing.

There's no conventional name in English for the first and second halves of a pair. If you have to make up names, car and cdr are pretty good choices, because they're short and the same length and naturally composable (e.g. cadr).

Example. I played a little the other day to implement surreal numbers (http://en.wikipedia.org/wiki/Surreal_number) in Lisp, using conses.

Basically, surreal numbers are a pair of two (surreal) numbers sets, the left one, and the right one.

0 is (() . ()), (cons () ()), where () is the empty set.

1 is (() . <surreal 0: (() . ())>)

-1 is (<surreal 0> . ())

It doesn't make sense to get the right set by saying (rest <surreal 0>), because it's just not the "rest", it's just the... cdr, i.e: the second halve of the 'cons. I mean conceptually, it's not the "rest".

2. Car means "something one drives" to almost everyone. No, no, NO. Ask, for instance, the 1+ billion Chinese people if "car" means anything to them. Just stop the fucking English-centrism. Will English be the proeminient language in 100 years? Is programming reserved to English-native-speakers? Is it good to mimic human languages in programming languages (hint: Algol VS C syntax)?

I love car/cdr because they don't mean anything.

Well actually, yes, they mean/meant something: content of {address|decrement} registry. But, in my view, they have just turn into arbitrary-chosen names for basic operations, like "+" is the arbitrary name of the "addition op" in our current arithmetic. You just learn that +/car means "this basic op", it becomes common knowledge, and you're done. I don't know, it's not even a name at this point, just the representation symbol.

I love APL (http://en.wikipedia.org/wiki/APL_(programming_language)) because it uses just symbols for ops. I love Perl's $_ / $| / $\ / etc. special vars because they don't mean anything by themselves, etc. I don't know, it just makes programmers from any country equals when it comes to speak to a computer. I love maths because nearly all the maths stuff use arbitrary-chosen "names", making people equals when it comes to speak to the Universe.

-----

2 points by thaddeus 5569 days ago | link

1. So is "last" not a pair too ? [edit] I see last does mean the last even when a pair. Where as rest may not. I'll check this out. In the end it just may be worth while to include rest and next as extra functions for the sake of language adoption? At an abstract level "rest" and "next" do accomplish what most expect it should.

>"No, no, NO. Ask, for instance, the 1+ billion Chinese people if "car" means anything to them. Just stop the fucking English-centrism."

I am willing to bet if you asked that question to every person on earth "what is car?" that statistically, the answer would represent my statement, even if by merit that some languages do not have a meaning for "car" and English, in my opinion, is more widely adopted. I could be wrong, but I don't feel bad about making that statement.

[Edited - deleted some of my own BS comments :) - thank you pg for having edit time]

Still- Maybe I should have written it this way: "Car does not mean first to almost everyone"

>"Will English be the proeminient language in 100 years?"

Not sure. I think the world we be a much better place if the average world citizen spoke multiple languages. And you never know maybe in doing so new languages could emerge and maybe there will be a "most powerful language" yet maybe it will not be widely adopted, or maybe it will.

We shall see :) (Edit - Opps - I just realized we will not)

Also I believe everyone is overlooking one point. Scheme is already more powerful, yet not widely adopted. I don't believe pg's goal in building arc is to make a scheme even more powerful. I'd like to think that pg acknowledges that language adoption should be an equally important factor to arcs' potential success.

-----

4 points by palsecam 5568 days ago | link

About 'last. Conses are a powerful, general data type. One way you could use them is to build another little-less-general data type, a subset of them, a "list", where (list 'a 'b 'c) is (cons 'a (cons 'b (cons 'c nil))).

Then you define some functions to operate (exclusively) on this new "data type", and 'last is one of them. Exclusively: (last (cons 'a 'b)) doesn't work, because it'd have no meaning to use 'last here. '(a . b) is not a list, just a cons.

Similarly, one way you could use lists is to build a-little-less-general abstraction, association lists. Then you define 'alref/etc. to use with this new data type. But (alref (list 'a 'b 'c) 'a) doesn't work, since it has no meaning in this context.

But 'car/'cdr, they operate on raw conses, not only on lists. And I said before, IMHO, 'rest is not good, because you're assuming by using this name that it is an operator for lists only. Yes, (rest '(a . b)) would work, but its meaning is crappy here (IMHO).

But you're making an interesting point. Maybe 'rest/'first should be also included, as synonyms for 'cdr/'car because actually people almost always use 'car/'cdr when working with lists, and in list context, their meaning may be easier to understand. But this is another debate.

---

About the meaning of 'car. Sure, if you're programming in one of the current dialects of Lisp, you have some basic notions of English, even if you're Chinese. Yet, when reading some Lisp code, if I see 'car I just know it means "first halve of the pair". I mean, before you pointed out that "car" means "a vehicle" most of the time, I didn't ever think about this (valid) point when reading/writing Lisp code. That's why I don't see it as a problem.

I don't know, I suppose it's because the context is important. When I see 'map in a Lisp file, I don't think about a (geographical) map. When I see 'cons I know it's not as in "pros & cons". When I see 'table, I know it's not about a dining table. When I type `cd' in my shell, I know it means "change directory" and not "compact disc", etc.

Yes, if you ask a random guy in the street what "car" means he'll answer you "a vehicle" and not "the first halve of the pair". But it's the same problem if you ask it what "cd" or "table" means. There are ton of issues like this, even in natural languages. For instance, homonyms: a tire is both a car wheel and the feeling of fatigue.

---

About language adoption. It seems pg knows it is important: So whether or not a language has to be good to be popular, I think a language has to be popular to be good. And it has to stay popular to stay good. (http://paulgraham.com/popular.html)

OTOH, remember Arc is made for "hackers" and to be adopted by "hackers" (at least at first). And there is the "100 years" idea (i.e: no rush in adoption may not be a problem). So maybe pg's idea of "language adoption" is not the same than yours ;-)

---

> (Edit - Opps - I just realized we will not)

Funny yet true one :-)

I always felt a little uncomfortable about the "100 years" idea. I keep saying to myself it's just a catch phrase for a decent goal, trying to design something timeless. But still, it also reminds me of "I intend to set up a thousand-year Reich and anyone who supports me in this battle is a fellow-fighter for a unique spiritual — I would say divine — creation". You know, the fooliness to not want to live in the current, real, impure world.

-----

1 point by thaddeus 5568 days ago | link

> "I don't know, I suppose it's because the context is important. When I see 'map in a Lisp file, I don't think about a (geographical) map. When I see 'cons I know it's not as in "pros & cons". When I see 'table, I know it's not about a dining table. When I type `cd' in my shell, I know it means "change directory" and not "compact disc", etc"

Absolutely and it's "because the context is important" that I made the suggestion. I don't really care that it's called "car". I'm just suggesting that IF you're going to have a function called "last" why wouldn't you create "first", as the user will intuitively try to use it given that last exists.

:)

-----

1 point by conanite 5563 days ago | link

You make a powerful point about cons cells being a more fundamental type than lists. I think if we really wanted english language words to describe the parts of a cons, "left" and "right" would be appropriate for what a cons is in isolation, but would unfortunately be meaningful only if you're using conses to represent binary trees. The beauty of a cons is that it's the smallest possible structure out of which one can build arbitrarily larger composites. And I'm not sure how valuable metaphors from the physical world are when contemplating abstractions - a cons is another degree removed from everyday reality than windows, buttons, dialogs, tabs, and menus are.

-----