Arc Forumnew | comments | leaders | submit | sacado's commentslogin
2 points by sacado 6349 days ago | link | parent | on: Poll: ssyntax

"maybe we shouldn't make use of non-ascii characters" : why not ? Characters like λ have their place in a Lisp, and I think ∧and ∨ have their place too. Anyway, such characters wouldn't be used very frequently (do you often use andf & orf ?) and could be ignored if typing them is too painful. That's better than consuming ASCII characters that sometimes fit well in symbol names, IMO.

-----

9 points by kens 6348 days ago | link

I think it would be hilariously ironic to make non-ASCII Unicode characters part of Arc's syntax and functions.

A few proposals for giving functions new names: ☢ for atomic, ✄ for cut, ✔ for check, ⌚ for time, ⌛ for sleep, ☠ for kill-thread, ☇ for zap, ♭for flat.

-----

4 points by almkglor 6348 days ago | link

Given that it didn't originally have good Unicode support ^^

-----

4 points by sacado 6348 days ago | link

lol, I really like the "flat" idea :)

-----

2 points by almkglor 6349 days ago | link

> (do you often use andf & orf ?)

Yes, in arc2c ^^

-----

3 points by sacado 6348 days ago | link

Oh, well, ok then... :)

But anyway, I still think they're not worth loosing an ASCII character, and using mathematical notation would be very useful. It would make code readable by people a little aware of mathematics. That is, most programers. It would be definitely better than arbitrary characters.

Why should we restrict to ASCII anyway ? I mean, a lot of symbols I use are not ASCII anymore (they are accentuated, I'm French so something like 'year is translated into 'année, not into 'annee). Sure, they're hard to type, but are they any longer than they symbol counterpart ? If you type them often, just make them a vi macro (or whatever in your favorite text editor) and you're done.

It might end up looking like APL, for sure, but I think Fortress, Sun's new language designed by Guy Steele, is going that way too. And Steele cannot be wrong :)

-----

5 points by absz 6348 days ago | link

I don't mind non-ASCII, I mind weird non-ASCII. Even in English, we leave ASCII behind: “As I was going to the café—what fun—my naïve friend said…” It's just that I don't know of any keyboard layout that supports ∧ or ∨. I agree that they would look great, as would Fortress.

I wonder if anyone's given any though to using (La)TeX in a language? So that something like (number{\wedge}acons var) would be the same as (number∨acons var)? Or just as a nice way of typing things like Fortress? (Which I agree looks very interesting.)

-----

2 points by almkglor 6348 days ago | link

> Oh, well, ok then... :)

I'd probably use them a lot more often if the syntax was a little easier, which is why I suggested using ssyntax for them. Currently the syntax is ((orf this that the-other) foo), and doubled starting parens feel rather strange to me.

-----

5 points by sacado 6352 days ago | link | parent | on: Idioms for programming in Arc

