16 ms·
Factor – A practical stack language
- samatman 12y agoI want to like Factor. I've tried to use it a couple of times, and found at least under OSX that the samples I tried to compile (tetris and one other) didn't actually function. More relevantly, I feel like Factor has lost the literal relationship between machine and software that is Forth's distinctive contribution. Our processors have drifted away from that mapping as well, though there are of course GreenArrays and a few other stack chips out there. For a Forth that's pleasant to use and retains that feel, I suggest Retro. The Ngaro virtual machine is pure art, and the additions, particularly the [ and ] quotation words, are thoughtful contributions to the Forth lineage.
- desireco42 12y agoThank you for the pointer. I enjoyed Forth long time ago and wanted to rekindle that love with Factor, but honestly I ran into bumps. I am not giving up, but will definitely check Retro.
- e12e 12y agoThank you for the pointer to retro[1] and related[2] projects! I also sort of found Factor interesting -- but much of the point with Forth, is a high-ish level of abstraction on bare metal hardware. If you're going to be using a vm etc... why not program in something that is much more abstract, like Smalltalk, Lisp, Python -- whatever really? Retro I can get, apparently it is small and very portable -- that makes sense (perhaps not more sense than Smalltalk, though). [1] http://www.forthworks.com/retro/ http://www.forthworks.com/retro/ [2] http://www.forthworks.com/parable/ http://www.forthworks.com/parable/ http://retroforth.org/docs/The_Ngaro_Virtual_Machine.html http://retroforth.org/docs/The_Ngaro_Virtual_Machine.html
- mjackson 12y agoMaybe of interest: Zed Shaw, creator of Mongrel, gave a talk a few years back where he mentioned that he was using Factor to create the slides in his presentation. http://vimeo.com/2723800 http://vimeo.com/2723800
- swah 12y agoSample "presentation" https://github.com/littledan/Factor/blob/master/extra/galois-talk/galois-talk.factor https://github.com/littledan/Factor/blob/master/extra/galois...
- Zikes 12y agoIt's entirely my own failing, but I just can't get the hang of postfix languages. Feels too much like coding in Yodaspeak.
- GregBuchholz 12y agoThe Postscript language might be another chance for you to flex you postfix muscles. Still concatenative, dynamic programming, with built-in graphics.
- kevin_thibedeau 12y agoDon Lancaster[1] is notable for producing a long running newsletter with a library of hand coded Postscript to handle layout and rendering of charts and graphs. He provides all the source code for those interested. [1] http://www.tinaja.com/gurgrm01.shtml http://www.tinaja.com/gurgrm01.shtml
- swah 12y agoSome short functions look so beautiful... but I have a hard time as stuff gets more complex. https://github.com/slavapestov/factor/blob/master/extra/anagrams/anagrams.factor https://github.com/slavapestov/factor/blob/master/extra/anag... IMO this: MEMO: dict-words ( -- seq ) "/usr/share/dict/words" ascii file-lines [ >lower ] map ; is beautiful.
- PurplePanda 12y agoI believe the same is true of other paradigms. Of course complexity is difficult. Do concatenative languages exaggerate the effect?
- exch 12y agoThey 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.
- undrcvr-lagggal 12y agoI've always wanted to learn a Lisp, but I've found Scheme too academic, so I ended up learning other variants such as Common Lisp and Clojure. Could the same thing be said about Factor vs Forth?
- breckinloggins 12y agoYes. Factor definitely has a much more modern feel but loses a lot of the purity. That said, Factor is still pretty "pure" by the standards of most languages. Forthish languages are very interesting. I feel they might even represent a "third way" from the normal LISP / FORTRAN dichotomy.
- kbenson 12y agoThere's a always been more than just those. E.g. declarative languages, such as prolog.
- avmich 12y agoYes, and even "FORTRAN" side represent several approaches - for example, straightforward imperative, like in assemblers or classic BASIC, or structural - which was a big step forward at the time - like Pascal. Then you have object-oriented languages, which are still different from structural, string-oriented Tcl, array-oriented APL...
- kazinator 12y agoYou get Lisp or Fortran by adding discipline and using the stack language as a back end. Then instead of "pop three things off the stack and put one back", that stuff is hidden and generated by the compiler, so (on the plus side) the stack pointer is never wrong. You don't have to worry about: if I take this branch of the conditional, will the stack be left at a different height. Or worse: be tempted to exploit that somehow as a feature. The stack basically disappears from view. And then (on the minus side) you can't do things any more like replace a function that pops three things, by a sequence of two functions where each pops two and puts one back. On the plus side again, because the stack has disappeared, you can really change how it is represented. Like pass and return in registers; aggressively inline functions, etc.
- bcheung 12y agoI really love the power of Factor. It is probably the most powerful language I have ever come across. That being said, I think there needs to be a more interactive method where you can see things on the stack in real time as you are programming. I found myself not being able to focus on the problem I wanted to solve and instead was spending too much of my brainpower on remembering what was on the stack where. If you study human computer interaction and cognetics the human brain can only remember so many short term memory "variables" at once. Programming in Factor uses up too many of those spaces. I think the problem can be solved though if the development environment shows the stack at each point in time; that way the computer does the thinking instead of the programmer. One way to do this is to supply some arguments to the word (function) and as you manipulate it in real time you can see how it is transformed. Your steps get recorded as the word. This solves the problem of programming blind and having to play interpreter in your head as you are programming. Thus, freeing up cognitive space and making the programmer more efficient.
- innguest 12y ago> I think the problem can be solved though if the development environment shows the stack at each point in time; that way the computer does the thinking instead of the programmer. If you're up for it I have some code that I wrote with this very idea in mind, in Factor. I'll put it on github later today and put the link here anyway. I agree with you 100%. If Factor were transparent that way and interactive that way (to the point it's almost like a dialog, which it already almost is with its Listener but you and I want stack transparency) then it would probably be one of the most productive languages for fast prototyping (at least).
- bcheung 12y agoI'd be curious to take a look. I have plans to do something similar but in the browser in Javascript. Basically, build up the AST based on the commands that are issued against the stack. Then use the Mozilla Parser API to generate Javascript code. Additionally, with the example arguments supplied you have test driven develop built right in. Not only do you get tests, but it helps you visualize things as you program.
- swah 12y agoIIUC the creator, which had already written a popular text editor (jEdit), and now a successful programming language, considered his objectives complete with Factor and moved on. AFAIK he still works at Google, and never posted in his blog again (http://factor-language.blogspot.com/ http://factor-language.blogspot.com/).
- koverstreet 12y agoI think the current rumor is that he's now doing lots of drugs and working full time on bcache.
- swah 12y agoI did not know about the bcache thing - interesting!
- doublec 12y agoI used to use Factor as my main programming language for a few years and really enjoyed the language and environment. It feels like a mix of Forth, Lisp and Smalltalk. I wrote a number of blog posts about it which might help give a feel for what can be done in the language: http://bluishcoder.co.nz/tags/factor/ http://bluishcoder.co.nz/tags/factor/
- openthedamper 12y agoChris, amazing body of work at your blog. What are your thoughts on the continued maintenance factor and long term viability? what caused you to drop out?
- pseudonom- 12y agoI wonder what makes them say this in the FAQ: "a flexible enough type system for concatenative languages has not yet been designed. However, Factor 2.0 may include optional static typing, if a suitable type system can be found." http://kittenlang.org/ http://kittenlang.org/ gives the impression of having a fairly sensible static type system.
- evincarofautumn 12y agoHey, I’m the author of Kitten. The site & repo are a bit out of date, but I’m currently working on a release. Would be happy to answer any questions. :) I think the problem is that you want some words with dynamic/value-dependent stack effects. It’s hard to intermingle static and dynamic typing well, and hard to bring the utility of dependent typing for enforcing program properties into the realm of properties that are actually useful to enforce while remaining usable.
- LBarret 12y agoSlava created an interesting language but I never saw an explaination of why he moved away from Factor. He just stopped (writing and caring ?) about it.
- gyim 12y agoIt took me a while to find at least some explanation of what happened: http://article.gmane.org/gmane.comp.lang.factor.general/4940 http://article.gmane.org/gmane.comp.lang.factor.general/4940 http://article.gmane.org/gmane.comp.lang.factor.general/4505 http://article.gmane.org/gmane.comp.lang.factor.general/4505 Still, it's so strange to me: not only Slava disappeared, but most of the original authors stopped participating in the development and even stopped blogging about Factor. See http://planet.factorcode.org http://planet.factorcode.org - most blogs have been abandoned for years, some of them are dead links... Also, I have not found any public announcement about who will maintain Factor in the future. I really like what I know about Factor, and I have tremendous respect for Slava and others who created this language. I looked into the code a little bit, and it looks a very well-thought and very serious work, and I have no idea how they could create it in such a short time. Still, you can't manage a project like this. No matter how great the language is technically, I won't start using it for any serious work if I don't see any vision, any chance that the project will not get stuck in this stage. I really hope that Factor will overcome these challenges. It would be so sad to see such a brilliant piece of work to be abandoned.
- orbifold 12y agoOne thing I find interesting about stack languages is that if you imagine the stack tilted by 90 degrees, you realize that you are doing operations in some monoidal category.
- Francky 12y agoMaybe of interest too : oforth language