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

Pages: 1-4041-

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 2007-09-10 0:31 ID:Heaven

fuck off STACK FAG

Name: Anonymous 2007-09-10 1:28 ID:dxw83E1T

Factor looks like the only one worth learning, since it actually has some relevant libraries.

It also has zero noteworthy tutorials.

Name: Anonymous 2007-09-10 1:33 ID:Heaven

>>1
>>3
STACK FAGS

Name: Anonymous 2007-09-10 1:56 ID:JdAHaYKN

>>3
Factor has very nice documentation and workspace too... i guess i'll go with factor.
Are stack oriented languages worth it though? Or am i wasting my time with rot swap dup swap over ?

Name: Anonymous 2007-09-10 2:04 ID:Heaven

>>5
STACK FAGGOT

Name: Anonymous 2007-09-10 2:36 ID:vEwu+s8Z

>>2,4,6
STACK FAGGOT STILL IN THE CLOSET

Name: Anonymous 2007-09-10 3:23 ID:PeoOIyO4

: (fib) ( n next result -- result ) pick zero? [ 2nip ] [ rot 1- -rot over + swap (fib) ] if ;
: fib ( n -- result ) 1 0 (fib) ;

Name: Anonymous 2007-09-10 3:24 ID:dxw83E1T

>>5
I don't think so, honestly.

You can do funky tricks with them, since they're pretty much Lisp minus the parens, but the readability leaves a lot to be desired.

Name: Anonymous 2007-09-10 5:41 ID:5o5mycBj

>>2-9 STACK FAGGOTS BECAUSE YOU REPLIED TO THE THREAD
>>1, RUN! IT IS CONTAGIOUS!

Name: Anonymous 2007-09-10 5:43 ID:m+tPw7eX

>>9
you dont know lisp

Name: Anonymous 2007-09-10 6:48 ID:g2+im1Xr

>>8
That's almost as ugly as Perl. You want to calculate Fibonacci numbers, and you have to put up with the stack. The language model clearly gets in your way. You need to know Factor to understand these lines, yet I can't possibly think of a Fibonacci implementation that's not trivial in any other language:


(define (fib x)
        (if (< x 2)
            x
            (+ (fib (- x 1)) (fib (- x 2)))))

def fib(x):
    if x < 2: return x
    else:     return fib(x - 1) + fib(x - 2)

fib(x) = lambda x if x < 2 else fib(x - 1) + fib(x - 2)

unsinged int fib(unsigned int x) {
    return x < 2 ? x : fib(x - 1) + fib(x - 2)
}

Name: Anonymous 2007-09-10 9:20 ID:U3CZB9B+

I tried factor, but the hello-world hangs at 100% CPU. It's a piece of shit.

Name: Anonymous 2007-09-10 10:29 ID:WHIEP5VK

I tried factor and it crashed jedit

Name: Anonymous 2007-09-10 10:35 ID:Heaven

TO BAD FACTOR FUCKS SHIT AND STACKFAGS SHOUDL DIE!

Name: Anonymous 2007-09-10 11:22 ID:q7Y2EzAM

>>12
fib(x) = lambda x if x < 2 else fib(x - 1) + fib(x - 2)
That was seriously fucked up, copypasted bits of the def one and failed it.

fib = lambda x: x if x < 2 else fib(x - 1) + fib(x - 2)

Name: Anonymous 2007-09-10 11:41 ID:Q+Fb0Mox

>>12,16
non-tail recursive fib = FAIL.
>>8 is tail recursive.

Name: Anonymous 2007-09-10 22:54 ID:PeoOIyO4

age because i want to see how ugly it will be if >>12 or >>16 do tail recursive fib in their shitty languages

Name: Anonymous 2007-09-11 5:01 ID:mKYw34Im

>>18
(define (fib n)
  (define (iter i a b)
    (cond ((= i 0) a)
          ((= i 1) b)
          (else (iter (- i 1) b (+ a b)))))
  (iter n 0 1))

Name: Anonymous 2007-09-11 7:49 ID:nT9V1pO+

Stack fag is now a meme. I actually invented this meme one day, when someone was asking about ``How to learn forth.''

Name: Anonymous 2007-09-11 11:27 ID:mHjylK78

>>20
I was the first person on this board to use the insult "stack fag"

Name: Anonymous 2007-09-12 16:45 ID:ETHKH4yd

I've seen Expert Programmers debate Lisp vs. Forth. They are surprisingly equivalent in abstraction level. Lisp manipulates lists; Forth manipulates stacks. But Forth is closer to the hardware, and you'll have to worry about word sizes and the like more often in Forth than in Lisp. Conversely, there's a lot of work in embedded microcontrollers going on, and Forth fits in that small space better than Lisp (assuming you need on-board programming).

Name: Anonymous 2007-09-12 21:25 ID:4QjO5CeF

fib = 0:1:(zipWith (+) fib (tail fib))

Name: Anonymous 2007-09-13 8:56 ID:PV9g3/CG

>>23
Shit, nice

Name: Anonymous 2007-09-13 9:12 ID:QnDNytk1

>>23
Stackfag

Name: Anonymous 2007-09-13 9:25 ID:C6NcMZoo

>>25
Fackstag

Name: Anonymous 2007-09-13 10:10 ID:QnDNytk1

>>26
I see what you did there
That's how stack fags think, isn't it?

Name: Anonymous 2007-09-13 12:03 ID:C6NcMZoo

