47

I find myself repeatedly annoyed by having to teach freshmen about special language rules (like array-to-pointer decay) that have absolutely nothing to do with programming in itself. So I wondered:

What is the programming language with the smallest number of special language rules, where everything is first class and can be composed without annoying technical restrictions? Wouldn't such a language be the perfect teaching language?

Moderator Note

We're looking for long answers that provide some explanation and context. Don't just list a language: please explain why you think the language answers the question. Answers that don't explain anything will be deleted. See Good Subjective, Bad Subjective for more information.

Ixrec
  • 27,711
fredoverflow
  • 6,954

9 Answers9

54

When it comes to 'very few rules', I would argue, Lisp or Smalltalk would win. The bare Syntax can be written on one beer tab.

But in my experience, the simplicity of Lisp and Smalltalk does not mean they are simple to understand and easy to teach. While not the 'pure' way, in my experience the to-do-list-style of imperative languages is the easiest to grasp for newbies.

Therefore, I would suggest Python, Ruby or something of similar abstraction: You find (nearly) every basic concept in them (OK, no pointers), but you don't need to understand it from the start to make something working.

Glorfindel
  • 3,167
keppla
  • 5,210
  • 26
  • 32
42

I'd say LISP, or Scheme or a language from that family would be the most orthogonal. With let, lambda, define, if, cons, list, and ( ) you can teach pretty much anything that you'd want to in an intro course. There's also no need for preprocessing directives or int main() and stuff like that which students just include but don't see a reason for.

In my intro CS courses, we did a lot of really cool things with Scheme: implement a Turing machine, implement a TC-201 computer, write a context free grammar, use recursion, write merge and insertion sort, implement adders, and tons of other stuff.

I had done Java in AP comp sci before college, but Scheme was great because I could cut the clutter and focus on the actual concepts in my program. It was a great class and I'd highly recommend you try it for your teaching.

BlackJack
  • 3,877
  • 5
  • 35
  • 52
17

Pascal was specifically designed to teach programming. It's easy to learn (it was one of the first programming languages I learned).

Henrik
  • 297
14

Logo: it's still alive and kicking!

; draws a triangle
FORWARD 100
RIGHT 120
FORWARD 100
RIGHT 120
FORWARD 100
RIGHT 120

It might seem more like a toy then a programming language, but it wouldn't be a bad first step for a lot of people. The syntax is very simple, but the turtle provides a more concrete form of feedback than most languages/environments. Trying to create a specific shape is a great way to learn the process of thinking ahead to solve a problem.

If you have an aversion to turtles, though, I really think Scheme is the way to go.

benzado
  • 2,293
10

I would propose both SML and Haskell. Orthogonality has been a principal design point for both. In particular, the core of SML (that is, the portion of the language not concerned with modularity) is pretty much a typed lambda calculus. As a result, most language features are driven by types and the types in turn drive the introduction and elimination forms for the values. This is pretty much ideal.

There are a few non-type-theoretic warts in both languages (eqtypes in SML, seq in Haskell) but they still beat the pants of anything else out there in terms of bizarre interactions of unrelated language features.

8

Whatever the choice, I would strongly urge teaching a “real” language. Teaching toy languages works for some people, but for others it’s very, very frustrating due to the disconnect to the real world. Some people need real-world relevance as a motivation for learning, and it’s not our place to judge this learning strategy (in fact, that’s a common misconception).

This disqualifies languages such as Logo, but also domain-specific languages such as Processing. While the latter is extremely useful for certain things (e.g. producing info graphics), the use is too restricted for most uses (and thus most users). This also excludes Gofer, a useless Haskell subset. It also excludes Pascal because although the latter has been used in real projects, it just isn’t relevant any more and simply lacks essential features (e.g. built-in strings).

Of the practical languages, I’d agree with those already mentioned: modern Lisp or Scheme dialects, Haskell, Python or Ruby. Personally, I’d probably use Python but all those choices have their share of advantages and disadvantages.

7

Tcl has 12 rules that govern the entire language.

[1] Commands. 
[2] Evaluation. 
[3] Words. 
[4] Double quotes. 
[5] Argument expansion. 
[6] Braces. 
[7] Command substitution. 
[8] Variable substitution.
[9] Backslash substitution.
[10] Comments. 
[11] Order of substitution. 
[12] Substitution and word boundaries.

There are very few special cases or reserved words or characters.

gnat
  • 20,543
  • 29
  • 115
  • 306
Bryan Oakley
  • 25,479
4

What is the programming language with the smallest number of special language rules, where everything is first class and can be composed without annoying technical restrictions? Wouldn't such a language be the perfect teaching language?

To expand on my comment, in Jot everything is first class (because it's a lambda calculus) and can be composed. There is only one instruction. It's an absolutely awful teaching language.

In general, Turing tarpits have very few special rules and require you to understand the fundamentals of computation very well before you can do anything. The perfect teaching language allows students to experiment without pulling out all of their hair, so higher level abstractions are actually a good thing.

Peter Taylor
  • 4,043
2

The most important features in a langage you learn are:

  • principle of least surprise (PASCAL)

  • readability (Ada)

In my opinion, the second trumps the first, since reading code is even more important than writing it.

Now again, I write C#, Java, Objective-C and Javascript for a living, all of which have horrible quirks :D

Still if I had to choose one langage to start with, I'd go for C#. It's relatively easy to read, has few serious surprises in itself (they are most often hidden in MS tools/frameworks...) and a massive amount of code to be read and documentation, both of which are essential to learning well.

Kheldar
  • 219