If you are learning about computer programming, you should hear about the book, Structure and Interpretation of Computer Programs by Harold Abelson, et al (1996). This book (SICP) has made a positive impression on some people. Here is a Wikipedia article on the book. The point of this book is to influence the thinking process, to stretch the mind. But it is not going to teach you how to write useful code. It uses a form of Lisp, called Scheme, which is available for free download from MIT. I can report that the Windows installer works and the Scheme interpreter launches successfully on Windows 7. If you want to work through this book, there is free support material available at this website: http://www.mitpress.mit.edu/sicp/.
Eventually, the Structure and Interpretation of Computer Programs was replaced by How to Design Programs (HtDP) by Matthias Felleisen, et al (2001). This book continues the MIT tradition of using the Scheme language. Here is a Wikipedia article on this book. Again, the emphasis is on stretching the mind rather than teaching a useful programming language. Theoretically, the student is taught by this book to design software. This is a very important point.
Not every programmer can design software. There are programmers, paid to write code for a living, who are incapable of designing software. Here is one definition of a software hack: software that is not designed. There is a synonym for a software hack: a kludge. To be fair, some people can hack-out decent code. Also, some programmers can carry a complex design in their heads so that they do not feel the need to document the design.
Returning to the topic of teaching computer science at MIT, I found evidence that MIT does have a programming course for students that have no experience writing software. This particular class uses the Python programming language. However, I find it hard to believe that a student majoring in computer science at MIT would be taking this particular course. I have seen no evidence in the internet of MIT continuing to use How to Design Programs, but I have discovered that the authors have a 2nd edition in progress (2012): http://www.ccs.neu.edu/home/matthias/HtDP2e/
How to Design Programs by Matthias Felleisen is a current book that is worthy of your consideration if you want to be a good programmer. But you need to learn languages for producing software products (Java, e.g.) from another source. Scheme and Lisp are not production languages, i.e., languages used to create significant products.
In closing, The Structure and Interpretation of Computer Programs (2nd Ed.), might be out of print, but it has left a lasting influence. It is an engaging book to read. You can also purchase the Instructor's Manual if you are going through the book on your own.
Robert
Here is a blog post by a high school student that briefly mentions SICP. People are still studying this book.
Sunday, November 4, 2012
Monday, October 22, 2012
Logic for Programming and Comments on C Programming
On two occasions I have handed a copy of The C Programming Language by Kernighan and Ritchie (K&R) to a bright young person. I had a chance to speak with one of these young people later on and found that he had been stopped in his tracks when he got to Boolean algebra. He totally ground to a halt when he hit bit-wise operators.
I wrote a hand-out on the logical operators, AND and OR to help young people who are studying programming. I have included the bit-wise operators used in C and I have posted this hand-written set of truth tables on the internet. There are a lot of bright young people who are capable of teaching themselves how to program, but they have to really want to learn how to do it in order to overcome obstacles.
Then again, young people should not have too many obstacles. The K&R book is brilliant, but it is terse and might not be a good fit for everyone. C Programming, A Modern Approach by K.N. King has more explanation and might be a better match for some people. On the other hand, The C Programming Language has a companion book that is a valuable complement: The C Answer Book: Solutions to the Exercises in 'The C Programming Language' by Tondo and Gimpel. Scott Gimpel is the creator of FlexeLint, a useful static analysis tool.
Overall, I believe a young person learning to program will benefit from some coaching, especially when learning to program in C.
Robert
A previous article on C programming is:
"A Fix for K & R Chapter 1", July 2, 2012, Monday
I wrote a hand-out on the logical operators, AND and OR to help young people who are studying programming. I have included the bit-wise operators used in C and I have posted this hand-written set of truth tables on the internet. There are a lot of bright young people who are capable of teaching themselves how to program, but they have to really want to learn how to do it in order to overcome obstacles.
Then again, young people should not have too many obstacles. The K&R book is brilliant, but it is terse and might not be a good fit for everyone. C Programming, A Modern Approach by K.N. King has more explanation and might be a better match for some people. On the other hand, The C Programming Language has a companion book that is a valuable complement: The C Answer Book: Solutions to the Exercises in 'The C Programming Language' by Tondo and Gimpel. Scott Gimpel is the creator of FlexeLint, a useful static analysis tool.
Overall, I believe a young person learning to program will benefit from some coaching, especially when learning to program in C.
Robert
A previous article on C programming is:
"A Fix for K & R Chapter 1", July 2, 2012, Monday
Saturday, October 13, 2012
Notepad++ and Python
Python is very sensitive to white space because it interprets code blocks by indentation level instead of curly braces. It is vital to use uniform spacing. I agree with those programmers who use 4 spaces for Python indentation and avoid use of tabs. You can setup Notepad++ to help maintain this standard. Here is how:
Open Notepad++. Select Settings > Preferences > Language Menu/Tab Settings
Leave Tab Size at 4, but check the box that says "Replace by space".
Then go back to the main menu and select View > Show Symbol > Show White Space and Tab.
If you look closely you will see faint dots for the spaces.
If you open a file that has tabs you will see them displayed with arrows so you know you have them.
You can do a Control-f to open the find window. It has a radio button in search mode that has "extended" and allows you to search for the \t character, which is a tab. You can use the "replace" tab in the find window to replace all tabs (\t) with 4 spaces. This is a convenient way to clean up files with tabs.
If you work on projects with multiple people you will see all manner of tabbing and spacing, which can break Python code. Python code is sensitive to indentation errors. It is important to be consistent. This sensitivity to indentation errors makes Python code brittle in a large programming environment.
James Coplien had this to say: "Back in my days working in the Bell Labs Software Production Research organization ... we had some back-of-the-envelope findings that suggested that consistent indentation style was one of the most statistically significant indicators of low bug density."[1]
Robert
[1] Forward by James Coplien, p. xxii, in Clean Code, A Handbook of Agile Software Craftsmanship by Robert C. Martin
Open Notepad++. Select Settings > Preferences > Language Menu/Tab Settings
Leave Tab Size at 4, but check the box that says "Replace by space".
Then go back to the main menu and select View > Show Symbol > Show White Space and Tab.
If you look closely you will see faint dots for the spaces.
If you open a file that has tabs you will see them displayed with arrows so you know you have them.
You can do a Control-f to open the find window. It has a radio button in search mode that has "extended" and allows you to search for the \t character, which is a tab. You can use the "replace" tab in the find window to replace all tabs (\t) with 4 spaces. This is a convenient way to clean up files with tabs.
If you work on projects with multiple people you will see all manner of tabbing and spacing, which can break Python code. Python code is sensitive to indentation errors. It is important to be consistent. This sensitivity to indentation errors makes Python code brittle in a large programming environment.
James Coplien had this to say: "Back in my days working in the Bell Labs Software Production Research organization ... we had some back-of-the-envelope findings that suggested that consistent indentation style was one of the most statistically significant indicators of low bug density."[1]
Robert
[1] Forward by James Coplien, p. xxii, in Clean Code, A Handbook of Agile Software Craftsmanship by Robert C. Martin
Installing Python
Here is a tip for when you install Python. After you have googled python, gone to their website, downloaded the version you want, and launched the installer, you will get to a box that has a list of features to install. At the bottom of the list it says "Add python.exe to path" and there is a red X in the box next to that choice. Right-click on that choice, read the options on the drop-down box that appears, and check the box that says "install all features." You do not want to leave that red X in that box.
You do want the installer to add python to your path variable. If you do not have the installer add python to your path, you will have to do it yourself. Here is how you test to see that your path does have python in it: Open a Windows command window and type PATH and hit a carriage return. The OS will print the path and you can read it and look for "C:\Python33" or whatever version is latest. Or, you can just test to see if the path variable is set properly by entering "python --version" and see if the command works. The output will by "Python 3.3.0" or something similar if you get another version.
If you already know how to program, The Quick Python Book is a good introduction to the language. My preference is to edit Python code with Notepad++ and use a command window for running code. The Quick Python book acts like you will do all your work with the IDLE Python GUI. I just use the IDLE tool to test small commands.
Python is a nice language. I went back to look at PERL and I can see why people prefer Python to PERL. PERL forces you to put funny symbols called sigils in front of variables. I forgot about that.
Robert
You do want the installer to add python to your path variable. If you do not have the installer add python to your path, you will have to do it yourself. Here is how you test to see that your path does have python in it: Open a Windows command window and type PATH and hit a carriage return. The OS will print the path and you can read it and look for "C:\Python33" or whatever version is latest. Or, you can just test to see if the path variable is set properly by entering "python --version" and see if the command works. The output will by "Python 3.3.0" or something similar if you get another version.
If you already know how to program, The Quick Python Book is a good introduction to the language. My preference is to edit Python code with Notepad++ and use a command window for running code. The Quick Python book acts like you will do all your work with the IDLE Python GUI. I just use the IDLE tool to test small commands.
Python is a nice language. I went back to look at PERL and I can see why people prefer Python to PERL. PERL forces you to put funny symbols called sigils in front of variables. I forgot about that.
Robert
Saturday, October 6, 2012
Install Tkdiff on Linux
If you want a visual comparison between two files on Linux, then vimdiff is available for you, but the visual presentation is very ugly. Vimdiff comes with vim. Fortunately Tkdiff is available for Linux and it is easy to install if you know how.
Here are directions for installing Tkdiff on Linux. My primary machine is a Windows box, so I download using my Windows box and then move files over to my Linux box. If you download from the internet using your Linux box, the directions might be very similar, but a little different.
Use this link to download Tkdiff for Linux:
http://sourceforge.net/projects/tkdiff/files/tkdiff/4.2/tkdiff-4.2.tar.gz/download
Use WinZip extract once to get from tkdiff-4.2.tar.gz to tkdiff-4.2.tar
Use WinZip extract again to get from tkdiff-4.2.tar to folder called tkdiff-unix which has these files:
CHANGELOG.txt
LICENSE.txt
README.txt
tkdiff
Move the entire folder to your linux box, although you really only need the tkdiff file. When you place licensed software on your linux box, I think it is appropriate to have the license on the machine.
Change tkdiff to Unix format, and put it in the bin directory. Here are the commands to do this. Of course, when you execute su to become root, you must know the root password.
dos2unix tkdiff
su
cp tkdiff /usr/local/bin/
Now you can go to some directory and execute
tkdiff file another_file
and see the difference.
You will be please to see the visual improvement over vimdiff. If you downloaded directly onto the Linux box, the tkdiff file might not be in DOS format. The program dos2unix fixes the carriage return differences between Unix and Windows.
I will also mention that there is a Windows version available here.
http://sourceforge.net/projects/tkdiff/
The Windows version has an installer called TkDiff-4.2-Setup.exe
I prefer Kdiff3 for comparing files on Windows. I installed Tkdiff instead of Kdiff3 on Linux because Tkdiff is generally much easier to install on Linux.
Robert
May 2017: Tkdiff is nice because you can put it on media and install it on a computer that does not have a decent visual tool for diff'ing files. However, if you are on a Linux computer, look and see if the kompare (on KDE systems) or meld (on Gnome systems) tools are available. Then you won't need Tkdiff.
Here are directions for installing Tkdiff on Linux. My primary machine is a Windows box, so I download using my Windows box and then move files over to my Linux box. If you download from the internet using your Linux box, the directions might be very similar, but a little different.
Use this link to download Tkdiff for Linux:
http://sourceforge.net/projects/tkdiff/files/tkdiff/4.2/tkdiff-4.2.tar.gz/download
Use WinZip extract once to get from tkdiff-4.2.tar.gz to tkdiff-4.2.tar
Use WinZip extract again to get from tkdiff-4.2.tar to folder called tkdiff-unix which has these files:
CHANGELOG.txt
LICENSE.txt
README.txt
tkdiff
Move the entire folder to your linux box, although you really only need the tkdiff file. When you place licensed software on your linux box, I think it is appropriate to have the license on the machine.
Change tkdiff to Unix format, and put it in the bin directory. Here are the commands to do this. Of course, when you execute su to become root, you must know the root password.
dos2unix tkdiff
su
cp tkdiff /usr/local/bin/
Now you can go to some directory and execute
tkdiff file another_file
and see the difference.
You will be please to see the visual improvement over vimdiff. If you downloaded directly onto the Linux box, the tkdiff file might not be in DOS format. The program dos2unix fixes the carriage return differences between Unix and Windows.
I will also mention that there is a Windows version available here.
http://sourceforge.net/projects/tkdiff/
The Windows version has an installer called TkDiff-4.2-Setup.exe
I prefer Kdiff3 for comparing files on Windows. I installed Tkdiff instead of Kdiff3 on Linux because Tkdiff is generally much easier to install on Linux.
Robert
May 2017: Tkdiff is nice because you can put it on media and install it on a computer that does not have a decent visual tool for diff'ing files. However, if you are on a Linux computer, look and see if the kompare (on KDE systems) or meld (on Gnome systems) tools are available. Then you won't need Tkdiff.
Sunday, September 9, 2012
Install Time: Just Basic vs VB Express
There is a significant difference in the time to download and install Just Basic and downloading Microsoft Visual Basic Express. The Just Basic product is small and downloads within a minute, and its installation takes about a minute. If your version of Windows is missing the Microsoft WinHlp32.exe file, then downloading and installing that will take about 10 minutes. So the total time to download and install Just Basic is less than 15 minutes. If you are using Windows XP, then you already have WinHlp32.exe and your computer will take less than 5 minutes to download and install Just Basic.
Microsoft Visual Basic Express is a large product. Plan on an hour to download and install it. You need to check on it every 15 minutes. At some point during the download you might need to restart your computer. Then the download resumes. After the download and installation, go ahead and launch it. The first time it comes up it does some final installation chores and that takes a couple of minutes.
Don't download Microsoft Visual Basic Express unless you have at least an hour to spare.
Robert
Microsoft Visual Basic Express is a large product. Plan on an hour to download and install it. You need to check on it every 15 minutes. At some point during the download you might need to restart your computer. Then the download resumes. After the download and installation, go ahead and launch it. The first time it comes up it does some final installation chores and that takes a couple of minutes.
Don't download Microsoft Visual Basic Express unless you have at least an hour to spare.
Robert
Saturday, September 8, 2012
Just Basic Tutorials and WinHlp32
I have investigated Just Basic, a free version of basic. It is at version 1.01 and was released in 2004. They have a commercial version, Liberty Basic, that is just $60. That is cheaper than a meal at the Cheesecake Factory. So if you really like Just Basic, there is an upgrade available if you want to continue working with it.
Just Basic comes with a tutorial. You can find it under Help > Just Basic Tutorial. It works just fine in Windows XP. However, Microsoft dropped a file WinHlp32.exe, from Windows releases subsequent to XP. The tutorial requires this executable file, but it is still available from Microsoft. You just have to get it and install it. Of course, Microsoft has made this more difficult by requiring that you use their proprietary browser, MS Internet Explorer.
WinHlp.exe comes in different versions for Windows Vista and Windows 7. Google to get the download page for WinHlp.exe for your version of Windows using Microsoft Internet Explorer. That is important. Microsoft has designed their download for WinHlp32 so it will not work with Mozilla or Chrome. Once the download and installation is complete (the download process has an installation step), you can open the tutorial.
The tutorial is designed for real beginners. It has a section in Week 1 (the tutorial is designed as a 6 week class) entitled, "Programming - What is it?" This is important for a person not previously introduced to programming. The book Head First C, for example, explicitly says it does not teach programming. The Head First organization has a book to teach programming, Head First Programming, but it uses Python as the teaching language. Python is a fine language, but scripting languages tend to be faddish and fall by the wayside, replaced by the latest fad in scripting languages. If you only learn one programming language in your entire life, it should be Basic. It is a language that is here to stay. It was created 48 years ago and is still used by businesses in creating professional, complex products and tools. Visual Basic for Applications (VBA), for example, is embedded by Microsoft in some of its products. I have created complex, technical applications using VBA in Excel and in Visio. I will mention, however, that VBA will choke on large problems. It has limited memory available to it and chokes on large data sets and large quantities of data structures. Professional programmers must know more than one language.
Visual Basic 2010 Express is also a free tool. I will discuss this another time.
Robert
PS: Remember that the book Programming for the Absolute Beginner by Jerry Ford uses Just Basic.
Just Basic comes with a tutorial. You can find it under Help > Just Basic Tutorial. It works just fine in Windows XP. However, Microsoft dropped a file WinHlp32.exe, from Windows releases subsequent to XP. The tutorial requires this executable file, but it is still available from Microsoft. You just have to get it and install it. Of course, Microsoft has made this more difficult by requiring that you use their proprietary browser, MS Internet Explorer.
WinHlp.exe comes in different versions for Windows Vista and Windows 7. Google to get the download page for WinHlp.exe for your version of Windows using Microsoft Internet Explorer. That is important. Microsoft has designed their download for WinHlp32 so it will not work with Mozilla or Chrome. Once the download and installation is complete (the download process has an installation step), you can open the tutorial.
The tutorial is designed for real beginners. It has a section in Week 1 (the tutorial is designed as a 6 week class) entitled, "Programming - What is it?" This is important for a person not previously introduced to programming. The book Head First C, for example, explicitly says it does not teach programming. The Head First organization has a book to teach programming, Head First Programming, but it uses Python as the teaching language. Python is a fine language, but scripting languages tend to be faddish and fall by the wayside, replaced by the latest fad in scripting languages. If you only learn one programming language in your entire life, it should be Basic. It is a language that is here to stay. It was created 48 years ago and is still used by businesses in creating professional, complex products and tools. Visual Basic for Applications (VBA), for example, is embedded by Microsoft in some of its products. I have created complex, technical applications using VBA in Excel and in Visio. I will mention, however, that VBA will choke on large problems. It has limited memory available to it and chokes on large data sets and large quantities of data structures. Professional programmers must know more than one language.
Visual Basic 2010 Express is also a free tool. I will discuss this another time.
Robert
PS: Remember that the book Programming for the Absolute Beginner by Jerry Ford uses Just Basic.
Subscribe to:
Posts (Atom)