>>27
lllllllllaaaaaaaasdalkjsjdfjjjjjjjjjjjl;kjjjlkjjzxcvbvvvooiuuuwert;lkjadfsgggggggggggg,m.nf,.mnn.,mnnlkjsdfg;lkjxcoijupqwe;jasdfnlxcvnnnnnkjlvlkjljklkj;l;klk;lkjlkjmnnsadffffffffffffffopiuuu;pouiyhaerggi;;;;;uhvaiiiadvvvvvvvvvvvvvho;ijaaaaaaaaaaaaaaifevawhifehiufvpokkkkewqopiwqeoipwqeopiewqkjdcdddddddddddddhhhhhhhasdhlkfhsadbfjjsadbhkhbjkdfbhjkafsmnqqqqqqqqqqqqqmwmwqem,nqwe,nmeqw,nmqew,nmenm,qweijvvvvoisasdfoiuasdfjkwfeakjlhfejhklfehkjfeoiuuvdzoiuviouzdoipudoiuweeeeenkjjerttkjhlzx`cvoisaduasdfkjhawerrrrrrrrrrrrrasdfgsdfgfhrh

Name: Anonymous 2007-09-18 9:42 ID:ThF4J9Z/

much nicer than >>8:
: (fib) ( result next n -- result ) 2dup zero? [ 3drop ] [ roll + swap 1- (fib) ] if ;
: fib ( n -- result ) 0 1 rot (fib) ;

Name: Anonymous 2007-09-18 11:06 ID:y4Z5Oz1t

[/code]: fib ( n -- result ) dup zero? [ 1 ] [ 1- dup fib 1- fib + ] if ;[/code]

much nicer than >>29

Name: Anonymous 2007-09-18 11:33 ID:Heaven

>>30
>>29 is much nicer than that shit because >>29 is tail recursive.
and because your bbcode segfaulted.

Name: Anonymous 2007-09-18 11:52 ID:Heaven

>>23
much nicer than stackshit

Name: Anonymous 2007-09-18 15:25 ID:Heaven

stackshit is just a fucking horrible unreadable shit

Name: Anonymous 2007-09-18 18:33 ID:TflVMsK9

ATTN FACTOR GUY:

Write a Factor intro article following the style of this obsolete but fun Lua intro:
http://www.gamedev.net/reference/articles/article1932.asp

Then maybe more of us will join you.

Name: Anonymous 2007-09-18 20:48 ID:sYOGj6Gb

FORTH:

: NEXT-FIBS OVER + SWAP ;
: FIB 0 1 0 2SWAP DO NEXT-FIBS LOOP DROP ;

I have to say I like Lua better though:

function fib(x)
  local a,b = 0,1
  for i = 1,x do
    a,b = b,a+b
  end
  return b
end

Name: Anonymous 2007-09-18 21:52 ID:Heaven

>>35
YOU ARE NOT FACTOR GUY.
Factor Guy always sages.

Name: Anonymous 2009-02-09 21:05

USING: math.matrices sequences.deep memoize ;
MEMO: fibs ( n -- seq )
 2 + { { 1 1 } { 1 0 } } <array>
 2 identity-matrix [ m. ] binary-reduce
 flatten reverse { 0 1 3 } swap nths ;
MEMO: fib ( n -- r ) dup 3 mod [ - fibs ] keep swap nth ;

Name: Anonymous 2009-02-09 21:31

>>35
local
not forth

Name: Anonymous 2009-02-09 21:44

>>38
Lua
lrn2read

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.

Name: Anonymous 2009-02-09 23:09

Name: Anonymous 2009-02-10 0:24

>>41
Yes. Hopefully before long we'll have a proper book (i.e. something longer than 16 pages).

Name: Anonymous 2009-02-10 0:48

>>42
http://useless-factor.blogspot.com/2007/12/books-that-should-exist.html
Programming with Factor

Factor's included documentation is great, but it's not enough, by itself, to learn Factor. I, and probably most people who know Factor, learned through a combination of experimenting, reading blog posts and the mailing list, and talking on #concatenative. Many people will continue to learn Factor this way, but it still seems somehow insufficient. It should be possible to learn a programming language without participating in its community.

Of course, we can't write a book on Factor until we get to see what Factor will look like in version 1.0. But I'm confident that this book will be written, even if it goes unpublished in print, and I'm fairly sure that I'll have at least some part in it. Maybe it'll be a big group effort by the whole Factor community.

What I'm thinking is that we could have a book which teaches programming through Factor, to people who aren't yet programmers. I've talked a lot about this with Doug Coleman, and we agree that most programming books are bad; we should make a new book that does things very differently. But we can't agree or imagine just how...

Name: Anonymous 2009-02-10 1:45

>>43
Yes.

Name: Anonymous 2009-02-10 22:18

>>43
[quote]...most programming books are bad; we should make a new book that does things very differently. But we can't agree or imagine just how...[/quote]

translate SICP to FUUUUUctor

Name: Anonymous 2009-02-10 23:15

>>40

Oh my fucking god is that an em-dash what is wrong with you?

Name: Anonymous 2009-02-11 1:21

>>46
What's wrong with em-dashes? I use them all the time. I also use en-dashes where appropriate.

Name: Anonymous 2009-02-11 1:26

>>46
lrn2punctuation

Name: Anonymous 2009-02-11 2:32

Have you read your EoS today?

Name: Anonymous 2009-02-11 10:57

>>49
Did you mean: “Have you read your EoS to-day?”?

Name: Anonymous 2009-02-11 11:20

Adiós muchachos

Name: Anonymous 2009-02-25 7:29


The heavens increase your   registry There is   just completely useless   for any real   work in your   way You need   to decide on   an ABI and   parameter passing system   for your operating   system and write   to new stream   z decryption for.

Name: Anonymous 2011-02-02 22:54

Name: Anonymous 2011-02-17 20:07

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