Enter your Email Address:

Delivered by FeedBurner

To get posts delivered to your Email

05 March 2017

Programming Language Pragmatics [Chapter 1, Section 1.5] Check Your Understanding

This post has my answers for "Check Your Understanding" questions in section 1.5, Chapter 1 of the book Programming Language Pragmatics by Michael L. Scott.

Chapter 1, Section 1.5 - Check Your Understanding

Question # 11. Explain the distinction between interpretation and compilation. What are the comparative advantages and disadvantages of the two approaches?
Compiler produces machine code from high-level language. After the compilation, the machine code can be directly run on the target system which is locus during runtime. The machine code produced on one architecture cannot be run on a machine with different architecture. The compiled program is faster than its interpreter counterpart.

The interpreter is usually the locus when the program is running. The program written in high-level language is directly run on the target machine through interpreter. In a sense, the high-level code is machine instruction for interpreter. Most of the interpreter are slower in execution as most of the decisions during the course of the program are deferred until the control reaches to the particular statement. However the debugging is much more easier to do in interpreter as interpreter has control throughout the execution of the program. Moreover the interpreter can do useful features like on-the-fly compilation so that the program can generate code during execution which is again consumed/executed by interpreter.

Question #12. Is Java compiled or interpreted (or both)? How do you know?
Java is both compiled and interpreted. Java compiler transforms Java source code to bytecode. Java Virtual Machine (interpreter) executes bytecode.

Question #13. What is the difference between a compiler and a pre-processor?
Pre-processor is needed step before compilation. Compilation transforms the code substantially but pro-processing is usually is light-weight such as removing comments, replacing macros etc.

Question #14. What was the intermediate form employed by the original AT&T C++ compiler?
The intermediate form produced by AT & T C++ compiler is "C".

Questions #15. What is P-code?
P-code is intermediate code that are produced by Pascal compiler. P-code is run by Pascal interpreter during runtime.

Question #16. What is bootstrapping?
Typically the programming language compiler is written by itself meaning that a C compiler is usually written using C. However at first there will not be any compiler to compile the code written in C. Usually a tiny interpreter is written in a different language to produce machine instruction (tiny compiler). Later the tiny compiler produced by interpreter is used to compile the compiler. This is called bootstrapping. In similar fashion more features are added incrementally to produce high quality compiler.

Question #17. What is a just-in-time compiler?
Just-in-time compiler is a feature of interpretor that converts byte-codes to machine instruction while the program is under execution. This is done mainly to increase performance (speed of execution)

Question #18. Name two languages in which a program can write new pieces of itself "on the fly"
List and Prolog (Python, Perl, TCL also have similar features)

Question #19. Briefly describe three "unconventional" compilers - compilers whose purpose is not to prepare a high-level program for execution on a microprocessor
  1. SQL - Translates statements to operations on database
  2. Compilers to translate logic-level circuit specification into photographic masks for computer chips
  3. TEX that translates document to commands for printers

Question #20. List six kinds of tools that commonly support the work of a compiler within a larger programming environment
  1. Debuggers
  2. Editors
  3. Pretty-Printers
  4. Style Checkers
  5. Configuration Management
  6. Profilers
Question #21. Explain how IDEs differs from a collection of command-line tools
All the tools are integrated in an environment often collaborates amongst themselves where as the command line tools are used merely in isolation. For example when a program crashes, IDE points which line of the code is causing the issue and pops up the code in the editor. The developer can make the change and save the file. IDE automatically builds it.

26 February 2017

Programming Language Pragmatics [Chapter 1, Section 1.3] Check Your Understanding

This post has my answers for "Check Your Understanding" questions in section 1.3, Chapter 1 of the book Programming Language Pragmatics by Michael L. Scott.

Chapter 1, Section 1.3 - Check Your Understanding

Question #1: What is the difference between machine language and assembly language?
Machine language is written using the instructions set of the processor directly. Each operation supported by the processor is given a code using which the operation is carried out. The code written in Machine language will be in hexadecimal. But in the case of assembly language the program is written using mnemonic (often represented as operations such as MOV, STORE, ADD, SUB etc) which later translated to machine instructions by software called assembler. The assembly language also has provisions for macro definition which expanded by assembler before producing machine code.

Question #2: In what way(s) are high level languages an improvement on assembly language? In what circumstances does it still make sense to program in assembler?
While assembly language is faster to execute, high-level languages can be easily learnt by programmers, ported to varied architecture without requiring to rewrite entire logic on many architectures and saves programmers time since high-level languages are not one-to-one mapping of machine instructions. High level languages often use functions (in the context of mathematical functions) to produce highly expressive code. However assembler will be default choice for system specific performance reasons.

Question #3: Why are there so many programming languages?
There are several programming languages because of the following reasons - evolution, special purpose, personal choice, 

Question #4: What makes a programming language successful?
The programming languages are successful because of one or several of the following reasons - expressive power, Ease of use, ease of implementation, standardization, open source, excellent compilers, economic, patroage and internia.

Question #5: Name three languages in each of the following categories: von Neumann, functional, object-oriented. Name two logic languages. Name two widely used concurrent languages
von Neumann - C, Ada, Fortran
Functional: Haskell, ML, Scheme
Object-oriented: Java, C++, Smalltalk
Logic Languages: Prolog, spreadsheets
Concurrent Languages: C++, Java 

Question #6: What distinguishes declarative languages from imperative languages?
Imperative languages solves a problem by sequence of steps with each steps produces some side effects. The imperative language focuses on how a problem should be solved rather than what to do. The declarative languages on the other hand focuses on what needs to done.

Question #7: What organizations spearheaded the development of Ada?
US Department of Defence

Question #8: What is generally considered the first high-level programming language?

Question #9: What was the first functional language?
Lisp, Scheme?

Question #10: Why aren't concurrent languages listed as category in Figure 1.1?
Concurrency support is available in many of languages such as Java, C++ and C. Several concurrency packages are available as language extensions

25 February 2017

Abstraction - Events IN, Solutions OUT

Abstraction is a great tool for mankind. The history of human evolution has seen uncountable number of evidences on the usefulness of abstraction. Abstraction is to absorb important attributes and leaving out unimportant attributes. Very state that we are in is the fruit of our ability to abstract - Ideas.

Image result for abstraction problem solving
Ideas - what are ideas. Ideas are fruits of abstraction of events happening around us or impulse of information that happens elsewhere (which again an event to us). In problem solving domain, ideas are output of abstraction (elevated thinking) and inference (desirable response from higher plane of thinking). 

While most of us think creativity is for people who are brainy. But the truth is that the creativity is fruit of hard work, systematic way of abstracting the problem and connecting those events with our experience. Like anything, it is only the practice that makes it smart work. The first step towards solving problems is to understand a problem or rather find/recognize a problem, understanding it at higher plane and giving way for ideas to emerge. 

Abstraction is what it took us where we are and it is the only thing that is going to take us where we ought to go.

PS 1: This is hangover of reading programming languages pragmatics which i think is a wonderful book. I will be reading for next several months (so surely there are going to be numerous posts on that)

PS 2: I am posting after an year. I have to admit that i ran out of ideas and since i am reading a book i think i will get a lot more ideas

07 January 2016

Fallacy and Bias

Most of the times we think we are "sound" and better than others. We keep carrying this in our head - "if you take average score of intelligence, i am above average than most of the people". We fail to understand that all of us feel the same way. 

When you think you are better than your neighbor, your neighbor thinks he is better than you. If this is true, the average will be lower than individual scores. This clearly shows that we have fallacies and biases. The things we think are NOT what we think. Our concept of being neutral or unbiased is more biased towards us. This is a paradox. Ex: We often think that we are modest and in fact we "say" so - "i am modest".

Feel happy - everyone is wired that way. 

Our brain works and everyone's brain is wired for biases and fallacies. Our excellence lies in knowing these biases (making us counter productive) and putting checkpoints to bring some sense - an order from chaos. Only when we understand our biases and put some checkpoints, we will be making some sense.

31 December 2015

Be your own case study

Reading books gives knowledge. But mere knowledge does not guarantee behaviors. All behaviors do not yield experience. All experiences do not give wisdom.

But it all starts with being theoretical (reading books). Read books and "do" something with the learning. Be your own case study - conduct experiments and create positive feedback.

After definite amount of work, there comes a masterpiece - hidden gem inside you that gets polished with every effort you make.

My "rational" tells to my "emotional" self when i am not yet there.

