views:

808

answers:

22

For my computing languages class, we've been assigned to read On the Design of Programming Languages by Niklaus Wirth. One of Wirth's main points is that programming languages should choose a few abstractions and stick with them.

I'm trying to brainstorm some more modern examples than the ones that Wirth gives (although they don't necessarily have to be from the latest and greatest languages) for my paper on the subject. Of course, I'm not asking anyone to write this section of my paper for me. Thus, don't try to make any of these examples relevant to Wirth's paper. Instead, I'm really just looking for a base of examples I can examine and then choose the best one(s).

TL;DR I'm looking for things along the lines of UNIX's "everything is a file" but for programming languages.

Note: One other thing I should point out, the examples don't necessarily have to be along the lines of "Everything is a..." For example, Ruby's blocks are a good abstraction, but not everything in Ruby is a block.

+14  A: 

Of course, Smalltalk's "everything is an object" is a good example of such abstractions that has carried over into several more modern languages.

Jason Baker
+12  A: 

LISP - Everything is a list.

DrJokepu
That's a good one, especially when dealing with macros.
Tom Ritter
Of course, I use a lot of arrays and structs in my Common Lisp coding. However the idea that source code is S-expressions is a very valuable abstraction.
David Thornley
Has hurt lisp more than helped, sadly...
Norman Ramsey
Pfft. You have no idea, Norman.
Svante
@Svante: You really don't think that LISP's unusual syntax has hurt adoption by mainstream programmers? That's what Norman meant.
j_random_hacker
+3  A: 
  • BCPL's everything is a machine word? Infamous rather than famous, perhaps.
  • SQL - everything is a relation
  • TECO (an ancient editor) - every sequence of characters is a valid command
anon
+3  A: 

Erlang's pervasive processes, perhaps? And its shared-nothing message passing.

Dana
+5  A: 
  • C makes heavy use of things are files (look at all of the functions that work with file descriptors that are not really files)

  • Java takes it further, you have the ability to treat Strings, Files, arrays, etc... the same (Reader/Writer/InputStream/OutputStream)

These are library ones instead of language ones... does that make a difference?

TofuBeer
"Everything is a file" is not really C -- the language spec itself doesn't even mention file descriptors. It is a core value of UNIX philosophy, though.
ephemient
I used the Java one for my paper, so I'll mark this answer.
Jason Baker
+3  A: 
  • SQL has views that provide a layer of abstraction.
  • Both C++ and Java have classes and operators that allow you to work on streams of data (I know other languages do too, but those are the languages I use every day).
Bill the Lizard
+15  A: 
  • C - everything needs an error check
  • Perl - everything is illegible
  • Python - whitespace is everything
  • .Net - everything is the CLR or System. is everything

;)

Tom Ritter
I think you mean that in Whitespace, whitespace is everything :P
Dana
+1  A: 

Interfaces can be understood as abstractions of contracts.
In XML, everything is a node.
In LISP everything is a function.

Dave Nichol
In Lisp, everything is a function, or a macro, or a class or struct or type, or a constant, or ... :-)
Anonymous Coward
Ha! Apparently I don't remember my college lisp class as well as I thought...
Dave Nichol
+1  A: 

Although my answer is also in the line of ...everything... but much around XML world is: everything is XML!

Think about the description format XML Schema, which is XML by itself,

Think also about XSLT which is also XML. The advantage is that XML tools can be applied on every other XML file, for instance, an XSLT script can be applied to the same XSLT script itself.

Roalt
A: 

Common Lisp: (almost?) all formatting functions that take a stream can also take nil to mean "write this to a string".

Anonymous Coward
+3  A: 

Lua - all complex data is a table

Nick
+6  A: 

Garbage collection is an abstraction from memory management

+7  A: 

C# 3: The Object/Relation problem can be solved by embedding a DSL for querying in an imperative language.

ML: The Hindley-Milner type system is a powerful tool for writing correct programs.

Haskell Has a number of non-mainstream principles including:

  • Category Theory is a powerful basis for computation.
  • Side effects and mutable state can be integrated into a pure functional language using monads.
  • Laziness is a useful tool, EG for infinite lists.
RossFabricant
+1  A: 

SQL - Everything is a set. Lots of people don't seem to realise this. Whey you've got this you'll never get those strange answers with far too many rows again, or at least you'll understand why. Select, project and join.

C - Everything is an int, except when it isn't, then it's a pointer to an int (I once wrote an article about this on my blog)

Java - Everything is a String or an int (most of the time you'll be using Strings, be honest now). (more blog stuff here and here, plus here)

Seriously, I like the idea of the nil object in languages like Ruby and Python (and Smalltalk, I think?). It is way superior to the strongly-typed NULL in languages like Java, where you can end up with null pointer exceptions about 20 miles away from where you started.

Ghoti
+2  A: 

In Ruby, everything is an object. There are no base types. So, for example, number 5 is an object.

Leon Katsnelson
+1  A: 

Functional:

  • Everything's a lambda expression
MichaelGG
Not really. That would be pure lambda calculus.
Jørgen Fogh
+1  A: 

CLU: everything is an abstract data type. Worth the 2008 Turing award!

Norman Ramsey
A: 

TCL: everything is a string.

UnLambda: Everything is S, K or I (With some `'s for syntactic sugar)

Real answers follow:

Python has list comprehensions. This is a way of combining a number of APL like operators into a human readable form. Map and filter may be expressed this way, as can (possibly join forming nested) for-each loops. If a generator expression is used, then no memory is allocated, and elements are produced one at a time as they are consumed. This kind of construction is slowly creeping into some other languages.

C++ has generic programming, making static-analysis on generic code fairly transparent. This has since appeared in other static-typed languages, namely Java and C#

TokenMacGuy
+1  A: 

As referenced in this blog post:

Java:

  • Everything's a noun.
Chamelaeon
+3  A: 

COM: everything is an IUnknown

DSO
A: 

tasks (Ada)

none
It would be interesting to know, if those people who downrated my posting are actually familiar with Ada/SPARK, and the task-based programming/concurrency model? In other words, if you care to take the time to rate something down, I'd appreciate if you could also take the time to clarify your decision ;-)
none
Hear, hear.
j_random_hacker
+1  A: 

Python has always impressed me with its "everything is what it looks like" attitude. If an object has the correct methods to be used as a file / dictionary / list / etc., then you can use it in any situation where you need a file / dictionary / list / etc., without worrying whether its internal implementation actually uses the structure its mimicking.

While that's essentially just polymorphism, Python has the simplest, broadest, and most consistent implementation of any of the languages I use frequently.

Ben Blank