Monday, April 11, 2005

Language Oriented Programming: Everything is a Language

Some people don't 'get' Language Oriented Programming. It's a different perspective. Once you make the mental shift, everything starts to fall into place. Over the past few months, I've been looking at the software development world with LOP-coloured glasses, and I've come up with a quick zen-slap phrase which I hope will help shift your paradigm.

(If that last sentence made you think, "I hate the word 'paradigm'! It's a meaningless marketing buzzword," then read this before reading on below.)

Everything is a Language
Just as OOP introduced 'everything is an object', I propose for LOP that 'everything is a language'. Keep this in mind as you read about and discuss software, and suddenly things will look very different to you. But what the heck do I mean?

Programming is Communication
When you want to communicate an idea to someone, how do you do that? You use the tool that Homo Sapiens 1.0 has evolved over millions of years: Language. You'll speak, you'll make gestures. If you want the communication to last over time, you'll write it down in symbols. These days you can use fancy tools like keyboard, mouse, digital memory, and graphic display to write these symbols.

Now, when you want to instruct a computer, how do you do that? You write symbols using keyboard, mouse, digital memory, and graphic display. You're doing the same things, but instead of communicating ideas to people, you are communicating ideas to the computer. Now, of course, there are a couple of important differences, such as the fact that there are strict rules on which symbols are used and how they are arranged, and also the fact that the symbols have a very precise, concrete meaning (e.g. '2 + 2' actually performs a physical action in the computer to produce the symbol '4'). However, at the end of the day, a programmer's work primarily involves communicating to the computer via language.

The Editor is the Medium
Before I go into the examples, there is one important thing to know. Language does not exist without a medium. Spoken words require a mouth to speak, air to propagate sound waves, and an ear to listen. Sign language requires hands to make the signs, light to carry the image, and eyes to read the signs. Writing requires a pen, paper, and eyes. Programming requires a keyboard to type, an editor to accept the input, and a compiler or interpreter to execute the program. Take away any of these things, and communication is much more difficult.

Marshall McLuhan tried to emphasize this fact by saying that "the medium is the message". He, perhaps, overstated his case for emphasis. But the fact remains that the medium of language is an important, indispensable part of the language. So I will now put '2 + 2' together to state something that will likely bother some hard-core programmers: The editor is an important, indispensable part of the programming language. The editor is the medium of the programming language.

Examples
When you start to think 'everything is a language', you will start to see computer languages everywhere.

JUnit and TestNG
JUnit is the most popular unit testing framework, but there are many clones and variations. They are all languages. With a unit test, you attempt to communicate to your system that, when the environment is set up in this way, this is what you expect, and this is what actually occurs. But have you noticed how ugly it is to write a test that says "this method should throw this exception"? That is because JUnit is written in Java, and the only way to do this in Java is to wrap the method in a try/catch statement. JUnit is a language on top of Java. Notice how new frameworks such as TestNG try to modify Java (with annotations) to make writing tests more natural? That is because they want to be true languages.

EasyMock and jMock
The Mock Objects pattern is another language, and two popular frameworks again try to adapt Java into a mock-object language. EasyMock uses dynamic proxies to generate mock objects on the fly. But notice how you have to have this clumsy MockControl object to specify return values and exceptions? jMock goes further than EasyMock, allowing you to specify in a fairly natural way the expected inputs and outputs. But notice how you lose Java's language support for interfaces; instead you have to specify method names with Strings, making refactoring method signatures with an IDE more difficult. And while writing mock expectations may be fairly natural, it's actually not very natural at all; it doesn't look like a normal Java method call as it would with EasyMock. That's because both of these frameworks are languages on top of Java. I think it would be great if my editor allowed me to write out the expectations using special notation that isn't possible in Java, like this:

myObj.myMethod(obj equals expectedObj, date between startDate .. endDate) returns expectedResult;

XML this and XML that
Have you noticed the proliferation of all these XML dialects? Why is that? It's because XML gives you a standard and relatively easy way to invent your own languages. The parser is already built, all you need is a DTD for your syntax and to wire up the grammar to your Java (or other language) objects for your semantics. Ant is one example, but there are zillions more. Obviously, there is a need for the ability to easily create specialized languages. This is one of the primary forces behind Language Oriented Programming.

