11 Ağustos 2020 Salı

Nesneye Yönelik Programlama Tarihçesi - Object Oriented Programming History

Giriş
Nesneye Yönelik Tasarım (Object Oriented Design) kelimesi ilk olarak Alan Kay tarafından kullanıldı. Bu kelimeler 1960'lı yıllardan itibaren hayatımızdalar. Simula ise ilk nesneye yönelik tasarımı kullanan dil olarak kabul edilir.

Cobol
Açıklaması şöyle. 1959 yılında icat edildi. Sanırım Object Oriented Programming'e en büyük katkısı record mantığını yerleştirmesi.
The core notion of the eponymous object emerges from the desire to bundle information which belongs together in structures or records. As COBOL shows, this is a natural projection of tabulated data into databases and computer memory in general. The alternative — keeping each field in a separate variable — becomes a maintenance nightmare which worsens exponentially with the program complexity. Bundling associated data in this way is a paradigm shift from emphasizing rows as opposed to columns of tabulated data.

Once you have structures you write subroutines that take them, or pointers to them, as parameters. That is fundamentally object orientation: Objects consisting of associated data plus operations on them.

The next step is almost minor: You bundle the functions with the data in a supercharged, self-contained structure called a class, so that you can pass the set of allowed functions around together with the data. As a side effect, this obviates the need to pass the specific object as a parameter to the operation because the operation is part of the specific set of data.

Once we realize that the object owns its operations, wouldn't it be nice if we could customize the behavior? Voila, polymorphism.
Simula 
1960 yılında icat edildi. Açıklaması şöyle.
Kristen Nygaard started writing computer simulation programs in 1957. Nygaard saw a need for a better way to describe the heterogeneity and the operation of a system
Simula 67 için açıklama şöyle
Simula has objects, classes, subclasses, and inheritance.
Simula ile C++ ilişkisi şöyle


Smalltalk
1972 yılında Alan C. Kay tarafından icat edildi. Açıklaması şöyle.
Let me [Alan C. Kay] first present the general development of the Smalltalk-72 system up to the transition to Smalltalk-76, and then follow that with the several years of work with children that were the primary motivation for the project.
Smalltalk Dilinin Simula'dan Aldığı İlham
Açıklaması şöyle.
What I got from Simula was that you could now replace bindings and assignment with goals. The last thing you wanted any programmer to do is mess with internal state even if presented figuratively. Instead, the objects should be presented as sites of higher level behaviors more appropriate for use as dynamic components.

Even the way we taught children (cf. ahead) reflected this way of looking at objects. Not too surprisingly this approach has considerable bearing on the ease of programming, the size of the code needed, the integrity of the design,
Smalltalk'un Kökleri
Kökleri 1969 yılına dayanıyor. Burada çözülmesi gereken problemin açıklaması şöyle.
Kay traces the origins of SmallTalk to his time in the Air Force. In 1961, he was stationed at Randolph Air Force Base near San Antonio, Texas, and he worked as a programmer, building software for a vacuum-tube computer called the Burroughs 220. In those days, computers didn't have operating systems. No Apple iOS. No Windows. No Unix. And data didn't come packaged in standard file formats. No .doc. No .xls. No .txt. But the Air Force needed a way of sending files between bases so that different machines could read them. Sometime before Kay arrived, another Air Force programmer—whose name is lost to history—cooked up a good way.
Bu koda aynı bir nesne gibi takılabilen yapılar gerekiyordu. Açıklaması şöyle.
This unnamed programmer—"almost certainly an enlisted man," Kay says, "because officers didn't program back then"—would put data on a magnetic-tape reel along with all the procedures needed to read that data. Then, he tacked on a simple interface—a few "pointers," in programmer-speak—that allowed the machine to interact with those procedures. To read the data, all the machine needed to understand were the pointers—not a whole new way of doing things. In this way, someone like Kay could read the tape from any machine on any Air Force base.

Kay's programming objects worked in a similar way. Each did its own thing, but could communicate with the outside world through a simple interface. That meant coders could readily plug an old object into a new program, or reuse it several times across the same program. Today, this notion is fundamental to software design. And now, Habitat wants to recreate this dynamic on a higher level: not within an application, but in a way that allows an application to run across as a vast computer network.
Daha sonra Smalltalk moleküler biyolojide kullanılmaya başlandı. Açıklaması şöyle
IN THE EARLY 1970s, at Silicon Valley's Xerox PARC, Alan Kay envisioned computer software as something akin to a biological system, a vast collection of small cells that could communicate via simple messages. Each cell would perform its own discrete task. But in communicating with the rest, it would form a more complex whole. "This is an almost foolproof way of operating," Kay once told me. Computer programmers could build something large by focusing on something small. That's a simpler task, and in the end, the thing you build is stronger and more efficient.

The result was a programming language called SmallTalk. Kay called it an object-oriented language—the "objects" were the cells—and it spawned so many of the languages that programmers use today, from Objective-C and Swift, which run all the apps on your Apple iPhone, to Java, Google's language of choice on Android phones. Kay's vision of code as biology is now the norm. It's how the world's programmers think about building software.
Aslında bu düşünme şekli dağıtık ortamlara dahi uygun. Eğer sınıflar yerine sistemler veya servisler koyarsak yine benzer bir yapı elde ederiz. Açıklaması şöyle
But Kay's big idea extends well beyond individual languages like Swift and Java. This is also how Google, Twitter, and other Internet giants now think about building and running their massive online services. The Google search engine isn't software that runs on a single machine. Serving millions upon millions of people around the globe, it's software that runs on thousands of machines spread across multiple computer data centers. Google runs this entire service like a biological system, as a vast collection of self-contained pieces that work in concert. It can readily spread those cells of code across all those machines, and when machines break—as they inevitably do—it can move code to new machines and keep the whole alive.
Algol-60
Simula ve Algol-60 1960 yılında icat edildiler. Simula'da generics kavramı yok. Bu kavram Algol-60 ile geliyor. Bence ilginç olduğu için not almak istedim. Açıklaması şöyle
Q : What was the first programming language with generics?
A: That was Algol-60.
Alan Kay'ın Mesajlaşan Nesneler Hayali
Kay'in fikri şöyleydi.
"OO" was about messaging, not objects and drew a parallel to biological cells.
Alan Kay biyoloji kökenli olduğu için hücrelerin birbirlerinden bağımsız çalıştıklarını biliyordu. Açıklaması şöyle
Alan Kay, the creator of OOP had a background in biology. He had an idea for a language (Simula), that would allow writing computer programs in a way that resembles biological cells. He wanted to have independent programs (cells) communicate by sending messages to each other. The state of the independent programs would never be shared with the outside world (encapsulation).

Alan Kay never intended for the “cells” to reach directly into the internals of other cells to make changes.
Ancak günümüzdeki ana akım OO diller böyle çalışmıyor. Daha çok senkron metod çağırma üzerine kurulu. Açıklaması şöyle
So it may be useful if you are programming in Smalltalk, or writing event driven code, but not if you are talking about today's accepted meaning of Object Orientated Programming, which has methods - not messages.

If you call car.stop() you aren't sending the stop message to car and carrying on with your life, maybe getting a message back at a later date. You are "going to" the code in the stop method, running each statement in turn and returning a result back to where you left off.
C++
Smalltalk ile ilişkisinin açıklaması şöyle. Maksat hız sağlamak
The motivation for creating a new language originated from Stroustrup's experience in programming for his PhD thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level to be suitable for large software development. When Stroustrup started working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his Ph.D. experience, Stroustrup set out to enhance the C language with Simula-like features
Represents Kelimesi
Bir çok CASE aracında sınıfın açıklama bölümünde "represents" kelimesi kullanılıyordu. Şöyle yapardık. Bu biraz saçma gelse bile bir alışkanlık haline gelmişti.
"a car object represents a real life car"
Bu mantığın açıklaması şöyle. Yani sınıf tam bir araba olmasa bile, kod içinde özelliklerine bizim karar verdiğimiz bir arabayı temsil eder.
The representation of an object is meant to correspond to the object - it tells you some information about the object, or it identifies the object - but it's not actually the object.

"Represent" is an English word which is not specific to OOP. A photograph of a car represents a car, because it isn't a car, but we can pretend it is.

Hiç yorum yok:

Yorum Gönder