📜 ⬆️ ⬇️

OOP of the Future: Baruh Sadogursky and Yegor Bugayenko on how we will program in 20 years

The concept of object-oriented programming is perceived by developers in different ways: someone says that it is time for her to go to the dustbin of history; someone kodit and does not think about what, how and why he does; and someone is trying to work in the "pure OOP" paradigm, turning the classic patterns on its head.

On the eve of Joker 2016, we asked Baruch Sadogursky to discuss the fate of Java and OOP with Yegor Bugaenko. What came out of this, listen in audio format or look in the video:


')
And under the cut is a complete transcript of the interview with all the links.

Baruch jbaruch Sadogursky: Hello everyone. My name is Baruch, I am a developer advocate at JFrog , the host of the debriefing podcast , a speaker at conferences like Joker , JPoint , and any kind of crap like JavaOne , Devoxx and others. And today, in sunny Mountain View, we are sitting with famous in certain circles Yegor Bugayenko, met to talk for life.

Yegor yegor256 Bugaenko: For life? And I thought about OOP, Java ...

Baruch: Our life is OOP, Java. First, tell about yourself for those who have not heard.


Egor: Java-programmer, architect. I started programming 20 years ago, back in school - at first it was PASCAL, then assembler, then C, then C ++, then Java. For the last two and a half years I have been keeping a blog , thanks to which some kind of fame has appeared. I am writing books, now I am writing the second volume. I try to correct a little object-oriented approaches which are used in Java. Somewhere it turns out, somewhere less, but I try to convey this idea to the masses, so that these masses ...

Baruch: Seethe!

Egor: Seethe and react differently, yes. Someone likes it, some do not, but it produces an effect, some thoughts reach someone. Someone is against it, and I cannot say that I myself am confident in all my thoughts at the current moment, but the process is underway. Yes, what I do for a living: I have a small distributed team in Palo Alto, about 50 people are now working, so to speak, and a total of 100 people. We write software to order in Java. Our customers here in Silicon Valley, I manage these processes with several project managers. Programmers in different countries, from everywhere. This is what I earn, and the book gives a little bit of money.

Baruch: I have a lot of questions for you. First, ask a sharp question: where did you come from? You appeared on the surface of the Russian-speaking Java-community a year ago, you walked around the conferences in the post-Soviet space, and I understand that you started. What was it, Barrymore?



Egor: I didn’t start, I still have 7 conferences ahead - they invite me, I don’t refuse. But now not so active. I spoke over the past six months at 25 conferences, a little bit too much.

Baruch: So, how did it happen, why do you need it? This is quite a hard job, I know from my own experience. A programmer, an architect, the CTO suddenly decides: “But if I don’t spend six months traveling around conferences”.

Egor: Good question, I have no answer to it. But at some point I realized that I wanted to expand the audience. A blog has hit me on this.

Baruch: Why do you need this audience? You can't earn much on a blog, you won't earn much on a book, I don't see any commercial interest in it. Maybe you hayrysh people so?

Egor: You understand, I no longer control this process, I became a hostage of the process that I myself created. I started a blog, a community appeared, people give their feedback and start pulling me out so I can talk to them. This is a bidirectional process. On the one hand, I wanted to speak at several key conferences: the JPoint in Moscow, in Kiev JEEConf , in Belarus the same JET . And other places appeared themselves, because people began to see me and say, "Come here, too."

Baruch: I have an interesting allegory, it is very difficult, but I will try. What you do causes me religious connotations. You have a "prophecy" as a process: you walk around the world, tell some absolutely "heretical" things, people love you, hate you, you no longer control it. This is a completely biblical story. And they usually end up badly, these prophets!

But I have a lot of questions about your concept of object-oriented programming, now we will try to build them somehow. The main question is this: you are trying to give the term "object-oriented programming" a meaning that it does not only now have, as you say, but which, in my opinion, it never had.

There is what we call object-oriented programming. This, I think, is different from what you call object-oriented programming. And the question "why?" There is the way that you think is right, and it may have pros and cons, like any paradigm - functional, object-oriented, and so on. Why are you trying to stick your way into our familiar, cozy, habitable, object-oriented programming niche?

Egor: Why not create some kind of new paradigm, you ask?

Baruch: Well, she is a new paradigm. Words have their meanings. OOP is classes, objects, sending messages to objects with specific parameters to get back some value. This is polymorphism, inheritance, some things that we know, love and so on. Now you come and say: "No, object-oriented programming is not that." What for?

