Arc Forumnew | comments | leaders | submit | akkartik's commentslogin
2 points by akkartik 17 days ago | link | parent | on: How to handle Racket types?

Try https://github.com/arclanguage/anarki/blob/master/lib/json.a...?

reply

3 points by hjek 8 days ago | link

Someone should get rid of json.rkt and json.arc from the Anarki repo.

Racket already has a built-in JSON parser[0] that works just fine with Arc.

[0]: https://docs.racket-lang.org/json/index.html

reply

3 points by krapp 17 days ago | link

I am, and json.rkt is modified for Arc but the json response is still returning Racket types, which is weird:

    #hash((challenge_ts . 2018-08-03T12:59:44Z)
          (hostname . testkey.google.com) 
          (success . #t))

reply

3 points by i4cu 17 days ago | link

I think the problem might be that Arc doesn't support some of data types that you are getting from the json response. For example Arc does not support booleans true/false it only has 'nil' or not a nil value. That's why, in the past, I used Andrews library [1].

That said I haven't had a running install of arc in many years so I could be off base.

1. https://github.com/awwx/lib/blob/master/fromjson2.arc

reply

4 points by akkartik 17 days ago | link

Looking through the Anarki logs I think I'm seeing signs of our first edit war. It's been very gradual so we haven't noticed until now.

Anarki used to use Andrew's library from http://awwx.ws/fromjson (perhaps an older version of your link, i4cu) I switched it out back in 2009 for a faster replacement (https://github.com/arclanguage/anarki/commit/dad4dc6662), not realizing that I was breaking the read side in this rather obvious manner. Since then a bunch of work has happened on emitting JSON, but apparently nobody tried parsing JSON until now.

We could retrofit these bugfixes, but I think it would just give up the speed gains to parse things character by character. May be worth just returning to Andrew's version.

But I'll try working with the existing version first, just in case it's still fast.

reply

4 points by i4cu 17 days ago | link

Just my two cents, but if I were using Arc today I'd consider doing what could be done to conform to the edn spec [1]. It was born out of Clojure, but is not Clojure specific. Also, as I understand it json is actually a subset of edn thus the two would not collide. But for now I think just getting a json parser running would be a win.

https://github.com/edn-format/edn

reply

4 points by krapp 16 days ago | link

Possibly a silly question but... could we just add support for those types in Arc?

I mean, as long as Racket interop is going to be a thing, maybe using the boolean type isn't a bad idea.

And by "we" I mean "probably you," of course.

reply

2 points by hjek 8 days ago | link

Arc already supports Racket booleans:

    arc> (if $.#f 'foo 'bar)
    bar
    arc> (if $.#t 'foo 'bar)
    foo
They work, so what is the problem?

Also, I don't get why the Anarki repository contains a JSON parser implemented in Racket, when the built-in Racket JSON parser works just fine with Arc:

    arc> ($ (require json))
    arc> ($.write-json (obj foo "bar"))
    {"foo":"bar"}#<void>
    arc> (w/instring in "{\"foo\":\"bar\"}" ($.read-json in))
    #hash((foo . "bar"))
I fail to see the problem with the Racket built-in JSON parser here. Would anyone care to explain?

reply

2 points by akkartik 8 days ago | link

Thanks! I think you're right that the existing JSON parser is unnecessary. But there's still an open problem about translating to Arc:

    arc> (w/instring in "{\"foo\": true}" ($.read-json in))
    #hash((foo . #t))
We'd like this to translate to:

    #hash((foo . t))
Perhaps what we're looking for isn't related to JSON at all, but a general shim for translating the output of Racket functions. That could be broadly useful.

reply

2 points by hjek 8 days ago | link

Why do we need to explicitly translate #t to t? Arc has no problem handling Racket booleans.

I'd like to see perhaps a specific brief example, where using Racket booleans within Arc actually is a problem, because I haven't encountered any myself.

If I try to use the hash from your example in actual Arc code, it works fine:

    arc> (if ((w/instring in "{\"foo\": true}" ($.read-json in)) 'foo) 'yes 'no)
    yes
    arc> (if ((w/instring in "{\"foo\": false}" ($.read-json in)) 'foo) 'yes 'no)
    no

reply

2 points by akkartik 7 days ago | link

Wow, that's kinda mind-blowing. I had no idea. Thanks!

Ah, here's perhaps the only special-case we need to handle:

    arc> (= x (w/instring in "{\"foo\": null}" ($.read-json in)))
    #hash((foo . null))  # expected: #hash((foo . nil)) or #hash()
    arc> (if x!foo (prn "error"))
    error

reply

2 points by rocketnia 7 days ago | link

For round-tripping between JSON and Arc, I would expect the JSON values {}, {"foo": null}, {"foo": false}, and {"foo": []} to parse as four distinct Arc values.

I recommend (obj), (obj foo (list 'null)), (obj foo (list 'false)), and (obj foo (list (list))). Arc is good at representing optional values as subsingleton lists:

  ; Access a key that's known to be there.
  t!foo.0
  
  ; Access a key that isn't known to be there.
  (iflet (x) t!foo
    (do-something-then x)
    (do-something-else))
Using my `sobj` utility, you can write (obj foo (list 'false)) as (sobj foo 'false).

Meanwhile, I don't think there's any big deal when we don't have Arc-style booleans....

  ; Branch on the symbols 'false and 'true.
  (if (isnt 'false x)
    (do-something-then)
    (do-something-else))
  
  ; Alternative
  (case x true
    (do-something-then)
    (do-something-else))

reply

2 points by hjek 7 days ago | link

> ; Branch on the symbols 'false and 'true.

We do already have booleans that work in Arc without any conversion. Please see http://arclanguage.org/item?id=20492

There's absolutely no need to convert the booleans to symbols and other hackery.

reply

3 points by rocketnia 7 days ago | link

I liked it when it was returning #f.

But now that I look closer at the ac.scm history (now ac.rkt in Anarki), I realize I was mistaken to believe Arc treated #f as a different value than nil. Turns out Arc has always equated #f and 'nil with `is`, counted them both as falsy, etc. So this library was already returning nil, from Arc's perspective.

There are some things that slip through the cracks. It looks like (type #f) has always given an "unknown type" error, as opposed to returning 'sym as it does for 'nil and '().

So with that in mind, I think it's a bug if an Arc JSON library returns 'nil or #f for JSON false, unless it returns something other than '() for JSON []. To avoid collision, we could represent JSON arrays using `annotate` values rather than plain Arc lists, but I think representing JSON false and null using Arc symbols like 'false and 'null is easier.

reply

2 points by hjek 7 days ago | link

Having nil represent both false and the empty list is also what Common Lisp does.

Really, #t and #f are not proper Arc booleans[0], so it makes sense that Arc can't tell what type they are.

You can configure the value Arc chooses for a JSON null with the $.json-null function, which I think is fine as JSON APIs might have differing semantics.

[0]: http://arclanguage.github.io/ref/combining.html

reply

2 points by rocketnia 6 days ago | link

That documentation may be wrong. On the other hand, it may be correct in the context of someone who is only using Arc, not Racket.

There are a lot of ways to conceive of what Arc "is" outside of the Racket implementations, but I think Arc implementations like Rainbow, Jarc, Arcueid, and so on tend to be inspired first by the rather small set of operations showcased in the tutorial and in arc.arc. (As the tutorial says, "The definitions in arc.arc are also an experiment in another way. They are the language spec.") Since #f isn't part of those, it's not something that an Arc implementation would necessarily focus on supporting, so there's a practical sense in which it's not a part of Arc our Arc code can rely on.

(Not that any other part of Arc is stable either.)

reply

2 points by i4cu 6 days ago | link

> Really, #t and #f are not proper Arc booleans[0], so it makes sense that Arc can't tell what type they are.

Really, #t and #f are not proper Arc anything, but the language apparently handles them so IMHO Arc should also be able to know what type they are. Otherwise, I fear, this will become a Hodge Podge language that will lose appeal.

Personally I don't care if Arc supports booleans. I only care that it can translate booleans (when need be) to a meaningful Arc semantic. That said, if we're going to support booleans then let's not create partial support.

reply

2 points by hjek 7 days ago | link

Nice example. (So much easier to tell what's going on when you have these brief examples)

Actually the Racket docs[0] clarifies the situation with null in JSON:

    (json-null) → any/c

    (json-null jsnull) → void?
      jsnull : any/c
> This parameter determines the default Racket value that corresponds to a JSON “null”. By default, it is the 'null symbol. In some cases a different value may better fit your needs, therefore all functions in this library accept a #:null keyword argument for the value that is used to represent a JSON “null”, and this argument defaults to (json-null).

If you set the JSON null to nil before running your example, it works as you'd expect:

    arc> ($.json-null nil)
    #<void>
    arc> (= x (w/instring in "{\"foo\": null}" ($.read-json in)))
    #hash((foo . nil))
    arc> (if x!foo (prn "error"))
    nil
I think we should get rid of json.rkt and use the Racket built-in. It's way better documented, and we should use that one. (But I'm not going to delete json.rkt myself, particularly when I know someone is working with it.)

[0]: https://docs.racket-lang.org/json/index.html

reply

3 points by krapp 7 days ago | link

I got an error saying #t was an unknown type when I tried to do a boolean check on it, as it was passed from a JSON response. It's the reason I started this thread to begin with.

reply

2 points by hjek 7 days ago | link

Would you mind preparing a simple code example to show this issue? I'm not sure exactly what you are doing.

reply

2 points by krapp 7 days ago | link

Sure... the if statement in verify-captcha is where the problem occurs.

It currently works but that's only because json.rkt has been modified.

    (def post-getjson (url params (o port stdin))
      (fromstring (post-url url params) 
        (read-json (port))))

    (def recaptcha-response (s r)
      (post-getjson "https://www.google.com/recaptcha/api/siteverify"
      (list 'secret s 'response r)))

    (def verify-captcha (req)
      (do
        (= resp (recaptcha-response recaptcha-secret* 
        (alref (req 'args) "g-recaptcha-response")))
      (if resp!success 
        (pr "success") 
        (pr "failure"))))

reply

2 points by hjek 7 days ago | link

> when I tried to do a boolean check on it,

Can I ask how you did a "boolean check" on #t?

reply

2 points by i4cu 8 days ago | link

$.#f means you need to add a handler on a value, that's not handling the value as it's supposed to.

reply

2 points by hjek 8 days ago | link

Is the $ the handler you are referring to?

You don't need to add any $ handlers to handle Racket booleans. They can be passed directly to Arc functions.

The $ is just there to get some Racket booleans.

reply

2 points by i4cu 8 days ago | link

sorry I don't have an install. I've been assuming:

  (if #f 'foo 'bar)
 
would error.

edit: and now I have and install... :)

reply

1 point by hjek 8 days ago | link

> sorry I don't have an install.

http://tryarc.org/

reply

3 points by akkartik 7 days ago | link

In fairness, tryarc.org it isn't always up lately. evanrmurphy has broached the subject of someone taking it over, but it hasn't happened yet.

reply

2 points by hjek 7 days ago | link

Yes, looks like it's plain Arc 3.1.

reply

2 points by akkartik 17 days ago | link

Can you share the input JSON? Let's treat this as a bug and see if we can fix it.

reply

3 points by krapp 16 days ago | link

It's just the default Recaptcha response found here[0]:

    {"success": true,  
     "challenge_ts": "2018-08-03T22:31:05Z",  
     "hostname": "testkey.google.com"}
[0]https://developers.google.com/recaptcha/docs/verify

edit: I went ahead and pushed my current working branch[1] if anyone wants to see it.

[1]https://github.com/kennethrapp/anarki/tree/dev-test

reply

2 points by hjek 8 days ago | link

Great, that looks fine. Then you can just access the `success` key like this:

    ($ (require json))
    
    (if
       ((w/instring json "{\"success\":false}"
                          ($.read-json json))
                          'success)
       'success ; proceed to login
       'fail    ; must be a robot then
     )

reply


What's the thinking behind implementing captcha? I really, really hate ReCaptcha. For most sites the payoff to a spammer isn't really worth even the simplest robot test. A new site that throws ReCaptcha is an instant bounce.

reply

3 points by krapp 17 days ago | link

>What's the thinking behind implementing captcha? I really, really hate ReCaptcha.

It might be useful if it only shows up on the login/signup page after failed attempts, but it might also be overkill. Personally, I prefer overt solutions to opaque ones like shadowbanning and throttling IPs. But mostly it seemed like a good way to figure out some basics (managing keys, how the app server manages the form loop, API responses and JSON.)

I could finish the test I have, push that and leave integration for later.

reply

2 points by akkartik 17 days ago | link

I agree with overt vs shadowbanning. My tendency is to just add tools for moderation. Let bots sign up and spam, but make it easy to take them down and ban them at that point. Arc is reasonably decent there.

reply

2 points by i4cu 17 days ago | link

If the content is publicly accessible and free then that works, but otherwise it doesn't help.

reply

2 points by akkartik 17 days ago | link

I don't follow the connection.

reply

3 points by i4cu 17 days ago | link

Sorry, my comment was rather lazy. Let me try again.

I get the impression many of the people who want to start a HN like clone are considering using it as a content delivery platform. For example http://arclanguage.org/item?id=20452 notes a revenue sharing model for specialized content. Now, if that's the case these site owners will have both spammers and content scrapers to contend with. So my initial comment was also referring content scrapers too.

However there's another thing to consider: Session storage costs. About 6 months ago I went through a process to reduce the cost of data held in memory for session storage (redis in this case). The session data was continually analyzed for determining both who the bad users were and for knowing what value the good users are getting out of the app (feature planning etc). It was an interesting process, where just by reshaping the session data, thousands of dollars per month could be saved in db fees. Now I realize the someone starting a HN clone is probably not dealing with that, but I'd be willing to bet that part of the reason Captcha was implemented in HN proper was to reduce fees associated with the volume of requests, session costs and even network load. It's my feeling that, generically speaking, adding captcha functionality is a good Option to have.

reply

2 points by i4cu 16 days ago | link

> I'd be willing to bet that part of the reason Captcha was implemented in HN proper was to reduce fees associated with the volume of requests, session costs and even network load.

Let me add some info to that.... I'm not sure if anyone noticed, but HN has implemented new session management strategies. You can see this as your login is now maintained across multiple devices, where the arc code (that we have access to) logs you out upon logging in elsewhere. I also believe that when pg handed over the HN code significant changes occurred including how session data is stored and how that data is utilized to integrate with cloudflare. Obviously I'm making big guesses, because I don't have access to the code, but I'm willing to bet the changes HN has put in place would surprise everyone here.

Sadly everyone who sees HN today will come here and look for the source code not realizing what's available here is not modern nor comparable.

reply

3 points by krapp 16 days ago | link

>Sadly everyone who sees HN today will come here and look for the source code not realizing what's available here is not modern nor comparable.

One thing I noticed when Arc gets brought up on HN is that everyone seems interested in the language but not so much the application. People seem to cargo-cult the forum for some reason.

reply

2 points by akkartik 17 days ago | link

Fascinating, thanks for that war story and perspective. That makes a lot of sense.

reply

2 points by i4cu 17 days ago | link

> For most sites the payoff to a spammer isn't really worth even the simplest robot test.

Maybe I am missing something.... Isn't captcha just a fairly simple robot test (and thus preventing spam)? Or are you suggesting something even simpler? Because I've run a few sites and had tried implementing very simple programmatic obstacles and it really didn't stop the spammers.

Maybe the better question is - what would you suggest?

reply

3 points by akkartik 17 days ago | link

Simple captchas are totally fine. My problem is with Google's ReCaptcha in particular, where the problems have gotten so difficult that I mostly can't prove I'm a human.

reply

2 points by i4cu 17 days ago | link

Hmm... That's not my experience. 90% of ReCaptcha tests are invisible if not a simple checkbox. Only a small optional subset requires introducing a problem solver.

https://developers.google.com/recaptcha/docs/versions

I do agree though, the text ones can be a pain, but that doesn't happen too often. Sadly HN seems to push those more often.

reply

1 point by akkartik 17 days ago | link

I don't get either a checkbox or text anymore. I get to identify pictures with cars and signs and whatnot.

reply

2 points by i4cu 16 days ago | link

I've never failed a cars or signs test. It's only the text scribbles that kill me :)

I have to wonder what you're doing that make google zero in on you.... lol. Tor? maybe proxy IP's?

reply

3 points by rocketnia 11 days ago | link

One time I spent a good 20 minutes identifying cars, signs, and storefronts before it would let me in, and that was with no VPN or Tor or anything. At some point they oughta be paying us. :-p

reply

3 points by hjek 7 days ago | link

Someone tried to take Google to court already, arguing exactly that :-)

https://arstechnica.com/tech-policy/2016/02/judge-tosses-pro...

reply

3 points by rocketnia 7 days ago | link

"Plaintiff has failed to allege how these numerous benefits outweigh the few seconds it takes to transcribe one word."

A few seconds is qualitatively different from 20 minutes, I'd think. :-p

reply

1 point by i4cu 11 days ago | link

This is probably going to sound super crazy, but I have to say it...

I know you (akkartik) have a google account, because I remember when you moved your blog over to google's services (I think they call it 'circles' or some such). I also remember you created a news aggregator application that scraped content. Yes, I know, it was a long time ago in a galaxy far, far away..., but still...

I'm thinking that google identified your scraping work and deemed you a risky robot type, but they also probably correlated your IP from the scraping to your IP from your google services login and tagged you that way. So now, even if your IP changed, they'll continue to have you in their cross-hairs for, like, ever.

Any takers? If you'd like I can also look into who killed JFK...

reply

3 points by akkartik 11 days ago | link

Lol, no.

Other possible reasons:

a) My cookie acceptance policies are non-standard. (I no longer even remember what they are anymore.)

b) I'm often behind a VPN for work.

c) I'm often on my phone, or tethering from my phone.

Complaints about ReCaptcha are fairly common if you look on HN and so on. You don't have to have run a scraper to hit it, I don't think. I think you may be a robot from the future for never having problems with the pictures of signs and cars :p

Final minor correction: I've played with Google+ in the past (I actually worked at Google on Circles for a year) but I never moved my blog there. I just linked to my blog posts from there.

reply

2 points by i4cu 11 days ago | link

> Complaints about ReCaptcha are fairly common if you look on HN and so on.

Yeah I'm aware of the complaints, but in my mind HN wouldn't be the best resource of information for such an assessment. By default HN members are non-standard in most ways that would matter to ReCaptcha.

It's an interesting dilemma and one that I'm coming up on soon as I plan to release a new app in a few months time. In my case the intended audience for the app is very widespread and not specific to a tech audience. It could be that the vast majority of my users (if I get any - lol) would never have a problem, because the vast majority of people using the net don't know what a VPN is or how to change a cookie setting (just as examples).

I'll have to give it some more thought, but in the mean time, are you aware of any resources on the matter that would be more reflective than HN?

edit: I often find info like this [1]:

  "Different studies conducted by Stanford University, Webnographer and 
  Animoto, showed that there is an approximately 15% abandonment rate when the 
  users are faced with CAPTCHA challenge."
1. https://www.infosecurity-magazine.com/opinions/captcha-fraud...

But really I do expect to take some loss when using reCaptcha. The question really becomes is it worth it? After all spam can also cause users to leave and content scrapers can also de-value your product.

reply

3 points by akkartik 11 days ago | link

Certainly, it's an issue only tech-savvy people will have.

However, every step you put users through is a place where your funnel will leak. So in your place I wouldn't turn on captcha until I actually see spam being a problem.

Also, independently, since I am personally ill-disposed towards ReCaptcha I have zero urge to help maintain it in Anarki :) You're welcome to hack on it, though!

reply

2 points by i4cu 11 days ago | link

> So in your place I wouldn't turn on captcha until I actually see spam being a problem

agreed.

> I have zero urge to help maintain it in Anarki

It's really only a few line of code (probably smaller than a unit test) and it has already exposed json bugs, so I consider it a win all around.

At any rate it's probably verging on discussion overkill for such a small item. :)

reply

2 points by krapp 10 days ago | link

I think it's less important to have Recaptcha or not than it is to have a working POC for interaction with a remote JSON API, and for parsing JSON in general, since that opens up a lot of possibilities. Recaptcha itself is just the low-hanging fruit for that, since it's so simple.

As far as integration goes, we could just leave it up to whomever wants to do the work or make it easily configurable with the default being not to use it at all.

reply

3 points by krapp 9 days ago | link

... well, it's up[0].

I don't know why the tests keep failing, though, it works locally.

[0]https://github.com/arclanguage/anarki/pull/102

reply

3 points by rocketnia 9 days ago | link

It's great to see a JSON API integrated in Arc. :)

I took a look and found fixes for the unit tests. Before I got into that debugging though, I noticed some problems with the JSON library that I'm not sure what to do with. It turns out those are unrelated to the test failures.

I left details about these in comments on the closed pull request, which might not have been the best place: https://github.com/arclanguage/anarki/pull/102

reply

2 points by krapp 9 days ago | link

The JSON solution is a quick and dirty hack by a rank noob, and I'm sure something better will come along.

And in hindsight the problem with the (body) macro should probably have been obvious, considering HTML tables are built using (tab) and not (table). I'm starting to think everything other than (tag) should be done away with to avoid the issue in principle, but that would be a major undertaking and probably mostly just bikeshedding.

reply


Can you link to the post you are referring to?

PR = Pull Request.

https://github.com/arclanguage/anarki/pull/99 https://github.com/arclanguage/anarki/pull/100

reply

3 points by i4cu 29 days ago | link

Ahh, well my whole comment is completely off topic; sorry. That's what 10 years of being a BA does to the mind :)

> Can you link to the post you are referring to?

I guess I should be using the expected terminology, that being a 'comment' not a 'post'. In my mind he 'post'ed a comment, but I understand I should have been more clear.

reply

2 points by akkartik 29 days ago | link

Oh I think I understand now, thanks :)

reply


I just went through this exercise as well. Once you define the server, you can then query it with this code:

    arc> (load "lib/client.arc")
    arc> (cdr (mkreq "http://localhost:8080/"))

reply

3 points by zck 33 days ago | link

Ooh, interesting! We might want to figure out a long-term documentation system for Anarki; the existing arclanguage.github.io documentation is for Arc 3.1. And while that's great, it's suboptimal for cases like this, because it says "...there is no support for outgoing network connections." (https://arclanguage.github.io/ref/networking.html).

reply

2 points by akkartik 33 days ago | link

Yeah, there's a reason why the documentation isn't linked on the right side at http://arclanguage.github.io :/

reply

3 points by christianbryant 33 days ago | link

How about UDP calls? I sucked this CL snippet a while back (sorry I don't have the author info at hand). Creates a socket, sends data and receives data:

  (defun create-client (port buffer)
     (let ((socket (usocket:socket-connect "127.0.0.1" port
					 :protocol 
                                         :datagram
					 :element-type 
  '(unsigned-byte 8))))
    (unwind-protect
	 (progn
	   (format t "Sending data~%")
	   (replace buffer #(1 2 3 4 5 6 7 8))
	   (format t "Receiving data~%")
	   (usocket:socket-send socket buffer 8)
	   (usocket:socket-receive socket buffer 8)
	   (format t "~A~%" buffer))
      (usocket:socket-close socket))))

reply

2 points by hjek 7 days ago | link

Check the Racket docs on UDP[0]. Arc itself is very high-level, but you can do more low-level stuff via Racket interop.

[0]: https://docs.racket-lang.org/reference/udp.html

reply


Thanks for the pointer to IOLib! We don't have anything like it, but there is an http client: https://github.com/arclanguage/anarki/blob/master/lib/client.... It also has unit tests, so is unlikely to have suffered bitrot.

I've built an http client several times in my life, particularly in Wart (https://github.com/akkartik/wart/blob/master/073http_get.war...) and in Mu (http://akkartik.github.io/mu/html/092socket.mu.html#L35). So I'd be happy to help if you want to try to put something together yourself.

reply

3 points by christianbryant 33 days ago | link

Thanks, Kartik!

I appreciate the info. I was actually just looking at Mu since I cloned that code for review recently. Since the framework I'll be doing this in is a testing suite, Mu may be the best model for me to follow.

Since I'm focused on UDP, Looking at comments in ac.scm in Arc, I realized MzScheme might hold the answer - there are plenty of UDP functions in those libraries.

Let me poke around a but and I'll shoot you an email if I have something to pass by you for opinion.

reply

3 points by christianbryant 33 days ago | link

It's about now I realize I'm using an old Arc (hence the MzScheme reference). Moving to arc-nu and Racket (as noted by Zachary) which provides all the UDP I need ;-)

I'll spend some time on this - appreciate the responses.

reply

4 points by akkartik 33 days ago | link

Great. Just one caveat: we tend to have more experience with just Anarki (https://github.com/arclanguage/anarki) which is also using the latest Racket.

If you're thinking of https://github.com/arclanguage/arc-nu, the author hasn't been active here in a while, so you may need to ping Pauan separately.

reply

3 points by christianbryant 33 days ago | link

Ah... thanks for that note. I am working with Anarki primarily now as noted earlier for News and similar, but also didn't catch on that it was the main working model here.

reply


Great to see! What's gotten you interested in it at the moment?

reply

3 points by christianbryant 35 days ago | link

My immediate interest is in "News". I was seeking a codebase to work from that would put me in a similar space as HN in look and function. I came across Anarki and was pleased to see it was related to Arc which I have recently been playing with.

My longterm interest is in shifting my mental focus to a more Lisp-oriented way of programming and thinking. I'm not a programmer by trade; I am a software tester and scripter, mostly. I use Python typically, but after working on an OS build I had to learn Guile and Emacs Lisp quickly. I fell in love with Lisp and Scheme due to this experience.

Arc interest came about after reading about it on Paul Graham's website. I'd worked through a portion of Practical Common Lisp by Seibel and decided to try out Arc. It felt right. Since I also happen to work in the Information Security space, I have ideas that for the most part feel like Lisp is the right language, but I will need to become more proficient. Anarki feels like a good place to start to get there from.

Side note: An an automation tester at UCLA working with SenseTalk via Eggplant, I came across Mu while researching alternatives to Eggplant in areas it fails to provide results, such as passing and receiving AIX system calls, or validating logs are being written to. Mu has caught my attention for the longterm, as well, so kudos for both Anarki and Mu.

reply

2 points by akkartik 34 days ago | link

Thanks for the kind words, and for the pointer to SenseTalk and Eggplant! I'd never heard of it, so I went off to correct that and ended up at this paper after a few clicks:

"Software Verification of Orion Cockpit Displays", https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/201700...

Very interesting. Though the thought of NASA just using Python and a proprietary solution seems worrying. Maybe it's just for the test harness and other scaffolding, not code that will actually run in orbit.

reply

2 points by christianbryant 34 days ago | link

I know lots of large organizations use Eggplant but this paper is a new one to me. Thanks - had to share this with my co-workers! Everyone seems enthused we share a testing tool with NASA ;-)

I work in Healthcare and we use Eggplant to test a large functional area of our Electronic Health Record (EHR). Like many automation tools, much of the success of the testing comes down to the testing team and how they develop the scripts.

I approach automated scripting design the way I approach programming an app, so I am pretty formal and diligent, I think. Hopefully I am taking lessons learned from Lisp and applying them to my work in automated testing to make the best tests I can.

reply

2 points by christianbryant 35 days ago | link

It's kismet, perhaps, but I also worked on a project called Arc some 9 years ago before I found - well, Arc. It was a build tool chain written in Scheme, developed by Gregor Klinke. I was at the height of my interest in Lisp and Scheme back then, and I liked the idea of this project for potentially building a Software Configuration Management system oriented to Scheme and Lisp.

Looking back at this project with new eyes, perhaps swapping out Scheme for Arc, I wonder...

Arc build tool project http://savannah.nongnu.org/projects/arc

reply

2 points by akkartik 57 days ago | link | parent | on: Problem with assignment

Yes, this is a bug in Arc 3.1: http://arclanguage.org/item?id=17699 [1]

Use Anarki or Anarki's stable branch. The latter is like Arc 3.1 but with a couple of bugfixes.

More details: http://arclanguage.github.io

[1] via google: 'site:arclanguage.org string-set contract violation' :D

reply

2 points by jsgrahamus 55 days ago | link

Windows 10: When I put the anarki folder in D:\, calling it worked fine.

However, when I put the folder in D:\Steve - D\Apps\, I got the following: D:\Steve - D\Apps\anarki>arc.cmd default-load-handler: cannot open module file module path: #<path:D:\Steve> path: D:\Steve system error: The system cannot find the file specified.; errid=2

I figure it has to do with spaces in the pathname, but unsure how to fix it.

reply

3 points by akkartik 55 days ago | link

It sounds like we need to put quotes around the '%arc_dir%boot.rkt' in arc.cmd: https://stackoverflow.com/questions/1851012/set-a-path-varia...

Can you check if that fixes it?

reply

3 points by jsgrahamus 55 days ago | link

That did it.

Thanks, akkartik!

reply

2 points by akkartik 55 days ago | link

Thanks! Wanna submit a Pull Request? ^_^

Not a big deal, I can do it too. But if it's easy you'd get to add your name to the repo :) Let me know.

reply

3 points by jsgrahamus 54 days ago | link

Sure. Never done such before. Where are instructions for it?

reply

2 points by akkartik 54 days ago | link

Maybe this will get too involved. Do you have experience with git, say making commits and so on?

Wanna switch to email? If you click on my username, my profile has my email address.

reply


My experience: https://lobste.rs/s/v17gol/switching_sublime_text_from_vim_2...

-----

2 points by hjek 79 days ago | link

Nice write-up.

I think regardless of whether it's really an editor to use on daily basis, it's quite interesting to see any new take on editor keyboard interaction.

-----

4 points by akkartik 142 days ago | link | parent | on: List comprehensions in Arc

musk_fan, your initial attempt inspired me to build on it :) Now that we can enumerate from a start number to an end, I hanker after something more comprehensive. Also, after reading malisper's description of iterate at http://malisper.me/loops-in-lisp-part-3-iterate, I thought I'd try to mimic its syntax, in hopes that it'll fit better with a Lisp and be extensible.

Here's what I ended up with: http://akkartik.name/post/list-comprehensions-in-anarki. Is the description clear?

-----

2 points by akkartik 117 days ago | link

List comprehensions are now in Anarki: https://github.com/arclanguage/anarki/commit/b7155e56a6

-----

4 points by akkartik 146 days ago | link | parent | on: List comprehensions in Arc

Yes, Arc doesn't come with list comprehensions. But it sounds like a fun exercise to build say a collect macro:

    (collect x for x in xs if odd.x)
I think it may be similar to the loop macro in Common Lisp. There's a Common Lisp implementation of loop at https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/... (via http://malisper.me/loops-in-lisp-part-2-loop by malisper)

-----

3 points by musk_fan 142 days ago | link

I wrote a simple version that only works like so (l 0 9) == '(0 1 2 3 4 5 6 7 8 9):

     (def l (start end)
       (let lis `(1)
         (pop lis)
         (while (<= start end)
           (= lis `(,@lis ,start))
           (++ start))
         lis))
The (collect ...) structure is really cool; I'd forgotten about that; it's been awhile since I touched CLisp

-----

2 points by akkartik 142 days ago | link

Great! A few comments:

1. Is there a reason you start with `(1) and then pop? Why not just initialize lis to nil?

2. Here's a slightly more idiomatic implementation (also more efficient, because it avoids deconstructing and reconstructing lis on every iteration):

    (def l (start end)
      (accum acc
        (for i start (<= i end) ++.i
          acc.i)))
Read more about accum and for:

    arc> (help accum)
    arc> (help for)
(I'm assuming Anarki in the above example. The Arc version is slightly different.)

-----

More