FORTH A slightly different Programming System Carsten Strotmann, - - PowerPoint PPT Presentation

forth
SMART_READER_LITE
LIVE PREVIEW

FORTH A slightly different Programming System Carsten Strotmann, - - PowerPoint PPT Presentation

Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover FORTH A slightly different Programming System Carsten Strotmann, Forth Gesellschaft e.V. 21st Chaos Communication Congress Carsten Strotmann FORTH


slide-1
SLIDE 1

Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

FORTH

A slightly different Programming System Carsten Strotmann, Forth Gesellschaft e.V. 21st Chaos Communication Congress

Carsten Strotmann FORTH

slide-2
SLIDE 2

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-3
SLIDE 3

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-4
SLIDE 4

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

BIRTH OF FORTH

The early years

the first program to be called Forth was written in about 1970 by Charles Moore. An Open Source Forth called FIG-FORTH made Forth known on many computer enthusiasts on may architectures. In the late 70s and during the 80s, Forth was often used on Mirco- and Home-Computer Systems.

Carsten Strotmann FORTH

slide-5
SLIDE 5

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

BIRTH OF FORTH

The early years

the first program to be called Forth was written in about 1970 by Charles Moore. An Open Source Forth called FIG-FORTH made Forth known on many computer enthusiasts on may architectures. In the late 70s and during the 80s, Forth was often used on Mirco- and Home-Computer Systems.

Carsten Strotmann FORTH

slide-6
SLIDE 6

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

BIRTH OF FORTH

The early years

the first program to be called Forth was written in about 1970 by Charles Moore. An Open Source Forth called FIG-FORTH made Forth known on many computer enthusiasts on may architectures. In the late 70s and during the 80s, Forth was often used on Mirco- and Home-Computer Systems.

Carsten Strotmann FORTH

slide-7
SLIDE 7

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

The Name

How did Forth get its name? Charles Moore: The first time I combined the ideas I had been developing into a single entity, I was working on an IBM 1130, a "third-generation" computer. The result seemed so powerful that I considered it a "fourth generation computer language." I would have called it Fourth, except that the 1130 permitted only five-character identifiers. So Fourth became Forth, a nicer play

  • n words anyway.

Carsten Strotmann FORTH

slide-8
SLIDE 8

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-9
SLIDE 9

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today

Forth is available for a wide range of architectures

native on bare hardware (i386-ia64, amd64, ppc, sparc ...) hosted on Operating Systems (Linux/Unix, Dos, embedded OS, even Windows ...)

  • r embedded in other Systems (Java, .NET, JavaScript,

BASH ...)

  • r as a Machine Language in Hardware (µCore, b16 ... )

Carsten Strotmann FORTH

slide-10
SLIDE 10

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today

Forth is available for a wide range of architectures

native on bare hardware (i386-ia64, amd64, ppc, sparc ...) hosted on Operating Systems (Linux/Unix, Dos, embedded OS, even Windows ...)

  • r embedded in other Systems (Java, .NET, JavaScript,

BASH ...)

  • r as a Machine Language in Hardware (µCore, b16 ... )

Carsten Strotmann FORTH

slide-11
SLIDE 11

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today

Forth is available for a wide range of architectures

native on bare hardware (i386-ia64, amd64, ppc, sparc ...) hosted on Operating Systems (Linux/Unix, Dos, embedded OS, even Windows ...)

  • r embedded in other Systems (Java, .NET, JavaScript,

BASH ...)

  • r as a Machine Language in Hardware (µCore, b16 ... )

Carsten Strotmann FORTH

slide-12
SLIDE 12

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today

Forth is available for a wide range of architectures

native on bare hardware (i386-ia64, amd64, ppc, sparc ...) hosted on Operating Systems (Linux/Unix, Dos, embedded OS, even Windows ...)

  • r embedded in other Systems (Java, .NET, JavaScript,

BASH ...)

  • r as a Machine Language in Hardware (µCore, b16 ... )

Carsten Strotmann FORTH

slide-13
SLIDE 13

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today (2nd)

Forth is often used “invisible”

as the Firmware (or BIOS) of all Apple and SUN Sparc Machines as a Bootloader in FreeBSD as embedded Software, e.g. in Vending Machines

  • r F1 Race Cars
  • r Satellites