Egor: Well, rather than “why”, but “why”. I do not have an answer to the question "why?", Because for this there must be some kind of goal, I have no such clear goal. Neither monetary nor any other. This is a question, rather, “why?”, Why I am doing this. Because I strongly dislike what I have been working with for many years ... I don’t like either the code I wrote, the Java I saw, or the libraries I’ve encountered, I hate to work with them. Not only me, but people who are around me, programmers. I see what kind of code they are writing, how hard it is to understand this code, to support it, and how unpleasant it is to program.


I don’t like the code I wrote, the Java I saw, or the libraries I’ve encountered, it’s not pleasant for me to work with them.



At the conferences I asked the audience a question: “Do you like what you are doing? You love this code, you wake up in the morning, look at this code and want to write it, or do you write because you need to do this? ”Someone says“ Yes, we like it, ”but I think many people are cunning. I remember myself when you write a program from scratch for the first three days or three weeks, and you like it, and for the next three years you write it because you must.

Baruch: Well, it's all clear, but this is normal ...

Egor: I think it's crazy.

Baruch: Well, I mean, this is a well-known phenomenon, and the solution to this is also unknown, for example, take everyone who uses functional programming today, they say “we don’t like object-oriented programming, and we went to another paradigm because we were disgusted by this your java. " And they took and went to another paradigm.

Egor: But they will spoil them there. If they didn’t understand OOP and just turned away from him, they said that it’s bad in general, all OOP ... As I recently blogged, I collected quotes from famous people about object-oriented programming. They all say mean things. Starting from Dijkstra, ending today. People say that this is a nasty concept in principle, let's not use it, because it helps to create a “spaghetti code”.

Baruch: Well, yes, they argue that the industry has outgrown object-oriented programming - just as it has outgrown the procedural programming. And here I again return to the same question. The natural answer would be: “OK, here is a new paradigm, here is“ OOP 2.0 ”. And you say: “No, what you don’t like is actually called differently.” And instead of introducing your new paradigm (which is in itself a difficult path), you add to this the resistance that people do not understand why you are trying to call it something else.


The whole mainstream is wrong, 95% are you doing wrong



Egor: Well, to poke their nose. This is an element of provocation, which is necessary for people to think. If I offer them “OOP 2.0”, as you say, well, a few people read, they will say: “Well, well, some other idea, put it off, think about it. We have Java, it is beautiful, it goes ahead, it is mainstream, everyone writes on it, huge conferences are held on it, huge frameworks on it, everything is fine. ” Is there some other, new parade? Well, well, he has a half-framework, eight programmers, well, let them sit there and dig. When I come to this central mainstream and say, “Guys, your whole mainstream is wrong, 95% you are doing wrong”, people start to move, fidget in the chair and realize that they don’t offer something third (where it can go, but can ignore), and explain that today you only harm everyone. Of course, it causes great emotions. I have a lot of emails, people write to me: “I realized that I had done something wrong for ten years, your such article opened my eyes, now I understood everything, I will do that”, and the other writes: “Shut up , stop telling it, we know what to do. ” Such a bipolar response suggests that it affects people, that they are not indifferent, and that is good. And if you do something standing aside, this will not seem interesting to anyone.

Baruch: So you specifically go into the line of fire in order to make people think.

Yegor: It happened. When I started writing articles, I had the first article that null reference is bad . She is not very provocative, because many people know and talk about it. I wrote in a slightly sharper tone: most articles say that you try to avoid it, and I wrote that this is basically bad, it’s evil, don’t touch it. Then he went a little further and wrote about the getters and setters . That is, I did not want to provoke anyone, I just wrote, based on my experience. Then I traced the reaction and realized that it catches a lot of life for many people, and they agree with that, I saw a lot of followers, not haters. And then the haters connected. But I ignored them, because I saw that someone was at the cashier, someone agrees with that. I went a little further. But I did not specifically, there was no such task: let us now provoke a crowd, see what they have a reaction to and start collecting traffic. This goal was not. I simply wrote several articles from my many years of experience.



Baruch: So, again, you are returning to a religious topic that does not let me go, this is some kind of reformation. That is, you are doing some new reading. And, as in any reform, there are people who call you a heretic and want to burn at the stake ... There are, on the contrary, followers. And, in general, you stirred this wasp-nest with a stick.

Egor: And the haters are mostly people who read little, who have heard little, heard the ringing - well, you yourself saw it on the Flight Debriefing in the 109th edition, when Zhenya EvgenyBorisov Borisov came and branded me, without particularly reading anything . I still want to send him a book. I would really like him to read everything and put it all together, you read the book, you understand it. And he read something, he heard: "Oh, he says that this is bad and this is bad, but he is a fool."

And most of the negative reactions are just that. People learned something by half a word and formed an opinion. It does not knock me down because there are people who agree. If they were all disagreeing, I would have thought a lot if I did not provoke the crowd in vain. And they did it recently at the Gitter-chat , 120 people gathered there in a month and a half, and people discuss it, often away from me. Often there is some kind of idea, one asks: “How would you do it?”, While others answer him: “We would do it like this” and give links to my blog. It is very cool to watch when thoughts are not mine, they already live there, people use it. It's nice. Although there are haters in the same chatik, we systematically try to extinguish, and they raise the flame. And this question is often asked there: “Why are you changing the PLO, we are fine, we have Java ... Well, call it your own way and leave us alone.”

Baruch : In my opinion, there is such a problem: to be a reformist and a prophet is usually bad for business. Because money loves silence. And my question is: how does this affect, for example, in your recruitment process?


When a client comes and hears that we are doing something very differently, then the question arises: “are they wrong?”



Yegor : Yes, you are absolutely right, it has a bad effect on business. First, there is a problem with hiring, and second, with finding customers. When a client comes and hears that we are doing something very differently than others, the question arises: “are they wrong?” We will order everything for you, and in six months we will look for a new team that will throw it all away, because only this one understands. It is. There is also a problem with recruitment - although there are people who really want to come to us, while there are few of them. But it is more interesting for me not to be another company in a large number of others, but to be a company that does something different and better. Maybe I'm wrong.

Baruch : Zhenya Borisov asked me to find out how often it happens that you give the applicant a test task for an interview, show a piece of code, and he turns the table over and says, "What the fuck is this, I will not write it."

Yegor : I also heard Zhenya Borisov saying in some “Flight Analysis” that he had a familiar team in Israel, where people did something differently, and all the other companies banned people from this team. That is, if you come from that company, then everything, no interviews, because your brain is broken and you write differently. I understand, we also have such a thing. When we hire Java programmers, we often give a piece of Java code, which, in my opinion, is written with a lot of errors. And please show errors. What would you fix? And to many, this piece of code seems to be correct, and there setters, getters, null ... Everything that I speak about is represented there. And those who do not pay attention to it, just refactor and believe that everything is fine. We reject such people. But there are people, there are not so many of them, but quite a few who find and say: “Why, here you have these setters, getters - what a garbage, it's nonsense ... you need to rewrite it differently.” Here we are such people at once: op, come in. And they are in the month of one or two quite good guys.

Baruch : This is a good pace.

Egor : We are not in a hurry, we are not building a team of a thousand people now. We currently have no such task. But the situation, it seems to me, is changing in the market. I hear, not so many people, but someone hears. I think that the changes will not go through my company, not through commercial ones. And people on the ground will begin to change. A man wrote to me a few weeks ago that he had read my book, he liked it very much, then he showed pieces of it to his colleagues, and now they are not friends with him. But he went and showed, it means that some effect went, I did not tell it, but he went. It's cool.

Baruch : I understand the anthropological interest in all this. Once the book pops up, let's talk a little about the book. It began as a blog that you decided to add together in some sort of selection ...

Egor : No, at first I wrote to the blog a little more than a year, and then Manning publishing house contacted me. And they offered to write a book: you write, we will publish. At first I said no, because I was busy, then after half a year I decided to write. I sat down last summer and wrote it in two months. It was easy, because the material from the blog. Now I am writing a second volume, and this is harder: I have never written about certain topics before, and there is no reaction from people. When I wrote the first volume, I knew the reaction of the readers, I had a bunch of comments. Manning did not work out later, and I published the book myself. I didn’t have the desire to write a book initially, but when the publisher suggested, I thought.

Baruch : Your concept is developing, there are contradictory moments in it, this is some kind of mental work in progress, when the picture has not yet fully formed. Which requires some rethinking of what has been written. This second volume is a rethinking of the first, or are you the first to postpone and say “what happened, then it was”?

Egor : No, I don’t touch the first one, I link to him in the second: “I said this now, but now I’m saying a little more ...”

Baruch : That's what I'm looking for: where will it be written that you were wrong?


immutability is now being actively discussed in our chat and cannot fully understand what an immutable object is ...



Egor : Well, it happens to me. I write that I was wrong, I clarify something. Suppose immutability is now being actively discussed in our chat and we cannot fully understand what an immutable object is ... And this discussion is very lively, I have four things on the blog, and there is a whole chapter in the book about ... If all this is folded, then There are things that contradict each other. But I am open to this, no problem to say that I was wrong.

