martes, 21 de julio de 2015

My first post on Forth

So...after a very long time...I finally decided to learn Forth...and if I thought I have dealt with difficult programming languages before...I was like Jon Snow...I knew nothing -:(

Forth is a stack based programming language...meaning that you program using a stack with the LIFO functionality...Last In - First Out...

Something like this...you enter 1 2 3 and Forth will output it as 3 2 1...weird, huh?

Of course...I started to read a book...and unlike most other times...I have finish it a long time ago...but with Forth...one book is not just enough...I have been reading and coding like crazy...

The book is Starting Forth by Leo Brodie...


The book itself is really good...it's 166 pages so it's not very long and gives you a nice introduction to the world of Forth...of course...as I said...one book is not enough...and even when this book is really good and highly recommended...Forth is very difficult to grasp but learning it is just amazing -:)

It took me a very long time but finally I was able to come with an example of my already "famous" Fibonacci Numbers...

Fibo.fth
: FIBO 
   1 SWAP 
   0 DUP . 
   ?DO 
      DUP . OVER OVER + ROT DROP 
   LOOP 
   DROP DEPTH 
   DEPTH 2 = IF 2DROP 0 THEN 
;

I told you...Forth is not by any chance and easy language...and actually I wrote the code in just one line...but put it here in different lines to make more clear...

Let's see an image...


I'm sure I going to spend quite more time with Forth...as I feel that's there so much to learn...if you like what you see...learn it too -;) Otherwise...look for something less weird -:)

BTW...I'm using pForth...I used gForth when I first started but I think pForth is more Forth complaint...

Greetings,

Blag.
Development Culture.