Carsten Strotmann FORTH

slide-14
SLIDE 14

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today (2nd)

Forth is often used “invisible”

as the Firmware (or BIOS) of all Apple and SUN Sparc Machines as a Bootloader in FreeBSD as embedded Software, e.g. in Vending Machines

  • r F1 Race Cars
  • r Satellites

Carsten Strotmann FORTH

slide-15
SLIDE 15

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today (2nd)

Forth is often used “invisible”

as the Firmware (or BIOS) of all Apple and SUN Sparc Machines as a Bootloader in FreeBSD as embedded Software, e.g. in Vending Machines

  • r F1 Race Cars
  • r Satellites

Carsten Strotmann FORTH

slide-16
SLIDE 16

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today (2nd)

Forth is often used “invisible”

as the Firmware (or BIOS) of all Apple and SUN Sparc Machines as a Bootloader in FreeBSD as embedded Software, e.g. in Vending Machines

  • r F1 Race Cars
  • r Satellites

Carsten Strotmann FORTH

slide-17
SLIDE 17

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Birth of Forth Forth Today

Forth today (2nd)

Forth is often used “invisible”

as the Firmware (or BIOS) of all Apple and SUN Sparc Machines as a Bootloader in FreeBSD as embedded Software, e.g. in Vending Machines

  • r F1 Race Cars
  • r Satellites

Carsten Strotmann FORTH

slide-18
SLIDE 18

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-19
SLIDE 19

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth Simplicity

Forth has just two rules:

1

You have NUMBERS (in any numeric base you could imagine). They are pushed on to the DATA STACK or compiled on to the DICTIONARY.

2

You have SYMBOLS. They are searched through the DICTIONARY and, if found, EXECUTED or compiled on to the DICTIONARY too.

Forth has two main modes: EXECUTE and COMPILE. Depending what mode you are in, the behavior of numbers and symbols changes accordingly. That’s it. Everything else is about WORDS, that means, what one of the SYMBOLS does when EXECUTED.

Carsten Strotmann FORTH

slide-20
SLIDE 20

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth Simplicity

Forth has just two rules:

1

You have NUMBERS (in any numeric base you could imagine). They are pushed on to the DATA STACK or compiled on to the DICTIONARY.

2

You have SYMBOLS. They are searched through the DICTIONARY and, if found, EXECUTED or compiled on to the DICTIONARY too.

Forth has two main modes: EXECUTE and COMPILE. Depending what mode you are in, the behavior of numbers and symbols changes accordingly. That’s it. Everything else is about WORDS, that means, what one of the SYMBOLS does when EXECUTED.

Carsten Strotmann FORTH

slide-21
SLIDE 21

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth Simplicity

Forth has just two rules:

1

You have NUMBERS (in any numeric base you could imagine). They are pushed on to the DATA STACK or compiled on to the DICTIONARY.

2

You have SYMBOLS. They are searched through the DICTIONARY and, if found, EXECUTED or compiled on to the DICTIONARY too.

Forth has two main modes: EXECUTE and COMPILE. Depending what mode you are in, the behavior of numbers and symbols changes accordingly. That’s it. Everything else is about WORDS, that means, what one of the SYMBOLS does when EXECUTED.

Carsten Strotmann FORTH

slide-22
SLIDE 22

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth Simplicity

Forth has just two rules:

1

You have NUMBERS (in any numeric base you could imagine). They are pushed on to the DATA STACK or compiled on to the DICTIONARY.

2

You have SYMBOLS. They are searched through the DICTIONARY and, if found, EXECUTED or compiled on to the DICTIONARY too.

Forth has two main modes: EXECUTE and COMPILE. Depending what mode you are in, the behavior of numbers and symbols changes accordingly. That’s it. Everything else is about WORDS, that means, what one of the SYMBOLS does when EXECUTED.

Carsten Strotmann FORTH

slide-23
SLIDE 23

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

How it works

Forth is a stack-based language based on PostfixNotation

all processing is done in “WORDS”, the Forth name for “Subroutines” Operations and function calls (Words) are placed after their arguments arguments are pushed on the data stack by the user or

  • ther “Words”, and then popped off the data stack by the

“Words”, performing their operation, and then pushing the results back on the data stack. Forth Systems can be Interpreter or Native-Compiler, or both, or Cross-Compiler.

Carsten Strotmann FORTH

slide-24
SLIDE 24

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

How it works

Forth is a stack-based language based on PostfixNotation

all processing is done in “WORDS”, the Forth name for “Subroutines” Operations and function calls (Words) are placed after their arguments arguments are pushed on the data stack by the user or

  • ther “Words”, and then popped off the data stack by the

“Words”, performing their operation, and then pushing the results back on the data stack. Forth Systems can be Interpreter or Native-Compiler, or both, or Cross-Compiler.

Carsten Strotmann FORTH

slide-25
SLIDE 25

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

How it works

Forth is a stack-based language based on PostfixNotation

all processing is done in “WORDS”, the Forth name for “Subroutines” Operations and function calls (Words) are placed after their arguments arguments are pushed on the data stack by the user or

  • ther “Words”, and then popped off the data stack by the

“Words”, performing their operation, and then pushing the results back on the data stack. Forth Systems can be Interpreter or Native-Compiler, or both, or Cross-Compiler.

Carsten Strotmann FORTH

slide-26
SLIDE 26

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

How it works

Forth is a stack-based language based on PostfixNotation

all processing is done in “WORDS”, the Forth name for “Subroutines” Operations and function calls (Words) are placed after their arguments arguments are pushed on the data stack by the user or

  • ther “Words”, and then popped off the data stack by the

“Words”, performing their operation, and then pushing the results back on the data stack. Forth Systems can be Interpreter or Native-Compiler, or both, or Cross-Compiler.

Carsten Strotmann FORTH

slide-27
SLIDE 27

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

How it works

Forth is a stack-based language based on PostfixNotation

all processing is done in “WORDS”, the Forth name for “Subroutines” Operations and function calls (Words) are placed after their arguments arguments are pushed on the data stack by the user or

  • ther “Words”, and then popped off the data stack by the

“Words”, performing their operation, and then pushing the results back on the data stack. Forth Systems can be Interpreter or Native-Compiler, or both, or Cross-Compiler.

Carsten Strotmann FORTH

slide-28
SLIDE 28

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth Programmers create Applications by extending Forth

creating (compiling) new Words (there is no difference between supplied Forth Words and User-defined Words) Programmers can choose to hide the Forth System in their application...

  • r choose to expose the System, e.g. as a powerful Macro

Language

Carsten Strotmann FORTH

slide-29
SLIDE 29

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth Programmers create Applications by extending Forth

creating (compiling) new Words (there is no difference between supplied Forth Words and User-defined Words) Programmers can choose to hide the Forth System in their application...

  • r choose to expose the System, e.g. as a powerful Macro

Language

Carsten Strotmann FORTH

slide-30
SLIDE 30

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth Programmers create Applications by extending Forth

creating (compiling) new Words (there is no difference between supplied Forth Words and User-defined Words) Programmers can choose to hide the Forth System in their application...

  • r choose to expose the System, e.g. as a powerful Macro

Language

Carsten Strotmann FORTH

slide-31
SLIDE 31

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-32
SLIDE 32

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-33
SLIDE 33

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-34
SLIDE 34

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-35
SLIDE 35

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-36
SLIDE 36

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Forth is not (only) the tool

Programming in Forth is somewhat different to “mainstream” languages

in Pascal, Perl, C/C++, Basic, there is a clear distinction between

the Tool (the Programming Language Compiler/Interpreter) and the Application (Binary or Sourcecode)

in Forth, a Basic Forth System will be extended and changed to become the Application = Tool and Application are not distinct

Carsten Strotmann FORTH

slide-37
SLIDE 37

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-38
SLIDE 38

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

What does it look like

C1 The function main

main() /* test power function */ { int i; for (i=0; i<10; ++i) printf("%d %d %d\n", i, power(2,i), power(-3,i)); }

Forth A word to test “power”

: main ( – ) \ test power function 10 0 do i . 2 i power . -3 i power . cr loop ;

1Example taken from Holon Forth Website Carsten Strotmann FORTH

slide-39
SLIDE 39

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

