Subscribe to andrewsw's Blog        RSS Feed

My Language Dabbling

Icon 4 Comments
I occasionally dabble with other programming languages. (I am avoiding the term 'study' as I am already versed in a number of languages and don't currently have a need, or incentive, to study another to any great depth.)

We all start with one language but, at some stage, it is an important part of your education to study another language, preferably one that isn't too similar to your primary language. More and more these days, it is expected that we are familiar with more than one language, as well as different tools, libraries and frameworks (etc..).

I will stress that you shouldn't consider exploring another language until you are able to build a non-trivial application in your primary language.

Functional programming is well outside my comfort zone. Ages ago I installed and explored Haskell, which is, I believe, considered a/the pure functional programming language. I found it a challenge. I switched to F# which is more accessible, particularly for a .NET'ter. If you have a full version of Visual Studio, or the Community Edition, then you can be up and running in no time, in a familiar environment. A brief introduction is Try F#, but it is brief.

Alternatively, Racket is good and accessible, and comes with the Dr Racket IDE. Its home.

Quick: An Introduction to Racket with Pictures
The Racket Guide

The Racket Guide is very thorough, a little too much to be an introductory tutorial, although the first two or three chapters are accessible. I might search further for a tutorial somewhere between these two.

I won't attempt to describe functional programming. This is an ongoing, and intermittent, (but non-essential) project for me. [In my head currently, functional programming is all about immutability. (It is about being stateless as well, but I'm lumping this in with immutability pro tem.)]

Don't Be Scared of Functional Programming
A practical introduction to functional programming

These articles use Javascript and Python respectively, emphasizing that functional programming is an approach, not a programming feature (although first-class functions are required).

Here's some Racket code to give a flavour:


Depending on your experience and expertise you may find a site like Learn X in Y minutes useful.

Racket is in the Lisp/Scheme family, so you could consider Lisp (or Scheme). Lisp is an early, significant and influential, language. It is a common misconception that Lisp is a functional language; it isn't although it can be.

I did install a version of Common Lisp, CLISP, but decided that I would use it with a version of Emacs (an editor/IDE) that I'd previously installed. Emacs is a natural home for Lisp. Rather than struggle to configure Emacs though, I instead installed Lispbox, which is essentially Emacs configured for Lisp. (Emacs itself already has a couple of versions of Lisp anyway, but Lispbox is nicely configured. Note, it is started from a batch file.)

Emacs itself is a challenge - few of my familiar Windows shortcut keys work! I took it as an opportunity to learn Emacs and Lisp, but to concentrate on Lisp, picking up a few shortcuts as I progress.


ctrl-c ctrl-c slime-compile-defun
ctrl-c ctrl-z switch to interactive Lisp
ctrl-c ctrl-q slime-close-parens-at-point

ctrl-x ctrl-e (SLIME) eval last expression

ctrl-x b switch-to-buffer
ctrl-x ctrl-s save-buffer
ctrl-x k kill buffer
ctrl-c ctrl-l slime-load-file
ctrl-c ctrl-k compile and load file

alt-shift-< beginning of buffer
alt-shift-> end of buffer

ctrl-alt-q from opening parens, reindent
ctrl-c alt-q from within function

ctrl-x ctrl-t transpose-lines

alt-x slime, restart Slime
REPL comma, quit
REPL comma, cd

(A number of these shortcuts are specific to the Lispbox installation, with SLIME.)

This is a good tutorial and assumes Lispbox is used:

Practical Common Lisp

A flavour of Lisp:


To be honest, I haven't decided which of Racket or Lisp I might continue to (occasionally) indulge in. I like the Lisp tutorial I referenced, but Emacs is a challenge to work with. At the stage/level that I am at currently the differences between them aren't significant, as you can probably tell from the code samples posted above.

A blog doesn't need to have a point, but mine usually do. I encourage you to explore (when you are ready) another language, particularly one that takes you outside of your comfort zone. Tickle those grey cells. (Tcl is another, though smaller/scripting, language influenced by Lisp.) Your first second-language doesn't have to be as challenging as a functional one though, it wasn't mine. For example, Java and Python are significantly different, and Javascript is different to most other languages (including Java).

4 Comments On This Entry

Page 1 of 1


07 January 2016 - 12:25 AM


It is a common misconception that Lisp is a functional language;

Looking at Hoyte's argument here, I'm calling bullshit. He loses it on the first turn: he tries to substitute the mathematical definition of "function" for the one standardly used in programming, and then proceeds as though nothing has happened. Well, something has happened: he's changed the rules. This is not what anyone means by a "functional language", and he knows it, and he's grandstanding.

Personally, I'm not convinced that the term "functional language" is well defined, but if the term has a meaning at all, it's a simple one: a functional language is a language which treats functions as first-class citizens, meaning they can be named, and passed as arguments, and returned as values, and stored in data structures. If you have that, you have a functional language. This annoys some people because it means that Python is a functional language, and so is Perl, but do we really care about those people? I don't.


08 January 2016 - 08:16 AM
I'll refine this a bit. A functional language is one that supports programming with pure functions. I use the word "supports" rather than "has" because many languages have pure functions and allow one to pass them around. The key thing to realize however is that not all languages make this a priority or try to support it to the same degree. Haskell goes out of its way to support it, Lisp goes a bit less out of it's way, and python a bit less, and C++ and Java a bit less still. Python does support functional programming to some degree but we don't think of it as a functional programming language because that is not the primary support; the primary support is one something else that is some mixture of features of functional languages and non-functional ones as well.


08 January 2016 - 10:23 AM
This is why I like the first article I linked (Don't Be Scared of..) because it uses Javascript to emphasize that functional programming is, essentially, an approach, rather than something intrinsic to only a small set of languages. It is an approach that, as ishkabible says, is supported by some languages more than others.


09 January 2016 - 01:09 PM


A functional language is one that supports programming with pure functions.

I think this is isomorphic with "has functions as first-class objects". If so, we're more or less on the same page, though I don't really see how or why you'd want to make "functional" a scalar property of languages - either it's a functional language, or it isn't. By my definition, and yours, Lisp, Haskell, Python, and Perl are all functional languages and Java, C, Fortran, and BASIC are not. A useful heuristic: Language L is a functional language if you could teach the material in SICP, using L instead of Scheme.

The phrase "purely functional" brings to mind the nearly-departed (and not much lamented) cult of FP, who require us to distinguish between "functional" (ie, SICP-ready) and "purely functional" (ie, ideologically correct). I never understood the defensive and cultish nature of this cult, but fortunately it seems to be withering away as their ideas are adopted into mainstream languages, and their preferred "pure" languages continue to fail to do anything at all. As a practical matter, it's hard to name a language in common use today which is not either Java, or C, or a functional language, and it's hard to find an example of real-world code written in a "purely functional" language. What place for ideologues now?
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

January 2021

242526 27 282930


    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)