Baruch : To say “I was wrong” in theoretical reflections is honorable, cool, but easy. Returning to the business: what to do with the code that went into production, and now you understand what it is ...

Egor : The question is good. But even if there were some mistakes, they are not so serious. There are no such fundamental errors that would need to be rewritten entirely. There are some moments that are slightly to the left, a little to the right, but in general, not. And the concept - I would not say "slim", but it is one with the other. I do not just write about ideas, I also write code as well. And there are some products that are three years old, two years old, one year old. You can view them and see that in products that are three years old, two years old, the mass of things that I recently came to was not. There were no setters, but in some places there is both a null pointer, and ORM is used somewhere. That is, some things can be opened in the open source and see that the theoretical thought was still there in the bud. And the fresher products are more interesting, they already use all the beauty of the PLO.

Baruch: Well, this is an interesting disclosure of the fact that in fact the concept of the PLO from Egor - it is work in progress. I’m not sure that many who are acquainted with your concept understand this. Mainly because of the book. Because usually, when a person writes a book, because it’s on paper and the author cannot add an update “they wrote to me in the comments that I was wrong,” it is somehow perceived to be complete. Immutable, so to speak. It seems to me that many people do not know that all this lives, develops, flows. And in fact, you are ready not only to listen, but also to accept criticism, and it really can somehow change the concept.


The class is generally a mistake. There should be no classes.



Egor: I will give an example. Well, for example in my book it is written that a class is a definite concept that is needed and important. I was talking with David West . And he told me that the class is generally a mistake. There should be no classes. I think I'm not sure yet, he is right or what he means.

Baruch: The concept that a class is a mistake is from JavaScript. Object-oriented programming through prototype. And there is a very serious dispute at a very high level, which has already been going on for twenty years, about whether a class is needed or not. And there are pros and cons. The argument for: in object-oriented programming, a class is really a completely redundant entity. She adds nothing. You create an object, as you think you need to create it, and then create some more of the same. But here, on the other hand, there are a lot of problems like immutability: the object can change, what happens to those who were created before? Should they be changed, should they be new or old? And why do similar objects created with a difference of several lines of code behave differently? Because in some other place the prototype has changed. Well, come, cool now. This concept of blueprint as a class from which you rivet objects, this question solves, because a class is something immutable, and objects from it will otpochkuyutsya and live their own lives. And with prototypes it is not so clear. Therefore, there is definitely something to think about.

Egor: Yes, yes. And what if I change my mind?

Baruch: Well, if you also refuse classes, it will be Armageddon.

Egor: I don’t give up on them yet, but David told me: “Who thought it up at all, why are they needed?”

Baruch: Now tell me, let's take such a hypothetical situation that you really decided to abandon classes and inheritance. You are a man who, with a deadly grip, clung to Java (you need to understand why, now we'll talk about this too), but you can only bend Java to your OOP to a certain extent.

Yegor: Yes.

Baruch: What will you do if you decide that the class is hostile to the PLO structure?

Yegor: I hope that I will not decide that, although ... You see, I have some articles that say “how bad it is to do this,” but no alternative to Java is offered, I finish them like this: if Java improves, and this there will be some new language, then we can do this and that.


I suggest memory management: saying that disks and memory should be something one. We give the programmer in Java to manage the file on the disk - opened, closed. Why can't the same be done with memory?



For example, I propose memory management: I say that disks and memory should be something one. We give the programmer in Java to manage the file on the disk - opened, closed. Why can't the same be done with memory? Here is a conceptual question. Java does not provide this, but it seems to me that the correct language should give the ability to manage memory. As in C / C ++, but in some convenient form. But I will not change Java.

Baruch: This brings me to the next question: why did you hold on to Java with a tight grip? You have already concluded that a true OOP language does not exist. We have a JVM platform, which allows us to write with any low blood any syntax of the language, in which there will be all card games and all the girls of easy behavior of a true OOP that you just want. Did it ever occur to you?

Egor: This is a big job, and as long as I do not have a large number of followers, the community, it will lead nowhere. There must be a large group of people, otherwise it will be a dead language. There are some people who would not mind helping, but this is a big job, I am not ready for it yet. I have a very old article, about four years old, where I summed up all the features I would like to have in the correct language. So, it seems to me that he should combine the language and the development platform. I will give an example. Why can't we access Git history from code? I can get in the comments what is my hashtag in this file, and that's all.

Baruch: I will probably answer you that this is an excellent library, but not necessarily a function of the language. There is an approach that, in principle, languages ​​should be minimized, and everything else is connected using the necessary libraries. And you care about the history of your commits in Git, but I don’t, for example. You need this feature - you connect the library, and you have it.

Egor: And it can not be done as a library, it must be in the language.

Baruch: This is an interesting question. Why?


Because this library will look crooked, like AOP in Java, glued to the side, like AspectJ



Egor: Because this library will look crooked, like AOP in Java, glued to the side, like AspectJ. Cool idea, cool, but there is no support for it in the language. There are annotations that appeared later. In the fourth Java, there was no support for AOP at all, and all this was glued through non-native technologies. Since they are non-native, everything is uncomfortable, ugly. Java, or any language, should give AOP by definition, it should be by default, embedded in the language. And also access to git. This is our story - who commits, how many commits is already part of the language.

Baruch: But today is Git, and tomorrow is Mercurial.

Egor: This is a problem, yes.

Baruch: And this problem is solved by the library. Today connected the library for tomorrow for another.

Egor: I agree, perhaps some kind of “language + library” is needed. Need the ability, using language, to access.

Baruch: With the fact that more SPI can be useful for a language, I may agree.

Egor: Here are 40 pieces of such features that should appear. Assume Continuous Integration. It is absolutely not glued to the tongue. Or build automation. We have all these Mavens and grades, which natively do not have any relation to Java. The Java code itself does not know that it will be built. I cannot access this information inside the code. Or, say, unit tests. They exist in Java as a simple class, but what are these classes? What are these objects? I have a book object, what is a bookTest object? This is strange. And these methods are not methods, they are pure procedures, microscripts. It must be done in some other way. This is done because the tests were done after Java. You need unit tests - well, sculpt like that. This is not native, not glued to one another. This is used, but there should be more convenient means inside the language. I think we are going to this. Such plain languages ​​like C, where you can simply compile a binary, are twenty years old, and now you need something new.

Baruch: This is Java twenty years ago, and C is already forty-five years old.

Egor: Moreover, there must be something new. I think it will. Maybe I will create something, I do not know. It takes time and, most importantly, there must be a community. Creating for themselves, I get a purely my decision. « Git, - », , Git -. « Mercurial Subversion», , . , .

: , ? — Kotlin , , Ceylon, .

: Ceylon , Kotlin — . , , , , , , , . — by definition. , ! design pattern — , « , ». , « design pattern, ». . .


Java EE, , best practices, Spring.



: . Java . . Java EE, , best practices, Spring. : Java EE , . , , best practices , . , Java- — Sun, Oracle, from the source, . .

: . , , . , . , Kotlin. Kotlin, : , , , , . : , - , . . , 4 , 14, , , .


Kotlin , -, . , .



Ruby. , , , … , - . , , . Ruby, - , Java . Kotlin , -, . , .

: , - .

: . «, , ». « , ». ? , .

: , , — . — , . , , — - , , , , , , , , , .

: , . , , , . , .



: Java C? , .

: . , . , , . , — , - , , , -, .


, . .



: . , , -, , . , null — , N , -. , , Java-. , , , , , . . , , . , . . , . , -. — . . , , « null, ». , . .

: , . . , , . . « , — , 20 . , ». : « — , ». - — , . , — . . . null -. , . , - , ? . « , ». « , ». , .

: . , , , 20 … — — , , . , , , , — , null' « ». , , Git «Yegor Style», code review . null', . , , — - , , , , .

: , , , antonarhipov , , .

: , , « »! — - ZeroTurnaround, . . , , , , , , , , , , …

: .

: , , , , . , , , -, , , — , , , . , , , , , , , -. , , , , , , ! , — null', — . — . , .



: , . , , : - , -, - ? , , ? - . .

: — , « ». one step at a time — . , . , credibility , , , , , - , , , , , … : , , - : «, , , , , , — ». , practical advice . , - , .

: , , .

: , , .

: , . , , . , « , ». , , , . concern.

: , revision . , . — , : . , revision , .

: .

: ? ?

: Java Day , , , , discussion board . , . JPoint' - , , .

: , , « » , . , .

: !

: . « , ». , , .


, - .



: , , , , - , . , -, - . ORM, , . , - . , . , , — Java Day , . , , . , ORM, .

: , , , . . ?

: Oredev . , , . , , JPoint', . , , .

: — . .

: , , ?

: .

: . , , , . ORM , MVC — , . , , -. , ORM .

: , .

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


All Articles