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

Let's 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. Later it will become clear why exactly.
Let's start from the beginning or Hello, Java World!  - 1
So, let's imagine Someone. This Someone wants to master alpine skiing. And for this he takes the following steps:
  • Instructors, textbooks, manuals, etc. - this is all from the evil one. You can learn skiing on your own. In addition, at school he learned to cross-country ski tolerably well. Accordingly, all advice from more knowledgeable people is ignored.

  • The coolest equipment is chosen. Not below the expert level. Hard boots that hurt your feet. Hard skis that require a fantastic amount of effort to bend, far exceeding the level of physical fitness of Somebody. Well, etc.

  • The test track is... well, let's say, the track hosting the World Cup giant slalom stage. This is just right for studying.
  • Continue in the same spirit.
So here's the question. What will you call this Someone? Personally, as a person who has been familiar with alpine skiing for about 20 years, I will call him (and this is still very mild!) - hopeless. It is completely impossible to learn anything with this approach. But a sure way to get hurt. And the MOST sure thing 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 expect anything unpleasant to be addressed to him. Now let’s imagine another Someone. Let him, say, be a computer science student. He has some knowledge of C++, C#, Pascal. He wants to learn Java. His actions:
  • Literature corresponding to his knowledge level (zero level, frankly speaking) is swept aside. Based on a slight 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, we select... well, let's say chat. A client-server application, the client part in the form of an applet, the server part - a web service or, at worst, servlets. Just right for studying.
Question. What will you call this Someone? Do you know what the paradox is? The fact is that in this case there will be significantly fewer 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 this is the problem? The situations are really very similar. I specifically described them in the same style. And a strange thing: if the absurdity of the first is obvious, then the second scenario is followed by an alarming number of novice developers. Mastering Java begins with writing MIDlets, clients for databases, chats, creating websites based on servlets... You can go on for a long time. But the point is nonetheless obvious. At the same time, entry-level literature is put aside with disdain. Read this? To me? Yes, I’ve been writing in C++ for three years now! (Options are in Pascal, and even in visual basic.) And I know OOP! Well, in general. So, what is next? And then this:
  • How to convert an array of 8 bytes to long?
  • Why does this happen NoClassDefFoundError?
  • Why do I launch the application in Eclipse ( NetBeans/IDEA/JBuilder), and everything is fine, but without it I type java HelloWorld.class, and there is an error?
  • Why does it crash ClassNotFoundException?
  • Why isn't there a library? I’ve already put it in classes.zip, but it’s all to no avail!
  • Why do I create an array of objects, but 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++ or 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 external resemblance is misleading. Of course, all these “whys” and “hows” have answers in books. In literature of the most basic level. But reading it is lazy (options: shame, no time, etc.). I know quite a lot of stereotypes that were transferred to Java by good C++ specialists. One recent example: you should never throw an exception in a constructor. Why? Yes, because in C++ the state of such an object is not defined. Accordingly, 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 according to 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 completely not enough. The ideology of language is much more important. And in order to master it most effectively, you should start from the very beginning. Why exactly and how? And this is another question. So. Where and how to start. It depends on what you want to achieve. If you want to become a skilled coding monkey, you can start with almost anything. If you want to become a professional, things are a little more complicated. My experience gives me reason to say the following. The difference between a professional developer and a "coder" is that he understands what's going on. He does a little more than press 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 make the product work without a development environment, then I shudder to think how it was written. At the very least, it was written by amateurs. What do I mean by "understands what's going on?" This means that a person must understand the following:
  • What is a virtual machine and why is it needed?
  • What is a class from the point of view of a virtual machine.
  • What is a package?
  • What is a library?
  • How the virtual machine looks for and loads classes; what is a class loader and how does it work; how many are there by default; what is classpath.
Etc. and so on. The list goes on. Please note that I did not include knowledge specific to the developer itself. What is a thread, what is a class from an OOP point of view and how does it differ from an object, how layout managers work - ANY developer should know all this. Everything I have listed is more of a technicality. But very often it turns out that knowing them is vital to understanding what is working wrong. An example from life. There is 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 have been 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 class loader works. I once saw a four-day discussion in one of the forums that ultimately came down to this question. The code did not work correctly precisely because the loader did not take the class that was expected from it. What am I getting at? Here's the thing: the more powerful the development environment, the more it does for the developer - the less he has to think. And this is already oh, how bad. So close to the monkey. This leads to the first conclusion, no matter how paradoxical it may seem:

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

I don't advocate writing in notepad-level editors. But I don’t do this for the only reason - they, as a rule, do not have syntax highlighting. This is an incredibly convenient thing that does not have a negative effect. You can use something like Notepad++ , it understands Java syntax and, by the way, is free. For example, I have the .java file type registered in the system specifically for it. So, a text editor with syntax highlighting and a command line. Two or three days of torment - and understanding what a classpath is, how the interpreter is launched and a bunch of other little things - understanding this will remain forever. Further. My experience gives me reason to say that it is impossible to acquire knowledge for future use. In the sense that it is worth reading literature only when there are questions to which it will answer. If you read a book without having questions about it, the information will disappear within a week. I know this very well, including from my own experience. I once started reading a book on servlets five times. Until I began to deal with them in my work, the information was not absorbed. And this is far from an isolated case. Once upon a time, a 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. You need to give it a language, several tasks and a minimum of documentation. Then, after a couple of months, when he begins to write at least in this language, provide comprehensive documentation. It will be read in two weeks like a detective novel, after which the person will be ready to work. 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 form, the answers to which will be provided by the documentation. This leads to the second conclusion, which seems no less paradoxical than the first:

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

Java API documentation is a must. I highly recommend keeping it locally, on disk. You will have to contact her more than once, not twice, or even ten. Personally, not a day goes by that I don’t go there. I also recommend keeping the Java tutorial locally. This is entry-level information that completely replaces a textbook. However, there is a fair amount of it there. I must say that in areas that I don't deal with at work, I still find something new for myself. Reading a lot is bad. As long as there is no request, there is no response. Reading a 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 moment that it is best to stop and continue on your own. The initial impetus has been received, and solving the problem independently 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’s worth reading the initial chapters. I can almost guarantee that you will learn at least something new. And this something may later turn out to be extremely important. OK. We seem to have figured out what to write about. How to write - too. But what should I write? Remember where this article began. Should I start by writing an instant messaging system? The choice is, of course, yours. It seems to me that it’s not worth it. The more complex 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, followed by a feeling of one’s own inferiority, stupidity, etc. Ultimately, this can lead to the decision “to hell with it...” and stopping learning the language. Those. to exactly the opposite effect than the one that was needed. This is characteristic not so much of Java as of the learning process itself. But for some reason they forget about this when it comes to teaching programming. Meanwhile, a small task completed to the end can give much greater satisfaction and much greater knowledge than a grandiose system abandoned at the very beginning of the journey. Hence the third conclusion: Conclusion 3. It is advisable to start learning Java with tasks that are adequate to your current level of knowledge of Java. You shouldn’t start learning to drive a car on a Formula 1 car. You shouldn’t start learning alpine skiing on the World Cup track. And in the same way, you shouldn’t start mastering Java by writing something huge. I understand that ambition is demanding. But in this case they are unfounded. And the more unreasonable ambitions you have, the less chance you have of becoming a professional. A remarkable phenomenon in terms of learning is, oddly enough, various forums. If you use them wisely. Wisely - this means that you need to do the opposite, not as usual. Namely, not to ask questions, but to answer them. Any that you have the strength to reach. If you think that I myself know everything, you are very mistaken. Yes, I know a lot. But there are areas that I have never encountered. Or I have, but very little. A classic example from my practice is working with certificates: code signing, secure connections, etc. In 1998, when writing my thesis, I did this, but since then everything has changed a lot. Over the years, I have had questions accumulated. I even started reading some literature. But, as I said above, you can’t get knowledge for future use. It's like a crowbar - it goes in one ear and comes out the other. There is no result except a hole in the head. And this continued until recently, when a question was asked in the forum about an SSL connection with tomcat. There were some problems. And only this question pushed me to dig deep. And if there is a request, there is also a response. Not only did I figure out what the person’s problem was, but I also found a bunch of other useful information. I finally understood how certificates work. The corresponding article is in the plans. And this happens all the time. 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 understood some of the capabilities of TextLayout. Before this question I had no idea about them. In the same way, I recently found out that it turns out that JButton also interprets html as its own header. Before this, I thought that only JLabel could 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 popular opinion that if a person sits on a forum, then he does nothing. This is far from clear and depends primarily on why exactly the person is on the forum. And what does he do mainly – ask or answer. In fact, you can even ask. But also wisely. Do not ask for a solution (and especially with the postscript “Please those who know, give an answer, and not ask questions!”, which I encountered just the other day!), but again, on the contrary, ask to set the direction of movement. It is completely understandable that it is difficult for a beginner to understand where to dig, because he simply lacks experience. This is not the person’s fault, and it’s not even a problem. This is fine. Everyone has gone through this. Me included. For me personally, it is much more important that a person wants to learn something. And not just get an answer, only to forget it five minutes after taking a programming lab. I will always tell you the direction of movement. If I know him myself. And if I don’t know, at least I can guess. And I will certainly also look for the answer. But I probably never give direct answers—at least, I don’t remember. By the way, it was because of this that I left one of the forums. When I started asking leading questions, they explained to me in unison that it is 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 off you go. By the way, this site appeared precisely thanks to one of the forums. After talking there for some time, 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 some discussions in the forum. Or following the correspondence that 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 who you want to be - a mindlessly button-pushing monkey or a professional. And only you yourself choose the path along which you can achieve this or that. The first way is clear. I tried to show the second one. Your move, gentlemen! Link to the original source: Let's start from the beginning or 'Hello, Java World!'
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION