OS X Scheme Language (dialect for lisp) - macos

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.

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

How to run mzscheme on DrRacket?

I have to make sure that my code is compatible with mzscheme but I don't know how to use it on my school's ssh servers. Is there anyway to test if my code is compatible with mzscheme on DrRacket?
Rackets default language was renamed from #!scheme to #!racket when the whole thing changed name from PLT to Racket. #!mzscheme is an old version of this which is made as a legacy language.
You switch language by making the language name the very first line in your source files. also instead of #!language you can write it more verbose as #lang language. It is exactly the same.
The legacy language uses the #!racket language pairs, which are immutable. Thus you cannot use set-car! and set-cdr! with the legacy library. If this is a problem use #!r5rs instead.
The bin directory installed with DrRacket (i.e., /Applications/Racket v6.3/bin on Mac OS X) has mzscheme as a working binary; you can just use it.
Also on DrRacket GUI, you can specify to use MzScheme with #lang mzscheme at the first line.

Does Mac OS X come with a Lisp environment built in with Emacs?

I have been trying to find an environment that does not involve installing anything else on my mac for Lisp, as I will not be using it after I get the homework done (who know if I continue using it). I have tried to look but I can't find anything. Anybody know if it does have it, and how to use it within Emacs?
You have a few options for one-click Lisp environments.
If you prefer an Emacs-based environment, check out LispBox. This actually installs a separate instance of Emacs, afaik, so you probably won't have your existing Emacs settings with it.
If you want to use your existing Emacs, SLIME is available both through quicklisp (which you really should be using) or through ELPA.
If you're ok with not having an Emacs environment, and you're not going to be using the language for long, look into LispWorks personal, which has a one-click environment installer in OS X.
If you were actually asking about Scheme (or could go for either Scheme or Common Lisp), take a look at Racket (not technically a Scheme, it actually has a lot of additional features, but they do support R5RS and have a fairly short list of unsupported R6RS features).
Emacs Lisp is rather different from regular Lisp, so it's probably not directly useful for classes or self-study if your target is something like Scheme or Common Lisp. But yes, Emacs has its own Lisp interpreter (or rather, is its own Lisp interpreter). You might want to read up on the differences between Emacs elisp and other dialects / variants to determine whether it might suit your needs.
Clozure CL is a available for free from the Mac App Store
http://itunes.apple.com/us/app/clozure-cl/id489900618?ls=1&mt=12
Have you checked Ready Lisp ?
Also have a look at here.

Recommendations for a lisp setup on Mac OS X (any dialect)?

What is your Mac OS X (Intel) based lisp setup (of any dialect), how do you like it, and how painful was it to set up? I'm looking for a versatile lisp that is easy to set up, but if you feel strongly about investing more effort, or even money, I would like to hear why you think it's worth it.
I am currently using newLisp, which was a breeze to set up and gives me simple access to things like graphics and sound. I have heard of SBCL with emacs and slime, but that seems a real pain to set up, and I'm still not friends with emacs. I want to see if there's anything I'm missing out on. I would primarily be using this for pleasure, with no commercial goal in mind.
Please recommend only one setup per answer to enable voting, but feel free to submit multiple answers.
Ready Lisp:
Ready Lisp is a binding together of several popular Common Lisp packages especially for Mac OS X, including: Aquamacs, SBCL and SLIME. Once downloaded, you’ll have a single application bundle which you can double-click – and find yourself in a fully configured Common Lisp REPL.
It’s ideal for OS X users who want to try out the beauty of Common Lisp with a minimum of hassle. It could also be used by teachers to give their Mac students a free, complete Common Lisp environment to take home with them.
The best Lisp for Mac OS X is LispWorks. It is commercial though. Installation is done with an installer in a few seconds. It is started then with a double-click from the programs folder. It has a Cocoa-Bridge and the user interface is written with it, but based on a portable substrate - so the same development environment is available for Windows and Unix/Linux/FreeBSD.
I suppose it depends on what you mean by "setup". Clozure CL (previously Open MCL) has an experimental Cocoa bridge, and you can even build a smallish IDE as well (just fire it up and do a (require "COCOA-APPLICATION") and it'll build the .app bundle for you). I use vim myself, but you're free to use whatever editor you like (+ Interface Builder), of course. CCL supports Emacs+Slime, but does not require it.
Try PLT Scheme. It is mature, has lot of libraries and comes with an IDE.
Gambit scheme is a "complete, portable, efficient and reliable implementation of the Scheme programming language":
Gambit consists of two main programs: gsi, the Gambit Scheme interpreter, and gsc, the Gambit Scheme compiler. The interpreter contains the complete execution and debugging environment. The compiler is the interpreter extended with the capability of generating executable files. The compiler can produce standalone executables or compiled modules which can be loaded at run time.
The Gambit compiler allows Scheme to be compiled to C, with some pretty cool applications, like writing an iPhone app in Scheme (with a REPL for remote debugging).
There is a FFI for Gambit so you can use external C libraries.
There is an installer or you can install via MacPorts.
You could install guile. I'd use fink.
That is easy, but it gives you a fairly lightweight scheme installation.
General Comments
Most lisps are not that hard to set up on OS X if you're used to working on the command line, though some are harder than others. I think the hardest to set up are CMUCL and Clozure; if memory serves, you need to make a symbolic link into a directory on your path if you don't want to run them from their respective directories (they don't install an executable into /usr/local/bin on installation). In any case, you'll put more work into getting Slime going in Emacs than you will actually installing a lisp. New Lisp is an easy install from the OS X gui, installed from a OS X package (making it the easiest install of all lisps except, perhaps, for PLT Scheme).
I do recommend using a some form of IDE, be it Emacs + Slime or the LispWorks or Clozure IDEs. People use other editors, but those are the ones that have been tailored most to programming in lisp. Personally, I wouldn't enjoy programming in lisp if I couldn't use Emacs + Slime, but I've put in a lot of time to learn the Emacs and Slime commands.
Implementation Recommendation
Here is a specific recommendation that is different from the others. If you are new to lisp and not too picky that it be Common Lisp, you should look at PLT Scheme. It comes with an IDE and an implementation (DrScheme and mzscheme) that can't be beat for ease of installation and use for a beginner. PLT Scheme comes with lots of extensions to Scheme that make is easier to use for more programming tasks than the other Schemes as well.
Easiest solution: (assumes you have the excellent Mac Ports installed)
Step 1:
$ sudo port install mit-scheme
Step 2:
$ scheme
Step 3:
Read Structure and Interpretation
of Computer Programs http://mitpress.mit.edu/sicp/full-text/book/book.html
Clojure is a wonderful lisp. it is truly modern lisp designed for pragmatic concurrent programming. It compiles to the JVM and can call and be called by java nativity with no wrapping and a minimum of ceremony.
clojure.org
try: XMLisp for OS X (FOSS)
3D: Open Agent Engine: scene graph based mini engine, 3D objects, animation, mouse hovering, selection, camera control, texture management
2D: controls: layout managers, buttons, sliders, text
http://code.google.com/p/xmlisp/
It is an extension of Clozure CL. IDE is included. You should be able to get this running in no time.
Alex

Resources