30 December 2015

Switch (Part 6) - How to keep the Switch going?

This is sixth and final part of my reflections on the book - Switch. This is going to be a short post. Before reading this post, read other posts.

Once the change process has kicked in and you got the Elephants moving, the next thing to do is to convert the momentum to forward momentum. A long journey starts with a step but a step does not guarantee the long journey towards the destination. We need to constantly reinforce - "point and move towards the destination", "get the elephant moving towards the destination" and remove impediments by "shaping the path". We need to follow the pattern of Switch.

A good thing about a change is that once you moved it an inch from stationary, the change feeds itself. Once you start, the change favors you. The mere exposure effect and cognitive dissonance play their part to continue to push through the change (snow balling effect). The only thing that you need to ensure is to follow the pattern again and again - "direct the rider, motivate the elephant and shape the path".

The learning from the book is immense and i think the insights are so engrained that i would follow Switch framework in my life - personal and profession. I would like to thank Heath brothers was writing such a wonderful book that is quite engaging. Hope to read the other books.

Want to read all the posts on Switch. Click here

Disclaimer: I neither get commission for a writing review nor using Affiliation of any Bookstore. The whole purpose of these posts is to provide value to my readers and give them information to be better.

29 December 2015

Switch - Video Review

Check this out - the review gives an overview of the book - Switch. This video provides quick overview of the book. I am sharing it here since i find it interesting and useful. This is published by Callibrain

Want to read all the posts on Switch. Click here

Disclaimer: I neither get commission for a writing review nor using Affiliation of any Bookstore. The whole purpose of these posts is to provide value to my readers and give them information to be better.

28 December 2015

Switch (Part 5) - Shape The Path

This is the fifth reflection post on Switch by Heath Brothers. If you are the first time reading the posts  on the book - Switch, it might help to skim through other posts thisthisthis and this.

Tweak the Environment - This is based on the premise that "What assumed to be a people problem is often situation problem". You see someone cutting across you at high speed and you curse him. You think that he is mad and yell at him. Do you think he is usually like that? We often see issues as people issues rather than situation issue. This is called as "Fundamental Attribution Error". The author discussed how to reward right behavior, making the environment easier for right behavior and making the environment little harder for bad behavior. The section provided ample case studies - Saints and Jerks Food Donation Campaign, Medication vests to keep nurses focused to reduce errors, Rackspace Fanatical Support. Haddon Matrix needs special mention on how the environment can be tweaked better (pre-event, event and post-event)

Build Habits - Habits are behavioral auto-pilots. Unless the behaviors are formed as habit, it is going to tax Rider and often needs Rider's supervision. Habits are environmental and mental. People are sensitive to environment and culture, we often try to fit to peer groups as behaviors are contagious. The second way of making habits is to have "action triggers". So it is very important to tweak the environment so that "expected" behaviors are formed as habits.

Rally the Herd - When you lead Elephant on an unfamiliar path, chances are it is going to follow the herd. Now, you need to create herd the way it is easier for change to happen. Make influencers and create free spaces so that the people flock together so that they build new identity.

The first part of the book covers three surprises about change, the second part covers how to "direct the rider", the third part covers how to "motivate the elephant" and the final part covers the role of the path and how to shape the path. This part "Shape the Path" discussed three important elements related to environment that are absolutely stunning and insightful. I often feel that each section gives an increased impact with respect to understanding the change, people's behavior and response to change and how it can be tweaked to yield better results. This section is no different.

Want to read all the posts on Switch. Click here

Disclaimer: I neither get commission for a writing review nor using Affiliation of any Bookstore. The whole purpose of these posts is to provide value to my readers and give them information to be better.

27 December 2015

New Year Resolution - Does it make sense?

