JavaRush /Java Blog /Random EN /Start from the beginning or 'Hello, Java World!'
articles
Level 15

Start from the beginning or 'Hello, Java World!'

Published in the Random EN group
I want to start this article with an unusual, at first glance, digression. It will become clear later why.
Starting from the Beginning or Hello, Java World!  - 1
So let's imagine someone. This Someone wants to master skiing. And for this he takes the following steps:
  • Instructors, textbooks, manuals, etc. - it's all from the evil one. You can learn skiing on your own. In addition, at school he learned tolerably cross-country skiing. Accordingly, all the advice of more knowledgeable people is ignored.

  • The equipment is chosen the coolest. Not below expert level. Hard shoes that hurt your feet. Rigid skis that require fantastic efforts to bend, far exceeding the level of physical fitness of Someone. Well, etc.

  • As a test track is chosen ... well, let's say, the track that hosts the World Cup stage in giant slalom. It's just for study.
  • Further in the same spirit.
So, question. What would you call this Someone? Personally, as a person who has been familiar with alpine skiing for about 20 years, I will call it (and this is still very mild!) - hopeless. Learning anything with this approach is impossible at all. But a sure way to get hurt. And the MOST faithful one is to abandon the idea of ​​skiing forever. I think you will agree with me in this assessment. In any case, I am almost sure that this Someone will not wait for anything personal in his address. Now imagine another Someone. Let him, say, a student of the Faculty of Informatics. He has some understanding of C++, C#, Pascal. He wants to learn Java. His actions:
  • Literature corresponding to his knowledge of the level (zero level, frankly) is swept aside. Based on a light familiarity with the mentioned C++, C# and OOP theory.
  • The most powerful programming environment is taken. Let's say Eclipse or NetBeans. The one that does everything itself, just press one button.
  • As a trial application is selected ... well, let's say, a chat. An application of the client-server type, the client part is in the form of an applet, the server part is a web service or, at worst, servlets. For study just right.
Question. What would you call this Someone? Do you know what the paradox is? In the fact that in this case there will be much less impartial assessments. Despite the fact that the situations are identical in all respects. Unless the consequences for health and life in the second case are less fatal. Maybe that's the issue? The situations are indeed very similar. I specifically described them in the same style. And a strange thing: if the absurdity of the first is obvious, then a frightening number of novice developers follow the second scenario. Mastering Java starts with writing MIDlets, database clients, chats, creating sites based on servlets... You can continue for a long time. But the point is nonetheless clear. At the same time, entry-level literature is dismissed with disdain. Read it? To me? Yes, I've been writing in C++ for three years now! (Variants are in pascal, and even in visual basic.) And I know OOP! Well, in general. So, what is next? And then here's what:
  • And how to convert an array of 8 bytes to long?
  • Why does it happen NoClassDefFoundError?
  • Why do I run the application in Eclipse ( NetBeans/IDEA/JBuilder) and everything is fine, but without it I type java HelloWorld.class, but there is an error?
  • Why is it flying ClassNotFoundException?
  • Why isn't there a library? I already put it in classes.zip, but it's all to no avail!
  • Why am I creating an array of objects, and when I try to use an element of the array, I get NullPointerException?
  • And why ...?
  • And why ...?
  • And why ...?
Why why why? But because Java is not C++ and not Pascal. And not Perl. Knowledge of these languages ​​not only most often does not help, but also hinders. If only because these languages ​​have completely different ideologies. But the resemblance is misleading. Of course, all these "whys" and "hows" have answers in books. In the literature of the most elementary level. But reading it is lazy (options - ashamed, no time, etc.). I know quite a lot of stereotypes transferred to Java by good C++ specialists. One recent example is that you should never throw an exception in a constructor. Why? Yes, because in C ++ the state of such an object is not defined. As a result, a memory leak occurs. In Java, there is no such problem in principle, due to the presence of a garbage collector. However, there are people who try to avoid such situations. Just an ingrained stereotype. And the worst thing is that as a result of these efforts, the code becomes much more complicated. The syntax is easy to learn. And absolutely not enough. The ideology of the language is much more important. And in order to master it most effectively, it is worth starting from the very beginning. From what exactly and how? And this is another question. So. Where and how to start. It depends where you want to get to. If you want to become a skilled coding monkey, you can start almost anywhere. If you want to become a professional, everything is a little more complicated. My experience gives me reason to assert the following. A professional developer differs from a "coder" in that he understands what's going on. He can do more than push buttons. A powerful environment is a very good help. For those who can do without it. But it is often the only tool of those who started with it. And in its absence, the value of the coding monkey is zero. Because there are no buttons to press. In general, button-pressing can take truly monstrous forms. One of my colleagues saw a product written in Java. The instructions for installing it began with the words: "Install JBuilder from the disk ..." Now THIS is already fatal. If the developers couldn't get a product to work without a development environment, then I'm scared to think how it was written. At least it was written by amateurs. What do I mean by "understands what is happening". This means that a person must understand the following: No. In general, button-pressing can take truly monstrous forms. One of my colleagues saw a product written in Java. The instructions for installing it began with the words: "Install JBuilder from the disk ..." Now THIS is already fatal. If the developers couldn't get a product to work without a development environment, then I'm scared to think how it was written. At least it was written by amateurs. What do I mean by "understands what is happening". This means that a person must understand the following: No. In general, button-pressing can take truly monstrous forms. One of my colleagues saw a product written in Java. The instructions for installing it began with the words: "Install JBuilder from the disk ..." Now THIS is already fatal. If the developers couldn't get a product to work without a development environment, then I'm scared to think how it was written. At least it was written by amateurs. What do I mean by "understands what is happening". This means that a person must understand the following: I dread to think how it was written. At least it was written by amateurs. What do I mean by "understands what is happening". This means that a person must understand the following: I dread to think how it was written. At least it was written by amateurs. What do I mean by "understands what is happening". This means that a person must understand the following:
  • What is a virtual machine and why is it needed.
  • What is a class in terms of a virtual machine.
  • What is a package.
  • What is a library.
  • How the virtual machine searches and loads classes; what is a classloader and how does it work; how many by default; what is classpath.
