Board index FlightGear Development Nasal

Nasal vs. Forth (offtopic)

Nasal is the scripting language of FlightGear.

Nasal vs. Forth (offtopic)

Postby Hooray » Wed Apr 02, 2014 12:39 pm

until I start on some random project, like writing a Forth interpreter in Nasal, but that probably won't happen so soon

You shouldn't write a forth interpreter in Nasal - if anything, it would make sense to re-target Nasal's codegen to emit Forth opcodes directly (it's basically all there, and forth can be optimized/compiled by gcc etc) :lol:
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11114
Joined: Tue Mar 25, 2008 8:40 am

Re: Updating and Refitting the DC-10-30ER

Postby Philosopher » Wed Apr 02, 2014 12:59 pm

Nah, there's too much type checking in Nasal ;). Besides, Forth is such an ancient niche language... last actual use in '09 or so? Not designed after '94? It really isn't good for many things outside of illustrating a stack language with reverse Polish notation. It has no "parser" at all, so getting to codegen would be too far. In fact, it's whole paradigm is executing built-in/user-defined words left-to-right, meaning everything is done using the functionality of words, even during compilation/interpretation, which are not different steps than execution. I'm not sure if I would be up to providing the default word set (aka syntax :)).

Anyhow, sorry for pollution :oops:
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal vs. Forth (offtopic)

Postby Hooray » Wed Apr 02, 2014 3:58 pm

it's not as "ancient" or "niche" as you may think - Forth still is being used these days, even in some fairly popular (or critical) applications (e.g. B777 systems development), including ebook readers, but also lots of other embedded hardware devices. Basically, Forth is a sure thing whenever there's no dedicated development environment available.
Forth is basically "timeless" because of its unique approach, and used in many areas where its use is not necessarily obvious.

http://www.findinglisp.com/blog/2008/06 ... redux.html
http://www.kiblerelectronics.com/corner/ccii_4.html
http://www.testra.com/Forth/VHDL.htm
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11114
Joined: Tue Mar 25, 2008 8:40 am

Re: Nasal vs. Forth (offtopic)

Postby Kabuki » Wed Apr 02, 2014 6:39 pm

The original Mars lander from 1976(?) was programmed in FORTH, with a whopping 8K of RAM. It's an extremely efficient and fast language, but it can be baffling to programmers used to "regular" -- programming languages because "there's no parser" -- the programmer is the parser. It's a strange language, but my experience with it taught me more about how a language works at the lowest levels. It was an invaluable experience working with FORTH.

If FORTH replaced Nasal as a programming language, I think we'd probably see a lot fewer mods written due to its obscurity and difficulty. But it would be fast.

I've always wondered why Nasal is used as the embedded high level language in flightgear. Whenever I try and find learning materials, they're always associated with flightgear. Nobody else uses Nasal, and when you google it, you get a lot of health websites telling you how your nose works. There are now syntax highlighters available for it now, but still few resources compared to other languages.

But I like it, and would use it over FORTH if given the option, simply because I lost the knack. "FORTH is the funnest computer game I ever played".

"A metacompiler is a very powerful tool, man!" -- John 'captain crunch' Draper, my FORTH guru from way back.
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Nasal vs. Forth (offtopic)

Postby Hooray » Wed Apr 02, 2014 7:33 pm

I've always wondered why Nasal is used as the embedded high level language in flightgear. Whenever I try and find learning materials, they're always associated with flightgear. Nobody else uses Nasal

Nasal was written from scratch by one of the FlightGear core developers back then, he used it in a side project (IIRC a game) and offered to integrate it into FG, which only had experimental JavaScript/PLIB PSL bindings back then:

http://wiki.flightgear.org/Nasal_success_stories
http://wiki.flightgear.org/Nasal_for_C% ... rogrammers

If FORTH replaced Nasal as a programming language, I think we'd probably see a lot fewer mods written due to its obscurity and difficulty. But it would be fast....
But I like Nasal, and would use it over FORTH if given the option, simply because I lost the knack. "FORTH is the funnest computer game I ever played".


I don't think anybody was suggesting to replace Nasal - Philosopher was just kidding about implementing a Forth interpreter using Nasal, which is when I said that this would not make much sense - but internally, Nasal is also implemented as a stack machine, so it's internal VM/codegen /could/ emit/use Forth internally - without the programmer being aware o fit.

In fact, back in the days of the Nasal mailing list, there used to be talk about doing something along those lines by targeting LLVM, so that Nasal code could be compiled into native binaries.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11114
Joined: Tue Mar 25, 2008 8:40 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests