📜 ⬆️ ⬇️

Dispelling myths or java with a human face

I decided to write a short note on this topic after reading here on Habré a discussion about choosing a development language for a new desktop application. With enviable consistency mentioned that moment that visually, Java applications look coarse. So I decided, slightly, to clarify this question.

So, what is the peculiarity of the implementation of desktop applications in Java and why are they able to be very beautiful? And also, where the myth of inferiority came from (some exalted personalities, sometimes even tend to use the word 'wretchedness') Java GUI, read below. I tried not to go into details, not to write any code, and generally not to use any knowledge specific to the world of Java. I would like the note to be understandable to people far from this technology.

Most erudite programmers do know that ... A Java application should be as cross-platform as possible. Also, as a rule, the most erudite of them know that the standards for appearance for different operating systems are somewhat different. So the question arises, and how to actually achieve what the application would look beautiful, in the sense of beauty, how users of specific operating systems used to evaluate it?
')
That's how. Apparently, I will not be mistaken if I say that any of us know what Winamp is. And most likely he knows what skin is. We are all accustomed to the fact that this program may look completely different if it changes the “skin”. Of course, many other programs have this feature. And now back to our ba ... our Java. The main software framework that is used to develop Java desktop applications and comes standard as part of the platform is Swing (silent hussars!). This framework is generally a good example of the design of OOP applications, but now, we are interested in only two of its features.

The number one feature is that all the visual elements that we see in the application are drawn directly and only by this framework itself, using the most basic graphic primitives of the system.

The peculiarity of the number two is that this entire drawing mutoten is carefully and carefully put into a separate layer with its clearly postulated and open interface. This clever layer is called Look & Feel. And here, please pay special attention to the words “clearly postulated open interface”. What does this mean in life? And in life, this means, neither more nor less, that we have some kind of “software skin” (skin) that absolutely any developer who knows this wonderful Java language can realize to his taste. Round, translucent buttons with Windows logo jumping inside? No problems!

But that is not all. The main thing is that the market for these same Look & Feel has already appeared. That is, there are a lot of enthusiasts who have begun to draw with enthusiasm these Look & Feels, from the point of view of their personal understanding of the nature of beauty.

Of course, for the warm-up, first appeared peel making appearance and behavior like Outlook (all versions can be found), like Windows XP, as well-known interfaces from the Unix world and ... it went. As you correctly understand, Look & Feel has long been a Java application giving the appearance of applications, as in the Apple OS. Including the work of standard keys to access the interface elements.
The standard Java library comes with several implementations of different Look & Feel. People with access to the Internet can find some good samples, for example, here:

www.jidesoft.com

or here:

www.incors.com/lookandfeel
www.javasoft.de/jsf/public/products/synthetica/themes

As you understand, this also means the following - any Java program written using Swing can have a-absolutely any conceivable visual interface that will look exactly the same in any operating environment. On the other hand, any program can be supplied with several visual interfaces that can be switched directly from the menu during operation. And these beautiful interfaces have long been done for you and are distributed free of charge. Or paid out. Those are sometimes even better free. Although not always. It is also obvious that all these visual components are inherited from one common ancestor and, therefore, relying on it, you can create your own visual component that will be drawn and work the way you personally like it. Considering all the above (and verified by me in practice), the statement that Java is ugly, this is probably the work of microsoftware who failed to quickly (in the presence of the customer) distinguish Java Windows XP Look & Fell from native Windows XP. Another explanation is difficult for me to find. :-)

Here, apparently, aesthetes, I will be objected, and not all this beauty is very long drawn, it turns out that every pixel needs to be drawn in Java? And they will be partially right. This is indeed a few milliseconds longer. For aesthetes, in the Java world there is a different approach and a different framework. It is called SWT (Standard Widget Toolkit). Of course open and free. Well, that's clear.

This framework is built on other principles. He makes the most of the graphical elements of the operating environment in which the application is launched. They are drawn, whenever possible, by means of the operating environment itself, and look as it is accepted in this environment. That is, a button, it will always be the same button as the users of the system where the application is launched are used to seeing it. Everything is drawn somewhat faster. Looks - more standard.

Everyone chooses what is closer to him. But ... In terms of the speed of the interface, there are two good examples. These are currently the most popular Java IDEs. I must say bluntly, these are very powerful IDEs. Probably the most powerful IDE that now exists on the planet in the world of software development. IntelliJ IDEA and Eclipse. The first is written in Swing, the second in SWT. I did not notice any striking difference (yes, what is there, simply - no) in the speed of work. Moreover, there is another well-known development environment - Visual Studio, from who you know yourself (calmly, this is not A. Lebedev), you yourself wrote what you know from. So subjectively assessing, it also, for some reason, subjectively, does not work faster. Well, here are the cases. :-)

And now, a few words about where the myth of misery comes from. As I think. The standard examples of the 'Hello World' level on Swing are written in such a way that they can somehow be run in any environment. Somehow ... Nobody puts the Tahoma font there to display the text. There are generally three or four fonts available on any system. And now this disgrace is launched with gray, ax-weathered buttons and ... it works. Everywhere! But spartan elegant and uncomplicated. The developers are looking at all this, scratching their turnips, and delivering a verdict - shit ... (crossed out) not a good GUI for this Java in your place, let me try Erlang or Haskel. That's all there, for sure, better done. And on Habré, the campaign, I will tell you what kind of shit ... (crossed out) this Java is not very good. Well, do not read in the documentation all the nonsense there about this Look & Feel your interface. There are enough other worries. :-)

Source: https://habr.com/ru/post/25492/


All Articles