Etc. and so on. The list goes on. Note that I did not include knowledge that is directly related to the developer. What is a thread, what is a class in terms of OOP and how it differs from an object, how layout managers work - ANY developer should know all this. Everything that I have listed in the list is rather technical subtleties. But very often it turns out that knowing them is vital to understanding what works wrong. An example from life. There is such a library for working with XML called xalan. It contains several javax.xml... packages - parsers, transformers, etc. This library is very popular. The problem is that these same packages are present in the J2SDK since version 1.4. Question. Which class will be loaded when accessing the javax.xml.transform.stream.StreamSource class from the library, if xalan is also present in the classpath - library or from J2SDK? To answer this question, you need to know how the classloader works. I once saw a four-day discussion in one of the forums, which ultimately rested on this issue. The code worked incorrectly precisely because the loader did not take the class that was expected from it. What am I leading to? Here's what: the more powerful the development environment, the more it does for the developer, the less he has to think. And this is oh so bad. So close to the monkey. From this follows the first conclusion, no matter how paradoxical it may seem: that the loader did not take the class that was expected from it. What am I leading to? Here's what: the more powerful the development environment, the more it does for the developer, the less he has to think. And this is oh so bad. So close to the monkey. From this follows the first conclusion, no matter how paradoxical it may seem: that the loader did not take the class that was expected from it. What am I leading to? Here's what: the more powerful the development environment, the more it does for the developer, the less he has to think. And this is oh so bad. So close to the monkey. From this follows the first conclusion, no matter how paradoxical it may seem:

Conclusion 1. It is desirable to start learning Java WITHOUT a powerful environment.

I do not encourage writing in notepad-level editors. But I do not do this for the only reason - they, as a rule, do not have syntax highlighting. This is an incredibly convenient thing that does not carry a negative effect. You can use something like Notepad++, it understands Java syntax and is free, by the way. For example, I have the .java file type registered in the system for it. So, a text editor with syntax highlighting and a command line. Two or three days of torment - and the understanding of what the classpath is, how the interpreter is launched, and heaps of other little things - the understanding of this will remain forever. Further. My experience gives me reason to assert that it is impossible to gain knowledge for the future. In the sense that it is worth reading literature only when there are questions that it will answer. If you read a book without having questions to it, then the information will disappear in a week. I know this very well, including from my own experience. Once upon a time, I read a book on servlets about five times. Until I began to deal with them in my work, the information was not assimilated. And this is far from an isolated case. Once upon a time, very long time ago, about 8-10 years ago, I read the following, unfortunately I don't remember the author: How to teach a person a new programming language? Very simple. It is necessary to give him a language, several tasks and a minimum of documentation. Then, after a couple of months, when he will already start writing at the very least in this language, give exhaustive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to go. I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: unfortunately, I do not remember the author: How to teach a person a new programming language? Very simple. It is necessary to give him a language, several tasks and a minimum of documentation. Then, after a couple of months, when he will already start writing at the very least in this language, give exhaustive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to go. I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: unfortunately, I do not remember the author: How to teach a person a new programming language? Very simple. It is necessary to give him a language, several tasks and a minimum of documentation. Then, after a couple of months, when he will already start writing at the very least in this language, give exhaustive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to go. I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: several tasks and a minimum of documentation. Then, after a couple of months, when he will already start writing at the very least in this language, give exhaustive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to go. I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: several tasks and a minimum of documentation. Then, after a couple of months, when he will already start writing at the very least in this language, give exhaustive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to go. I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first: I agree with this statement 100%. In two months, on the one hand, all minor issues will go away. The answers to them will be obtained independently, which will greatly increase their value. On the other hand, clear questions will already be formed, the answers to which will be given by the documentation. From this follows the second conclusion, which seems no less paradoxical than the first:

