Pages

20170815

Compiler Construction by Niklaus Wirth

  • It is the essence of any academic education that not only knowledge, and, in the case of an engineering education, know-how is transmitted, but also understanding and insight.
  • very academically educated computer scientist must know ho w a computer functions, and must understand that ways and methods in which programs are represented and interpreted.
  • Computer programs are formulated in a programming language and specify classes of computing processes. Computers, however, interpret sequences of particular instructions, but not program texts. Therefore, the program text must be translated into a suitable instruction sequence before it can be processes by a computer. This translation can be automated, which implies that it can be formulated as a program itself. The translation program is called a compiler, and the text to be translated is called source text (or sometimes source code).
  • The translation process essentially consists of the following parts:
    • The sequence of characters of a source text is translated into a corresponding sequence of symbols of the vocabulary of the language.
    • The sequence of symbols is transformed into a representation that mirrors the syntactic structure of the source text and lets this structure easily be recognized.
    • In addition to syntactic rules, compatibility rules among types of operators and operands define the language. Hence, verification of whether these compatibility rules are observed by a program is an additional duty of a compiler. This verification is called type checking.
    • On the basis of the representation resulting from step 2, a sequence of instructions taken from the instruction set of the target computer is generated. This phase is called code generation.
  • A partitioning of the compilation process into as many parts as possible was the predominant technique until about 1980, because until then the available store was too small to accommodate the entire compiler. Only individual compiler parts would fit, and they could be loaded one after the other in sequence. The parts were called passes, and the whole was called a multi pass compiler.
  • Modern computers with their apparently unlimited stores make it feasible to avoid intermediate storage to disk. And with it, the complicated process of serializing a data structure for output, and its reconstruction on input can be discarded as well. With single-pass compilers, increases in speed by factors of several thousands are therefore possible. Instead of being tackled one after another in strictly sequential fashion, the various parts (tasks) are interleaved.
  • A compiler which generates code for a computer different from the one executing the compiler is called  a cross compiler. The generated code is then transferred--downloaded--via a data transmission line.
  • Every language displays structure called its grammar or syntax.
  • A language is, therefore, the set of sequences of terminal symbols which, starting with the start symbol, can be generated by repeated application of syntactic equations, that is, substitutions.
  • A language is regular, if its syntax can be expressed by a single EBNF expression.
  • The reason for our interest in regular languages lies in the fact that programs for the recognition of regular sentences are particularly simple and efficient.
  • Sentence recognition is called syntax analysis.
  • Ultimately, the basic idea behind every language is that it should serve as a means for communication. This means that partners must use and understand the same language. Promoting the ease by which a language can be modified and extended may therefore by rather counterproductive.
  • The scanner has to recognize terminal symbols in the source code.
  • The essential characteristics of a good compiler, regardless of details, are that (1) no sequence of symbols leads to its crash, and (2) frequently encountered errors are correctly diagnosed and subsequently generate no, or few additional, spurious error messages.
  • The simplest form of data structure for representing a set of items is the list. Its major disadvantage is a relatively slow search processes, because it has to be traversed from its root to the desired element.
  • In languages featuring data types, their consistency checking is one of the most important tasks of a compiler.
  • Consecutively declared variables are then allocated with monotonically increasing or decreasing addresses. This is called sequential allocation.
  • The size of an array is its element size multiplied by the number of its elements. The address of an element is the sum of the array's address and the element's index multiplied by the element size.
  • Absolute addresses of variables are usually unknown at the time of compilation. All generated addresses must be considered as relative to a common base address which is given at run-time. The effective address is then the sum of this base address and the address determined by the compiler.
  • Although bytes can be accessed individually, typically a small number of bytes (say 4 or 8) are transferred from or to memory as a packet, a so-called word.
  • Following a longstanding tradition, addresses of variables are assigned negative values, that is, negative offsets to the common base address determined during program execution.
  • The acronym RISC stands for reduced instruction set computer, where "reduced" is to be understood as relative to architectures with large sets of complex instructions, as these were dominant until about 1980.
  • From the view points of the programmer and the compiler designer the computer consists of an arithmetic unit, a control unit, and a store.
  • Whenever arithmetic expressions are evaluated, the inherent danger of overflow exists. The evaluating statements should therefore be suitable guarded.
  • The essence of delayed code generation is that code is not emitted before it is clear that no better solution exists.
  • Conditional and repeated statements are implemented with the aid of jump instructions, also called branch instructions.
  • Procedures, which are also known as subroutines, are perhaps the most important tool for structuring programs.
  • Addresses of local variables generated by the compiler are always relative to the base address of the respective activation frame.
  • Parameters constitute the interface between the calling and the called procedures. Parameters on the calling side are said to be actual parameters, and those on the called side formal parameters.
  • An open array is an array parameter whose length is known (open) at the time of compilation.
  • The unit consisting of array address and lengths is called an array descriptor.
  • The type to which a pointer is bound is called its base type.
  • A variable is no longer relevant when there are no references to it, references emanating from declared pointer variables.
  • The range of visibility of an identifier in the text is called scope, and it extends over the block in which the identifier is declared.
  • Software is not "written", but grows.
  • Once agreement is reached about the partitioning of a system into modules and about their interfaces, the team members can proceed independently in implementing that module assigned to them.
  • The successful development of complex systems crucially depends on the concept of modules and their separate compilation.
  • A primary goal of good code optimization is the most effective use of registers in order to reduce the number of accesses to the relatively slow main memory. A good strategy of register usage yields more advantages than any other branch of optimization.
  • In many compilers, local variables are allocated to registers only in procedures which do not contain any calls themselves (leaf procedures), and which therefore are also called most frequently, as they constitute the leaves in the tree representing the procedure cal hierarchy.

20170814

Dr. Jordan B. Peterson's 10 Step Guide to Clearer Thinking Through Essay Writing

  • Essay writing is more than just a thing to do to get grades in college. It's a practical method for clarifying your thinking and learning to articulate yourself.
  • An essay is a relatively short piece of writing on a  particular topic. However, the word essay also means attempt or try. An essay is, therefore, a short piece written by someone attempting to explore a topic or answer a question.
  • The primary reason to write an essay is so that the writer can formulate and organize an informed, coherent, and sophisticated set of ideas about something important.
  • It is important to think because action based on thinking is likely to be far less painful and more productive than action based upon ignorance.
  • Here is something to think about: the person who can formulate and communicate the best argument almost always wins.
  • If you learn to write and to edit, you will also be able to tell the difference between good ideas, intelligently presented, and bad ideas put forth by murky and unskilled thinkers.
  • Those who can think and communicate are simply more powerful than those who cannot, and powerful in the good way, the way that means "able to do a wide range of things competently and efficiently."
  • Don't ever underestimate the power of words.
  • People's brains function better in the morning. Get up. Eat something. You are much smarter and more resilient after you have slept properly and ate.
  • Do not wait for a big chunk of free time to start. You will never get bug chunks of free time ever in your life, so don't make your success dependent on their non-existence. The most effective writers write every day, at least a bit.
  • Realize that when you first sit down to write, your mind will rebel.
  • Three productive hours are way better than ten hours of self-deceptive non-productivity, even in the library.
  • An essay, like any piece of writing, exists at multiple levels of resolution, simultaneously. First is the selection of the word. Second is the crafting of the sentence. Each word should be precisely the right word, in the right location in each sentence. The sentence itself should present a thought, part of the idea expressed in the paragraph, in a grammatically correct manner. Each sentence should be properly arranged and sequenced inside a paragraph, the third level of resolution.
  • As a rule of thumb, a paragraph should be made up of at least 10 sentences or 100 words. This might be regarded as a stupid rule, because it is arbitrary. However, you should let it guide you, until you know better.
  • You have very little right to break the rules, until you have mastered them.
  • You break a rule at your peril, whether you know it or not.
  • Rules are there for a reason. You are only allowed to break them if you are a master. If you're not a master, don't confuse your ignorance with creativity or style.
  • A paragraph should present a single idea, using multiple sentences. If you can't think up 100 words to say about your idea, it's probably not a very good idea, or you need to think more about it. If your paragraph is rambling on for 300 words, or more, it's possible that it has more than one idea in it, and should be broken up.
  • All of the paragraphs have to be arranged in a logical progression, from the beginning of the essay to the end. This is the fourth level of resolution. Perhaps the most important step in writing an essay is getting the paragraphs in proper order. Each of them is a stepping stone to your essay's final destination.
  • The fifth level of resolution is the essay, as a whole. Every element of an essay can be correct, each word, sentence, and paragraph--even the paragraph order---and the essay can still fail, because it is just not interesting or important.
  • An essay necessarily exists withing a context of interpretation, made up of the reader (level six), and the culture that the reader is embedded in (level seven), which is made up in part of the assumptions that he or she will bring to the essay.
  • For the essay to succeed, brilliantly, it has to work at all of these levels of resolution simultaneously. That is very difficult, but it is in that difficulty that the value of the act of writing exists.
  • If you are bored while writing, then, most importantly, you are doing it wrong, and you will also bore your reader.
  • You must choose a topic that is important to you. This should be formulated as a question that you want to answer. This is arguably the hardest part of writing an essay: choosing the proper question.
  • Having said all that, here is something to remember: finished beats perfect. Most people fail a class or an assignment or a work project not because they write badly, and get D's or F's, but because they don't write at all, and get zeros. Zeros are very bad. They are the black holes of numbers. Zeros make you fail. Zeros ruin your life. Essays handed in, no matter how badly written, can usually get you at least a C. So don't be a completely self-destructive idiot. Hand something in, regardless of how pathetic you think it is (and no matter how accurate you are in that opinion).
  • If you can't write, it is because you have nothing to say. You have no ideas. In such a situation, don't pride yourself on your writer's block. Read something. If that doesnt' work, read something else--maybe something better. Repeat until the problem is solved.
  • Assume you need 5-10 books or articles per thousand words of essay, unless you have been instructed otherwise.
  • When you are taking notes, don't bother doing stupid things like highlighting or underlining sentences in the textbook. There is no evidence that it works. It just looks like work. What you need to do is to read for understanding. Read a bit, then write down what you have learned or any questions that have arisen in your mind. Don't ever copy the source word for word. The most important part of learning and remembering is the recreation of what you have written in your own language.
  • Take about two to three times as many notes, by word, as you will need for your essay. You might think that is inefficient, but it's not. In order to write intelligibly about it, you need to know far more than you actually communicate.
  • Here's another rule. When you write your first draft, it should be longer than the final version. This is so that you have some extra writing to throw away. You want to have something to throw away after the first draft so that you only have to keep what is good.
  • Production (the first major step) and editing (the second) are different functions, and should be treated that way. This is because each interferes with the other. The purpose of production is to produce. The function of editing is to reduce and arrange.
  • There is almost nothing a novice writer can do that will improve his or her writing more rapidly than writing very short sentences.
  • Don't be tempted to use any word that you would be uncomfortable to use in spoken conversation.
  • Read each sentence aloud, and listen to how it sounds. If it's awkward, see if you can say it a different, better way. Listen to what you said, an then write it down. Rewrite each sentence. Once you have done this with all the sentences, read the old versions and the new versions, and replace the old with the new if the new is better.
  • If you force yourself to reconstruct your argument from memory, you will likely improve it. Generally, when you remember something, you simplify it, while retaining most of what is important. Thus, your memory can serve as a filter, removing what is useless and preserving and organizing what is vital.
  • You are not genuinely finished until you cannot edit so that your essay improves. Generally, you can tell if this has happened when you try to rewrite a sentence (or a paragraph) and you are not sure that the new version is an improvement over the original.

20170813

Teaching Critical Thinking: Lessons from Cognitive Science by Tim van Gelder

  • Almost everyone agrees that one of the main goals of education, at whatever level, is to help develop students' general thinking skills, including in particular their critical thinking skills. Almost everyone also agrees that students do not acquire these skills as much as they could and should.
  • Cognitive science is the best source we have for genuine knowledge about "what works and why" in teaching critical thinking.
  • Roughly speaking, critical thinking is thinking which helps you figure out whether you should believe some claim, and how strongly you should believe it. Since you should only believe what is true, critical thinking is, as I like to say, it is the art of being right.
  • The first and perhaps most important lesson is that critical thinking is hard. It can seem quite basic, but it is actually a complicated business, and most people are just not very good at it.
  • A majority of people cannot, even when prompted, reliably exhibit and the most basic skills of general reasoning and argumentation.
  • Humans are not naturally critical thinkers; indeed, like ballet, is is a highly contrived activity.
  • Evolution doesn't waste effort making things better than they need to be, and homosapians evolved to be just logical enough to survive while competitors such as Neanderthals and mastodons died out.
  • Michael Shermer describes us as "pattern-seeking, story-telling animals." We like things to make sense, and kinds of sense we grasp most easily are simple, familiar patterns or narratives.
  • Critical thinking is a complex activity built up out of other skills which are simpler and easier to acquire.
  • Critical thinking involves skillfully exercising various lower-level cognitive capacities in integrated wholes.
  • Because critical thinking is so difficult, it takes a long time to become any good at it. As a rule of thumb, my guess is that mastering critical thinking is about as difficult as becoming fluent in a second language.
  • Critical thinking may be hard, but it is certainly not impossible.
  • Ericsson found that achieving the highest levels of excellence in many different fields was strongly related to quantity of deliberate practice.
  • They have to actually engage in critical thinking itself, not just learn about it or observe others do it.
  • One of the biggest challenges in learning new skills, particularly general skills like critical thinking, is what is known as the problem of transfer. In a nutshell, the problem is that an insight or shill picked up in one situation isn't, or can't be, applied to another situation.
  • Transfer of acquired knowledge and skills certainly does occur to some extent; otherwise, education would be largely futile. The problem is that it tends to happen much less than you'd naively expect.
  • The problem of transfer affects critical thinking as much as any other skill. Indeed, critical thinking is especially vulnerable to the problem of transfer, since critical thinking is intrinsically general in nature.
  • Beyond a certain point, improvement demands getting some theory on board.
  • Knowledge of the theory allows you to perceive more of hat is going on.
  • The better you can "see" what is going on, the more effectively you can understand what you are doing and how you can do it better.
  • The mistake is to think that skills are a natural outcome of theory. They are not; skills are a natural outcome of practice.
  • At root, belief preservation is the tendency to make evidence subservient to belief, rather than the other way around; or, put another way, to use evidence to preserve our opinions.
  • When we strongly believe something (or strongly desire it to be true) then we tend to do the following things:
    • We seek out evidence which supports what we believe, and don't seek, avoid, or ignore evidence which goes against it.
    • We rate evidence as good or bad, depending on whether it supports or conflicts with our belief.
    • We stick with our beliefs even in the face of overwhelming contrary evidence, as long as we can find at least some support, no matter how slender.
  • The ideal critical thinker:
    • Puts extra effort into searching for and attending to evidence which contradicts what she currently believes.
    • When "weighing up" the arguments for and against, gives some "extra credit" for those arguments which go against her position.
    • Cultivates a willingness to change her mind when the evidence starts mounting against her.
  • As Richard Feynman said, "The first principle is that you must not fool yourself---and you are the easiest person to fool."
  • A core part of critical thinking is handling arguments.
  • An argument is a connected series of statements intended to establish a definite proposition.
  • If evidence forms complex hierarchical structures, then those structures can be diagrammed.
  • Argument maps are simply a more transparent and effective way to represent arguments, and so they make the core operations of critical thinking more straightforward, resulting in faster growth in critical thinking skills.
  • Motivation comes in two different kinds, knows as intrinsic and extrinsic. Intrinsic motivation is caring about an activity or achievement for its own sake.
  • Extrinsic motivation is caring about an activity or achievement only because it will get you something else, something extrinsic to the activity.

20170812

Metacognitive Education: Going Beyond Critical Thinking by Joe Y.F. Lau

  • Critical thinking necessarily involves a certain amount of "meta-cognition", or "thinking about thinking".
  • Critical thinking must involve some amount of meta-cognition, since a critical thinker ought to be able to reflect upon the reason for her beliefs, and take careful steps to ensure that her reasoning is correct.
  • One of the most basic reasons for teaching critical thinking is to help students improve their decisions about what to believe or what to do.
  • Meta-cognitive education can help students learn how to acquire new skills and expertise quickly and effectively.
  • Without creativity, critical thinking is impotent in changing the world. But creativity in turn requires critical thinking in testing and implementing ideas.
  • A key insight of the meta-cognitive approach is that being a good thinking is not simply a matter of knowing the principles of correct reasoning. It has to be supported by an appropriate system of knowledge, skills, and character traits.
  • Reflective thinking is the precursor to what we now call critical thinking, and it includes a fair amount of logic.
  • Higher-order monitoring is needed to correct and fine-tune our cognitive dispositions, and this is precisely a central function of meta-cognition.
  • Reasoning itself is a cognitive process.
  • We often over-estimate our abilities and underestimate our susceptibility to biases.
  • Accurate self-understanding is important for knowing our strengths and weaknesses, and for identifying areas of improvement.
  • Creativity is often thought to be a matter of innate talent or a product of mysterious inspiration, But many people fail to realize that creativity in a given domain depends a lot on extensive knowledge and the development of expertise over a long period of time.
  • Our meta-conceptions about learning can directly affect our actual learning and problem solving skills.
  • Students can improve their academic performance when they are taught that intellectual skills can be acquired and enhanced through effort and in overcoming challenges.
  • Exploiting the help of social networks and learning from the best people around us can boost our problem solving ability.
  • Conformity and group-think are examples of thinking traps that we should avoid.
  • It is worth nothing that cognitive biases can occur even when no logical fallacy is being committed.
  • Cognitive biases provide an important source of information about the architecture of the mind.
  • Accurate self-knowledge is essential in order to control and improve our thinking.
  • Self-regulation is surely crucial for critical thinking. A critical thinker understands the importance of clarity and truth, and takes careful steps to achieve those objectives. Deliberate effort is needed to analyze ideas systematically and to avoid rash judgments.
  • In many cases, daily practice for a whole decade is necessary to achieve world-class performance.
  • Grit presupposes self regulation, and is highly correlated with conscientiousness (but not IQ). Grit predicts educational attainment, undergraduate grade point average, retention in college, over and above IQ and conscientiousness.
  • In any case, meta-cognition ought to be given a more prominent place in the teaching of critical thinking itself.

20170811

Self-Reliance by Ralph Waldo Emerson

  • To believe your own thought, to believe that what is true for you in your private heart is true for all men,--that is genius.
  • A man is relieved and gay when he has put his heart into his work and done his best; but what he has said or done otherwise, shall give him no peace.
  • Society everywhere is in conspiracy against the manhood of every one of its members.
  • A man is to carry himself in the presence of all opposition, as if every thing were titular and ephemeral but he.
  • Do your work, and you shall reinforce yourself.
  • For nonconformity the world whips you with its displeasure.
  • A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines.
  • Speak what you think now in hard words, and tomorrow speak what tomorrow things in hard words again, though it contradict ever thing you said today.
  • To be great is to be misunderstood.
  • Prayer is the contemplation of the facts of life from the highest point of view.
  • Our minds travel when our bodies are forced to stay at home.
  • Insist on yourself, never imitate.
  • Every great man is a unique.
  • Society never advances. It recedes as fast on one side as it gains on the other.
  • For every thing that is given, something is taken.
  • Nothing can bring you peace but yourself. Nothing can bring you peace but triumph of principles.

20170804

How Computers Work by Roger Young

  • Computers are the most complex machines that have ever been created. Very few people really know how they work.
  • The ground wire is not shown because it is assumed that one connection of every light is always connected to the bottom of the battery by a ground wire in diagrams. Diagrams are simpler to draw than pictures that mean the same thing.
  • A key is a flat piece of springy steel that is bent up so that the key only touches the wire to the key's right when the key is pressed down by someone's finger.
  • An electromagnet is a coil of (plastic coated) wire. An electromagnet becomes magnetic when electricity goes through it.
  • A key and the electromagnet that controls it are, together, called a relay.
  • A computer is almost entirely made up of a lot of relays (today, transistors) connected by wires.
  • Today, transistors are used instead of relays for lower cost and greater speed.
  • Touching wires are connected wires.
  • Most relays in a computer are used to make loops, or connect the loops together.
  • A light bulb that is controlled by a loop is called a "pixel".
  • When the key is down and the light bulb is glowing, one says that the loop has value '1' and the pixel is 'on'.
  • When the key is up and the light bulb is not glowing, one says that the loop has value '0' and the pixel is 'off'.
  • A key is called 'closed' when electricity can flow through it from a wire on its left to a wire on its right. A key is called 'open' when electricity can't flow through it from a wire on the left to a wire on the right.
  • Any piece of wire that is powered is said to have value '1'. Any piece of wire that is not powered is said to have value '0'.
  • Writing to a latch will not clear any bits that were previously 1, so always clear a latch before copying (writing) data to it.
  • The next most important part of a computer, after memory, is the processor. A processor changes the values in memory as instructed by instructions stored in memory. An instruction is a group of bits (loop values) in memory that tell the processor to do something. A group of instructions that instruct the processor to do some task is called a program.
  • A transistor-based computer works in the same way as a relay-based computer.
  • A 16-bit computer has 16 bits in each 'word' and 65536 words of memory. This is because there are 65536 possible 16-bit addresses.
  • The data is the program. An instruction written with instructions that are just 1's and 0's is a machine language instruction. Machine language instructions are called 'machine code'.
  • A lookup table can be made to do any function with a limited number of possible inputs.
  • Modern computers use two types of transistors, which correspond to the two types of relays. An N-channel transistor corresponds to a normally open relay. A P-channel transistor corresponds to a normally closed relay.
  • It takes about twice a s many transistors as relays to do something. Of course, the high speed and low cost of transistors make transistors vastly superior in spite of the extra design effort required.
  • In modern designs, it is common for the ensuing instruction to be started before the prior instruction finishes, so a few instructions can be executed at once. This is called pieplining.

20170803

Programming Pearls by Jon Bentley

  • Careful analysis of a small problem can sometimes yield tremendous practical benefits.
  • Determining what the user really wants to do is an essential part of programming.
  • Don't write a big program when a little one will do.
  • Be familiar with advanced data structures. Advanced data structures aren't appropriate very often, but when you need them, they're indispensable.
  • Let the data structure the program. The theme of this column is that data can structure a program by replacing complicated code by a data structure.
  • The relations among input, program variables, and output describe the "state" of a program; assertions allow a programmer to enunciate those relations precisely.
  • To verify a subroutine, we first state its purpose by two assertions. Its precondition is the state that must be true before it is called, and its post-condition is what the routine will guarantee on termination.
  • The output of any calculation is only as goo d as its input.
  • Everything should be made as simple as possible, but no simpler.
  • The most important principle about code tuning is that it should be done rarely.
  • When efficiency is important, the first step is to profile the system to find out where it spends its time.
  • Simplicity can yield functionality, robustness, speed and space.
  • The space required to store a given object can be dramatically reduced if we don't store it but rather recompute it whenever it is needed.
  • Replacing a data structure can drastically reduce the space required to store given information.
  • How should you sort a sequence of records into order? The answer is usually straightforward: use a sort command provided by the system.
  • One part of a programmer's job is solving today's problem. Another, and perhaps more important, part of the job is to prepare for solving tomorrow's problems. Sometimes that preparation involve taking classes or studying books like Knuth's. More often, though, we programmers learn by the simple mental exercise of asking how we might have solved a problem differently.
  • Good engineers distinguish between what a component does (the abstraction seen by the user) and how it does it (the implementation inside the black box).
  • Before you build a fancy program, let potential users experiment with a simple prototype on many real inputs.
  • A well-built system is divided into independent components, each of which does one thing well.
  • The best design is usually the simplest.