It's been said many times, but your doc is really awesome. I need to use templates for what I'm doing at work (yep, I'm arcing one more time at work. Oh, god, I love my job) but I never really understood how all of that was working. Everything is clear, now. Thanks !

-----

8 points by kens 6350 days ago | link

Thanks for the encouragement. Sometimes I feel that I'm writing for the four or five remaining Arc users. It seems a bit quiet in this forum lately and the regulars seem to be disappearing, e.g. kennytilton hasn't been commenting for 40 days, pg for 22 days, byronsalty for 24 days, CatDancer for 50 days, nostrademons for 65 days. Are people losing interest, just lurking, or has the party moved somewhere else?

-----

8 points by stefano 6350 days ago | link

I see two main reasons for this. The first is obviously pg apparent disinterest in his own creature (in the sense that he seems to don't follow the forum anymore), because this makes people think "If its creator doesn't care about it, why should I?". Maybe pg is a bit too busy in this days, but I think Arc is still too young to survive if he doesn't come back soon, beacuse there are a lot of other interesting lisp projects out there that don't give the same sense of 'pause' that Arc gives (clojure is one of them). The second reason is the immature implementation that makes it difficult to write projects of moderate size in Arc, as an example think about Arc's error messages: they usually say something like 'You've got an error' and you simply don't get any hint about where it is. This is especially true about reader errors: I've read messages saying 'error at line 5234' in a file with just a few hundreds lines!

The good news is that these problems are, IMHO, fixable. Think about arc2c and how it is trying to fix the second problem to see the direction where the Arc community should go, but these solutions require time, and new users usually don't want to wait when there are other solutions already usable out there.

-----

8 points by lojic 6349 days ago | link

"The first is obviously pg apparent disinterest in his own creature..."

I think you hit the nail on the head there. I know pg has said that he does read the posts even when he doesn't reply, but let's face it, it doesn't take too long to post a comment occasionally. If he even took the time to communicate a vision to the "community", that would be helpful. I think people would be more patient if they had a clue about where this was heading.

Although it's certainly fun to pick up a new language, it also takes time and effort, and I'd like to see more evidence that Arc will continue to progress before I invest much time into it (especially since it lacks a couple "must haves" for me currently).

So, regarding the other comment about needing more publicity in terms of someone's pet project - I think there's a catch-22 there - who's going to put together a substantial application if they're unsure if the language will survive?

-----

4 points by stefano 6349 days ago | link

"who's going to put together a substantial application if they're unsure if the language will survive?"

This is true if you're writing your application for commercial use, but if you're doing it just for fun you can even use a language written by yourself that no one else know. The biggest problem is the lack of development and debugging tools. I few weeks ago I started a project to learn a bit more about compilers, and I ended up using Common Lisp because the task was very difficult by itself and I needed a good way to debug the program. Using Arc would have meant to make a difficult project even more difficult.

-----

3 points by lojic 6349 days ago | link

I think you just proved my point. I presume your project to "learn a bit more about compilers" was not commercial in nature, and yet you chose Common Lisp. Whether a project is for fun or for profit, I'd prefer to not waste my time, and it appears you feel the same.

I think the survivability (not popularity) of a programming language is closely correlated with its usefulness to programmers.

Of course, the best way to rebut my implicit assertion is to actually "put together a substantial application" with Arc instead of talking about it, right?

-----

1 point by sacado 6349 days ago | link

"(clojure is one of them)"

Come one, clojure is not a Lisp, it doesn't even have car and cdr :)

-----

3 points by stefano 6348 days ago | link

And Arc doesn't even have lambda! :)

-----

2 points by cooldude127 6347 days ago | link

arc has lambda, it's just renamed to fn (same as clojure).

clojure lacks car and cdr because it also lacks cons cells. there are other collections, but the little pairs we've come to know and love are gone.

-----

2 points by sacado 6347 days ago | link

yeah, we know, we were just kidding :)

However, seriously, clojure looks really interesting, being a cool language on the JVM and being purely functional. But does anybody know if it is possible in this language to make (easily) funny structures like circular lists, graphs, etc. ? AFAIK, that's the problem when you don't want to use set-car & set-cdr in Scheme (that's a problem in NewLisp too, for example) : you loose them. Did clojure manage to overcome this problem ?

-----

4 points by tokipin 6347 days ago | link

i'd say just take it easy. no need to hurry or anything

here's something from my experiences: a few times i have released things, and not responded to questions/comments about them for some time. not because i didn't care, but actually because i cared too much. to the people, those things were interesting curiousities, but to me they were things that my reputation was attached to. and so i felt that my statements, responses, and actions had to be well-calculated. and i had to consider the things themselves, which even by their lonesome were no walks in the park. it was somewhat daunting, which led to procrastination

not saying this is exactly the case here, but i remember this footnote: http://www.paulgraham.com/startuplessons.html#f2n

so yea, just relax imo. let the creators work things out at their own pace

-----

3 points by projectileboy 6348 days ago | link

I wouldn't be so discouraged. For my part, I'm simply in a mode where I'm working on stuff, and maybe (hopefully?) this is the case for other people as well.

FWIW, I'm trying to get a more robust version of the IntelliJ Arc plugin out the door, and I'm also working a very primitive project management tool in Arc.

-----

3 points by lojic 6349 days ago | link

"kennytilton hasn't been commenting for 40 days"

Kenny has definitely left the building :) I think he just wanted to put in his due diligence in checking out the language, but I don't think he ever bought in to Lisp-1 and is sticking with CL.

-----

2 points by mayson 6349 days ago | link

He hasn't posted on his own blog, either, so he may be doing something entirely different, like travelling: he gave a talk recently at the European Common Lisp Meeting (ECLM) in Amsterdam.

-----

2 points by lojic 6349 days ago | link

Traveling for 42 days? :) Nope. He's still active on c.l.l., and he's been pretty clear regarding his views on Arc.