Conclusion 2. It is desirable to start learning Java WITHOUT textbooks. Java API documentation + Java tutorial is more than enough.

Java API documentation is essential. I highly recommend keeping it locally on disk. You will have to turn to it more than once, not twice, or even ten. Not a day goes by for me that I don't go there. Java tutorial, I also advise you to keep it locally. This is entry-level information that completely replaces the textbook. However, there is quite a bit of it. I must say that in areas that I do not deal with at work, I still find something new for myself. Reading too much is bad. Until there is a request, there is no response. Reading too little is also bad. Where is the golden mean? I adhere to this rule: I read until it begins to seem to me that I have received the answer to the question. In 90% of cases this is not the case. But it is at this point that it is best to stop and continue on your own. The initial impetus has been received, and an independent solution of the problem will give much more. Of course after some time, it is worth taking up literature. But again, for entry-level literature. Even if it seems that all this is nonsense, it is worth reading the initial chapters. I can practically guarantee that you will learn at least something new. And this something later may turn out to be extraordinarily important. OK. What to write, sort of figured out. How to write too. But what to write? Remember where this article began. Should I start by writing an instant messaging system? The choice, of course, is yours. I don't think it's worth it. The more difficult the task, the more questions will arise. In the absence of experience, such a number of questions will give a feeling of the impossibility of solving them, then - a feeling of one's own inferiority, stupidity, etc. Ultimately, this can lead to a "what the heck..." decision. and stop learning the language. Those. exactly the opposite effect than that which was needed. This is not so much inherent in Java as in the learning process itself. But for some reason, it is in the application to teaching programming that they forget about it. Meanwhile, a small task, brought to the end, is capable of giving much more satisfaction and much more knowledge than a grandiose system abandoned at the very beginning of the journey. Hence the third conclusion: abandoned at the very beginning of the journey. Hence the third conclusion: abandoned at the very beginning of the journey. Hence the third conclusion: Conclusion 3. It is desirable to start learning Java with tasks that are adequate to the existing level of knowledge of Java. You shouldn't start learning to drive a car on a Formula 1 car. You shouldn't start learning to ski on a World Cup track. And just like that, you shouldn't start learning Java by writing something huge. I understand ambition is required. But in this case they are unfounded. And the more unreasonable ambitions, the less likely you are to become a professional. Strange as it may seem, various forums are a remarkable phenomenon in relation to learning. If they are used wisely. With the mind - this means that you need to do the opposite, not as usual. Namely, not to ask questions, but to answer them. On any, to which there is strength to reach out. If you think that I myself know everything, you are greatly mistaken. Yes, I know a lot. But there are areas that I have never encountered. Or faced, but very little. A classic example from my practice is working with certificates: code signing, secure connections, etc. In 1998, when writing my diploma, I did it, but since then everything has changed and much. Over the years, questions have been piling up on me. I even began to read some literature. But, as I said above, you can’t get knowledge for the future. It's like a crowbar - it goes in one ear, out the other. Nothing but a hole in the head. And so it continued until recently, until the forum asked a question about an SSL connection with tomcat. There were some problems. And just this question prompted me to dig deep. And if there is a request, there is a response. I not only figured out what the person's problem is, but also found a bunch of other useful information. Finally understood how certificates work. The corresponding article is in the plans. And this is all over the place. I worked quite a bit, for example, with the GUI. It was only as a result of someone's question in the forum that I figured out some of the possibilities of TextLayout. Until this question, I had no idea about them. Similarly, I recently found out that JButton also interprets html as its own title. Before that, I thought that only JLabel can do this. And this is again thanks to the forum. So it turns out: the more we answer questions, the more we learn ourselves. That is why I do not agree with the conventional wisdom that if a person sits in the forum, then he does nothing. This is far from being so unambiguous and depends primarily on why the person is sitting in the forum. And what he does mostly - asks or answers. In fact, you can even ask. But also smart. Do not ask for a solution (and even more so - with a postscript " they explained to me in unison that it was customary for them to simply answer. And with my questions, I can go further. Considering that the level of the forum left much to be desired, not least thanks to this approach! I decided not to waste any more time. So choose a forum to your liking - and go. By the way, this site appeared precisely thanks to one of the forums. After talking there for a while, I accumulated a list of the most frequently raised topics and realized that such a site would be in demand. And so it happened. Almost all articles are written in the wake of any discussions in the forum. Or in the wake of the correspondence, which I also conduct regularly. What is the result? Work, work and work again. The more you allow yourself to do for yourself at the initial stage, the less knowledge you gain. And the longer the road to professionalism. But only you can choose what do you want to be - mindlessly pushing buttons monkey or professional. And only you yourself choose the path by which you can achieve one or the other. The first way is clear. The second I tried to show. Your move, gentlemen! Link to original source: Starting from the beginning or 'Hello, Java World!'
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION