Monday, October 26, 2015

InteliJ is a joke part1


I already can see that there will be part2 and followups. I totally do not understand how as popular language as Java lacks a good and modern IDE. I started to write a code in Java 8.

I created a new project and I had to manually point IDEA to a location of my Java SDK - guys how silly is that. Why not figuring out at least the default Java location from PATH, or check JAVA_HOME variable. How about making programmers life easier!

But I still was not able to write using Java 8! First I had to deal with lambda expressions not supported at this language level error. But that wasn't it, then I was greeted with javactask source release 8 requires target release 1.8 problem. Somehow IDEA thought that I was going to code using Java in version 1.5. I can't believe it, I don't have any other version then 1.8 installed on my machine and it is 21 century; why would I want to code by default in Java 1.5?

I will just add that I am using the newest IDEA IDE; current version is 14.1.

Documentation for Maven archetypes

I don't start new projects in Java often. Each time I do it I have to go thru terribly written Maven documentation. 10 maybe 13 years ago when I was writing my first projects with Maven documentation was terrible and absolutely nothing has changed. If I didn't know what I am looking for I would be terribly lost. Even when I know what I want it takes me huge amount of time to figure out how it is labeled in Maven project. Have a look at a difference between Simple and Quickstart project archetypes.
  1. Simple: An archetype to generate a simple Maven project.
  2. Quickstart: An archetype to generate a sample Maven project.

Wow, now I learned something definitely. Guys, what is the difference between simple and sample. Which archetype should be used just to create a playground application to write some code and unit test it. I mean library project type. I just want to run tests on my code to check something.
What a wonderful explanation we get when we dig into a given archetype. When you click on Simple project you see this. What is it - empty page. Maybe some explanation of what do I see here. Not to mention that I would expect to see a in depth explanation of when should I use it and why should I use this one.
I am speeches, how can you have something like that. The sad part is that Maven is not the only project in Jave world that is terrible in documentation.
To answer my question about which archetype to use. I recommend using quickstart, that will create a following project structure.
project
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |       `-- App.java
    `-- test
        `-- java
            `-- AppTest.java

Monday, October 12, 2015

Object Oriented Programming - why the term, and are 3 principles of object oriented programming correct.

I had to explain the history of this phrase multiple times, so I gathered here some sources from Alan Key inventor of OOP as a prove that what he had in mind when he invented the term was not:
  1. 1) Encapsulation
  2. 2) Inheritance
  3. 3) Polymorphism
Date: Wed, 23 Jul 2003 09:33:31 -0800 To: Stefan Ram [removed for privacy] From: Alan Kay [removed for privacy] Subject: Re: Clarification of "object-oriented"

Hi Stefan --

Sorry for the delay but I was on vacation.

At 6:27 PM +0200 7/17/03, Stefan Ram wrote:

Dear Dr. Kay,

I would like to have some authoritative word on the term "object-oriented programming" for my tutorial page on the subject. The only two sources I consider to be "authoritative" are the International Standards Organization, which defines "object-oriented" in "ISO/IEC 2382-15", and you, because, as they say, you have coined that term.
I'm pretty sure I did.

Unfortunately, it is difficult to find a web page or source with your definition or description of that term. There are several reports about what you might have said in this regard (like "inheritance, polymorphism and encapsulation"), but these are not first-hand sources. I am also aware that later you put more emphasis on "messaging" - but I still would like to know about "object oriented".

For the records, my tutorial page, and further distribution and publication could you please explain:

When and where was the term "object-oriented" used first?
At Utah sometime after Nov 66 when, influenced by Sketchpad, Simula, the design for the ARPAnet, the Burroughs B5000, and my background in Biology and Mathematics, I thought of an architecture for programming. It was probably in 1967 when someone asked me what I was doing, and I said: "It's object-oriented programming".

The original conception of it had the following parts.

I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).
I wanted to get rid of data. The B5000 almost did this via its almost unbelievable HW architecture. I realized that the cell/whole-computer metaphor would get rid of data, and that "<-" would be just another message token (it took me quite a while to think this out because I really thought of all these symbols as names for functions and procedures.
My math background made me realize that each object could have several algebras associated with it, and there could be families of these, and that these would be very very useful. The term "polymorphism" was imposed much later (I think by Peter Wegner) and it isn't quite valid, since it really comes from the nomenclature of functions, and I wanted quite a bit more than functions. I made up a term "genericity" for dealing with generic behaviors in a quasi-algebraic form.
I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and designers). So I decided to leave out inheritance as a built-in feature until I understood it better.
My original experiments with this architecture were done using a model I adapted from van Wijngaarten's and Wirth's "Generalization of Algol" and Wirth's Euler. Both of these were rather LISP-like but with a more conventional readable syntax. I didn't understand the monster LISP idea of tangible metalanguage then, but got kind of close with ideas about extensible languages draw from various sources, including Irons' IMP.

