Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I believe the same is true of other paradigms. Of course complexity is difficult. Do concatenative languages exaggerate the effect?


I think so sir - I had only a couple beers and can't parse the function below.

    : <color-picker> ( -- gadget )
        vertical <track>
            { 5 5 } >>gap
            <color-sliders>
            [ f track-add ]
            [
                [ <color-model> <color-preview> 1 track-add ]
                [
                    [
                        vtruncate v>integer
                        first3 3dup "%d %d %d #%02x%02x%02x" sprintf
                    ] <arrow> <label-control>
                    f track-add
                ] bi
            ] bi* ;


It helps to be familiar with the words (Factor term for functions) in use. You can use http://docs.factorcode.org to look them up. All the help is also available from within Factor itself. You can click on word definitions and it comes up.

In this case there is a word called '<color-picker>' being defined. It takes no arguments off the stack and leaves one, gadget, on it.

Now working from left to right, 'vertical' is a constant. '<track>' creates a new GUI object called a track that requires the orientation to be on the stack. That what 'vertical' is. It's the orientation.

Now that there is a track object there we fill in the slots of that object. That's what '>>foo' does. It stores something in the 'foo' slot of the object on the stack. So "{ 5 5 } >>gap" stores the 2 element vector containing the integer 5 twice, into the 'gap' slot.

'<color-sliders>' creates a gadget and a model that is left on the stack. This is what 'bi-star' is now operating on.

'bi-star' is a combinator. It requires two objects and two quotations (quotations are factors term for anonymous functions or closures). It applies the first quotation to the first object, and the second to the second object. This system of combinators is described in the Joy language writings, although I think under different names.

"[ ... ]" is the syntax for the quotation. So "[ f track-add ]" is the first quotation. "bi-star" call this with the 'track' on the stack since that's the first object that "bi-star" gets access to.

The rest of the code can be worked through in a similar manner. In general you learn to recognise things like "<...>" for creating objects, ">>foo" for setting slots, "[ ... ]" for quotations and combinators to reduce stack management (like dup, rot, pick, etc).


Are you experienced with the language?

I can't parse it either, but I don't know if "readability for a beginner" is a metric I care a whole lot about in a programming language.


They do in my (marginal) experience. I have found it to be a very common idiom to keep word definitions in these languages as short as possible. Probably for this very reason.

You define new words for the sole purpose of keeping things short and to the point. This holds true for most languages (At least if you want readable and maintainable code), but a language like Factor, this becomes an absolute necessity.

I would not be surprised if this is the reason Factor is called Factor. Specifically when related to factoring in Algebra where you do much the same thing: "splitting" an expression into a multiplication of simpler expressions.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: