2

I'm toying with the idea of writing a command line interpreter and I suspect that a functional language such as Clojure is well suited to this task.

I am however 5 years out of a CS degree and my only experience with functional languages was a harrowing experience with Haskell in a third year languages course.

So, is a language such as Clojure ideal for this task? If not, what is an ideal language.

Loose requirements:

  • Has to run on a JVM
  • Provide an interactive shell where users enter commands with a CLI like syntax
  • User commands ultimately end up making calls to a remote service using SOAP.

Thanks!

1
  • So your requirements (from the list of your requirements and the title) are “functional programming language which runs on the JVM and does the compiling on a server which is connected via SOAP”?! Commented Dec 1, 2011 at 2:00

2 Answers 2

3

You can approximately do that out-of-the-box with Clojure and Scala, and with Java if you add BeanShell. You might look at the REPL facilities they already have.

I imagine that's suited only for sophisticated users. But really, it's hard to imagine a language that wouldn't do a fine job on a CLI.

Deciding between platforms, the more of a modern system it is, the more it will have scripting language convenience.

I certainly know what I would use given your requirements: JRuby. (It has an out-of-the-box REPL, too.)

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

2 Comments

Thanks for the leads. I'll certainly look into it. You make a very good point about sophisticated users. This is something that would be used primarily by sysadmins who would be hard pressed to learn functional programming. I want to become familiar with a language like Clojure so I'll find a better nail for that hammer. Thanks.
So if you install those, you get the Scala REPL by just running scala, the JRuby REPL by running jirb, the Clojure REPL by running bin/repl.sh and I have no idea how to run BeanShell, but wouldn't it be funny if it was $ bs. :-)
0

I don't think a CLI has any specific requirements language-wise; you could probably do just as well writing it in Java or Scala. Ultimately I think language choice is down to:

  1. Which ones you are most comfortable working with.
  2. Which ones have adequate library support for what you want to do (i.e. web services).

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.