The second phase of this was to finally understand LISP and then using this understanding to make much nicer and smaller and more powerful and more late bound understructures. Dave Fisher's thesis was done in "McCarthy" style and his ideas about extensible control structures were very helpful. Another big influence at this time was Carl Hewitt's PLANNER (which has never gotten the recognition it deserves, given how well and how earlier it was able to anticipate Prolog).

The original Smalltalk at Xerox PARC came out of the above. The subsequent Smalltalk's are complained about in the end of the History chapter: they backslid towards Simula and did not replace the extension mechanisms with safer ones that were anywhere near as useful.

What does "object-oriented [programming]" mean to you? (No tutorial-like introduction is needed, just a short explanation [like "programming with inheritance, polymorphism and encapsulation"] in terms of other concepts for a reader familiar with them, if possible. Also, it is not neccessary to explain "object", because I already have sources with your explanation of "object" from "Early History of Smalltalk".)
(I'm not against types, but I don't know of any type systems that aren't a complete pain, so I still like dynamic typing.)

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.

[Also,] One of the things I should have mentioned is that there were two main paths that were catalysed by Simula. The early one (just by accident) was the bio/net non-data-procedure route that I took. The other one, which came a little later as an object of study was abstract data types, and this got much more play.

If we look at the whole history, we see that the proto-OOP stuff started with ADT, had a little fork towards what I called "objects" -- that led to Smalltalk, etc.,-- but after the little fork, the CS establishment pretty much did ADT and wanted to stick with the data-procedure paradigm. Historically, it's worth looking at the USAF Burroughs 220 file system (that I described in the Smalltalk history), the early work of Doug Ross at MIT (AED and earlier) in which he advocated embedding procedure pointers in data structures, Sketchpad (which had full polymorphism -- where e.g. the same offset in its data structure meant "display" and there would be a pointer to the appropriate routine for the type of object that structure represented, etc., and the Burroughs B5000, whose program reference tables were true "big objects" and contained pointers to both "data" and "procedures" but could often do the right thing if it was trying to go after data and found a procedure pointer. And the very first problems I solved with my early Utah stuff was the "disappearing of data" using only methods and objects. At the end of the 60s (I think) Bob Balzer wrote a pretty nifty paper called "Dataless Programming", and shortly thereafter John Reynolds wrote an equally nifty paper "Gedanken" (in 1970 I think) in which he showed that using the lamda expressions the right way would allow data to be abstracted by procedures.

The people who liked objects as non-data were smaller in number, and included myself, Carl Hewitt, Dave Reed and a few others -- pretty much all of this group were from the ARPA community and were involved in one way or another with the design of ARPAnet → Internet in which the basic unit of computation was a whole computer. But just to show how stubbornly an idea can hang on, all through the seventies and eighties, there were many people who tried to get by with "Remote Procedure Call" instead of thinking about objects and messages. Sic transit gloria mundi.

Cheers,

Alan Kay




Alan Kay has argued that message passing is more important than objects in OOP, and that objects themselves are often over-emphasized. The live distributed objects programming model builds upon this observation; it uses the concept of a distributed data flow to characterize the behavior of a complex distributed system in terms of message patterns, using high-level, functional-style specifications.




I was too blythe about the term back in the 60s and should have chosen something like "message oriented" – Alan Kay
There is excellent answer in SO that targets this question:
Actually Alan Kay didn't have Smalltalk in mind when he came up with the term "object oriented programming":

At Utah sometime after Nov 66 when, influenced by Sketchpad, Simula, the design for the ARPAnet, the Burroughs B5000, and my background in Biology and Mathematics, I thought of an architecture for programming. It was probably in 1967 when someone asked me what I was doing, and I said: "It's object-oriented programming".

The original conception of it had the following parts.

I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).
I wanted to get rid of data. The B5000 almost did this via its almost unbelievable HW architecture. I realized that the cell/whole-computer metaphor would get rid of data, and that "<-" would be just another message token (it took me quite a while to think this out because I really thought of all these symbols as names for functions and procedures.
My math background made me realize that each object could have several algebras associated with it, and there could be families of these, and that these would be very very useful. The term "polymorphism" was imposed much later (I think by Peter Wegner) and it isn't quite valid, since it really comes from the nomenclature of functions, and I wanted quite a bit more than functions. I made up a term "genericity" for dealing with generic behaviors in a quasi-algebraic form.
I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and designers). So I decided to leave out inheritance as a built-in feature until I understood it better.
Smalltalk was the result of this conception, borrowing and extending the concepts of "object" and "class" from Simula, which Simula in turn inherited from ALGOL, as described on "The development of the Simula languages" by Kristen Nygaard and Ole-Johan Dahl (1978, page 253):

