onsdag, januari 02, 2008

Language explorations

I blogged about looking at languages a while back. At that point I didn't know what my next language to explore would be. I got lots of excellent suggestions. In the end I decided to try OCaML, but gave that up quickly when I found out that half of the type system exists to cover up deficiencies in the other half of it. So I went back and decided to learn Scala. I haven't really had time to start with it though. Until now, that is.

So let's get back to the motivation here? Why do I want to learn another language? Aren't I happy with Ruby? Well, yes and no. But that's not really the point. You can always point to the Prags one-language-a-year, but that's not it either. I mean, it's really good advice, but there is a more urgent reason for me to learn Scala.

I know many people have said this before, but it bears repeating. Everyone doesn't share this opinion, but have a firm belief that the end of big languages is very close. There won't be a next big language. There might be some that are more popular than others, but the way development will happen will be much more divided into using different languages in the same project, where the different languages are suited for different things. This is the whole Polyglot idea. And my take on it is this: the JVM is the best platform there is for Polyglot platform, and I think we will see three language layers emerge in larger applications. Now, the languages won't necessarily be built on top of each other, but they will all run on the JVM.

The first layer is what I called the stable layer. It's not a very large part of the application in terms of functionality. But it's the part that everything else builds on top off, and is as such a very important part of it. This layer is the layer where static type safety will really help. Currently, Java is really the only choice for this layer. More about that later, though.

The second layer is the dynamic layer. This is where maybe half the application code resides. The language types here are predominantly dynamic, strongly typed languages running on the JVM, like JRuby, Rhino and Jython. This is also the layer where I have spent most of my time lately, with JRuby and so on. It's a nice and productive place to be, and obviously, with my fascination for JVM languages, I believe that it's the interplay between this layer and the stable layer that is really powerful.

The third layer is the domain layer. It should be implemented in DSL's, one or many depending on the needs of the system. In most cases it's probably enough to implement it as an internal DSL within the dynamic layer, and in those cases the second and third layer are not as easily distinguishable. But in some cases it's warranted to have an external DSL that can be interacted with. A typical example might be something like a rules engine (like Drools).

I think I realized a long time ago that Java is not a good enough language to implement applications. So I came up with the idea that a dynamic language on top of Java might be enough. But I'm starting to see that Java is not good enough for the stable layer either. In fact, I'm not sure if Java the language is good enough for anything, anymore. So that's what my language exploration is about. I have a suspicion that Scala might be a good language at the stable layer, but at this point the problem is there aren't any other potential languages for that layer. So what I'm doing is trying to investigate if Scala is good enough for that.

But I need to make one thing clear - I don't believe there will be a winner at any of these layers. In fact, I think it would be a clearly bad thing if any one language won at any layer. That means, I'm seeing a future where we have Jython and JRuby and Rhino and several other languages coexisting at the same layer. There doesn't need to be any rivalry or language wars. Similarly, I see even less point in Scala and Ruby being viewed as competing. In my point of view they aren't even on the same continent. And even if they were, I see no point in competing.

I got accused of being "religious" about languages yesterday. That was an interesting way of putting it, since I have always been incredibly motivated to see lots of languages coexisting, but coexisting on the JVM in a productive way.

25 kommentarer:

Anonym sa...

http://haxe.org/

The honey monster sa...

I would love to hear a more in depth critique of ocaml, you condemn the language in one sentence, would you care to expand.

Jon Harrop sa...

F# is an incredibly good language and implementation. The JVM desperately needs something like that but it'll need fundamental fixes first (e.g. tail calls).

Scala seems to be very rewarding for Java programmers to learn but, as an OCaml developer, it is like beating my head against a brick wall...

See this post, for example:

http://flyingfrogblog.blogspot.com/2007/12/immutable-stacks-in-ocamlf-and-scala.html

Scala doesn't even infer as much as SML would, let alone the functional programming gold standards (OCaml and Haskell).

I would really suggest going back to basics and implementing an ML for the JVM.

Joshua Graham sa...

Along with F# is Nemerle (http://nemerle.org/Main_Page)
with Lispy macros and Haskelly lazy evaluation.

I actually suspect the Sun VM has a long way to go to support your layers but Sun appear to be willing at the moment. The CLR / DLR may be more forthcoming for the moment?

Other layers needed to support fault-tolerance and concurrent processing are a strict functional core of immutable state, one of deterministic concurrency, then asynchronous message-passing concurrency, and finally shared-state concurrency. See Peter Van Roy's "Convergence in Language Design").

Alex Miller sa...

Really great post. I think you nailed it. I added some thoughts on my blog Polyglotism.

Anonym sa...

Interesting post, I'd love to hear some more detailed insights from you about two things you mentioned:

- what exactly is the nature of the "stable layer" that you need type-safety there and that type-safety doesn't offer much in other layers? Or vice versa: That you can't implement the stable layer in a dynamic language?

- What is really so bad about Java that you can't implement the stable layer with it? Especially since the stable layer is a smaller part of the game? Java clearly has some weaknesses showing up as time goes by, but bashing Java seems so easy these days

Dan Sickles sa...

I really like your AND logic when so many are playing the OR game. It works across layers and within layers. It avoids artificial constraints and promotes forward motion.

There's some similar thinking here:
http://www.itworld.com/AppDev/choose-application-development-nlsebiz-071230/index.html

Henrik Engström sa...

Hi Ola,
Just a couple of questions regarding the categorization of layers you describe.

First: wouldn't the domain layer always be encapsulated by the dynamic layer? I mean, how can the application code be implemented without using a DSL (if you should use a DSL at all, but that's another point)?

Secondly: Why would you use a static layer at all? Could you give me some examples of when a static layer could come in handy?

Thanx for an interesting blog and good luck in the big country over there! :-)

PetrolHead sa...

I think this would benefit from a couple of things:

(1) Definitions for and examples of what lives in each of those layers.

(2) A more detailed analysis of why one language or another is not good for a layer.

This for me, really doesn't cut it:

"I think I realized a long time ago that Java is not a good enough language to implement applications. So I came up with the idea that a dynamic language on top of Java might be enough. But I'm starting to see that Java is not good enough for the stable layer either. In fact, I'm not sure if Java the language is good enough for anything, anymore. So that's what my language exploration is about. I have a suspicion that Scala might be a good language at the stable layer, but at this point the problem is there aren't any other potential languages for that layer. So what I'm doing is trying to investigate if Scala is good enough for that."

Dan.
http://www.dancres.org/

Anonym sa...

I cannot comprehend how any programmer could possibly think that Java is not a good enough language for any application or why some programmers feel the need for the language du jour like Ruby and Scala. What have you been smoking? Java can do A-N-Y-T-H-I-N-G. I don't care if you can declare a Map in less lines using Ruby. So what.

Ola Bini sa...

mr anonymous: "Java can do A-N-Y-T-H-I-N-G." Right. So can assembler. Why don't you use that for your next software integration project?

Anonym sa...

anonym said...
"I cannot comprehend..."

...

Need I say more?

Henrik Engström sa...

"... the harmony between thought and reality is to be found in the grammar of the language." - Ludwig Wittgenstein

Anonym sa...

http://www.javalobby.org/java/forums/t105687.html

Amen!!

Hadi Hariri sa...

Anonymous, Java can do anything. And as pointed out, so can assembly. Why do you pick Java vs Assembly? Because it's a trade-off. You learn a higher level language to solve the domain problem at hand more efficiently and not waste time with issues that don't concern your domain. Building a DSL, using dynamic languages, is just one step more. You don't see it as a trade-off. Others do.

The same reason why some of us choose to use NHibernate. C# can do all the persistence out of the box too, but it's worth the trade-off to learn the framework.

Anonym sa...

Are we not heading for the collapse tower of the IT tower of Babel? Everybody is speaking different languages, in terms of actual programming languages and in systems such as UML and extreme programming, which only member small cliques understand. Yes may be but a poor c# .net programmer in tharll to capatalist demon Gates and his infernally unreliable wares, but languages such as Perl and python seem like backward steps to primitive macros( the mere name Jython makes me want to scream!), and java is overcomplicated take ten times longer to do something that would take 2 minutes in .net.

Also there is the question of robustness, as Scotty said in one of the star trek movies “ the more complicated they make things the easier it is to throw a spanner in the work”. Whatever happened to parralel programming and knowledge based systems, surely we should be basing our systems on the based available model , the human brain. There would be several layers, but they would not be hierarchical, but more democratic, with different areas entertaining with each other in a ballet ,on a ‘conscious’ stage of thought with, unconscious relex support systems, such as breathing, circulation and digestion

Anonym sa...

Recently I began attempting to learn a new language online, just to have something else to put on my CV, and I was amazed how many different types of language cds there are available. In the end I decided to purchase some gear that would help me learn Japanese and it has been amazing, I can’t believe how quickly I am picking it all up! Going to give Russian a go next!

Anonym sa...

Why so many C# and .NET fanboys, Java can do what C# can do I dont see any benefits from .NET.

Use JVM, Java, Python/Jython or Ruby and your web framework of choice and just be.

PS. For RIA front-end Flex3 rocks!.

Anonym sa...

retard

Jon Harrop sa...

"Why so many C# and .NET fanboys, Java can do what C# can do I dont see any benefits from .NET."

F# is the benefit from .NET for us.

Anonym sa...

A good attempt, kudos for all the fun. It was amazing how these "screen shots" spread like wildfire through the net.

Flash Drive| Flash Card| Memory Module| Memory Card|
Smt Electronic Manufacturing|Electronics Contract Manufacturing| Electronic Contract Manufacturing Services| Subcontract Pcb Assembly

Anonym sa...

MAG Studios is a leading software development & web development company offering ecommerce web site development, search
engine friendly web development, customized software development services india delhi.
Software Development | SEO Services India | Website Design India | Content Management System (cms) | Customer Relationship Management (CRM) | BPO India Intranet Portal

Unknown sa...

You mentioned DSL's, have you tried Rebol (http://www.rebol.com/) or any other Forth-like languages out there ?

Anonym sa...

Thanks ur information



Small business website design

Anonym sa...

Thanks ur information


Small business website design