Struts, Spring, and Rails
Web frameworks are yet another kind of language we are seeing a lot of these days. Notice how Struts defines page navigation using XML, extends JSP with tag libraries, and provides special facilities with its class framework? I wonder why such a project as Struts Console exists, or the various IDE plugins. Could it be because Struts is a language? Spring wires up your application with a configuration script (hint: in its own specialized XML language). Rails rewrites entire classes, re-interprets method calls, and has dozens of other meta-programming tricks just to make your life easier. These frameworks are all attempts to work around the deficiencies of their host languages. Imagine the power that would be possible if they could be languages in their own right, with things like IDE support, refactoring, and whatnot. (I'm talking about LOP, people.)

Aspect Oriented Programming
Why isn't it popular? No IDE support. 'Nuff said.

Ruby, Python, PHP, and even JSP
Dynamic languages are on the rise. Why is that? Let's put on our LOP glasses. Static languages are great because you get lots of support from your tools. The compiler gives you lots of hints, and can do things like optimize your code. A smart IDE like IntelliJ IDEA can make judgments about code, allowing static analysis, refactoring, code completion, and navigation. But static languages also have some downsides. Every little detail has to be specified, sometimes more than once. Little errors can blow up in your face if you're not disciplined in your coding practices.

Dynamic languages make a trade-off. They try to be more flexible, and get out of the programmer's way, at the expense of losing some of the features of a static language. Sometimes, this trade-off is in the interests of the programmer. With more mature languages like Ruby and Python, the advantage is slowly tipping more and more in favour of dynamic languages. Wouldn't it be cool if you could have the power and flexibility of a dynamic language, with all the extra cool features of a static language, and a kick-ass editor to boot? Hmmm.

So...
Keep your eye out for this stuff. It's going to become more and more obvious to you. All you have to remember is that everything is a language.

28 Comments:

Anonymous Anonymous said...

A great post.

Have you noticed the proliferation of all these XML dialects? Why is that?

Because the Java language doesn't facilitate the level of expression needed for these situations. If you look at languages like Python and Ruby, you see XML being used much less for these tasks because the language accomodates much more.

Python's SQLObject ORM is a good example of this. The mapping information is specified within the language as opposed to XML mapping files.

Ruby on Rails is also a good example. Compare the configuration of controllers in RoR to, let's say, Strut's XML config.

April 11, 2005 4:45 PM  
Anonymous Anonymous said...

I wonder how you'd react to something I blogged a few weeks ago:

http://www.jroller.com/page/dhall/?anchor=just_what_constitutes_a_dynamic

(If the link doesn't due to formatting, the title of the entry is "What constitutes a dynamic language, anyway?")

I think we've come to some of the same conclusions via different paths.

David Hall
http://jga.sf.net/
http://jroller.com/page/dhall

April 11, 2005 6:13 PM  
Anonymous Anonymous said...

Yes, jMock was explicitly designed as a language, not an API. We recently gave a presentation on exactly this topic at SPA'05. The slides are here: http://www.spaconference.org/cgi-bin/wiki.pl/?EvolvingAnEmbeddedDomainSpecificLanguageInJava.

April 14, 2005 7:30 PM  
Anonymous Anonymous said...

Indeed, ITLS!

April 14, 2005 7:56 PM  
Anonymous Anonymous said...

Yup, you hit it on the head. The bottom line is, "how well does the tool I'm using express my intent?".

JMock's syntax feels like it wants to be a language, but it's still constrained by how Java wants code to look. A unit test language based on dynamic mocks would be a GREAT proof of concept for LOP. I want my unit tests to read like statements that can be made about how the program operates. I would love to see how close a testing-specific language could get to that ideal.

I think the success of Rails is due to the fact that it feels like a web application language, due to Ruby's flexibility and some really good API design.

Another example might be UI behavior design; often I feel like the UI control might be best expressed as a state diagram or a state table. A language that facilitated this would be excellent.

We as developers spend WAY too much time fighting our tools to get them out of our way so that we can get down to the real business that we want to accomplish in the first place.

I'm looking forward to JetBrains' first step forward with a LOP tool.

May 16, 2005 5:42 AM  
Anonymous Anonymous said...

JMock was explicitly designed to be an Embedded Domain Specific Language, embedded within Java. You're right, Java makes this kind of design very difficult. Smalltalk allows one to achieve what we wanted -- an embedded language that refers to the host language. To achieve this in Java required lots of hard work and still leaves a lot to be desired.

September 02, 2005 5:23 PM  
Anonymous Anonymous said...

Hello,

Just thought I would check out your blog.
I am new to blogging. I hope you don't mind me posting to your blog. If you are interested in checking out my blog and making a post that would be great.

I have a hosting lowcost web site/blog. It pretty much covers ##WEB HOSTING## related stuff.


Thanks,
Ed

November 22, 2005 7:05 PM  
Anonymous Anonymous said...

Well I just got back from the gym and I am beat. I am currently doing some research on web space hosting and stumbled across your blog. Which cracks me up really. The internet can certainly land you off base sometimes. Even though Language Oriented Programming: Everything is a Language is not completely related I think it is a cool blog. I have read back through the archives and lots of people make some very good points. Well I have been on-line forever it seems. I need to continue to plug away at web space hosting. If you have the energy swing by web space hosting. I try to update my site weekly and maybe you will see something you like. I already snagged your URL and put it in my favorites. If you do not mind I will be back again. Great job!

December 02, 2005 9:01 AM  
Anonymous Anonymous said...

Hi Rob Harwood your blog is really great! Wow :-) As I was out blog surfing and surfing the web for detailed info on web hosting company for small business I stumbled across your blog. Obviously my search landed me here and it is a little off subject compared to Language Oriented Programming: Everything is a Language, but I am certainly glad I did come across your blog. Did I already tell you I like it! If you would not mind, I would like to add your link to my "favorites" page to come back and read again sometime. Should you ever need it, there's lots of information on this site about web hosting company for small business. Again, great blog and keep up the great work!

December 02, 2005 7:12 PM  
Anonymous Anonymous said...

I love your blog Rob Harwood. How long has it been on-line? Reason I ask is I am doing a ton of work in the area of lowcost web hosting and will probably end up starting a blog of my own. Funny how the internet brought me here when I was doing searches on lowcost web hosting. Oh well, I am glad it did. Keep up the great blogging and I am sure I will visit Language Oriented Programming: Everything is a Language again!!

December 03, 2005 10:07 AM  
Anonymous Anonymous said...

I have been on-line searching for hours for information regarding personal web site hosting and stumbled across your blog during my journey :-) Rob Harwood your blog is really amazing! Keep up the great work. Obviously my search on personal web site hosting was way off when compared to Language Oriented Programming: Everything is a Language and find it funny how it landed me here. The internet is a funny thing. Anyways, great job on your blogging and keep up the good work! I been searching for personal web site hosting for over 2 hours and needed a break from it. I started reading your blog and really started getting into it.
P.S I will add you to my favorites so I can come back and visit later
P.S.S If you want to bookmark my site I am at personal web site hosting. You never know you may find some good deals!

December 04, 2005 8:26 AM  
Anonymous Anonymous said...

All I can say is WOW Rob Harwood. The other half and I just got back from our friends house (well her friends house) and I needed a huge break. I am working on a project right now that is based on web hosting company for small business. I have literally been on-line for 2-3 hours doing research. Even though Language Oriented Programming: Everything is a Language really isn’t on the same page as web hosting company for small business I am certainly glad I came across your blog. There are a ton of great view points on this blog. Well I think I can here the kids screaming in the background. I put you in my internet favorites and I will certainly come back and visit. If you want to take a peek at my site you can find me here at web hosting company for small business. I update my site very frequently. Again, great job blogging and I will be back again soon!

December 05, 2005 8:53 PM  
Anonymous Anonymous said...

Hey Rob Harwood. Very nice blog :0) I just got inside from washing and waxing my truck. It is my baby. Took me 2 hours though. So I settled down into my basement and started doing some web surfing. Anyways I am in the process of grabbing my masters degree and have spent the last 6 months researching small business web hosting services. In the midst of my surfing I landed smack dab in the middle of your blog. I hope you do not think I am intruding but I must say it is great blog. Even though Language Oriented Programming: Everything is a Language is way off base from small business web hosting services I found myself cruising through your blog archives for the last half hour :0) You have some nice blogging friends. Anyways, I need to get back to my mission. I wrote don’t your url and feel free to visit me here at small business web hosting services. I am so busy so I can only update my site monthly. Keep up the great work.

December 07, 2005 11:13 AM  
Anonymous Anonymous said...

I have been on-line searching for hours for information regarding small business web hosting services and stumbled across your blog during my journey :-) Rob Harwood your blog is really amazing! Keep up the great work. Obviously my search on small business web hosting services was way off when compared to Language Oriented Programming: Everything is a Language and find it funny how it landed me here. The internet is a funny thing. Anyways, great job on your blogging and keep up the good work! I been searching for small business web hosting services for over 2 hours and needed a break from it. I started reading your blog and really started getting into it.
P.S I will add you to my favorites so I can come back and visit later
P.S.S If you want to bookmark my site I am at small business web hosting services. You never know you may find some good deals!

December 08, 2005 10:50 PM  
Anonymous Anonymous said...

I love your blog Rob Harwood. How long has it been on-line? Reason I ask is I am doing a ton of work in the area of net web hosting and will probably end up starting a blog of my own. Funny how the internet brought me here when I was doing searches on net web hosting. Oh well, I am glad it did. Keep up the great blogging and I am sure I will visit Language Oriented Programming: Everything is a Language again!!

December 09, 2005 7:43 PM  
Anonymous Anonymous said...

Hey Rob Harwood. Very nice blog :0) I just got inside from washing and waxing my truck. It is my baby. Took me 2 hours though. So I settled down into my basement and started doing some web surfing. Anyways I am in the process of grabbing my masters degree and have spent the last 6 months researching web space hosting. In the midst of my surfing I landed smack dab in the middle of your blog. I hope you do not think I am intruding but I must say it is great blog. Even though Language Oriented Programming: Everything is a Language is way off base from web space hosting I found myself cruising through your blog archives for the last half hour :0) You have some nice blogging friends. Anyways, I need to get back to my mission. I wrote don’t your url and feel free to visit me here at web space hosting. I am so busy so I can only update my site monthly. Keep up the great work.

December 12, 2005 4:06 AM  
Anonymous Anonymous said...

Sad to say I just got back from a bowling tournament and decided to log in and do some websurfing. Rob Harwood I love your blog. I had some very good laughs. I am doing a paper on small business web hosting services and have been downloading information for the last hour. I don’t know how I came across Language Oriented Programming: Everything is a Language but I am glad I did. It has set me back a little because I have spent the last hour reading your archives. If you don’t mind I would like to add you to my favorites so I can back again and read some more. Well I need to get back to small business web hosting services. I am almost finished with it. Great job.
p.s some very good points on your blog

December 12, 2005 9:09 PM  
Anonymous Anonymous said...

Well I just got back from the gym and I am beat. I am currently doing some research on personal web site hosting and stumbled across your blog. Which cracks me up really. The internet can certainly land you off base sometimes. Even though Language Oriented Programming: Everything is a Language is not completely related I think it is a cool blog. I have read back through the archives and lots of people make some very good points. Well I have been on-line forever it seems. I need to continue to plug away at personal web site hosting. If you have the energy swing by personal web site hosting. I try to update my site weekly and maybe you will see something you like. I already snagged your URL and put it in my favorites. If you do not mind I will be back again. Great job!

December 14, 2005 8:51 PM  
Anonymous Anonymous said...

I love your blog Rob Harwood. How long has it been on-line? Reason I ask is I am doing a ton of work in the area of best web hosting company and will probably end up starting a blog of my own. Funny how the internet brought me here when I was doing searches on best web hosting company. Oh well, I am glad it did. Keep up the great blogging and I am sure I will visit Language Oriented Programming: Everything is a Language again!!

December 15, 2005 5:58 PM  
Anonymous Anonymous said...

All I can say is WOW Rob Harwood. The other half and I just got back from our friends house (well her friends house) and I needed a huge break. I am working on a project right now that is based on best web hosting company. I have literally been on-line for 2-3 hours doing research. Even though Language Oriented Programming: Everything is a Language really isn’t on the same page as best web hosting company I am certainly glad I came across your blog. There are a ton of great view points on this blog. Well I think I can here the kids screaming in the background. I put you in my internet favorites and I will certainly come back and visit. If you want to take a peek at my site you can find me here at best web hosting company. I update my site very frequently. Again, great job blogging and I will be back again soon!

December 17, 2005 8:21 AM  
Anonymous Anonymous said...

Hello, I found your blog while searching for baby sign language video information. Your site is informative, but not quite what I was looking for.

I'll have to come back and check it out again sometime soon though.
I'm going to keep searching around for baby sign language video info. Take care till next time.

February 03, 2006 8:46 AM  
Anonymous Anonymous said...

Just blogging for a while, my site is also about internet web hosting, so just saying hi.

Charles

February 18, 2006 1:53 PM  
Anonymous Anonymous said...

You blog sure gets quite a few comments. I'm going to read thru your posts and see why you are generating so much interest.

March 03, 2006 11:29 AM  
Anonymous Anonymous said...

Have you tried OCaml? Here is a comparison between Ruby and OCaml (on a Ruby mailing list):
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/45787

March 08, 2006 1:43 PM  
Anonymous Anonymous said...

Tcl is a language oriented programming language. You can make sure the code in your example works. Tcl is about as fast as Ruby, so not very fast, but not bad either.

March 08, 2006 8:57 PM  
Anonymous Anonymous said...

Hi there Rob Harwood, I am searching for the latest information on
and found your site. Although Language Oriented Programming: Everything is a Language wasn't exactly what I was searching for, it certainly got my attention and my interest. I see now why I found your post when I was looking for related information, I am glad I found your page and will add it to my list of great informational sites. Have a nice day!

March 16, 2006 5:37 AM  
Anonymous Anonymous said...

I was doing the Google search found your blogsite. Some content here is very thought provoking. Not sure i agree with all but hey this is a democratic society - on the whole!!

All the best again, from David at http://www.small-business-web-design.ssr.be which is about web ecommerce design

April 10, 2006 10:50 PM  
Anonymous Anonymous said...

Groovy refers to Domain Specific Languages, is this along the lines of what you mean?

http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific+Languages

April 24, 2007 7:30 AM  

Post a Comment

<< Home