Arc Forumnew | comments | leaders | submit | aw's commentslogin
4 points by aw 329 days ago | link | parent | on: What's broken about my "copy file" function?

Not all binary sequences encode valid utf-8 characters.


4 points by akkartik 329 days ago | link

This was my first thought as well. But why does `readc` (Racket's `read-char`) silently accept invalid utf-8?


5 points by rocketnia 300 days ago | link

It's reading the invalid sequence as � U+FFFD REPLACEMENT CHARACTER, which translates back to UTF-8 as EF BF BD (as we can see in the actual results above). The replacement character is what Unicode offers for use as a placeholder for corrupt sequences in encoded Unicode text, just like the way it's being used here.


5 points by aw 913 days ago | link | parent | on: ASK: Is arc better than clojure?

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

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

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

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

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

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

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

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

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

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

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

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

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

- UX (user experience design); I've heard that Design for Hackers is popular

- user testing

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

Now, that said, if you want to learn Lisp, Clojure is a good choice. There are books on Clojure available to learn from, and it's supported by platforms such as Heroku for example (

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

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

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

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

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

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

I hope this helps! :)



3 points by aw 950 days ago | link | parent | on: Capturing the Dynamic Environment


I think for it to be a good tutorial, it ought to do something that's useful on its own. Maybe an implementation of generators or something like that. `capture-dyn` is a useful tool for working with continuations (it seems like), but I think as a tutorial it may be a bit esoteric since you'd already need to know about the interaction of continuations with dynamic scope to see when and why you'd want to use `capture-dyn`.


2 points by aw 952 days ago | link | parent | on: A Functional Implementation of Dynamic Scope

Sounds like it. The idea is that you have some irreducible amount of imperative state out in the "real world" (files in the OS, your hardware screen, etc), and the goal is to keep that as small a part of your language as possible -- so that the rest of your language can be as functional as possible.


4 points by aw 1050 days ago | link | parent | on: POST requests in Arc

Arc handles HTTP requests character by character, which is fine for form submits or REST APIs, but not what you want for handling large binaries.

To be able to handle image uploads directly in Arc, you'd want an HTTP server implementation which supported binary buffers.

But, not everything needs to be implemented directly in Arc. Instead you could use e.g. Ngnix or Apache to handle the image uploads, or upload the images directly to AWS S3 from the browser.


2 points by hjek 1049 days ago | link

Interesting! Arc is reading the request one character at the time. I think I see where it's happening, in the handle-request-thread function where readc is called. So, for Nginx/Apache, are you suggesting Arc might be able to handle uploads if it's sitting behind Nginx/Apache acting as reverse proxy doing buffering? Or is it more like doing anything with big files in Arc is a no-go, so it's better to have a separate setup of Nginx/Apache (with PHP or whichever) handling file the uploads?


3 points by aw 1049 days ago | link

> So, for Nginx/Apache, are you suggesting Arc might be able to handle uploads if it's sitting behind Nginx/Apache acting as reverse proxy doing buffering?

Nope, that won't help.

> so it's better to have a separate setup of Nginx/Apache (with PHP or whichever) handling file the uploads

That's the easiest approach. Not that you'd need PHP, just pop in a module to handle file uploads for you.

> Or is it more like doing anything with big files in Arc is a no-go

Not Arc as such but the implementation in srv.arc isn't designed for large files. You could read the old MZScheme documentation at and figure out how to read an input stream into a binary buffer, but it would be more work.


1 point by hjek 1046 days ago | link

Thanks a lot for helping clear that up. Those limitations of Arc are definitely not immediately obvious from reading the docs and essays available on the language.


1 point by aw 2574 days ago | link | parent | on: Possible bug in coerce with quoted nils?

Just to be clear :-), I wasn't advocating for the behavior, merely answering the question if was there any use for it ^_^


1 point by rocketnia 2574 days ago | link

Thanks for not taking that too harshly. XD


2 points by aw 2574 days ago | link | parent | on: possible bug involving len and nil?

Which Arc implementation are you using? This is not the behavior of Arc 3.1


3 points by aw 2582 days ago | link | parent | on: Beginner - Programming without Prior Knowledge

The Arc tutorial:

Practice the examples in the tutorial yourself:


2 points by aw 2589 days ago | link | parent | on: Syntax.for(lisp)

secret formatting instructions:


1 point by aw 2591 days ago | link | parent | on: On Modules

Ah, so when a macro gets evaluated, it gets evaluated in its namespace? That's clever!


1 point by Pauan 2591 days ago | link

Yes. At runtime. Even ignoring the inefficiency of expanding macros at runtime, there's one other thing that concerns me, and that's anaphoric macros.

If somebody writes a macro like "aif" or "aand" or whatever, you want the variable "it" to refer to the caller's namespace, but all the other variables to refer to the definer's namespace...

I think this is a solvable problem, but I think it'll require more complexity to solve.

By the way, I think I can add in a system where you can selectively choose which variables should be expanded in your namespace, and which ones shouldn't. Something like this:

  (import foo)

  (w/names (it)
This says that the variable "it" should be expanded into your namespace, and all other variables should be expanded in foo's namespace.

Interestingly enough, if I implemented such a system, you could then overwrite certain variables in a macro's body:

  (def helper (x)
    (+ x 50))

  (foo!something) -> 15 ; uses foo's version of helper

  (w/names (helper) ; uses my version of helper
    (foo!something)) -> 60


1 point by Pauan 2591 days ago | link

Actually, there's another thing that also concerns me... Consider this macro:

  (def foo args
    (apply prn args))

  (mac bar (x . args)
    `(foo (string ,x) ,@args))
If you call bar, you want the variables "x" and "args" to be expanded in your namespace, but everything else to be expanded in bar's namespace.