Factor: an extensible interactive language
HTML-код
- Опубликовано: 6 фев 2025
- Google Tech Talks
October 27, 2008
ABSTRACT
Factor is a general-purpose programming language which has been in development for a little over five years and is influenced by Forth, Lisp, and Smalltalk. Factor takes the best ideas from Forth -- simplicity, succinct code, emphasis on interactive testing, meta-programming -- and brings modern high-level language features such as garbage collection, object orientation, and functional programming familiar to users of languages such as Python and JavaScript. Recognizing that no programming language is an island, Factor is portable, ships with a full-featured standard library, deploys stand-alone binaries, and interoperates with C and Objective-C.
In this talk, I will give the rationale for Factor's creation, present an overview of the language, and show how Factor can be used to solve real-world problems with a minimum of fuss. At the same time, I will emphasize Factor's extensible syntax, meta-programming and reflection capabilities, and show that these features, which are unheard of in the world of mainstream programming languages, make programs easier to write, more robust, and fun.
Speaker: Slava Pestov
Slava was born in the former USSR and emigrated to New Zealand at the age of 7. He moved to Ottawa, Canada when he was 18 to study for a Bachelors and Masters degree in Mathematics. He now resides in Minneapolis, Minnesota. An early adopter of Java, Slava wrote the popular jEdit text editor, then went on to design and implement the Factor programming language. At his day job he hacks on web apps, optimizing compilers, garbage collectors, and everything in between.
I keep coming back to this talk every few years! Never ceases to inspire me.
thank you for thinking of the online viewers and repeating the questions into the mic
and thank you for Factor, of course, it's a beautiful language!
This is one of the most inspirational programming language talks I have ever watched!
The further I got into the video, the more I got impressed
With the rectangle area example in classes part ~22 mins in, why use quotations and immadiately dequote again with bi operator ( [width>>] [height>>] bi *)? Couldn't you just do it directly like (width>> height>> *)?
It is a very interesting and fun language, but there needs to be more tutorial videos and written tutorials. This video is a good introduction, but not enough to become good with the language. It is not easy to learn because it take a while to get accustomed to using the stack. If you actually install the language, you will see the listener and the help window and the language and basic utilities are really impressive. There are load of useful functions. And it is so easy to extend. And when you extend it, the new functions become part of the language. I like the way you can factor out code until you have very simple and descriptive functions(words). Your own words become integrated into the help window automatically. You can call help and see the words you created. That is impressive.
can you recommend a good factor book or tutorial ?
Great talk!
This is pretty amazing!
Per Wikipedia, the last stable release of Joy was in 2003.
Message passing is great for cluster and cloud scalability. I'm looking for something simple in implementation to do multinode object system, and Forth and more closely Factor looks good for low-level script language to manage and create objects in this distributed database-like system.
Are any materials exists on Factor implementation? I'd like to have bootstrap VM written in Python for first steps (metaprogramming and dynamic compilation in the first place). Not a complex thing to do it myself, but it will be great to view some tricks used in Factor.
a guy named jephthai wrote a vm reverse shell in forth for his job as a penetration tester. It's called evilVM and can be found on google if you search either name
Haskell doesn't *really* have this problem. Classes are groupings of functions, and you can later make things instances of those classes by defining functions of that class for your new object.
I don't see a major advantage yet to factor, but the Forthiness is neat.
Haskell expresses things backwards unless you use (&) which is flip($) or a & f = f a. This means you can't just take data and then write code in terms of that data and create a function from that viewing the intermediate values. Its pretty trivial to change Factor code to Haskell code though if you just parsed Haskell code into Lisp code first, then you can use Factor/Joy as a fast way to code Haskell, Lisp, Python, Julia, etc... while seeing the intermediate values.
@@aoeu256 What are the best stack based/ concatenative languages in your opinion?
haskell does have this problem, and so does factor. you say it doesn't because, to add a new type to a typeclass, you just have to implement that typeclass's minimal interface... but that's the problem. that's the same as his ml example, just a bit more roundabout. factor's generics are the same way too.
the problem in question is actually very deep. the problem is how to add a new type in such a way as to get as many method definitions for free as possible, ideally, all of them. for instance, in the shape example, if the method dispatcher could do geometry, then it could give you area for free, and the base cass would be much more abstract, basically defining what area means in geometry.
that's a lot to ask from a programming language.
what he said about ruby (@ 45 mins) is only true of block parameters, not true of variables defined within the block/lambda in general. Further this was acknowledged as a 'bug' and is fixed in the most recent version of ruby.
How about:
[ ... code here in forward polish notation ... ] reverse call
So for example I could write:
[ map [ 1 + ] [a,b] 1 10 ] reverse call
Which reads: map the plus one function onto the integers from one to ten. At school we learn to read left-to-right. The computer can read either way, it doesn't care.
Of course you could write it better, and make it traverse down all quotations. Isn't this more readable?
No, because now you're back and forth and back and forth, RPN is solid.
See >> Wolfram Langage ::: Mathematica
Can't you use factor as an alternate postfix syntax for Haskell, Lisp, Julia, Python, Scala, Idris? You'd have a tabbed IDE that could show the code in Infix notation, S-expression notation, and postfix notation then you'd have a little animation that tweened how the symbols mapped in between the notations. It'd be nice to program in postfix that allows you to see the individual values.
what is program domain for this?
Thank you Slava!
boa constructor... nice :)
I noticed :) They didn't laugh. But it is great humour.
In a generic language like Haskell, or C++ with concepts, you really don't have the second problem of extending existing operations with new types. You don't add a new case to type switches for pattern matching. You decouple your algorithms from your data and code against algebraic operations. For example, you write your code so that it works for all foldable types and then if you want to extend an existing operation with a new type, you just make your new type foldable. This forcing to work in a generic setting might be limiting but it actually gives you a coding discipline, it forces you to write mathematically sound code. A fully-extendable CLOS like system is open to writing sloppy code just like Java, old C++, Smalltalk etc.
And compiler would show me the places I need to change, if I updated any of my product or sum types. Because it would not typecheck. I think I can't go back to dynamic languages after the taste of static type-checking, sorry.
Typing is just a library in Factor, optional as it should be ;)
PS: keep in mind this is an old presentation, back then there was only "stack typing", now there's a lot more. Check docs.factorcode.org/content/article-typed.html
How different from Joy?
estas tre sprita en la komenco: "saluton, cxiuj!" Kaj oni vidas preskaux neniun!!
It's so funny at the beginning. The guy says: "hello, everybody" and you can see almost nobody in the audience!!
You think Googlers weren't streaming this out live to their desks. Geez.
It seems a lot like Joy.
Not a coincidence, Factor takes inspiration from Joy and the theoretical work on concatenative programming by Manfred von Thun.
In particular, the preference on combinators (Joy's way) over stack shuffles (Forth's way) is a giveaway.
Lol, so they created a rpn (reverse polish notation) language to act as alike the calculator. neat.
this is a crazy comment