6

Is there a programming language which can be programmed entirely in interactive mode, without needing to write files which are interpreted or compiled. Think maybe something like IRB for Ruby, but a system which is designed to let you write the whole program from the command line.

1
  • I guess when I said "with ease" I meant that the language was designed to be coded from at the command line. Commented Feb 14, 2010 at 21:52

13 Answers 13

7

I assume you are looking for something similar to how BASIC used to work (boot up to a BASIC prompt and start coding).

IPython allows you to do this quite intuitively. Unix shells such as Bash use the same concept, but you cannot re-use and save your work nearly as intuitively as with IPython. Python is also a far better general-purpose language.

Edit: I was going to type up some examples and provide some links, but the IPython interactive tutorial seems to do this a lot better than I could. Good starting points for what you are looking for are the sections on source code handling tips and lightweight version control. Note this tutorial doesn't spell out how to do everything you are looking for precisely, but it does provide a jumping off point to understand the interactive features on the IPython shell.

Also take a look at the IPython "magic" reference, as it provides a lot of utilities that do things specific to what you want to do, and allows you to easily define your own. This is very "meta", but the example that shows how to create an IPython magic function is probably the most concise example of a "complete application" built in IPython.

Sign up to request clarification or add additional context in comments.

4 Comments

I looked at the IPython web site but I could not see any examples of a complete application built using IPython. Do you have any links that could help me?
I read the tutorials you mentioned, but it doesn't seem that trivial to create functions in IPython. It seems to save everything as a .py file
I'm not sure how much more trivial you want an interactive function definition to be. You still have to write the code for it somewhere, and you can type it into the command line then same way you'd write it into a .py file. Try it, the python command line is very convenient.
Also of note is that the interactive shell is not limited to iPython. The standard c-python distribution also includes it.
7

Smalltalk can be programmed entirely interactively, but I wouldn't call the smalltalk prompt a "command line". Most lisp environments are like this as well. Also postscript (as in printers) if memory serves.

Are you saying that you want to write a program while never seeing more code than what fits in the scrollback buffer of your command window?

2 Comments

I didn't think about it fitting into the scrollback buffer, but yes, I guess it would keep commands to a much smaller length.
this is why you need introspection as well!
4

There's always lisp, the original alternative to Smalltalk with this characteristic.

4 Comments

I checked on the web, but couldn't find much. How do I for example list all the functions I have created in lisp?
That depends on which Lisp implementation you're using, Zubair. Fortunately and unfortunately, Lisp has lots of implementations, and several philosophically-driven variations (Scheme, Common Lisp, Emacs Lisp, etc.)
Which is the most used Lisp which is interactive?
I haven't made extensive use of Lisp for 20 years. In the day, all lisps had a way to save the universe, and various introspective ways of, e.g. listing functions. I'm afraid I can't help you with modern details except to suggest reading the common lisp standard.
3

