Programming and writing about it.

echo $RANDOM

Category: Books

Land of Lisp

I came to know of this fun looking Lisp book on Slashdot book reviews. Its called Land of Lisp: Learn to Program in Lisp, One Game at a Time!

Here is fun video introducing the book: http://www.youtube.com/watch?v=HM1Zb3xmvMc

Book Review: A Byte of Vim

A Byte of Vim is a freely available, immensely useful and well written book on Vim which has made me more confident of using only the keyboard with Vi(m). I am not getting into a detailed review of the book, rather I will simply refer to the best (IMO) portions of the book.

The Introduction begins in a way, a thrilling flick would, by showing you the best of the ammo that you can get to watch during the rest of the movie.

The next few chapters talk about installation of Vim, the Vim modes and basic moving around tips.

Editing basics and More Editing talk heavily about yanking and more in Vim.

Multiplicity talks about tabs and a lot more in Vim. Reading this chapter will help you in working with multiple files in a single Vim instance.

Scripting and Plugins shows you how you could increase your productivity with Vim.

How can you set up your programming environment with Vim ? Programmer”s Editor helps you in that quest. Vim as an IDE?

More points some great resources to Vim scripts and resources.

This book definitely has increased by knowledge and confidence about Vim. It’s well worth your bookshelf (in your room or your computer)

Advertisement

Book Review: The Theory of Everything: The Origin and Fate of the Universe

I finished reading The Theory of Everything: The Origin and Fate of the Universe by Stephen Hawking, which is one of the newest additions to my library.

It is a collection of essays by Stephen Hawking as he shares his views on the origin of the universe with the reader. Rightly composed as a collection of essays, there possibly cannot be a unified treatment of the various theories that exist or existed or will exist on the subject. The essays talk about Black Holes, Bing Bang model, the theories that about of the current state and fate of the universe.

I particularly liked the essay on the arrows of time (Wikipedia article) . Starting from the earliest theories of about the Universe, this book proved to be a good refresher of the earliest science classes I took back in my pre-university classes.

I must confess that I did not get the hang of many a thing of what he has written about, but then I am no science geek.

Book Review: Practical Common Lisp

Practical Common Lisp is a freely available book on Common Lisp which gives the impression that it can be appealing to the ignorant but enthusiastic newbie to Lisp. Lisp and other languages of this niche category are often thought to be of any use, only in academic circles. This book attempts to dispel that myth by having a ToC which mixes theory and practical applications, both.

I have a working knowledge in C/C++, Python and Java and am knowledgeable of the Functional Programming paradigm. However, I have zero experience with any dialect of lisp.

In this post I shall try to put down my own reviews. chapter wise, as I read and work them.

Chapter 1: Introduction: Why Lisp?

From the book chapter: “If you think the greatest pleasure in programming comes from getting a lot done with code that simply and clearly expresses your intention, then programming in Common Lisp is likely to be about the most fun you can have with a computer. You’ll get more done, faster, using it than you would using pretty much any other language.”

This chapter puts the whole book into perspective and answers the first question that comes to the reader’s mind. A bit of history about Lisp is discussed, along with the author’s personal experiences with Lisp about getting the job done in much fewer lines of code.

Personally, I love picking up a new language from time to time. Lisp has been beckoning me for some time now. Hence, I picked up the book at the first instance.

A good first chapter. Me, the newbie likes it.

Chapter 2: Lather, Rinse, Repeat: A Tour of the REPL

The first taste of Lisp programming is felt in this chapter.

Lisp in a Box packages a Common Lisp implementation- Allegro with the Emacs editor and
SLIME– Superior Lisp Interaction Mode for Emacs. Once you extract the
tarball downloaded, you will find that there is Allegro CL
implementation, Slime and Emacs binaries.

On executing the ‘lispbox.sh’ script, you will finally get Lisp prompt:CL-USER>

You
can also modify the ‘lispbox.sh’ script to use your existing Emacs
binaries, instead of the one bundled. Modify the last line, starting
with exec emacs to point to your own Emacs installation. For eg.

exec /usr/bin/emacs --no-init-file --no-site-file --eval='(progn (load "lispbox") (slime))'<br />

The List processing is well introduced with examples such as (+ 2 3), (format t "hello world") . The concept of the return values and side-effects of functions is well demonstrated.

The rest of the chapter takes the reader in a REPL loop, moving from a “Hello, World” value Lisp code to a “Hello, World” program to the concepts of functions in Lisp. The reader also learns to save his Lisp programs and load use them in later sessions. The Lisp debugger is also mentioned.

Readers
new to Emacs are made familiar some rudimentary Emacs commands to move
around, save files, compile and re-compile Lisp sources.

Along with being a introductory chapter on Lisp programming, the reader almost has a feeling that he is learning Emacs as well, which is double whammy :-)

UPDATE: More than being a double whammy, I think its more of a hindrance to try and learn Emacs along with Lisp, even though the two do go hand-in-hand. You are better off just using the Allegro CL Environment for the code editing and execution.

All set for the next chapter.

Chapter 3: Practical: A Simple Database

This chapter is the book’s first Practical chapter in which you write some CL code to design a useful working application for you. Here, the reader code a MP3 database for a personal music collection.

This is the first post Hello World program and language features such as the fundamental list, Lisp operators- functions, macros, Property lists– simplified, but useful stripped down hash table-like data structure, Simple interactions with the user, loading and saving files on disk.

Lambdas, or anonymous functions are introduced and used widely in the code.

I come from a background in C/C++, Python, Java where one of the things I essentially do is call a function and use its return values in variables or placeholders. What I learnt in this chapter, is to design a program around functions and lambdas (anonymous functions). Yes, Python has lambdas, but I haven’t learnt to design my program around it, till now.

Another concept that I really found new is the concept of macros in Lisp:

“Common Lisp macro shares
essentially nothing but the name with the text-based macros found in
C and C++. Where the C pre-processor operates by textual substitution
and understands almost nothing of the structure of C and C++, a Lisp
macro is essentially a code generator that gets run for you
automatically by the compiler. When
a Lisp expression contains a call to a macro, instead of evaluating
the arguments and passing them to the function, the Lisp compiler
passes the arguments, unevaluated, to the macro code, which returns a
new Lisp expression that is then evaluated in place of the original
macro call.”

Pure enlightenment.

Somwhere in my mind, now I have started thinking about a program as independent blocks of symbols and operators with the order of evaluation being determined by the parenthesis. I think I will be able to write this in a more sensible way as I learn more of this.

As a side note, I would highly recommend you to read this article: The Nature of Lisp

Chapter 4: Syntax and Symantics

This chapter helps you to sink in all that has been introduced in the previous chapter. It introduces the basic paradigms and concepts behind a Lisp program with just the right amount of detail.

The burning question: What’s with All the Parentheses? is addressed in this chapter. Why does such a syntax make sense? This is explained by talking about how the execution of a Lisp program differs from the stages of execution of a program coded in other languages in Breaking Open the Black Box.

S-expressions and symbols– functions, macros and special symbols are all explained in detail. The usage of macros in the previous chapter is explained in greater detail here.

The reader also gets to know about how all (almost) Lisp operations are evaluated as functions and all expressions are Lists in Lisp. Thus, appreciating all the parenthesis that surrounds the code.

The chapter concludes by looking at Truth, Falsehood, and Equality in Lisp.

Chapter 5: Functions

Functions, which is one of the three basic components of Lisp programs (others being, macros and variables) are given detailed treatment in this chapter. After using them in chapters 2 and 3, this chapter looks at the various components of a function in great detail.

Different kinds of parameters that a function can take is discussed here.

Returning from functions, Higher Order functions, Lambdas (Anonymous functions) are the other things discussed.

Chapter 6: Variables

This chapter takes a look at another basic building block of Common Lisp- variables.
Lexical and Dynamic variables and their features are discussed in detail. Closures are discussed for the first time in this chapter.

Basic operations on variables are demonstrated.

Chapter 7 and 8: Macros: Standard Control Constructs, Defining your own

In these two chapters, the author writes about Macros in Common Lisp. In chapter 7, the author looks at the standard control construct macros defined by Common Lisp. This chapter helps the reader to understand a lot about how macros are used, almost everywhere in the language itself in Common Lisp.

The next chapter builds upon the former to help the reader to write a trivial, but useful macro on his own, introducing concepts along the way to write code that writes code.


Chapter 9: Practical: Building a Unit Testing Framework

In the second Practical
chapter, the author helps the reader code a simple Unit Testing
Framework, mostly making use of some of the concepts introduced in the
last couple of chapters on Macros.

Chapter 10: Numbers, Characters and Strings

As the name of the chapter suggests, this will be one of those reference chapters you will coming back to, as you use more of numbers, characters and strings in the Common Lisp language.

From here onwards, you will notice that, reviews for later chapters appear earlier and vice versa.

This indicates a couple of things:

  1. That I am reading the chapters, which I find interesting first and then coming back to some earlier chapter which might have been referred to in there
  2. More importantly: Most of the basics have been covered till Chapter 10


Chapter 21: Programming in the Large:Packages and Symbols

As is apparent, this chapter is a first step in the world of writing and using medium to large scale Common Lisp codes. As you start coding you may want to help the world by creating and distributing your own packages or use a lot of third party packages which provide Common Lisp features which may not be available in a standard implementation. This chapter takes on a tour of packages and a detailed look into how the REPL resolves symbols.

A must read before moving on to the later chapters.

Chapter 14 and 15:

Files and File I/O and the next Practical chapter, as their names suggest looks at working with files- text and binary using Common Lisp.

These chapters introduce important concepts such as Pathnames which help abstract Operating System level differences in the way files are referred to. The practical chapter builds upon Pathnames to code up a truly portable pathname library using *FEATURES* to work across several Common Lisp implementations. This pathname package will be used in later chapters to code up other practically useful tools.

Post last updated on March 10, 2009

Book Chapter Review: (Python) Package Management

Chapter 9 of the book Python for Unix and Linux System Administration, 1st Edition discusses package management in the Python programming language.

When you read the chapter, you get a feeling that you are reading about package management on your favorite Linux distro, which IMO is a good thing. I, personally love to co-relate the new things I learn with things I already know.

It starts off with Python’s own apt-get (or zypper or yum): easy_install. Then it moves on to Python eggs, and how simple it is to create them.

You have written a Python package and you want to upload it to the Python package index. The book shows you how.

The chapter also looks at Buildout, and virtualenv (which helps set up more than one ‘virtual’ Python environments on your system, like chroot does)

Update: The book also talks about ESP Package Manager (EPM)

Google Web Toolkit GWT Java AJAX Programming

I received a review copy of this book

Google Web Toolkit GWT Java AJAX Programming from Packt Publishing a couple of days back

Read the full Table of Contents for GWT Java AJAX Programming

Stay tuned for the review!

Tapestry 5, Building Web Applications- Review

This review was published on request of Packt Publishing who provided me with a review copy. I am not affiliated to them in any way.

Tapestry 5 Building Web Applications is an introduction to Java Web Application development using the Apache Tapestry Framework.

The book assumes development experience using Java, with no or little prior exposure to Java Web development. For readers who are well versed with other Java Web Frameworks, this book will serve as a nice, gentle introduction to Tapestry.

The entire text of the book is covered in 8 different chapters with a natural flow between the chapters, and will be best benefited by reading from the beginning. This gives a “text-book”, rather than a reference flavor to the book.

The author takes a hands-on approach to present the concepts. New concepts are well explained by code examples. Readers are advised to hand code the examples in the book, rather than download the code examples.

Besides Tapestry, software tools you will come across in this book are “db4o”, “Maven”, “NetBeans IDE” and “Eclipse IDE”.

In the next sections, chapter wise summary of the book follows.

Chapter 1: Introduction to Tapestry

This chapter begins with an introduction to the need for web frameworks, following it up with a gentle introduction to the Tapestry web framework. It briefly touches on the features of Tapestry 5, most of which are dealth with in later chapters.

For developers who have used earlier versions of Tapestry, the journey from Tapestry 3 to 5 is also discussed.

Chapter 2: Creating Your Working Environment

As the chapter title suggests, here the author shows how you can set up your working environment to begin Tapestry development on Linux, MS Windows or Max OSX. Though explicit instructions for Linux are not given, the Mac OSX instructions can be easily followed there.

The approach followed in this book is to first create a default Tapestry application using Maven, and then either use NetBeans IDE or Eclipse IDE to carry on the compilation, build and deployment of the application.

