Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

stack based languages

Name: Anonymous 2007-09-10 0:18 ID:JdAHaYKN

Hello, i am interested in learning a stack oriented language, so i started learning Forth. (from http://www.amresearch.com/starting_forth/)
Some alternatives i heard of are cat and factor.

What is best to learn from those? And suggest a good tutorial

Name: Anonymous 2009-02-09 22:56

>>1
Wow, I see this thread and I'm like, "Too bad I showed up to late to have any valuable input." Not so, apparently.

Factor is the correct choice here. It's the only concatentative language (besides Forth) that even has intentions of being a real boy, as far as I can tell. And it's actually doing a very good job of it. The downfall (at this time) is that there is very little introductory material. You can probably learn to write algorithms in it on your own. Writing a GUI program is going to require deciphering examples, which aren't badly written but are written in a language you don't know using libraries with no overview. At least the whole system and its libraries are documented. OTOH, I think a introductory material phase is coming when Factor hits 1.0, and from what I've seen of the people behind Factor, it's actually going to happen.

>>5
Are stack oriented languages worth it though? Or am i wasting my time with rot swap dup swap over ?
Yes, no, in that order.

I'm still a stack nub, but I've been Lisping for a while and concatenative languages are looking really good from here. Forth's a neat language, but lacks a lot of modern features. Thanks to being roughly Lisp-equivalent, you can actually write elegant programs despite this, but it's not necessarily something you want to do all the time. Factor, on the other hand, seems pretty much like an improved CL in every way.

I'll start with the second yes. Yes, you're wasting your time with shuffle words because using combinators whenever possible is best. Learn those well, and try to forget you know any shuffle words.

For the first yes, part of the reason concatenative languages are so cool is because combinators to encapsulate some of the most common patterns can be implemented, since words allow factoring at a finer granularity than functions (you can start a word "in the middle" of an expression whereas functions always need to operate through arguments.

Combinators are possible in Lisp:
[m](defun bi (function-1 function-2 &rest args)
  (values (apply function-1 args)
          (apply function-2 args)))

;; But in use, shit's clunky as hell.
(multiple-value-bind (a b)
  (bi (lambda (x) (* x 2))
      (lambda (x) (* x 3))
      2))[m]

Combinators are cool from both directions: they're both a way to avoid stackrobatics, and a reason to use a concatenative language in the first place — elegant expression of a fundamental type of logic.

The other part of the reason for the first yes is that concatenative languages, since they don't have variables [as the primary way of handling values], more clearly depict the flow of data, which is the interesting thing.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List