The only way to avoid writing any files is to move completely to a running interactive environment. When you program this way (that is, interactively such as in IRB or F# interactive), how do you distribute your programs? When you exit IRB or F# interactive console, you lose all code you interactively wrote.

Smalltalk (see modern implementation such as Squeak) solves this and I'm not aware of any other environment where you could fully avoid files. The solution is that you distribute an image of running environment (which includes your interactively created program). In Smalltalk, these are called images.

4 Comments

Of course, the interactive shell would have to have built in version control to save your code.
You would have a command like "make image", "make exe", or something like that to distribute your program
@Zubar: What you're looking for doesn't exist because isn't useful or safe outside of a learning environment. Your "make image/exe" wish isn't very practical, how would you test your code? How would you fix the exe without re-keying the entire program again, which has the obvious dangers of introducing new bugs?
Hi Binary, what I meant was that you could redistribute the running program via an exe. But the source code remains in the interactive system. Is that even possible to do what I am saying?
3

Any unix shell conforms to your question. This goes from bash, sh, csh, ksh to tclsh for TCL or wish for TK GUI writing.

2 Comments

Can you give an example of this? Haow does it compare to IRB or IPython for example?
Which TCL implementation should I use?
2

As already mentioned, Python has a few good interactive shells, I would recommend bpython for starters instead of ipython, the advantage of bpython here is the support for autocompletion and help dialogs to help you know what arguments the function accepts or what it does (if it has docstrings).

3 Comments

Very cool, never heard of bpython before, I will check it out. It should be noted, however, that ipython also supports auto-completion and docstrings, although bpython definitely is prettier in that respect. It does not look like bpython supports re-executing, editing, and saving "slices" of your command history like ipython does.
How does this differ to IPython? (in another answer to this question)
How do you add functions in BPython?
2

This is really a question about implementations, not languages, but

  • Smalltalk (try out the Squeak version) keeps all your work in an "interactive workspace", but it is graphical and not oriented toward the command line.

  • APL, which was first deployed on IBM 360 and 370 systems, was entirely interactive, using a command line on a modified IBM Selectric typewriter! Your APL functions were kept in a "workspace" which did not at all resemble an ordinary file.

  • Many, many language implementations come with pure command-line interactive interpreters, like say Standard ML of New Jersey, but because they don't offer any sort of persistent namespace (i.e., when you exit the program, all your work is lost), I don't think they should really count.

Interestingly, the prime movers behind Smalltalk and APL (Kay and Iverson respectively) both won Turing Awards. (Iverson got his Turing award after being denied tenure at Harvard.)

1 Comment

Intersting about smalltalk. I am looking for something that works from the command line, and optionally has a GUI, but that is not a must.
2

TCL can be programmed entirely interactivly, and you can cetainly define new tcl procs (or redefine existing ones) without saving to a file.

Of course if you are developing and entire application at some point you do want to save to a file, else you lose everything. Using TCLs introspective abilities its relatively easy to dump some or all of the current interpreter state into a tcl file (I've written a proc to make this easier before, however mostly I would just develop in the file in the first place, and have a function in the application to resources itself if its source changes).

2 Comments

I almost always prototype my programs first in tkcon. Tkcon allows you to open a more friendly editor to edit functions by using the edit command.
yes tkcon is certaily more freindly then the default console for a number of reasons e.g. syntax highlighting
2

Not sure about that, but this system is impressively interactive: http://rigsomelight.com/2014/05/01/interactive-programming-flappy-bird-clojurescript.html

Comments

1

Most variations of Lisp make it easy to save your interactive work product as program files, since code is just data.

Charles Simonyi's Intentional Programming concept might be part way there, too, but it's not like you can go and buy that yet. The Intentional Workbench project may be worth exploring.

Comments

1

Many Forths can be used like this.

Comments

1

Someone already mentioned Forth but I would like to elaborate a bit on the history of Forth. Traditionally, Forth is a programming language which is it's own operating system. The traditional Forth saves the program directly onto disk sectors without using a "real" filesystem. It could afford to do that because it didn't ran directly on the CPU without an operating system so it didn't need to play nice.

Indeed, some implementations have Forth as not only the operating system but also the CPU (a lot of more modern stack based CPUs are in fact designed as Forth machines).

In the original implementation of Forth, code is always compiled each time a line is entered and saved on disk. This is feasible because Forth is very easy to compile. You just start the interpreter, play around with Forth defining functions as necessary then simply quit the interpreter. The next time you start the interpreter again all your previous functions are still there. Of course, not all modern implementations of Forth works this way.

1 Comment

Which is the most popular Forth, I would like to try this.
1

Clojure

It's a functional Lisp on the JVM. You can connect to a REPL server called nREPL, and from there you can start writing code in a text file and loading it up interactively as you go.

Clojure gives you something akin to interactive unit testing.

I think Clojure is more interactive then other Lisps because of it's strong emphasis of the functional paradigm. It's easier to hot-swap functions when they are pure.

The best way to try it out is here: http://web.clojurerepl.com/

ELM

ELM is probably the most interactive you can get that I know of. It's a very pure functional language with syntax close to Haskell. What makes it special is that it's designed around a reactive model that allows hot-swapping(modifying running code(functions or values)) of code. The reactive bit makes it that whenever you change one thing, everything is re-evaluated.

Now ELM is compiled to HTML-CSS-JavaScript. So you won't be able to use it for everything.

ELM gives you something akin to interactive integration testing.

The best way to try it out is here: http://elm-lang.org/try

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.