Overriding vs Shadowing
Hi, in short, I’d like to describe why using method shadowing in a project can be dangerous.
First, let’s have a short introduction to what method overriding and shadowing is.
Overriding – it’s changing the method body. What’s important is that the method signature is resolved at runtime based on the object’s type. The base method has to be declared with ‘virtual’ modifier.
Shadowing – it’s changing the method body. It’s early bound, thus resolved at compile type based on the object’s type. The base method doesn’t have to have any special modifier. However, in the derived class, the shadowing method can optionally include ‘new’ modifier (it’s not necessary, but without it compilers generate a warning).
How to Create a Mind – Ray Kurzweil
The Structure
“How to Create a Mind” is the latest nonfiction book by Ray Kurzweil as of today. It starts technical and shifts toward the philosophical aspect of a mind. After a brief introduction to the nature of thinking, the author moves to use cases of the Markov model in the speech recognition systems based on Siri and IBM’s Watson examples. Kurzweil also elaborates on the history of computing from the very first algorithms from the 18-th century, through Turing machine and the works of John von Neumann, which laid the foundations for the current machines. Few next chapters touch are dedicated to neocortex part of the human brain and the ability to reproduce the pattern-recognition ability in a digital form. The remaining part is purely philosophical but in a good way.
The Essence
It’s the mind. Observed from different angles. Most of the examples included in this book are stimulating, such as the experiments with split-brain patients and the reasoning about a false cause. In short, split-brain is a syndrome in which the two cerebral hemispheres get disconnected. It turns out that even though the hemispheres cannot communicate with each other, which means that patients live with two separate brains, subjects may function normally. However, since the hemispheres are cross-connected (left hemisphere is connected to the right part of the body and vice-versa), limiting brain inputs to one of the hemispheres bring some unexpected results.
The left hemisphere in a split-brain patient usually sees the right visual field, and vice versa. Gazzaniga and his colleagues showed a splitbrain
patient a picture of a chicken claw to the right visual field (which was seen by his left hemisphere) and a snowy scene to the left visual field
(which was seen by his right hemisphere). He then showed a collection of pictures so that both hemispheres could see them. He asked the patient
to choose one of the pictures that went well with the first picture. The patient’s left hand (controlled by his right hemisphere) pointed to a picture of a shovel, whereas his right hand pointed to a picture of a chicken. So far so good—the two hemispheres were acting independently and sensibly.
“Why did you choose that?” Gazzaniga asked the patient, who answered verbally (controlled by his left-hemisphere speech center), “The chicken
claw obviously goes with the chicken.” But then the patient looked down and, noticing his left hand pointing to the shovel, immediately explained this (again with his left-hemisphere-controlled speech center) as “and you need a shovel to clean out the chicken shed.”This is a confabulation. The right hemisphere (which controls the left arm and hand) correctly points to the shovel, but because the left
How to Create a Mind – Ray Kurzweil
hemisphere (which controls the verbal answer) is unaware of the snow, it confabulates an explanation, yet is not aware that it is confabulating. It is
taking responsibility for an action it had never decided on and never took, but thinks that it did.
Ray also discusses the quirks of free will and the problem of determining how to “proof” consciousness. In numerous experiments (the most famous is the Libet one), when the research group had to make a simple decision such as whether they’ll like to have a coffee. It turns out that the motoric part of the brain raises activity even half a second earlier before the decision-making area of the brain gets stimulated. This means that the body is already preparing the movement for grabbing the coffee before the aware decision is made, thus implying our free will is limited and we act as complicated state machines, not fully aware of the reasons behind our actions.
I find the consciousness theory part the most interesting. Kurzweil briefly describes the two consciousness theory by David Chalmers.
Chalmers does not attempt to answer the hard question but does provide some possibilities. One is a form of dualism in which consciousness
per se does not exist in the physical world but rather as a separate ontological reality. According to this formulation, what a person does is basedon the processes in her brain. Because the brain is causally closed, we can fully explain a person’s actions, including her thoughts, through itsprocesses. Consciousness then exists essentially in another realm, or at least is a property separate from the physical world. This explanation doesnot permit the mind (that is to say, the conscious property associated with the brain) to causally affect the brain.
Another possibility that Chalmers entertains, which is not logically distinct from his notion of dualism, and is often called panprotopsychism, holds that all physical systems are conscious, albeit a human is more conscious than, say, a light switch.
I tend to agree with the second theory that everything is conscious ‘to its own measure’, however, most of the subjects are simple. A light switch is ‘conscious’ of its two states (on/off). An ant is conscious of its closest surrounding, able to move based on inputs that come to its brain and perform logical operations such as to eat, to fight or to run (ant example is even more interesting by the fact for it seems a hive of ants is more intelligent and ‘aware’ than a single representative). A fish then is more conscious than an ant because of the more advanced decision-making system and event more inputs that it can accept and process at a given time. Then we move to mammals such as dogs, which have dreams, can solve simple logic problems, have more diverse and even more advanced brain. However, most experiments proof that dogs are unaware of their reflection. Well, human beings until the age of 2 can do neither, however, we learn that by observing a mirror and using our cause-and-effect system to link our movements with the reflection movements and eureka! comprehend our own reflection. Interestingly, chimpanzees, having a brain which almost resembles ours, can do that too.
We usually think of insects as mechanical constructs, by virtue of the rather simple and transparent logic they follow. Yet while rejecting consciousness of dogs or chimpanzees, we find some of the human traits in them, because we tend to interpret their actions by wrapping them with human intentions. However, if there was a machine or an organism 100 times more intelligent than humans, what would it think of us? Driven by desires, fears, hunger etc. which all stem from chemical reactions. Vessels armed with really complex (from a human perspective) processor, pattern-recognizer and uncertainty-based decision-making system? Wouldn’t it find our actions semi-automatical? If we were able to completely disassemble the brain, tracking each signal bit by bit, wouldn’t we found ourselves just the executors of some greater, reversed entropy, which drives spiders to weave their nets?
Summary
Overall, the book is a great brain teaser, however, one thing I find unnecessary is the chapter containing riposte for the critics of Kurzweil works. I may only wonder why Kurzweil decided to include those in this book. Nevertheless, I appreciate the world blooming with writings like this one.
Summa Technologiae – Stanisław Lem
It’s 1964, one of the greatest Polish science-fiction writers and futurologists is about to finish his latest book called “Summa Technologiae”. The name refers to the “Summa Theologiae” by Thomas Aquinas, which in the 13th century was the compendium of all the main theological teachings. It summed up the current state of knowledge. Similarly, in the middle of 1960s Lem sets off to a meta-journey to recon the world of technology, armed only with his intellect bounded by the restrictions of the Iron Curtain.
To approach this book without consideration of its historical and geopolitical background would be inappropriate. Moreover, hardly could we appreciate the charm of the writer, who, 26 years before the Internet became public, foresaw that for people to become a singular intelligent organism they would need “some kind of telephone” for sharing information globally…
Largest region in the matrix – DFS & BFS
If you have or had troubles understanding breath or depth first search, you’ve come to the right place. Here it is – recursive graph search made easy.
Depth-First Search
Depth-first search (DFS) is a method for exploring a graph. In a DFS, you follow the child of traversing node, meaning if the current node has a child, with each step you’ll go deeper into the graph in terms of distance from the root. If a node hasn’t any unvisited children, then go up one level to parent.
Breadth-First Search
Breadth-first search (BFS) is a method for exploring a graph. In a BFS, you first explore all the nodes one step away from the root, then all the nodes two steps away, etc.
The Problem
Consider a matrix with rows and columns, where each cell contains either a ‘0’ or a ‘1’ and any cell containing a 1 is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. If one or more filled cells are also connected, they form a region. find the length of the largest region.
Input : M[][5] = { 0 0 1 1 0
1 0 1 1 0
0 1 0 0 0
0 0 0 0 1 }
Output : 6
Ex: in the following example, there are 2 regions one with length 1 and the other as 6.
The largest region : 6
Code Complete – Steve McConnell
In this short review, I’ll try to distill key features of this over 900 pages book.
Simply speaking, if the Clean Code by G. Martin is the “what”, this book is the “how” of programming practices. It covers key areas of daily programming tasks from problem definition, through planning, software architecture, debugging, unit testing, naming to integration and maintenance.