A technical discrepancy was discovered in this chapter. According to the author, any changes in the template file (‘start.tml’) would not be reflected if the accompanying class file (‘start.java’) is not changed. This is not found to be true when the steps were reproduced on NetBeans IDE 6.0 or Eclipse 3.0 (‘Europa’).

The major steps are correctly mentioned in a clinical manner. However, the reader who is not experienced with Maven might feel that some necessary details have been given the miss. Some desirable additions to this chapter would be brief descriptions of:

  1. How Maven creates the whole Tapestry project structure?
  2. What are files that it downloads and why?
  3. References to more information about Maven

Chapter 3: The Foundations of Tapestry

As a natural follow-up to the previous chapter, the basics of Tapestry Development is introduced here. Concepts such as Plain Old Java Object(POJO), Components, Event Handling, Pooling of Tapestry pages, Application State Object (ASO) are introduced to the reader in an easy fashion.

After reading this chapter, the reader can start building simple multi-purpose Tapestry Web Applications.

Chapter 4: Simple Components

This chapter introduces simple Tapestry components such as TextField, Password Field, PageLink, Loop and Select. Instead of giving a demo working of each component, the author adopts a practical approach by showing how each component fits in with the others in a near real-life Web Application- ‘Celebrity Collector Project’. This project is enhanced in each chapter by integrating the new concepts introduced there.

This chapter also introduces an important concept- that of “Message Catalogs”.

Chapter 5: Advanced Components

More useful components such as ‘Grid’, ‘BeanEditForm’, ‘DateField’, ‘FCKEditorComponent’ are introduced here. This chapter also demonstrates the usage of JavaScript components such as ‘DateField’ without writing a single line of JavaScript.

Chapter 6: User Input Validation

The reader is introduced to input validation concepts in this chapter. Providing custom error messages is another concept discussed here.

Chapter 7: Internationalization and Localization

The topic of Internationalization and Localization is touched in this chapter.

At the end of this chapter, the reader will have a pretty “Celebrity Collector” Web Application with Internationalization support.

Chapter 8: Creating Custom Components

After having introduced simple and advanced Tapestry components, the author demonstrates to the reader the creation of custom components. Custom Components are useful in cases, such as when the developer needs to duplicate a single functionality on all or multiple pages of a Web Application.

Appendices

The book is accompanied by two appendices- one “The Basics of Java for the Web”- describes the general concepts of Java Web Application. Readers new to Java Web Application development are advised to consult this appendix to learn some basic Java Web Application concepts.

The second appendix, “Creating a Real Data Source with db4o”, introduces the object databased named “db4o” which will give a nice insight into enhancing the mock Web Application by doing away with the Java class way of storing and retrieving data.

End-Notes

I took my first step in the Apache Tapestry using this book, and I must admit that I now know much about it after reading the book. This is an important observation, since this means that the book has successfully introduced Java to its target audience.

No work can of course be perfect. Here are some suggestions to improve the book:

  1. The chapter wise source code downloaded from the book’s website was often found inconsistent with that written in the text and some amount of tweaking was required to get the correct functioning.
  2. The source code would be best distributed as NetBeans and Eclipse projects, to enable auto-inclusion of the libraries and enable to reader to directly start working on the projects.
  3. An appendix each for working with Maven, Eclipse and NetBeans will make the novice readers more comfortable working with these tools.

If Apache Tapestry interests you, and you know nothing about it, add this book to your book repository.

Build your web applications with Tapestry 5

Packt Publishing, the publishers of computer related books have released their latest book on Tapestry 5, the Apache open-source framework for creating dynamic, robust, highly scalable web applications in Java. The new book titled, Tapestry 5: Building Web Applications is a step-by-step guide to Java Web development with the developer-friendly Apache Tapestry framework.

The book based on the latest version of Tapestry Web development framework and helps you get working with Tapestry components. It builds up an example website through each the book.

The book assumes that the reader is reasonably comfortable with the Java programming language, but no knowledge of web technologies is needed. For experienced Servlet, JSP, or Struts developers, the book will show an alternative way that will allow them to raise their productivity to an incomparable level. With this book you will see that a contemporary component-based framework can be easy to learn and a pleasure to work with.

More information about the book can be found at: http://www.packtpub.com/tapestry-5/book