Thanks to visit codestin.com
Credit goes to jugad2.blogspot.com

Showing posts with label FORTH. Show all posts
Showing posts with label FORTH. Show all posts

Friday, March 1, 2013

repl.it, online REPL for many languages, and empythoned

By Vasudev Ram

repl.it is an online REPL (Read-Eval-Print-Loop) for multiple programming languages, including for Python. Some of the other supported languages are QBASIC, FORTH, Lua and Scheme and Ruby (it says "beta" for Ruby, but the other languages also may not have full support, e.g. see the excerpts below).

Here is a small test run of using repl.it with Python, that I just did:
Python 2.7.2 (default, Jul 20 2011, 02:32:18)
[GCC 4.2.1 (LLVM, Emscripten 1.5, Empythoned)] on linux2
   def foo(bar): 
..   print "in foo, bar =", bar 
..   
   foo(1)
in foo, bar = 1
   foo("ab")
in foo, bar = ab
   
   for i in range(4): 
..   foo(i) 
..   
in foo, bar = 0
in foo, bar = 1
in foo, bar = 2
in foo, bar = 3

   class Foo(): 
..   def bar(self): 
..     print "in Foo.bar()" 
..     
   
   foo = Foo()
   foo.bar()
in Foo.bar()
    

About repl.it.

For running Python, repl.it uses empythoned, which in turn uses emscripten.

Excerpts from the related tools' sites:

[ Empythoned is a build script that uses Emscripten to compile CPython for use in a browser. It attempts to compile the main interpreter as a single small executable and the whole standard library as dynamically loaded libraries.

The project is in its infancy. Right now the core interpreter works very well, but many of the libraries either don't work at all or contain various bugs. ]

[ Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Links to demos, tutorial, FAQ, etc: https://github.com/kripken/emscripten/wiki

Main project page: http://emscripten.org ]

- Vasudev Ram - Dancing Bison Enterprises



Tuesday, September 20, 2011

Classic book Starting FORTH now available online

By Vasudev Ram - dancingbison.com | @vasudevram | jugad2.blogspot.com

This post is for programming language fans.

FORTH is a pretty interesting language. It's one of the oldest programming languages.


It was originally invented by Charles Moore to control telescopes in the early days of computing:

http://www.forth.com/resources/evolution/evolve_0.html

(Also make sure to google for FORTH and check the Wikipedia entry, etc.)

The classic FORTH language tutorial, the book "Starting FORTH", is now available online.

Check it out here:

http://www.forth.com/starting-forth/?programming

The book's author was Leo Brodie:

http://punchandbrodie.com/leo/

(Again, google for him.)

I was lucky enough to find a copy of the original book (in hard-cover!) many years ago, when I was fairly new to programming, and bought it on the spot :), even though it was a bit expensive for me back then.

I enjoyed reading it, and playing around with the language using a FORTH interpreter.

Now you can read the entire book online at the above URL if you're interested in going FORTH :)

Here is the introduction page, which is quite interesting too, and may spark your interest in FORTH:

http://www.forth.com/starting-forth/sf0/sf0.html

Some people say that is more efficient than assembly language for certain types of programs.

Whether or not that is the case, I certainly found it a fun and unique language to program in.

YMMV, of course. Only one way to find out ... (TM). [1]


UPDATE: I checked out a FORTH implementation, GForth (that's GNU FORTH) v0.5.0 for DOS. Tried the Windows version first but the EXE gave some error, and I didn't want to bother right then with building it from the Windows source. There is also a Linux version which you can try out; you may have to build it from source using the usual configure / make / make install method (plus maybe some tweaks). You can find the GNU FORTH site via Google: http://google.com/search?q=GNU+FORTH


Anyway, the DOS version of GForth worked okay. I could enter a few FORTH expressions and they ran right.
Also defined and ran a FORTH word or two to check a bit more. That worked too. Looking forward to doing some FORTH programming in my spare time ...

.

Posted via email

- Vasudev Ram @ Dancing Bison


[1] By trying it :)