Retrospection, questions and answers
  1. Have you ever taken a resolution on new year eve? 
    • Mostly yes. I often take every year since i became professional. Sometimes i share it with others and sometimes i do not share with others reason being "fearing failure". It looks like the goals should not to be made public.
  2. Have you ever successfully able to keep up the commitment to yourself? 
    • Yes for initial days/weeks and then it fades away. After few months, i hardly remember the resolution unless someone remind me
  3. What is the motivation behind your resolution?
    • I want to lead a better life. I think everyone has every right to be better and be happier. When i take resolution, it always give me a fresh thought and a fresh start. I feel that i can erase all the past and give my life a fresh start. I understand that it need not be a new year. But then it is a nice way to start a year so that we can review it mid way through the year.
  4. How does it feel when you have given up resolution?
    • It feels very hard. Though i smile, i really takes a toll on my self-confidence. I feel like i am an excellent starter & planner but a poor finisher.
  5. What do you think is root cause of failing in resolution?
    • There is no single answer. It is lack of experience, lack of ability to split the goals into minor critical accomplishments, lack of prioritization, lack of ability to connect emotional with the goal (Elephant), lack of understanding of tiny improvements & small wins, lack of commitment.
  6. Is it still relevant?
    • Yes, i do think that i am going to have very few resolutions.
  7. How do you think that you will be different this year?
    1. I need to think a lot. 
    2. I should marry my long term goals to shorter term wins (Rider, Elephant). I should focus on one month at a time than a year (a lot of things can happen in a year but shorter periods are almost certain)
    3. Focus should be on Health, Happiness and Skill building than making money.
    4. Approach this more psychologically by forming habits rather than seeing this as end points. (For example losing 30 pounds should directly related to walking. Unless i form walking as a habit, i cannot lose 30 pounds.)
    5. Whatever it is, i should share my progress with others.

26 December 2015

Switch (Part 4) - Motivate The Elephant

This is fourth part of my review/learning while reading the book Switch and it forms a critical step for the change process. This post covers - Motivate the Elephant.

Before reading this post, please read previous posts - this, this and this.

If you drive any vehicle, have you ever wondered why it takes more energy to move the vehicle in first gear. Read this in Quora. The simple answer is - "more" energy is needed to overcome inertia. It applies to Change too. When you are about to Switch, the folks who need to undergo a change and responsible for the change have to beat their initial inertia. It needs a lot of motivation to embrace the change as the people are quite comfortable in status quo.

In previous posts, we saw that Elephant is powerhouse and actually works on getting things done. It gives energy to the change process. Without Elephant's energy (and motivation), the change process is very likely to be a failure. In this section, Heaths discusses three important methods of getting started with change and keep it going - Find the FeelingShrink the Change and Grow the people.

Find the Feeling - The section on "Find the Feeling" discusses the importance of appealing to Elephant and help Elephant make the first step. It is very difficult to make Elephant move with analytical acumen. We have to appeal to Elephant emotionally by SEE-FEEL-CHANGE. The case study of HopeLab is amazing and it conveys how appealing Elephant changes one's life. It also discussed the effects of "Positive Illusion" with a case study. It is very important to find the feeling - feeling of control and power, determination to fix the issues or undergo the change and being empathetic. For any change that is big, we need to get to the Elephant with positive psychology, fresh thinking, creativity and instill hope and optimism.

Shrink The Change - Why is it important to shrink the change? Because the Elephant feels that it is easier to "do" which is very important to beat the inertia. Not only does it help to beat inertia, it constantly helps Elephant to march towards the destination (remember sequence of bright spots?). The case studies on Hotel Maids and Free Car Wash are excellent examples for a head start and keeping the ball rolling. Two strategies are discussed here - Limit the investment (amount of time required to complete the tiny change) and Small wins (ensure that small wins are meaningful and within immediate reach).

Grow The People - One way to make Elephant to make feel big is to shrink the change. Another way is to actually grow the Elephant big (bigger than the size of change). In both cases, the Elephant feels that it is easier to get it done. The section gives out two models of decision making - consequences model and identity model and discusses why the identity model is so important during a change process. It also discusses building identities leading to people learning new things and why it is important to set expectations of failure when people learning (During the learning process people tend to fail. Every failure will demotivate Elephant and hence set expectation on failure during learning process). It discusses on two mindsets - fixed mindset and growth mindset (pain now, payoff later). The case study of minimally invasive cardiac surgery is simple awesome.

Like previous sections, the section is also to the point and centered on critical case studies with some serious takeaway. After reading this chapter, you would certainly feel that you can catalyst a change (the chapter kindles your Elephant)

Want to read all the posts on Switch. Click here

Disclaimer: I neither get commission for a writing review nor using Affiliation of any Bookstore. The whole purpose of these posts is to provide value to my readers and give them information to be better.