-----

2 points by lojic 6349 days ago | link

Your documentation is great, but what happened to wanting to avoid karma accumulation?

http://arclanguage.com/item?id=5522

Since you returned to your original kens, I've been bumped down a notch. Not that I'm counting or anything ;)

-----

3 points by kens 6349 days ago | link

Someone named lojic said it was too confusing with kens2, etc so I went back to the original. But it looks like a tie as far as karma :-)

-----

1 point by lojic 6349 days ago | link

I'm just messin' with ya. It's definitely better to not use multiple user names IMO. And as far as the tie - that 40+ point jump looks awfully fishy to me. Two can play that game though, so knock it off :)

-----

1 point by drcode 6350 days ago | link

Yeah, it's definitely been getting a bit quiet in the arc world... I'm planning on using arc long term, so I hope the community survives...

And I second the motion that your docs are extremely useful, kens. I have a bookmark link for them on my main toolbar, along with only a handful of other essential tools on the web. No question though, your audience is unfortunately is pretty small these days...

-----

2 points by bOR_ 6350 days ago | link

Still here, but dividing my time in finishing my phd, learning to use arc to code for a pet project of mine.

Can't imagine pg just abandoning arc, but a bit more excitement from the regulars would be a good thing. Perhaps we can do something like start writing the great computer language shootout progs in arc (although not for speed, we'd be able to go for brevity and clarity)?

-----

1 point by sacado 6349 days ago | link

As for shootout , that would be a good idea, but the current implementations (arc2, arc2c or even others) aren't mature enough to compete.

I mean, arc2 takes 3 sec. to startup (and it cannot even take command line arguments) and arc2c is not meta-circular yet (and lacks a lot of things, including command-line args, but that is easy to add), so a real benchmarks would need both arcs (one to compile, the other to run the compiler). I don't know the precise status of other implementations, but I guess they aren't mature enough either.

And, that's a chicken-and-egg problem, but I don't think the shootout admins would accept to add an Arc implementation until the language is a little more popular (or there would have thousands of languages referenced).

-----

2 points by almkglor 6350 days ago | link

IMO what we need is publicity. Meaning someone's pet project, in Arc, will (by definition of "publicity") need to be done publicly. ^^

-----

2 points by bOR_ 6349 days ago | link

heh. Will work on it tonight then :), so that I at least can post about it.

-----


now that's a fork :)

-----

1 point by sacado 6354 days ago | link | parent | on: arc2c update

hmm, interesting. I'm not really fond of refcounting. It makes FFI or C extensions really hard. That's what I don't like with Python's FFI. You always have to think : "do I have to increment the refcount ? decrement it ? Leace it alone ?" If you don't do it well, you have random bugs. The sad story is that Python makes C programming harder than it already is.

On the opposite, palying with mzscheme's or Lua's FFI is a real pleasure : you don't have to bother with GC. You even have (sometimes) your malloced object collected for you.

But if we can cetnralize the refcount operations in a single (or a very small number) of places, I'm OK... Their talking about stack_push / stack_pop is rather inspiring...

For information : On a GC-relativey-intensive program (mainly calculating (fib 40), which generates a lot of garbage), and with a heap of 50 million possible references, for a total time of 228000 ms, i got the following GC info :

  total time : 177ms, nb cycles : 17, max time : 42ms, avg time : 10 ms
That's far from perfect, of course, but it doesn't look so bad to me.

Btw, doctstrings are a real performance killer : they are useless, but are allocated on the heap and fill it up really quick (ah, recursive functions...). We should add something in the code removing immediate values in functions.

-----

3 points by almkglor 6354 days ago | link

> Btw, doctstrings are a real performance killer : they are useless, but are allocated on the heap and fill it up really quick (ah, recursive functions...). We should add something in the code removing immediate values in functions.

Really? You've tried it? Because docstrings are supposed to be removed by the unused global removal step.

Edit: I just did. This is a bug.

Edit2: Fixed and on the git.

-----

1 point by stefano 6354 days ago | link

> Btw, doctstrings are a real performance killer : they are useless, but are allocated on the heap and fill it up really quick (ah, recursive functions...

Are you saying that you alloc a docstring at every function call?

-----

1 point by sacado 6354 days ago | link

Well, for the moment, yes. Every object appearing in the program has to be allocated (it's not an optimizing compiler yet). Useless objects are not detected, so every time the compiler sees a string, it generates code to allocate it, and it is freed on the next GC cycle. Every time, you call the function, that code is executed. Well, that's an easy optimisation, so I'll work on it very soon I guess.

-----

1 point by stefano 6354 days ago | link

Yes, it's not difficult. You just have to find all constant values, create a global var for each constant, assign the const value to the global var and substitute the occurence of the constant with the global var name.

-----

3 points by sacado 6355 days ago | link | parent | on: ffi sqlite3 - help

OK, here we go :

  ; Implementation note : mzscheme's #f can be used as the C NULL pointer
  (= NULL* #f)

  (= callbacks* nil)
  (def sqlite3-callback args t)
  (let cb (ffi-callback sqlite3-callback (list cptr cint cptr cptr) cint)
    (push cb callbacks*) cb)

  ; Here, we defined cb as a callback of type cptr cint cptr cptr :
  ; no cstring here, as we have char** and not char *

  (def topcb () (let cb (pop callbacks*) (push cb callbacks*) cb))

  (w/ffi "libsqlite3" ;in mac os x "sudo port install sqlite3"
    (cdef sqlite3-open "sqlite3_open" cint (cstring cptr))
    (cdef sqlite3-exec "sqlite3_exec" cint (cptr cstring cfptr cptr cptr))
    ; Here again, cptr instead of cstring for error : we need a ptr to string
  (cdef sqlite3-close "sqlite3_close" cint (cptr)))

  ; Last warning : 2nd arg to sqlite3-open is a sqlite3**, i.e.
  ;  it returns the address of the actual sqlite3* used by sqlite3-exex & sqlite3-close

  (= &sqlite3 (cmalloc 4)) ; address of the actual sqlite3*
  (= sqltxt "create table bar (id integer primary key, text varchar(255));")
  (= sqlerrormsg (cmalloc 4))
  (= sqltxtptr NULL*)

  (sqlite3-open "test" &sqlite3)
  (= sqlite3 (cpref &sqlite3 cptr)) ; dereference to have an sqlite3*
  (sqlite3-exec sqlite3 sqltxt (topcb) sqltxtptr sqlerrormsg)
  (sqlite3-close sqlite3)
Not tried with an actual callback function, though, but on my machine it works perfectly...

-----

2 points by jmatt 6354 days ago | link

Thanks for the help. I'll test this out tonight.

Good to know that C NULL == mzscheme's #f.

-----

1 point by sacado 6355 days ago | link | parent | on: fork() in Arc

Yes and no. I think mzscheme's GC can handle it without explicitly calling free at the right time, but you have to register a "finalizer" function to do so. That function will be called when the GC collects the object.

It does not know the size of malloced objects however, so be careful (no pb there, but if you allocate something very big, mzscheme will only see a new reference and will not necessarily call GC when you will actually lack memory).

-----

3 points by stefano 6355 days ago | link

If you alloc memory with cmalloc mzscheme will automatically delete it for you. Try

  (def infinite ()
    (cmalloc 4)
    (infinite))

  (infinite)
You shouldn't run out of memory. If you do, then I'm wrong.

-----


It is probably written in C and does not check its args every time it is called. Basically, every time you call 'is, '<, '+, or any other primitive operation, it checks whether its arguments are numbers, then performs the operation. All these checks are useless since, within the body of your function, you know the type of your args are numbers, but you cannot avoid them anyway. Optimization will come, later :)

-----

5 points by sacado 6355 days ago | link | parent | on: Will/Can Arc create a LISP-revival?

Lisp is a strange world. It is very powerful and you can easily tailor the language the way you want. That, plus the fact there are many dialects, and that even within major dialects, you have many slightly different implementations, makes it harder to build a community.

Arc has a few advantages : it's got a canonical implementation (the fact that code is specification makes it easier), a charistmatic benevolent dictator and it is directed toward a popular and modern concern : web apps.

It could make Lisp popular, but it needs some kind of killer app. The news app is cool, but it won't be enough. Anybody's got an idea ?

As for being purely functional or not, well I really like the compromise Lisp (and particularily Arc) is. You can make your programs purely functionals, and it is generally easier, but you can also switch to an imperative paradigm whenever it makes sense.

-----

6 points by almkglor 6355 days ago | link

> it's got a canonical implementation

...until you realize that nearly every non-pg, non-rtm Arc user prefers to use the non-canonical Anarki, and recommends it because of the sheer number of bug fixes (never mind the new features, such as 'defcall, 'defm, 'p-m:, 'sync, 'thread-local, 'file-table ... etc.)

> It could make Lisp popular, but it needs some kind of killer app. The news app is cool, but it won't be enough. Anybody's got an idea ?

http://arclanguage.com/item?id=5697

-----

2 points by sacado 6355 days ago | link

Yes, but Anarki's primary goal is still to keep fully compliant with canonical Arc (except for bugs, of course). Now, sure, there are the additions...

-----

4 points by almkglor 6355 days ago | link

There's also the other problem with canonical Arc: pg has expressly stated that he will not retain backward compatibility between versions.

This also means that if Anarki tries to keep full compliance with ArcN in the future, without pg updating ArcN reasonably frequently, eventually (in a year? half a year?) Anarki will either: 1) die out as a source of innovation, because people will simply rather wait for pg's next update rather than push a change that might be overridden by pg in the future, or 2) drift so far away from pg's internal ArcN that when pg releases it, the merge hell will be very, very hot.

Take an example this: http://arclanguage.com/item?id=6138

  arc> (ssexpand 'foo?x)
  (is foo x)
Certainly I could implement that, and I think it's a good idea. The problem is pg's plans: does he intend a different meaning for #\? ? I don't dare to push this on Anarki, because if I do, I don't dare use it anyway, because pg might change its meaning in the future.

Edit: Ah, crick. I wish I can just say "Anarki promises to always keep compatibility with existing Anarki code. If pg breaks existing Anarki code in the next ArcN, we either (1) ignore the new feature, especially if we as a community feel that the existing Anarki feature is better, (2) rename pg's feature if possible, or (3) write a converter for old ArcN-1 based Anarki to ArcN based Anarki. Feel free to program in Anarki, where the magic carpet is assured of not being pulled out under you while you're exploring."

-----

4 points by applepie 6355 days ago | link

> the fact that code is specification makes it easier

The fact that broken pg's code is specification is a pain in the back and doesn't make anything easier.

Read RnRS for a _real_ specification of Lisp.

-----

3 points by sacado 6355 days ago | link

I was not talking in practice, in was meaning "in theory". In theory, the fact that most of the language is specified via code helps avoiding incompatible implementations. In practice, that's another problem, but it's only the beginning...

-----

2 points by almkglor 6355 days ago | link

Where pg fails.... --warning-blatant-self-promotion-- Anarki! Whee!

Hmm. Probably need a "Report on Anarki" as a spec of the standard Anarki, particularly 'call* and 'defcall, which may very well be the most important extension in Anarki.

-----


http://my-arc-stuff.blogspot.com/2008/02/i-needed-web-app-fo...

-----

3 points by sacado 6356 days ago | link | parent | on: arc2c update

I've got a dumb (but obviously working) implementation of hash tables. Actually, it is so dumb that it cannot really be called a hash table, but at least you can use it.

The implementation consists in two arrays : one for the keys, the other one for values. When you look for an object, it goes through the keys array and performs 'is comparison until it finds it. It is as scalable as alists, I know, but I'll work on the actual implementation later...

There are a few other new things. Most notably, the functional notation for accessing parts of lists/strings/hash tables is now implemented : ('(foo bar baz) 2) returns 'baz.

I thought it would bring horrible performance : since something at a functional position can be not only a closure, but also a string, a table or a pair, you have to do multiple dispatch every time you call a closure. Ugh... Well, obviously, gcc (with -O3) is very clever, or I'm missing something, because the actual slowdown isn't really significative.

Will be pushed tonight (Paris time).

-----

3 points by almkglor 6355 days ago | link

Note that a list key is compared using 'iso, not 'is (the quoted list bug notwithstanding)

> There are a few other new things. Most notably, the functional notation for accessing parts of lists/strings/hash tables is now implemented : ('(foo bar baz) 2) returns 'baz.

Cool! How'd you implement it?

I assume it doesn't have support for the 'call* table yet?

-----

3 points by sacado 6355 days ago | link

It looks a little hackish. I implemented it in the END_JUMP macro. If the object in LOCAL(0) (supposed to be a closure) is a string, a table or a cons, perform the adequate lookup operation (taking LOCAL(2) as a parameter). Then perform the actual jump : BEGIN_JUMP, PUSH(LOCAL(1) (which is the continuation)), PUSH(resut of lookup operation), END_JUMP.

call* is not implemented yet.

As for keys in hash tables, I admit I didn't really bother yet. It is quite broken in canonical Arc anyway (and in Anarki too for that matter) : it doesn't work correctly with lists and does not work correctly with strings too (if you update a string key, you're dead). If the hash itself is its own key, it breaks, but I don't know if this is supposed to be feasible or not.

So I'll focus on symbols and numbers as keys, first, as they are the most usual key types anyway, and will gradually introduce other key types.

-----

3 points by almkglor 6355 days ago | link

Just wondering if it's possible to create a bunch of primitives to do the referencing?

  %string-ref
  %list-ref
  %table-ref
Then possibly we could add to lib-ac.scm.arc:

  (= call* (%table)) ;or whatever the table-creating primitive is
  (%sref-table call* 'string
    (fn (s i) (%string-ref s i)))
  (%sref-table call* 'list
    (fn (s i) (%list-ref s i)))
  (%sref-table call* 'table
    (fn (s i) (%table-ref s i)))
  ; for compatibility with existing Anarki
  (set ref
    (fn (c i)
      (if (%is (%type c) 'string)
          (%string-ref c i)
          (if (%is (%type c) 'list)
              (%list-ref c i)
              (if (%is (%type c) 'table)
                  (%table-ref c i)
                  ; dummy stub for error message, when
                  ; errors are implemented
                  ())))))
Then maybe change code-execute* to something like:

  obj fn = SYM2OBJ("fn");
  obj typ;
  goto initjump;
  jump:
  // most common case, so check it first
  if((typ = type(LOCAL(0))) == fn){
    goto realjump;
  } else {
    memmove(&LOCAL(3),&LOCAL(2), (num_args - 2)*sizeof(obj));
    ++num_args;
    LOCAL(2) = LOCAL(0);
    LOCAL(0) = table_lookup(GLOBAL(CALL_TABLE), typ);
    //possibly add a check here to see if it's a function
  }
  realjump:
  pc = LOCAL(0)[0]; //or whichever it should be
  initjump:
  switch(pc){
    ...

-----

1 point by sacado 6355 days ago | link

good idea, I'll implement that soon...

-----

1 point by almkglor 6355 days ago | link

  -#define CAR() { if (TOS() != NILOBJ) {pair * p = (pair *) POP(); PUSH((obj)(p->car)); }}
  -#define CDR() { if (TOS() != NILOBJ) {pair * p = (pair *) POP(); PUSH((obj)(p->cdr)); }}
  +#define CAR() { pair * p = (pair *) POP(); PUSH((obj)(p->car)); }
  +#define CDR() { pair * p = (pair *) POP(); PUSH((obj)(p->cdr)); }
Just wondering: Why was this changed? Shouldn't it be that (car nil) == nil?

-----

1 point by sacado 6355 days ago | link

oh, oh, that's a mistake, sorry. I forgot to merge this with my own code. I'll do it on the next commit, if you don't do it before me...

-----

1 point by almkglor 6355 days ago | link

I'll change it back then ^^

Edit: done

-----

1 point by sacado 6355 days ago | link

pushed

-----

More