In ALGOL, blocks (including procedures) are seen externally as generalized operations. By introducing mechanisms for quasi-parallel sequencing, ~essentially the same construct could play the role of processes in parallel, and through mechanisms for naming block instances and accessing their contents they could function as generalized data objects. The essential benefits of combining data and operations in a single construct were already there to be explored.

One result of this exploration was the discovery that "procedure attributes" might be useful. The following example of a class of "abstract" car objects is quoted from the Language Definition document (Dahl and Nygaard 1965), sect. 5.3.
Further inspiration, especially for sub-classing, was C.A.R. Hoare's record class (page 258):

The subclass idea of Hoare (68) was a natural starting point, but there were two difficulties:

We needed subclasses of processes with own actions and local data stacks, not only of pure data records.
We also needed to group together common process properties in such a way that they could be applied later, in a variety of different situations not necessarily known in advance.
Much time was spent during the autumn of 1966 in trying to adapt Hoare's record class construct to meet our requirements, without success. The solution came suddenly, with the idea of "prefixing", in December 1966. We were thinking in terms of atoll booth on a bridge, with a queue of cars which were either trucks or buses. (This example reappears in (Dahl and Nygaard 1968)).
The terms "class" and "object" also appear on SIMULA 67 COMMON BASE LANGUAGE by Ole-Johan Dahl, Bjorm Myhrhaug, and Kristen Nygaard (pages 4-5):

The block concept corresponds to the intuitive notion of "sub-problem" or "sub-algorithm" which is a useful unit of decomposition in orthodox application areas.

A block is a formal description, or "pattern" of an aggregated data structure and and associated algorithms and actions.

...

An extended block concept is introduced through a "class" declaration and associated interaction mechanism such as "object references" (pointers), remote accessing", "quasi-parallel" operation, and block "concatenation".
Classes are discussed in more detail in chapter 1.3.3 (page 5):

A central new concept in Simula 67 is the "object". An object is a self-contained program (block instance), having its own local data and actions defined by a "class declaration". The class declaration defines a program (data and action) pattern, and objects conforming to that pattern are said to "belong to the same class".

...
So, although the term "object oriented" wasn't invented yet, both "class" and "object" were used similarly to their modern use before Alan Kay began developing Smalltalk in 1969.

Ivan Sutherland goes as far as identifying Simula as the first object oriented programming language, on Sketchpad: A man-machine graphical communication system (page 4), also recognizing C.A.R. Hoare's, Douglas T. Ross', ALGOL's and Sketchpad's influences:

Nevertheless, Sutherland's attempt to remove the division between users and programmers was not the only system that, in failing to do so, provided the imaginative leap to a new programming paradigm. Nygaard and Dahl's Simula [7] was the first conventional programming language incorporating the principles of object orientation, but Sketchpad's implementation of class and instance-based inheritance (though not called objects) predated Simula by several years.

There appears to have been a common influence through the work of Douglas T. Ross, who is mentioned in the acknowledgements of this dissertation and also cited in the MIT Lincoln Laboratory technical report based on it. Ross sat on the Algol 68 committee with C. A. R. Hoare in the mid-1960s, where his previous work on a record-like data structure (called a plex) influenced Hoare's own ideas on abstract data types [3], later credited by Nygaard and Dahl as the origin of the class definition mechanisms in Simula [7].

Alan Kay's seminal Dynabook project, which led both to the Xerox Star and to the explosion of interest in object oriented programming through his language Smalltalk, was directly influenced by Sketchpad. Kay has written of the fact that the genesis of Smalltalk lay in the coincidental appearance on his desk of both a distribution tape of Simula and a copy of Sutherland's Sketchpad thesis [5]. Kay recognized that the two systems were based on the same underlying type concepts (apparently derived via two different routes from Ross's plex), and that these could form the basis of a more widely usable programming system. In comparing these two routes of influence, Simula was a far larger project than Sketchpad, rightly recognized as the first object-oriented programming language, but we hope that the special emphasis of Sketchpad on supporting abstraction in the user interface itself may yet become viable as a result of ongoing research efforts [2,6].
However Alan Kay, obviously, considers Smalltalk to be the first object oriented language:

Though it has noble ancestors indeed, Smalltalk’s contribution is a new design paradigm–which I called object-oriented–for attacking large problems of the professional programmer, and making small ones possible for the novice user. Object-oriented design is a successful attempt to qualitatively improve the efficiency of modeling the ever more complex dynamic systems and user relationships made possible by the silicon explosion.
and having coined the term, I think there isn't much of a debate there.

To finally answer your question: Some of the core concepts of object orientation did exist on Simula, and on earlier languages like Algol and LISP, but the paradigm itself didn't, hence there wasn't really a need for a name.

Smalltalk was designed with object orientation in mind, at least what Alan Kay thought of as object orientation:

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
The architecture may seem like an amalgamation of earlier concepts, but its central concepts were introduced by Smalltalk, thus marking the first implementation of the paradigm.