More Forth vs. C

C2 Here is the K&R version of the function power power(x,n) /* raise x to the n-th power; n > 0 */ int x,n; { int i,p; p = 1; for (i=1; i<=n; ++i) p = p * x; return(p); }

2Again: Example taken from Holon Forth Website Carsten Strotmann FORTH

slide-40
SLIDE 40

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

More Forth vs. C

In Forth it can be written as Definition of Word “power” : power ( x n – p ) \ raise x to the n-th power; n > 0 1 swap 0 do over * loop nip ;

Carsten Strotmann FORTH

slide-41
SLIDE 41

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

More Forth vs. C

  • r in more detail

Definition of Word “power” : power ( x n – p ) \ raise x to the n-th power; n > 0 1 swap \ – x 1 n \ – x 1 n 0 do \ – x 1

  • ver

\ – x 1 x * \ – x 1*x, finally: – x x^n loop nip \ – x^n ;

Carsten Strotmann FORTH

slide-42
SLIDE 42

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-43
SLIDE 43

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth can be easily extended because the programmer has full access to the underlying system extending Forth is changing the Forth System (including the Forth Compiler and/or Interpreter) Porting Forth to a new Processor or OS can be done in 1-2 Weeks (or less) New Ideas can be added to the language easily (like OOP , Object Oriented Programming)

Carsten Strotmann FORTH

slide-44
SLIDE 44

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth can be easily extended because the programmer has full access to the underlying system extending Forth is changing the Forth System (including the Forth Compiler and/or Interpreter) Porting Forth to a new Processor or OS can be done in 1-2 Weeks (or less) New Ideas can be added to the language easily (like OOP , Object Oriented Programming)

Carsten Strotmann FORTH

slide-45
SLIDE 45

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth can be easily extended because the programmer has full access to the underlying system extending Forth is changing the Forth System (including the Forth Compiler and/or Interpreter) Porting Forth to a new Processor or OS can be done in 1-2 Weeks (or less) New Ideas can be added to the language easily (like OOP , Object Oriented Programming)

Carsten Strotmann FORTH

slide-46
SLIDE 46

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth can be easily extended because the programmer has full access to the underlying system extending Forth is changing the Forth System (including the Forth Compiler and/or Interpreter) Porting Forth to a new Processor or OS can be done in 1-2 Weeks (or less) New Ideas can be added to the language easily (like OOP , Object Oriented Programming)

Carsten Strotmann FORTH

slide-47
SLIDE 47

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

Extending Forth

Forth can be easily extended because the programmer has full access to the underlying system extending Forth is changing the Forth System (including the Forth Compiler and/or Interpreter) Porting Forth to a new Processor or OS can be done in 1-2 Weeks (or less) New Ideas can be added to the language easily (like OOP , Object Oriented Programming)

Carsten Strotmann FORTH

slide-48
SLIDE 48

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Forth Basics Examples (Forth vs. C) Forth is easily extensible

OOP Extension in 655 Bytes

OOP Extension to ANSI Forth

\ Mini-OOF 12apr98py : method ( m v "name" -- m’ v ) Create over , swap cell+ swap DOES> ( ...

  • -- ...

) @ over @ + @ execute ; : var ( m v size "name" -- m v’ ) Create over , + DOES> ( o -- addr ) @ + ; : class ( class -- class methods vars ) dup 2@ ; : end-class ( class methods vars "name" -- ) Create here >r , dup , 2 cells ?DO [’] noop , 1 cells +LOOP cell+ dup cell+ r> rot @ 2 cells /string move ; : defines ( xt class "name" -- ) ’ >body @ + ! ; : new ( class -- o ) here over @ allot swap over ! ; : :: ( class "name" -- ) ’ >body @ + @ compile, ; Create object 1 cells , 2 cells ,

Carsten Strotmann FORTH

slide-49
SLIDE 49

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-50
SLIDE 50

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Learn more on Programming

Forth naturally teached you to use techniques rediscovered today in “Extreme Programming”3

create small parts (Forth Words), test them, make them work “fun-down approach" of software development - start where you will get the most immediate gratification Refactor - make your code work well

read “Thinking Forth” (published 1984), now available under Creative Commons License4

