Wednesday, February 11, 2009

Swing should be a standalone library

The public parts of AWT and Java2D should be Java’s sole interface to the native GUI system. Java2D is already accelerated, and one even have some amount of control of such features with VolatileImage and friends like BufferStrategy. I would personally don't mind more intimate control of and access to the hardware. And I wouldn't be terribly sad if there had to come a Java2D 2 and 3 to handle any new types of GUI hardware, in the same way we have java.io, NIO and More New IO.

Swing ought to be a standalone, separate, pure java library, built on top of AWT/Java2D. Actually, initially Swing was just that; a library that you had to download on the side, w/o any hidden magic. It was called JFC, Java Foundation Classes (to compare against MFC, Microsoft Foundation Class, a tradition that was upheld with JSP vs ASP and others) and is actually still available. With the release of the absurdly named "Java 2" (which gave rise to version names like "Java 2 SDK v1.3.0" and "J2SE v1.4.0"), the JFC was included with the java releases, and the downward spiral of spaghetti was started.

Even if one cannot at this point drop the backward compatibility for the current Swing (at least not for a couple of major java versions), one could simply abandon it - and make a refactored Swing2. Here one would drop all the extreme amount of cruft that has accumulated, and fix the problems and annoyances and incorporate the knowledge gained through years since Swing 1 in 1997. The native code of Swing that obviously crept in as long as Swing was a integral part of the JRE, would be ripped out and the necessary parts "ported back" to AWT/Java2D. Importantly, however, this new Swing 2 shoud never be included in the JRE: Applications would have to include it themselves. I know what you immediately think, but this is not as awful, sizewise, as one first might believe. By separating the subsystems themselves into distinct packages (check out Project Jigsaw), you'd get better code with fewer interdependencies. Swing needs all the separation it can possibly get. By using jarjar, only classes used by the application would be included. Possibly proguard can help shrink the jar size, and Pack 200 shrinks jars by about 60%. You probably already have 10-20 external jars for any little app. Given the enormous potential resulting by separating Swing into an external jar, I'd love to depend on this jar too!

Swing1 could at some point become an optional element that itself needs download. Given that the JRE by v6u10 goes exactly in this direction, that wouldn't be a problem at all. And I would already look forward to the complete rewrite in Swing3 - or me and some friends would fork Swing2 into Swing2NG or something if we didn’t like the direction Sun's Swing was taking - thereby getting progressive dynamics into the development!

On a related note: The project called Cacioavallo, proposed here by Roman Kennke, is a project which wants "to improve the AWT and Java2D interfaces to enable the implementation of external backends to AWT/Java2D". He (and apparently one more) finished it up, and it is now present in OpenJDK. This is awesome. Furthermore, he followed up by implementing AWT using Swing (all the widgets-parts). This has now been taken further to the point where to implement the entire "GUI Java", you apparently only need implement a single Graphics2D class onto a direct "pixel plane". All other is thus taken care of. He "proofed" this by making a full implementation using DirectFB (and had already made a version running on VxWorks).

Actually, pretty much everything this guy does seems brilliant: http://kennke.org/blog/.

This stuff reminds me of two extremely interesting projects which are similar to each other and yet the complete opposite of each other: SwingWT and SWTSwing. Too bad those seem dead.

18 comments:

  1. Ai cũng biết rằng collagen là một loại protein rất tốt cho cơ thể nhằm làm đẹp da , sáng da và ngăn ngừa lão hóa da rất hiệu quả , bổ sung collagen bằng cách nào ?, hiện nay có nhiều cách bổ sung collagen cho da hiệu quả như dùng thực phẩm chức năng , tiêm qua da , và một cách khác là dùng những thực phẩm giúp bổ sung collagen, collagen có nhiều trong loại thực phẩm, thực phẩm bổ sung collagen, collagen rất tốt cho cơ thể sẽ làm biến mất các vết chân chim trên da và kéo dài sự trẻ trung, collagen tự nhiên có trong thực phẩm, thuc pham bo sung collagen, những món ăn nhiều collagen, món ăn chứa nhiều collagen, bổ sung collagen cho da bằng thực phẩm với cách bổ sung collagen bằng các món ăn hay thực phẩm này rất an toàn cho người sử dụng mà không sợ các tác dụng phụ về sau này. Đừng quá lo lắng hay thử ngay như trước khi thử thì nhớ tham khảo ý kiến chuyên da dinh dưỡng trước nhé.

    ReplyDelete
  2. Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
    Data Science Certification in Hyderabad

    ReplyDelete
  3. Wow, happy to see this awesome post. I hope this think help any newbie for their awesome work and by the way thanks for share this awesomeness, i thought this was a pretty interesting read when it comes to this topic. Thank you..
    Artificial Intelligence Course

    ReplyDelete
  4. Excellent Blog! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
    Data Analytics Course

    ReplyDelete
  5. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
    Business Analytics Course in Bangalore

    ReplyDelete
  6. What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
    AI Courses in Bangalore

    ReplyDelete
  7. I have voiced some of the posts on your website now, and I really like your blogging style. I added it to my list of favorite blogging sites and will be back soon ...

    Digital Marketing Training in Bangalore

    ReplyDelete
  8. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    Data Analytics Course

    ReplyDelete
  9. I am really enjoying reading your well written articles. I am looking forward to reading new articles. Keep up the good work.
    Data Science Courses in Bangalore

    ReplyDelete
  10. A good blog always contains new and exciting information, and reading it I feel like this blog really has all of these qualities that make it a blog.

    Artificial Intelligence Training in Bangalore

    ReplyDelete
  11. I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.

    Data Science Training in Bangalore

    ReplyDelete
  12. I really enjoyed reading this post and keep up the good work and let me know when you can post more articles or where I can find out more on the topic.
    Data Science Online Course

    ReplyDelete
  13. I really enjoyed this article and it turned out to be really helpful for me and it's always nice to be able to not only be informed, but also entertained!
    Digital Marketing Training in Hyderabad

    ReplyDelete
  14. I really appreciate this wonderful message you have given us. I assure you that would be beneficial for most people.

    Data Analytics Course in Nagpur

    ReplyDelete
  15. The best slots online - DrMCD
    What are the best slots 충주 출장안마 online? · 천안 출장안마 How good 동두천 출장마사지 do slots have to be to play them? · Which are the best 당진 출장마사지 slots online for 전라남도 출장안마 2021?

    ReplyDelete
  16. Good blog and absolutely exceptional. You can do a lot better, but I still say it's perfect. Keep doing your best.

    Data Science Training in Durgapur

    ReplyDelete
  17. It was really awesome and I gain more information from your post. Thank you!
    Woman Divorce Lawyers Near Me
    Divorce Custody Laws

    ReplyDelete