yet another colorforth

View: New views
4 Messages — Rating Filter:   Alert me  

yet another colorforth

by David Goehrig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So my new colorforth dialect is compiling itself, and I've got a couple screen shots up on a website.

http://newscript.org

It differs from Chuck's Colorforth in a number of ways, but owes a huge debt to it in terms of programming philosophy and spirit.  Probably the most significant departure is in how color is applied to words.  Rather than having a bunch of different space bars, I use space, tab, and enter in different combinations to change the case of the word.  This means that whitespace is syntactically significant similar to Python.

There is also some additional grammar that isn't described on the website yet that some people may find fun.  Newscript has no IF THEN or FOR NEXT constructs.  Rather is uses punctuation to designate different mood or tenses:

        word? interogative mood, conditional jump
        word. imperative  mood, unconditional jump
        word, adjuvantive mood, call & drop
        word; future tense, push word onto return stack
        word present tense, call word
       
So branching requires factoring out each branch.  IF ELSE THEN translates roughly to:
       
        thenword; ifword? elseword.

Push the thenword onto the return stack, then if the condition is met jump to ifword (which returns to thenword), or jump to elseword (which then returns to thenword).  So far I've never actually used ; for this purpose, but its there :)

Similarly, variables can have @ and ! appended directly to them in order to compile an immediate fetch or store opcode: (stand alone @ and ! still exist and work as expected)

        word! locative case, store at the address of word
        word@ genetive case, fetch from the address of word

Since the address of word (whatever it might be) is known at compile time, (and compile time can be at run time), these usages only compile the address of word as an immediate value in the x86 instruction.  With the top two items on the data stack stored in registers, the resulting code almost never touches the data stack at all.  As a result, I'm both very happy with the speed of compilation and execution.  But most of all, I love having a color coded forth, with both syntax and grammar!

Anyways, code will be available soon-ish, as I'd like to put the finishing touches on the OpenGL based editor before releasing it into the wild.  The ncurses interface is useable, but currently requires using a C-bootstrap executable to get running.  Also the Mach-O generation really needs to be rewritten in Newscript, because patching the header is just too prone to breaking when building larger images.

Hope this inspires some people to go out and start playing with their colorforths again!

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@...
For additional commands, e-mail: colorforth-help@...
Main web page - http://www.colorforth.com


Re: yet another colorforth

by vaded :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for sharing.

I look forward to downloading it and giving it a spin.

On Mon, 16 Feb 2009 20:06:31 -0500, "David J. Goehrig"
<dave@...> said:

> So my new colorforth dialect is compiling itself, and I've got a couple
> screen shots up on a website.
>
> http://newscript.org
>
> It differs from Chuck's Colorforth in a number of ways, but owes a huge
> debt to it in terms of programming philosophy and spirit.  Probably the
> most significant departure is in how color is applied to words.  Rather
> than having a bunch of different space bars, I use space, tab, and enter
> in different combinations to change the case of the word.  This means
> that whitespace is syntactically significant similar to Python.
>
> There is also some additional grammar that isn't described on the website
> yet that some people may find fun.  Newscript has no IF THEN or FOR NEXT
> constructs.  Rather is uses punctuation to designate different mood or
> tenses:
>
> word? interogative mood, conditional jump
> word. imperative  mood, unconditional jump
> word, adjuvantive mood, call & drop
> word; future tense, push word onto return stack
> word present tense, call word
>
> So branching requires factoring out each branch.  IF ELSE THEN translates
> roughly to:
>
> thenword; ifword? elseword.
>
> Push the thenword onto the return stack, then if the condition is met
> jump to ifword (which returns to thenword), or jump to elseword (which
> then returns to thenword).  So far I've never actually used ; for this
> purpose, but its there :)
>
> Similarly, variables can have @ and ! appended directly to them in order
> to compile an immediate fetch or store opcode: (stand alone @ and ! still
> exist and work as expected)
>
> word! locative case, store at the address of word
> word@ genetive case, fetch from the address of word
>
> Since the address of word (whatever it might be) is known at compile
> time, (and compile time can be at run time), these usages only compile
> the address of word as an immediate value in the x86 instruction.  With
> the top two items on the data stack stored in registers, the resulting
> code almost never touches the data stack at all.  As a result, I'm both
> very happy with the speed of compilation and execution.  But most of all,
> I love having a color coded forth, with both syntax and grammar!
>
> Anyways, code will be available soon-ish, as I'd like to put the
> finishing touches on the OpenGL based editor before releasing it into the
> wild.  The ncurses interface is useable, but currently requires using a
> C-bootstrap executable to get running.  Also the Mach-O generation really
> needs to be rewritten in Newscript, because patching the header is just
> too prone to breaking when building larger images.
>
> Hope this inspires some people to go out and start playing with their
> colorforths again!
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: colorforth-unsubscribe@...
> For additional commands, e-mail: colorforth-help@...
> Main web page - http://www.colorforth.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@...
For additional commands, e-mail: colorforth-help@...
Main web page - http://www.colorforth.com


Relational DB in ColorForth

by vaded :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm sick of using linux/apache/mysql/php.

Can anyone point me in the direction of any database work that's been in
forth, particularity colorforth?  

Also, does anyone have any book recommendations on information systems
or databases that are not part of the unix/C mindset and that would be
useful for a colorforth programmer?

Thanks in advance.

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@...
For additional commands, e-mail: colorforth-help@...
Main web page - http://www.colorforth.com


Re: Relational DB in ColorForth

by David Goehrig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 19, 2009 at 12:39:30AM -0700, vaded@... wrote:
> Can anyone point me in the direction of any database work that's been in
> forth, particularity colorforth?  

I have to say when I read this I laughed out loud (scared my kid too).  

A little bit of history on forth & databases:
        http://www.ultratechnology.com/essence.htm (Jeff Fox)

An old school introduction to database writing:
        http://www.theforthsource.com/fp003.html (Glen Haydon)

In order to replace PHP, you might want to look at:
        http://www.jwdt.com/~paysan/httpd-en.html

Not particularly elegant, but it will get you started.

My recommendation, think about what you store in your SQL tables, then
think about what varchar(255) actually means.  Then just write forth :)

The amount of work it takes to write some field access words in forth
is about as much work it takes to write the equivalent SQL to do the
query. The hardest part will be breaking all the bad habits you've
developed in designing DBs to fit the SQL idiom.

Good Luck!

Dave





---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@...
For additional commands, e-mail: colorforth-help@...
Main web page - http://www.colorforth.com