Interpreting SCHEME for SICP - scheme

I have read through a bunch of Structures and Interpretations of Computer Programs and it has really captured me. I love they way it explains programming concepts. But the problem is that I don't know how to get MIT Scheme working. I don't know much about how to quickly interpret/compile in languages that require a compiler/interpreter. (doing it in JavaScript is incredibly easy) I have tried DrRacket but would love to use sublime text then quickly run it.
I have downloaded the official MIT-SCHEME bundle but I have no idea on how to get it actually working after 3 hours.
Thank you for reading!

It sounds like you may be familiar with the sicp package for Racket that allows you to write programs in a #lang sicp language. If you're interested in running them from the command line a la Javascript, that's certainly possible; if you run
racket
on a file that starts with #lang sicp (and you have the sicp package installed), it should run fine at the command line. It should be easy to bind this to a sublime command.
HTH

Related

Running simplescheme in DrRacket

I want to run code for 'simplescheme' (http://bryanchadwick.com/simplescheme/) on DrRacket to test it before putting it on the device's android. I could not find "#lang simplescheme" in the list of languages provided in DrRacket's menu.
I have 'simplescheme's android app (https://play.google.com/store/apps/details?id=chadwick.apps.simplescheme) installed on the device, but how can I test the code first on a desktop? I could not find 'simplescheme' interpreter for Linux or Windows on the net.
How can I solve this problem? Thanks for your comments/answers.
According the Simple Scheme web-site: http://bryanchadwick.com/simplescheme/index.html
Simple Scheme is a language inspired by Scheme and Racket.
This means that the only implementation of Simple Scheme is the Android one.
There are however two options to run your programs on the desktop.
The first one is to install an Android Emulator and run Simple Scheme in the emulator. This will allow you to run the real Simple Scheme.
The other options is to use #lang racket and restrict your self to use the constructs that are supported by Simple Scheme: http://bryanchadwick.com/simplescheme/index.html#functionlist
On the plus side this allows you to use DrRacket, but you risk using a construct missing from Simple Scheme.
NB! This answer is off topic as it's about Simply Scheme and not SimpleScheme. I'll leave it here as the names are rather similar
Racketeer and SO-er Danny Yoo has made a Racket module language to support Simply Scheme in the racket language suite. In Racket with the bottom left dropdown set to "Determine language from source" and replace the definitions window, including the #lang line to the following:
#lang planet dyoo/simply-scheme:2
(se (butlast (bf "this"))
"world")
And press RUN. It will download and install the language and then you'll see the answer (hi "world"). The first time around you might see an error, but my experience is that it will go away on a consecutive run.
The definitions will have all the simply scheme features described in the the documentation. Happy hacking!

How do I run a scheme script from notepad++/cmd/powershell?

In python, I add python and the path of the file, and my script will run.
In haskell, I invoke the GHC compiler on my file to make an executable, or I load GHCi and load the path of the file to use functions, and my script is running.
In Scheme, neither type of approach works for me. Everywhere I search, I only hear about emacs and SLIME. I am not interested in either. I just want to write scripts in notepad++ or any other simple text editor, and either run them through a scheme interpreter, or compile it into an exe, for the purpose of testing code from the MIT SICP book.
I installed MIT/GNU Scheme for learning purposes. I am not interested in Racket because of how different it is from Scheme now (I don't want to confuse myself further, I just want to learn the basics.)
One thing that is contributing to my confusion is the following. When I open mit-scheme through the start menu shortcut, it opens the edwin editor (its tutorial (C-h t command) is apparently "corrupted" so I can't use that instead of notepad++ nor would I want to at this point (just too frustrated with it)). The file location for the edwin editor is in the bin folder. The bin folder though, only has 2 files: mit-scheme.exe and dibutils.dll. If I double-click on mit-scheme.exe it just gives me an error, but apparently using the shortcut opens the edwin editor (that is supposed to be located in the same folder as mit-scheme.exe (it isn't)).
Why is all of this so convoluted? Isn't there a simple way to get my scheme scripts running? I just want to run things like:
(define hello-world
(lambda ()
(begin
(write ‘Hello-World)
(newline)
(hello-world))))
Searching for solutions online was futile for me, I've already wasted many hours- so hopefully I can finally get an answer here.
Thank you.
EDIT: I am on windows 7 and *nix operating systems isn't an option.
mit-scheme has the --load switch. thus
mit-scheme --load path/to/script.scm scrip2.scm -- args ...
I think you also can use Racket to run standard r6rs like this:
plt-r6rs script.scm
For r5rs there is plt-r5rs. Racket can also make executables that run faster with raco exe script.scm.
EDIT
BTW: plt-r6rs is for running programs using the standard R6RS scehem report. plt-r5rs is for running programs using the standadr R5RS scheme report. I have no idea what you mean by "different it is from Scheme". Racket has it's own language, which is the default, which is it's own incompatible dialect of Scheme, but it is not a reason for not using the software. It's like not using gcc because it supports a non standard C++ language and ignoring that you can get ot to behave standard with switches.
There is only one R7RS-small implementation, the reference implementation chibi scheme. Every imlpementation is waiting for the full R7RS report I guess so it's R6RS which is the current standard.
The lists in R5RS and R6RS are mutable (but in R6RS you need to import (rnrs mutable-pairs), but thats a part of the standard. Try not import racket libraries from the standard schemes unless you have no other choice. Check the SRFIs first.
There are not so many Scheme versions and scheme implementations. For every popular programming language that has been for at least 10 years there are more than 3 implementations and several incompatible versions of the standard. If you think there are few implementations of the languages you mentioned you are quite wrong. Python has many implementations and incompatible standard versions. Haskell also has many implementations and versions of their standard. Scheme is from the 70s so it's been around for 40 years so it's only natural that there are more versions of Scheme than Haskell and Python.
This is how I was able to run scheme code from notepad++,
I put to notepad++ run configuration:
"C:\Program Files (x86)\MIT-GNU Scheme\bin\mit-scheme.exe" --heap 512 --library "C:\Program Files (x86)\MIT-GNU Scheme\lib" --load "$(FULL_CURRENT_PATH)"
and then I was able to run. However, I had to save file first, otherwise it is not running. Also notice that (+ 2 2) is not printing as a result, But If I call procedures it is working fine.
sample

OS X Scheme Language (dialect for lisp)

I've only learned Python, and have recently begun to learn a new language called Scheme. I have a few basic questions regarding Scheme. 1) If I want to open a scm file on sublime text 2, can I just select "Lisp" for my language settings? 2 To run python on terminal, all I had to do was python file.py, what command do i do to open a scm. file on my os x.
1) Yes. You could also install a more Scheme oriented version.
2) Yes. Depends on the implementation. For racket you can start with plt-r6rs-script file.scm, plt-r5rs-script file.scm or you can compile raco exe file.scm and then just run file which then is a executable. Racket also had an IDE called DrRacket suitable for programming, debugging and running in the IDE and it supports standard Scheme versions such as R5RS, R6RS as well as it's own languages racket, typed racket and lazy racket. Don't confuse the language racket with the whole imlementation with the very same name that also runs Scheme very well.
For ikarus you do ikarus --r6rs-script file.scm
If you're looking to pick up a Scheme dialect, you may want to do it via Racket. At that point, if you're comfortable with the terminal, you can go through their Systems Programming With Racket tutorial, which will clarify how you'd go about editing and running scheme files from a command line.

Scheme & Smalltalk

Not really a question as such in here regarding Smalltalk and Scheme. I only started playing in Smalltalk 3 weeks ago and have been bouncing between Squeak and Pharo. Both are amazing its hard to think to me smalltalk isn't the most popular language going. Everything is in the one image I don't need an interactive command prompt an editor a web page for Rdoc etc I just do it click it mess around, heck if I do UiDesigner Open. I get a GUI app close to QT4. There are database utilities for my small databases like magma.
Anyway, I also started to play with Scheme in Racket and though there are a lot of () involved it still had a lot of simplicity; it seems to be quite logical from the get go. The only thing I am finding is that there are a lot of scheme/Lisp dialects. Racket seems to be quite an easy environment as well, however, notably, there seems to be Chicken and MIT Scheme.
Is there a particular reason I should be using Chicken over Racket or MIT? Or Vice Versa. Good System support, Database or GUI support...etc.
PS I am clearly not picking the most popular languages but I am having fun :-)
Both Racket and Chicken have good library support. (GUI, database, networking etc). If you are just having fun, I suggest you go with Racket. It has full support for the Scheme standards (R5RS, R6RS) and good documentation. There are a few good programming books that use Racket as the implementation language. On the other hand, if you are looking for portability of your compiled code across a wide assortment of hardware, Chicken might be better than Racket.
If R6RS is important to you, go with Racket. Chicken(among others) is not and will not be R6RS compliant, as there is a widespread perception that it is flawed. R7RS is being worked on and should address some of the concerns. As far as R5RS compliance goes, Chicken tries hard to stay in the standard (there are two pages in the manual listing differences). Racket is different enough that it shed the "Scheme" name a while ago.
That said, my preference lies with Chicken. Chicken's FFI is fantastic (even more so with the Bind egg). As it is compiled to C, interfacing with C libraries is a breeze. I have even added some of Chicken's runtime source files (a process documented in the manual) directly into an iPhone application I am working on, along with Scheme code translated to C, it works like a charm. There's no need to create a cross-compilation environment that way, as it is all C and compiled by XCode.
Chicken has a lot of eggs and growing every day. I suggest checking out the eggs page link text to see if it has what you need. If so, I strongly suggest giving it a try.

Is IronScheme suitable for working through SICP?

Will there be any incompatibilities with the code in SICP if I use IronScheme?
There shouldn't be any significant incompatibilities.
If you find any, why not post them here (as problems to solve), to document them?
You may want to use DrScheme (http://www.plt-scheme.org/) in 'Pretty Big' language mode and allow redefinition of initial bindings for working through code examples and exercises in SICP. I have been using it for trying out examples and exercises in SICP and have not run into any problems with the interpreter. It's also much more developed compared to IronScheme.

Resources