Dawsy
Dawsy

Reputation: 10609

Are there any decent scripting languages that use functional programming?

I've been reading a bit about functional programming recently and am keen to get have a bit of a play. are there any decent scripting languages that support functional programming? I find that the bulk of my ad-hoc programming is done in Python, so I thought I might be able to do the same with a functional language. Any recommendations?

Upvotes: 19

Views: 11618

Answers (9)

devdanke
devdanke

Reputation: 1590

Kotlin is a practical functional language, mainly for the JVM. It has a scripting flavor called kscript. I've used it for shell scripting in personal projects. Simple example:

#!/usr/bin/env kscript

args.forEach { arg -> println("arg: $arg") }

Run it:

  > ./example.kts hey you
  arg: hey
  arg: you

Drawbacks:

  • Requires JVM
  • Slow startup

For more info:

If you're comfortable with the JVM and like functional programming, kscript is worth exploring.

Upvotes: 2

ein mensch
ein mensch

Reputation: 341

I recently work on a functional scripting language and already finished the first version. It is a bit like a haskell/perl combination and therefore nice for scripting and mathematical problems, too. For example here is a code snippet demonstrating how easy it is:

5 times {echo["Iteration: " concat str[x]]}

If you are interested, you can give it a try: http://ac1235.github.io

Upvotes: 1

Julia language. Also not just a "scripting" language, as fast as C.

See my answer here: https://www.quora.com/Whats-a-good-scripting-functional-programming-language/answer/Páll-Haraldsson

Upvotes: 0

Jason Miesionczek
Jason Miesionczek

Reputation: 14448

Scala can also be used as a scripting language. It runs on the JVM and supports both imperative OO and functional programming. Using this you can have access to the entire Java class library.

Upvotes: 6

Telemachus
Telemachus

Reputation: 19705

Perl can do functional style programming very well. It isn't a pure functional language by any means, but it supports quite a lot of functional idioms. The classic full-length treatment is Mark Jason Dominus's Higher Order Perl, which is now available freely online.

For briefer introductions, take a look at these slides:

Upvotes: 3

unwind
unwind

Reputation: 399813

GNU's Guile can be used as a stand-alone script interpreter, see this FAQ entry for the details. Not sure how much general programming support is in Guile, though, but it could at least get you started quickly with something that should look and feel like a "traditional" functional language.

Upvotes: 4

Chuck
Chuck

Reputation: 237040

It depends on what you mean by "scripting language." It isn't commonly viewed that way, but many Scheme implementations seem to fit the bill as well as Python, and Lisp is sort of the archetypal functional language.

Upvotes: 1

Alnitak
Alnitak

Reputation: 339816

Lua appears to fit your needs:

Lua (pronounced /ˈluː.ə/ LOO-uh) is a lightweight, reflective, imperative and functional programming language, designed as a scripting language with extensible semantics as a primary goal.

Upvotes: 14

mishac
mishac

Reputation: 3314

Python can be written in a functional style, as can JavaScript. If you mean something more purely functional, then you could try Haskell.

Upvotes: 3

Related Questions