|
|||||||
| Blog | / | OSGi Alliance Blog: 200709 | |||||
|
Simplicity, Size, and Seniority2007-09-14
It must have been 1996 when I explained to Ralph Johnson that I liked Java over Smalltalk because it was so small and simple. He looked at me warily and said: "wait a couple of years, it will grow". Ralph is a wise man and after a few years when Java grew from a handful of packages to hundreds of packages I understood what he had meant.
I was reminded of this conversation when I read a blog that compared HK2 with OSGi. HK2 was simpler because it had only 50 classes (!) and only a few pages of documentation. To be honest, I had not yet heard of HK2 so I investigated. This turns out to be the Glassfish module system developed by Sun. From the blog you get the false impression that OSGi is the Goliath spec of thousands of classes and HK2 is this new little David that has a more human size. Interestingly, it is more the other way around, despite their immaturity. Their module/life cycle layer is comprised of 30 classes, their service/component layer is 20 classes. Security is absent. The only mandatory package in OSGi is org.osgi.framework, which is comprised of only 25 classes and contains the security, module, and service layer. Realistically one should add Package Admin, which adds another 3 classes. Still significantly smaller than the 50 classes of HK2, and they have only just started while we have been around for 9 years and had to address all the hard problems that happen when you build real life applications for constrained environments. All the other classes in the OSGi specifications are optional, when you have a specific problem we might have a specification that addresses that problem, when you do not care, just stick to the framework. HK2 stands for Hundred Kilobytes Kernel. I guess this is something similar as the 1 dollar stores that over time become extremely creative or outright deceit because this (artificial) limit is not maintainable. I am not sure where they are today, but I am pretty sure that HK2 will require more than 100K within 2 years if they want to do it right, the real world tends to be quite messy. Anyway, for a specification the code size of the implementations is a bit different. OSGi R3 can be implemented in less than 100k, look at Concierge. However, R4 likely requires a larger implementation because it addresses so many more use cases. Apache Felix and Knopflerfish are around 250K and Eclipse Equinox is around 900K. Why is Equinox so big in comparison? Well, their non-functional requirements state that they must be able to handle 5000 bundles. To make such a gigantic system work, they need to revert to many optimizations and caching techniques which add complexity. This difference is one of the best illustrations why the OSGi specifications are important. Depending on your needs you can choose to use Felix, Knopflerfish, Equinox, or a commercial implementation. Each implementation has made trade offs that you can match against your requirements. However, they all over the same basic OSGi environments and most bundles run on all systems. Comparing the documentation of HK2 and OSGi it is the other way around: OSGi is bigger. The core OSGi framework specification with the optional system services is 288 pages. I agree it is a lot easier to read the 3 web pages and the Javadoc of HK2, but does it help you when there is a problem? It is interesting how the size of the documentation can be used against you. Yesterday, on the Python list someone asked if there could be an OSGi for Python and the reply was a joke about how "impressed" he was with the 1000 pages of the specification. To set the record straight, all the OSGi specifications combined comprise a 1000 pages but the core is less than 300 pages including the Javadoc. This is still a lot of text but we really tried very hard to make them as readable and usable as possible. So what do you prefer? A handful of web pages or a detailed specification. I can only defer to another wise man: "Things should be as simple as possible, but not simpler". Peter Kriens CommentsSOA & OSGi2007-09-04
Nine years ago, when we started working on the OSGi specifications, we used the word service to describe the object that acted as a conduit between bundles. Today, Service Oriented Architectures (SOA) are hot and every software vendor seems intent on confusing a muddy picture even further by bringing their products under this wide umbrella. The result is that many people file OSGi under webservices, as the most popular exponent of SOA, and then conveniently ignore any further documentation because they already know what web services are. As an example, a friend of mine consistently gets his papers rejected because many of the reviewers make this very false assumption.
A bit of history. In 1985, I was developing systems for the newspaper market and we just started our Magnus Opus: a newspaper page makeup terminal (this was the time that a 25 Mhz 286 was state of the art). This product was of strategic importance for our company and I did due diligence on a lof of languages to select the best one for this project. After discovering Smalltalk/V 286, I fell head over heels in love. I thought object oriented (OO) software was the best thing since sliced bread! I never had been comfortable with the common design methodologies at that time called Structured Design. Discovering OO felt like coming home after a long journey. After grasping the technology I made my second worst advice ever (the worst was when I told a programmer friend in 1994 that building an e-commerce shopping cart application was a silly idea, sorry Matts). I told my manager that if we started to build our systems using objects we would be able to get fantastic reuse after a year or so. Obviously under the condition that he allowed me to go to all these cool conferences like the OOPSLA. I assured him, new applications could be build in days instead of years, just using objects ... Well, as most of us know it did not turn out this way. Yes, we got a lot of advantages using OO technology but reuse turned out a lot harder than we thought. Sadly, I think the key cause of the lack of reuse was the violation of the two sacred rules of Structured Design: low coupling, high cohesion. It was very much like a couple of girls on the beach trying desperately not to expose themselves to the boys in front of them while changing into their swimming gear; not realizing that there were also some boys sitting behind them. We were so busy hiding our data in instance variables writing get and set methods that we never realized that we were exposing the object structure to anybody using our classes. That is, if you do new Foo() from class Bar, you just coupled the classes Foo and Bar for eternity. Trying to reuse Bar immediately drags in Foo. Now if Foo and Bar had been cohesive (meaning they are really parts of the same function) this would not be such a problem. However, because we were so busy writing get/set methods we mostly ended up with systems that had transitive dependencies that basically included all classes in your company's repository. If you want to see an example, write a "Hello world" program with an empty local Maven repository. Not only made this coupling reuse very hard, the coupling made making changes also very complicated because many changes were far reaching.At the end of the previous millennium our industry learned many hacks to reduce this structural coupling; the most (in)famous is the Factory pattern. This pattern allowed you to manage the coupling outside the original program by moving the coupling to a runtime decision. However, it is a hack. OO languages have no built-in answer to this problem, just look at the large number of attempts one can find in Java to solve this coupling problem.Also, if you look at one of the great insights of the last decade, Inversion of Control (IoC), you see that this is really about decoupling. IoC (or the Hollywood principle of "do not call us, we will call you") takes an object and provides it with its dependencies instead of this object trying to create its dependencies. This simple idea allows for POJOs, objects that are minimally coupled. Services are trying to solve the same problem: minimize complexity by decoupling. The key insight that lead to the service model is that the OO has an important role in modularization on the small scale but we need something of a bigger granularity on the larger scale. A modularity that minimizes coupling to well defined conduits between coarse components. This was exactly the problem we tried to solve since that 1998 meeting in the Research Triangle Park in Raleigh where the technical OSGi work got started. Our key assignment was to let software from many different service providers collaborate in a single residential gateway. Trying to standardize large class libraries with highly coupled frameworks would have taken forever and it would have done a terrible job. By focusing on the coarse components (the bundles) that would collaborate through objects named by their interface that were found in a registry (the services) we created a model that had minimal, well defined, and documented coupling between bundles. The key advantage of SOA is therefore the reduced coupling between the blocks of a system. The model became wide known with Webservices because Microsoft and IBM decided to put a lot of marketing dollars in that direction, making SOA almost synonymous with XML, SOAP, HTTP, some other acronyms, and associated distributed computing problems. It is not. Service Oriented Architectures reduces the complexity caused by not managing structural coupling by providing well defined conduits between components. Webservices achieve this using a myriad of acronyms, OSGi technology achieves this by using an extremely low overhead in-VM service publish/find/bind model. So the key question is if the confusion between Webservices and OSGi is doing us harm? I think it does, many people fail to look further because they assume they understand. For example, I am flabbergasted that leading software magazines like ACM Communications and IEEE Software never had an in-depth article about OSGi technology because I strongly believe that the ramifications of this technology for our industry are profound. Peter Kriens Labels: object oriented oo component design software osgi structured coupling soa webservices Commentsrathish :
Too good explanation on tightly coupled systems. I like OSGi framework for it simplicity which helps me to achieve loosely coupled design.
Aggelos Mpimpoudis :
I agree with you. As you already know, I got involved with OSGi some months ago, and I have experienced the same confusing situation.
I blogged about this here. Always My Best Regards, Aggelos Dieter :
I couldn't agree more with you:
1) SOA usually triggers people to think about Web Services. 2) There is few OSGi material to be found in software magazines. I hope we can fight both :) Ad. 1), I have a large project ongoing that is all about OSGi and SOA, but not necessarily Web Services (that may just be one possible service). Maybe you have time to stop by and drop me some comments or hints how we could improve public awareness about the issues. Coalevo an OSGi and SOA based community platform project. Ad. 2) I think the only way to do something about it is to submit articles. I have quite some work going on in OSGi and I would be willing to contribute if you write something up and need helping hands. Regards, Dieter
|
||||||
I'm glad Java has grown. It means that I can usually find something in the API to help save me re-writing that code that gets written over and over. If you use a language which does not have an extensive API then as a company (or an individual) you tend to build libraries of code that you think you might re-use (and often don't).
So... do you think OSGi will grow?
I've only jumped on the band wagon recently and really love it. But I feel as though I have come on board at about the same time as I came on board with Java so many years ago. OSGi feels about the right size now but I am sure there is room to accommodate more use cases. I fine with this though, because I feel I can track the additions that will be made from here on in. However, new comers to OSGi may find it overwhelming when we get to r5, r6 or beyond. For example the Java API added logging relatively recently, but by then a lot of people are using Log4j (or similar). Newbies will pick up these practices from their peers and may not be aware of the logging API for sometime.
As for OSGi's documentation, I think it's great. It really is clear to understand and helped me get up speed very quickly. I'm sure I still have lots to learn, but the detailed specs have helped me to hit the ground running rather than spending hours of trial and error.
I also especially appreciated the Best Practices PDF that was circulated on the internet recently. That has already saved me a lot of time and future maintenance troubles.
Too many open source projects with potential just have a few web pages of description and expect people to be able to hit the ground running. It is almost as if the IT community has forgotten the value of good documentation.
Thanks,
Chris
Do you think that the .Net framework would be a viable platform to implement OSGi upon?
If you look at the OSGi specifications there are virtually no convenience functions, almost all code is there to allow multiple implementations, convenience functions can be built upon this foundation.
However, we will clearly add more optional services, that direction has almost infinite potential.
Thanks for the compliments, very much appreciated!
About .NET, there has been research in this direction and that showed that we could not combine two key features of OSGi. The first being the possibility to unload a bundle, second the ability to communicate over services with zero overhead, i.e. direct method calls. If you want to unload code, you must use a process for each bundle which makes any method call to another bundle an interprocess call. If you load assemblies in the same process, you can not unload them ...
We are working on Universal OSGi which will still require Java but will allow the service registry to be reused between .NET and Java. However, this is still in its infancy.
Kind regards,
Peter Kriens