Arc Forumnew | comments | leaders | submit | evanrmurphy's commentslogin
1 point by evanrmurphy 4767 days ago | link | parent | on: Using arc on production system

Readwarp?

-----

1 point by akkartik 4767 days ago | link

Yup

-----

1 point by akkartik 4760 days ago | link

It's back up but quite slow and flaky because it has a lot less RAM now: http://readwarp.com.

-----

5 points by evanrmurphy 4768 days ago | link | parent | on: Apologies for the frequent downtime

Good news - copy and paste is finally working now (just fixed it). So now people will be able to paste in your examples! :-)

Thank you for the encouraging/motivating comment! Fixing copy-paste has been on my list for a long time, but this finally got me to do it.

I appreciate your offer to help. Maybe I should open-source Try Arc and then people can start issuing pull requests when they're motivated to fix something.

-----

2 points by zck 4768 days ago | link

Awesome! That'll really help me show people arc code, as I'm rarely at a computer with Arc installed when I want to show people.

Open-sourcing Try Arc would be cool. I'd love to look at larger Arc projects -- all of mine are middling at best. I'm working on bigger ones, but the lack of libraries is...frustrating, so I'd love to see how other people work with Arc.

-----

2 points by akkartik 4768 days ago | link

I'm curious: who are these people you're showing arc to and how do you find them on a regular basis? ^_^

-----

2 points by zck 4768 days ago | link

Generally, I'll try to show it to some of my programmer friends, or to people at work.

I had actually come up with an interview question: take two strings and return the index of the first difference. I posted some arc code, and wanted to have people run it.

My code:

  (def first-difference (seq1 seq2 (o comparer is))
       "Returns the index of the first difference between seq1 and seq2, or nil if
        they are the same. This function uses 'comparer as the function to compare
        elements of the sequences."
       (withs (len1 (len seq1) ;; 'withs ([var1 val1]* ) binds each var to its val
               len2 (len seq2)
               helper (afn (seq1 seq2 pos) ;; 'afn makes an anonymous function that
                                           ;; can recurse by calling 'self
                           (if (is len1
                                   len2
                                   pos) ;; at end of both sequences
                               nil
                             (or (is len1
                                     pos)
                                 (is len2
                                     pos)) ;; at end of only one sequence
                             pos
                             (~comparer seq1.pos
                                        seq2.pos) ;; found a difference
                             pos
                             (self seq1 seq2 (+ pos 1)))))
               (helper seq1 seq2 0)))

-----

2 points by akkartik 4768 days ago | link

Nice example. For exposition is it useful to simplify the problem by focusing on lists?

  (def first-difference(seq1 seq2)
    (if (or no.seq1 no.seq2
            (~iso car.seq1 car.seq2))
      0
      (+ 1 (first-difference cdr.seq1 cdr.seq2))))