3See DDJ Article “Extreme Forth” 4see http://thinking-forth.sourceforge.net/ Carsten Strotmann FORTH

slide-51
SLIDE 51

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Learn more on Programming

Forth naturally teached you to use techniques rediscovered today in “Extreme Programming”3

create small parts (Forth Words), test them, make them work “fun-down approach" of software development - start where you will get the most immediate gratification Refactor - make your code work well

read “Thinking Forth” (published 1984), now available under Creative Commons License4

3See DDJ Article “Extreme Forth” 4see http://thinking-forth.sourceforge.net/ Carsten Strotmann FORTH

slide-52
SLIDE 52

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Learn more on Programming

Forth naturally teached you to use techniques rediscovered today in “Extreme Programming”3

create small parts (Forth Words), test them, make them work “fun-down approach" of software development - start where you will get the most immediate gratification Refactor - make your code work well

read “Thinking Forth” (published 1984), now available under Creative Commons License4

3See DDJ Article “Extreme Forth” 4see http://thinking-forth.sourceforge.net/ Carsten Strotmann FORTH

slide-53
SLIDE 53

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Learn more on Programming

Forth naturally teached you to use techniques rediscovered today in “Extreme Programming”3

create small parts (Forth Words), test them, make them work “fun-down approach" of software development - start where you will get the most immediate gratification Refactor - make your code work well

read “Thinking Forth” (published 1984), now available under Creative Commons License4

3See DDJ Article “Extreme Forth” 4see http://thinking-forth.sourceforge.net/ Carsten Strotmann FORTH

slide-54
SLIDE 54

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Learn more...

Forth ideas can be used in any programming language DDJ Electronic Review of Computer Books: Even if you never use Forth, however, you might benefit from studying some of its features. For example, all of the internal code used by the Forth interpreter and compiler is available to application developers. This simple idea has many benefits - it exposes a complete standard set of tools, it lets you extend the environment and language in deep ways, and it enables some very advanced development paradigms.

Carsten Strotmann FORTH

slide-55
SLIDE 55

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-56
SLIDE 56

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Forth allows for lots of functionality into limited memory

(small Forth System ~ 4 KB, large Forth System ~ 100-200 KB)

Code (and much data) is ROM-able (good for embedded Systems) Is a "HighLevelLanguage" that encourages highly modular code.

Carsten Strotmann FORTH

slide-57
SLIDE 57

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Forth allows for lots of functionality into limited memory

(small Forth System ~ 4 KB, large Forth System ~ 100-200 KB)

Code (and much data) is ROM-able (good for embedded Systems) Is a "HighLevelLanguage" that encourages highly modular code.

Carsten Strotmann FORTH

slide-58
SLIDE 58

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Forth allows for lots of functionality into limited memory

(small Forth System ~ 4 KB, large Forth System ~ 100-200 KB)

Code (and much data) is ROM-able (good for embedded Systems) Is a "HighLevelLanguage" that encourages highly modular code.

Carsten Strotmann FORTH

slide-59
SLIDE 59

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Can be interpreted at high speed (approaching that of machine code). Think "interactive hardware debugging". Easily compiled to machine code. Integrated access to assembly language. Is "fully and easily extensible." (Only a few low-level routines of the runtime are not written in FORTH.)

Carsten Strotmann FORTH

slide-60
SLIDE 60

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Can be interpreted at high speed (approaching that of machine code). Think "interactive hardware debugging". Easily compiled to machine code. Integrated access to assembly language. Is "fully and easily extensible." (Only a few low-level routines of the runtime are not written in FORTH.)

Carsten Strotmann FORTH

slide-61
SLIDE 61

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Can be interpreted at high speed (approaching that of machine code). Think "interactive hardware debugging". Easily compiled to machine code. Integrated access to assembly language. Is "fully and easily extensible." (Only a few low-level routines of the runtime are not written in FORTH.)

Carsten Strotmann FORTH

slide-62
SLIDE 62

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Save Time, Memory and CPU Cycles

Can be interpreted at high speed (approaching that of machine code). Think "interactive hardware debugging". Easily compiled to machine code. Integrated access to assembly language. Is "fully and easily extensible." (Only a few low-level routines of the runtime are not written in FORTH.)