Edit: no, that's not right, because it doesn't return nil on identical sequences. Here are two variants with and without the accumulator. Which is easier for noobs?

  (def first-difference(seq1 seq2 (o pos 0))
    (if
      (and no.seq1 no.seq2)
        nil
      (or no.seq1 no.seq2 (~iso car.seq1 car.seq2))
        pos
      'else
        (first-difference cdr.seq1 cdr.seq2 (+ pos 1))))

  (def first-difference(seq1 seq2)
    (if
      (and no.seq1 no.seq2)
        nil
      (or no.seq1 no.seq2 (~iso car.seq1 car.seq2))
        0
      'else
        (only.+ (first-difference cdr.seq1 cdr.seq2) 1)))
 
  (test-iso "" 0 (first-difference nil '(34)))
  (test-iso "" nil (first-difference '(1) '(1)))
  (test-iso "" 1 (first-difference '(1) '(1 2)))
  (test-iso "" 3 (first-difference '(1 2 3 4) '(1 2 3)))

-----

1 point by jsgrahamus 4767 days ago | link

  arc> (def 1st-diff (str1 str2 i)
    (if (or (is str1 "") (is str2 ""))
      0
      (or (> i (- (len str1) 1)) (> i (- (len str2) 1)))
      i
      (no (is (str1 i) (str2 i)))
      i
      (1st-diff str1 str2 (+ i 1))))
  #<procedure: 1st-diff>
  arc> (1st-diff "" "" 0)
  0
  arc> (1st-diff "" "" 0)
  0
  arc> (= astring "abcde")
  "abcde"
  arc> (= bstring "abced")
  "abced"
  arc> (1st-diff "" "" 0)
  0
  arc> (1st-diff astring "" 0)
  0
  arc> (1st-diff "" astring 0)
  0
  arc> (1st-diff astring bstring 0)
  3
  arc> (1st-diff bstring astring 0)
  3
  arc> (1st-diff astring "abcdef" 0)
  5
  arc> (1st-diff "abcdef" astring 0)
  5
  arc>

-----

1 point by jsgrahamus 4767 days ago | link

It's interesting to compare this to the solution in my workday language. One of the reasons that M is shorter is because its functions are more tolerant. For arc, I had to make sure that the index to the string was not too large. In M, it simply returns an empty string if you attempt to access a string position beyond the length. And I used iteration with M. Perhaps the arc solution would have been shorter had I done the same there.

Interesting exercise for this newbie.

-----

2 points by akkartik 4767 days ago | link

Yeah you can index past the end in my arc variant (http://github.com/akkartik/wart). But it currently returns nil. What should it be?

I'd love to see the M version expanded into english.

-----

2 points by jsgrahamus 4767 days ago | link

Great.

I'm used to seeing it as the empty string

Here is the expanded M version (! = LF):

  IF X=Y WRITE !,0 ; No difference
  ELSE  FOR I=1:1 IF $EXTRACT(X,I)'=$EXTRACT(Y,I) WRITE !,I QUIT

-----

1 point by akkartik 4766 days ago | link

I still don't know enough MUMPS to follow it :)

Are you concatenating strings? Is that where returning "" is useful? In wart concatenating strings is tolerant of non-strings, so I think returning nil should be ok.

-----

2 points by jsgrahamus 4765 days ago | link

If the string X = the string Y, print 0 (to indicate there are no differences / MUMPS uses 1-based indexing of strings)

Otherwise, go through each character of the strings and at the point where they differ, print that index and quit looping.

MUMPS does not error out on attempting to extract a character beyond the string's length. So in that event, 1 string's extract will return the empty string, which will differ from the other string's extract and will cause you to print the index and quit. Not generating such an error, of course, cuts down on the code needed.

-----

2 points by zck 4765 days ago | link

So if we enter the for loop, we know there is a difference between the two sequences.

So we just need to find an index position i where (isnt seq1.i seq2.i) is true. If indexing off the end of a string causes an error, we need to put in code to prevent that. If indexing off the end of a string returns anything that can't be an element of the string, we can compare each index i until we find a difference, knowing that we'll eventually find one.

-----

1 point by jsgrahamus 4765 days ago | link

Correct.

-----

1 point by jsgrahamus 4767 days ago | link

test-iso?

-----

1 point by akkartik 4767 days ago | link

https://github.com/nex3/arc/blob/ec47676f99af11b6fa8935a3cb0...

-----

3 points by jsgrahamus 4768 days ago | link

In my work language:

  I X=Y W !,0 ; No difference
  E  F I=1:1 I $E(X,I)'=$E(Y,I) W !,I Q
A challenge for me is arc/lisp/scheme's verboseness.

-----

1 point by akkartik 4768 days ago | link

What is that, J?

-----

1 point by rocketnia 4768 days ago | link

I think you may already have an inkling somewhere in the back of your mind.... http://arclanguage.org/item?id=15341

-----

1 point by akkartik 4767 days ago | link

Lol.

-----

1 point by jsgrahamus 4767 days ago | link

MUMPS / M / Caché - Used it for most of 30 years. In the U.S. mostly used on medical information systems, however it is also used in banks, credit unions, Ameritrade, etc.

-----

2 points by jsgrahamus 4768 days ago | link

Can you employ Racket's libraries for what you need?

-----

1 point by zck 4767 days ago | link

Some of it. What I've been working on lately is trying to get the Twitter API to work with Arc. I haven't found any Racket libraries for Twitter or even for OAuth. I would be very excited to find one, though -- this project has been [stuck](http://arclanguage.com/item?id=16040) for [way](http://arclanguage.com/item?id=15207) too [long](http://arclanguage.com/item?id=14817).

-----

1 point by evanrmurphy 4768 days ago | link

That worked for me with Try Arc. It's really not a large program, the portion that I wrote. On the backend, all the heavy lifting is done by Racket's sandbox library and srv.arc. On the front-end, it's Chris Done's jQuery console (and to some extent now, WordPress).

-----

3 points by akkartik 4768 days ago | link

Hells yeah!

-----

1 point by evanrmurphy 4769 days ago | link | parent | on: Apologies for the frequent downtime

I just wanted to apologize for the frequent downtime that has been occurring at Try Arc (you may or may not have noticed). I hope it hasn't inconvenienced too many people trying to hack on Arc while away from their installations or newcomers just getting started. I know at least one time zck was unable to test some code because of it (http://arclanguage.org/item?id=15207).

Thanks for your patience while I get this figured out.

-----

2 points by jsgrahamus 4767 days ago | link

I haven't experienced the downtime. However, I would like to use it on my Android, but the Enter key does not seem to end the input line. Any ideas on how to handle that?

Thanks, Steve

-----

1 point by evanrmurphy 4767 days ago | link

Hi Steve, have you had a chance to try this on your Android since yesterday? I think the update I made to fix copy-paste may have also fixed this.

The reason I say this is that I just tried it on my Android - a Samsung/Google Nexus S - and it worked (the Enter key did successfully end the input line). But it may also be due to us having different phones, so when you get a chance to try it out again, please let me know.

Also, thanks for your patience and for reminding me about this issue. I remember you first raising it a long time ago.

-----

1 point by jsgrahamus 4767 days ago | link

I have a T-Mobile G-1 and it does not terminate the line. Perhaps because I have version 1.6.

You're welcome of course.

-----

1 point by evanrmurphy 4766 days ago | link

Ok, thanks. I've created an issue for this in the Feedback forum, which is my running todo list for try arc: http://tryarc.uservoice.com/forums/80605-general/suggestions...

-----

1 point by evanrmurphy 4768 days ago | link

I think it turns out that my Linode just needed more memory. I added some a few minutes ago, we'll see if that fixes the problem.

-----

1 point by akkartik 4769 days ago | link

Lol, that blog post seems down right now :)

-----

1 point by evanrmurphy 4769 days ago | link

Strange. Haven't noticed that go down, try again :-)

-----


> The most natural interpretation of generic-noun function names is as constructors.

Before I was lukewarm on the name, but this reminded me of the pronunciation difference. Pronounce it like the noun (predikit) and it sounds confusing, but pronounce it like the verb (predikayte) and it sounds great.

I like it!

-----

2 points by rocketnia 4815 days ago | link

I think a verbalization of "predikit" is a better way to read it. "Predikayte" already has a different meaning, one that could make people think of assertions... essentially the same meaning trouble as "testify," right? :-p

Personally, I think this is all moot, but I'd go with "checkify" or "to-check".

  testify
    Pro: Only 7 characters long.
    Pro: Bunches with related words containing "ify."
    Con: Bunches with unrelated words containing "test."
    Con: Is a neologism if used in English.
    Con: Has non-sequitur homonyms in English (one meaning "claim").
    Con: The vocal majority here at Arc Forum seems to dislike it. :-p
  
  predicate
    Pro: Bunches with related words containing "icate."
    Con: Debatable pronunciation.
      "predikayte"
        Con: Is a neologism if used in English, I think. It
          reinterprets the verb as a verbalization of the "predikit"
          version, when "predikit" is actually something of a
          nominalized form of "predikayte" in the first
          place[Wiktionary]. Is it already used this way?
        Con: Has non-sequitur homonyms in English (one meaning
          "assume").
      "predikit"
        Pro: Same as a related term used in English discussion.
      "predikahtay"
        Con: Has a non-sequitur homonym in Italian (meaning
          "preach")[Wiktionary].
    Con: Since it has the same spelling as a noun, it may conflict with
      other noun-based names (e.g. accessors, local variables).
    Con: In English discussion, needs special formatting to look like a
      variable name.
  
  checkify
    Pro: Bunches with related words containing "check."
      Pro: "Check" is a related term that can be dropped casually into
        English discussion.
      Con: "Check" has many non-sequitur homonyms in English (one
        meaning "restrict").
    Pro: Bunches with related words contianing "ify."
    Con: Is a neologism if used in English.
  
  to-check
    Pro: Bunches with related words containing "check."
      Pro: "Check" is a related term that can be dropped casually into
        English discussion.
      Con: "Check" has many non-sequitur homonyms in English (one
        meaning "restrict").
    Pro: Bunches with related utilities containing "to-".
    Con: Is a downright technical term if used in English.
    Con: "To check" could be seen as an infinitive form.

-----


Just added one to this blog post, as well as a link in the Try Arc nav to try and assist with this issue: http://tryarc.org/blog/how-to-install-arc

-----

1 point by kinleyd 4850 days ago | link

Thanks evanrmurphy, that's a good additional link to have.

-----


Nice PSA, that should definitely help steer newcomers in the right direction.

-----

1 point by evanrmurphy 4960 days ago | link | parent | on: New in wart: param aliases

Very interesting feature.

Does this mean that '/' is a disallowed character in wart symbols in general, or only in parameters?

-----

2 points by akkartik 4960 days ago | link

Only in parameters. And even there you can start variables with a '/'. See http://github.com/akkartik/wart/blob/2299ca5f0f/030num.wart#... for multi-ary division -- the $/ expands to something like /170.

-----

2 points by evanrmurphy 4967 days ago | link | parent | on: Try Arc ported to WordPress

Hey folks,

WordPress has become my favorite platform for building websites. The software is so robust and the ecosystem of themes and plugins so rich - I find it's really conducive to productivity.

That's why I'm excited to announce this port of Try Arc to WordPress. I think it will make the codebase more maintainable, and help me to get features & fixes out faster.

If you're curious, the Arc web server is still in play here. But now rather than the whole site being hosted that way, only the REPL is (the only component that needs to be). The rest of the site is served from a separate Apache instance; it gives way to the REPL through a simple IFrame in a WordPress page template.

Hope you enjoy! Let me know what you think.

Evan

-----

2 points by akkartik 4967 days ago | link

Looks great!

Can you make the nav links only open in new tabs for the repl page, not otherwise?

-----

1 point by evanrmurphy 4967 days ago | link

Yes, you're right. It is very annoying to have the new tab on every nav link. I will try what you suggested. Thanks, Kartik. :-)

Update: For now I just disabled the new tab feature altogether. Later we'll find a way to add it just for the REPL page or otherwise address the problem. For now, be careful what you click on while working at the REPL!

-----

1 point by akkartik 4966 days ago | link

Gmail and a few other places (basecamp) have a way of detecting when you have an unsubmitted form and popping up a confirmation dialog if you accidentally try to navigate away. I used to know how to do this - it's a standard javascript function that works on all browsers..

-----

1 point by evanrmurphy 4966 days ago | link

Ok, I did it your way with the confirm dialog. :-)

-----

2 points by thaddeus 4964 days ago | link

Just out of curiosity... what about using a hidden session id? It could be used to re-connect to the old session whenever you swing over to the repl.

Or does using WordPress prevent that somehow? (really, I've never used WordPress... so I have no clue what the limitations are... if any.)

-----

1 point by evanrmurphy 4964 days ago | link

Hey thaddeus, the main issue I run into with something like this is that sessions are very resource-intensive on the server side. As it stands I get to reclaim session resources right when people leave, and still Try Arc gets overloaded and requires manual restart about once every two weeks.

Ah, but the solution seems so straightforward now: just put sessions to sleep. Every session can be stored efficiently as a list of expressions, and then re-awakened by running the expressions through a new REPL before showing it to the user.

Maybe this should be the next update.

-----

3 points by rocketnia 4964 days ago | link

If the REPL session takes any input, including by measuring timings or generating random numbers, it won't be deterministically recreated by a list of commands. And what if I want a fresh REPL?

When I go to Try Arc, I imagine there's a single REPL per window/tab, which goes away as soon as I leave the page. So I think it would be cool to be able to copy out transcripts (without spurious hyphens showing up :-p ) and load/paste Arc libraries, but that's all the power I hope for.

If you're looking for more of a server-side challenge (and more of a productivity site rather than a tutorial :-p ), it would be awesome to have a user account system that lets me paste a bunch of Arc utilities and load them automatically every time I start a REPL.

-----

4 points by akkartik 4964 days ago | link

Nah, don't get into the business of managing user logins and passwords if you can possibly avoid it.

An alternative is a session system. Menu commands: "save this session", "past sessions". Give each session a URL so it can be bookmarked/shared.

-----

3 points by rocketnia 4964 days ago | link

Works for me. ^_^

I'm still a bit suspicious about abstraction leaks in the concept of "save this session." I'd prefer to think in terms of a library pastebin, where I may choose to turn my REPL session into a library but I'm not misled into thinking it'll preserve more about my session than the raw code I entered.

-----

2 points by evanrmurphy 4963 days ago | link

For what it's worth, managing user logins and passwords is a very easy business with WordPress! The challenge would be figuring out how to interface those WordPress user accounts with REPL functionality.

-----

2 points by thaddeus 4964 days ago | link

> And what if I want a fresh REPL?

If implemented like HN x-id's you could just refresh or reload the page in order to get a new session. And like HN one could just expire a stored session after x minutes without being used.

Note though: Originally when I posted the session-id idea I was thinking tryarc was only one session with many threads, where each session-id would really just point to its own namespace. Had this been the case it would just be the functions and variables being stored in memory. And then threads/session-ids/namespaces (whatever) could be spun up or down and managed in a myriad of ways.

-----

2 points by rocketnia 4964 days ago | link

Me: "And what if I want a fresh REPL?"

You: "If implemented like HN x-id's you could just refresh or reload the page in order to get a new session."

That's the behavior I expect, but then I also expect to get a new session if I navigate somewhere and click the back button. If the back button case does not give me a new REPL, I don't see why refreshing the page would.

-----


Interesting. I wonder if he's writing that stuff in arc.

-----


Having both macros and eval always seemed redundant to me, because they're both for letting you treat code as data. Also, since the eval in most lisps (Arc included) doesn't accept a second parameter for the environment context, they might as well not have eval in the first place.

1. A good theoretical lisp should be fexpr-based and have an eval which accepts both parameters.

2. A good practical lisp wants to be fast, so it should use macros instead of fexprs. Eval is basically irrelevant here.

-----

2 points by Pauan 5047 days ago | link

"...they might as well not have eval in the first place."

Although I agree with you in principle, eval is needed in at least one place: load. So I don't think we can necessarily get rid of it completely, unless we used a different method of loading/evaling files...

eval is also used in a few other places in ar, but not very many. So rather than getting rid of it, I think a better solution is to say, "eval is generally a bad idea, so use something else unless you absolutely positively must use eval" which is exactly what we do.

By the way, I'll note that when I tried to use eval to expand a macro at runtime, it ended up being horrendously slow. I changed it to use a function (which did the same thing, but with thunks) and suddenly my code ran at least 100 times faster than it did with eval.

-----

2 points by evanrmurphy 5047 days ago | link

Ah, you're right. You may not be able to do away with eval.

And do you know what you just helped me realize? If we've already identified ourselves as a practical lisp, why should we try to get rid of features like eval in the first place?

A theoretical lisp tries to get rid of unnecessary features to approach being as minimal as possible. A practical lisp has already decided that it would rather be useful than theoretically minimal.

So a practical lisp probably shouldn't worry about getting rid of things unless they are actively causing problems. If it wants to be as useful as possible, it might as well leave in unnecessary features. Because they're probably still useful some of the time to some people, even if they're not totally necessary.

-----

More