Carsten Strotmann FORTH

slide-63
SLIDE 63

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Outline

1

Forth in Time Birth of Forth and the roaring 80s Forth Today

2

An Overview on Forth Forth Basics Examples (Forth vs. C) Forth is easily extensible

3

Why learning/using Forth Broaden your horizon Create lean and fast Programs Forth, the good and the bad

4

21C3 - Forth Crossover

Carsten Strotmann FORTH

slide-64
SLIDE 64

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is good at Forth

It is simple to build from the bottom up. You can get an application to run in a miniscule amount of RAM. You can try things out in real time as you build your system. Compared to any other interpreted language, it is fast.

Carsten Strotmann FORTH

slide-65
SLIDE 65

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is good at Forth

It is simple to build from the bottom up. You can get an application to run in a miniscule amount of RAM. You can try things out in real time as you build your system. Compared to any other interpreted language, it is fast.

Carsten Strotmann FORTH

slide-66
SLIDE 66

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is good at Forth

It is simple to build from the bottom up. You can get an application to run in a miniscule amount of RAM. You can try things out in real time as you build your system. Compared to any other interpreted language, it is fast.

Carsten Strotmann FORTH

slide-67
SLIDE 67

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is good at Forth

It is simple to build from the bottom up. You can get an application to run in a miniscule amount of RAM. You can try things out in real time as you build your system. Compared to any other interpreted language, it is fast.

Carsten Strotmann FORTH

slide-68
SLIDE 68

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is (maybe) bad on Forth

If you know one Forth System...

... you know one Forth System ... at one point of time, because Forth Systems are totally comprehensible by one person, ... ... Forth Programmer start do create their own Forth, their

  • wn OOP etc etc etc

but this can also be seen as a good thing ;)

Carsten Strotmann FORTH

slide-69
SLIDE 69

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is (maybe) bad on Forth

If you know one Forth System...

... you know one Forth System ... at one point of time, because Forth Systems are totally comprehensible by one person, ... ... Forth Programmer start do create their own Forth, their

  • wn OOP etc etc etc

but this can also be seen as a good thing ;)

Carsten Strotmann FORTH

slide-70
SLIDE 70

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is (maybe) bad on Forth

If you know one Forth System...

... you know one Forth System ... at one point of time, because Forth Systems are totally comprehensible by one person, ... ... Forth Programmer start do create their own Forth, their

  • wn OOP etc etc etc

but this can also be seen as a good thing ;)

Carsten Strotmann FORTH

slide-71
SLIDE 71

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is (maybe) bad on Forth

If you know one Forth System...

... you know one Forth System ... at one point of time, because Forth Systems are totally comprehensible by one person, ... ... Forth Programmer start do create their own Forth, their

  • wn OOP etc etc etc

but this can also be seen as a good thing ;)

Carsten Strotmann FORTH

slide-72
SLIDE 72

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

What is (maybe) bad on Forth

If you know one Forth System...

... you know one Forth System ... at one point of time, because Forth Systems are totally comprehensible by one person, ... ... Forth Programmer start do create their own Forth, their

  • wn OOP etc etc etc

but this can also be seen as a good thing ;)

Carsten Strotmann FORTH

slide-73
SLIDE 73

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

No, but you should give it a try

If you like it, keep it If you don’t like it, there is always a lesson learned You might need a Forth-compatible brain to enjoy Forth

Carsten Strotmann FORTH

slide-74
SLIDE 74

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

No, but you should give it a try

If you like it, keep it If you don’t like it, there is always a lesson learned You might need a Forth-compatible brain to enjoy Forth

Carsten Strotmann FORTH

slide-75
SLIDE 75

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

No, but you should give it a try

If you like it, keep it If you don’t like it, there is always a lesson learned You might need a Forth-compatible brain to enjoy Forth

Carsten Strotmann FORTH

slide-76
SLIDE 76

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

No, but you should give it a try

If you like it, keep it If you don’t like it, there is always a lesson learned You might need a Forth-compatible brain to enjoy Forth

Carsten Strotmann FORTH

slide-77
SLIDE 77

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

Keep in mind:

Forth might not be the best solution for every problem (Universal truth) There is no such thing as the “best programming language” Build your skills for a bag of tools for the bunch of problems

  • ut there

Carsten Strotmann FORTH

slide-78
SLIDE 78

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

Keep in mind:

Forth might not be the best solution for every problem (Universal truth) There is no such thing as the “best programming language” Build your skills for a bag of tools for the bunch of problems

  • ut there

Carsten Strotmann FORTH

slide-79
SLIDE 79

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

Keep in mind:

Forth might not be the best solution for every problem (Universal truth) There is no such thing as the “best programming language” Build your skills for a bag of tools for the bunch of problems

  • ut there

Carsten Strotmann FORTH

slide-80
SLIDE 80

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover Broaden your horizon Create lean and fast Programs Forth, the good and the bad

Should I start using (only) Forth now?

Keep in mind:

Forth might not be the best solution for every problem (Universal truth) There is no such thing as the “best programming language” Build your skills for a bag of tools for the bunch of problems

  • ut there

Carsten Strotmann FORTH

slide-81
SLIDE 81

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

Summary

Forth is different enough to be worth learning. Forth is fun. Forth is flexible. Forth is fast and small.

Carsten Strotmann FORTH

slide-82
SLIDE 82

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

Summary

Forth is different enough to be worth learning. Forth is fun. Forth is flexible. Forth is fast and small.

Carsten Strotmann FORTH

slide-83
SLIDE 83

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

Summary

Forth is different enough to be worth learning. Forth is fun. Forth is flexible. Forth is fast and small.

Carsten Strotmann FORTH

slide-84
SLIDE 84

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

21C3 - Forth Crossover

Brainf*ck in Forth, see Talk #65 Clifford Wolf

( Brainf*ck in FORTH, 2003, Carsten Strotmann ) CR ." BrainF*ck " 0 VARIABLE IP : IP+ IP @ 1+ IP ! ; : IP- IP @ 1 - IP ! ; : IP@ IP @ C@ ; : 2DUP DUP DUP ; : BF+ 2DUP C@ 1+ SWAP C! ; : BF- 2DUP C@ 1 - SWAP C! ; : BF> 1+ ; : BF< 1 - ; :

  • BF. DUP C@ EMIT ; :

BF, DUP KEY SWAP C! ; : BF[ DUP C@ 0= IF BEGIN IP+ IP@ 93 = UNTIL THEN ; : BF] BEGIN IP- IP@ 91 = UNTIL ; : BFI ( addr -- ) IP ! BEGIN IP@ 93 = IF BF] THEN IP@ 91 = IF BF[ THEN IP@ 62 = IF BF> THEN IP@ 60 = IF BF< THEN IP@ 46 = IF BF. THEN IP@ 44 = IF BF, THEN IP@ 45 = IF BF- THEN IP@ 43 = IF BF+ THEN IP+ IP@ 0 = UNTIL ; : BF HERE 3000 ERASE HERE BL WORD 1+ BFI ; Carsten Strotmann FORTH

slide-85
SLIDE 85

institution-logo Forth in Time An Overview on Forth Why learning/using Forth Summary 21C3 - Forth Crossover

21C3 - Forth Crossover

Forth in Hardware

See Talk #42 Cored Programming - Building systems on your own soft core, Klaus Schleisiek

Carsten Strotmann FORTH

slide-86
SLIDE 86

institution-logo Appendix For Further Reading

For Further Reading I

Leo Brodie, Starting Forth. http://www.forthfreak.net/wiki/index.cgi/?StartingForth Leo Brodie, Thinking Forth. http://thinking-forth.sourceforge.net/ ForthFreak Wiki http://www.forthfreak.net/wiki/index.cgi?ForthFreak Forth Gesellschaft e.V. http://www.forth-ev.de/ Forth Interest Group (FIG) US http://www.forth.org/

Carsten Strotmann FORTH

slide-87
SLIDE 87

institution-logo Appendix For Further Reading

For Further Reading II

Forth Inc. http://www.forth.com/index.html c2 Wiki (Ward Cunningham) on Forth http://c2.com/cgi/wiki?ForthLanguage DDJ Re-Review of Thinking Forth, 2003 http://www.ercb.com/ddj/2003/ddj.0308.html

Carsten Strotmann FORTH