Wednesday, March 5, 2014

Learning JavaScript: CDNs, Mathjax, SVG

For the past six weeks or so, we have been focusing on learning JavaScript programming through our web consoles at www.codeacademy.com. Please continue completing your JavaScript sequence at Code Academy. The value of interactive practice will make you a  better programmer. However, to apply our skills learned from Code Academy, we are going to need more resources. If you have not done so already, install an appropriate code editor. I recommend Notepad++ for Windows or TextMate for MAC. There are a number of JavaScript based editors available. For example,  Js.do is a javascript based editor that allows the user to edit code online. 

Some javascript code we worked on today is below. The point of the lecture was to 
  •  Demonstrate linkage of code to Content Distribution Networks (Mathjax in this case.)
  •  Show embedded SVG drawing code
  •  Demonstrate event based buttons that use Javascript's Math class functionality.
Some URLS with more information are:
It is worth working through the Javascript tutorials at W3Schools. They provide excellent reference with online practice. You can paste their code in js.do as well.  Mathjax provides an excellent example of a callable external library of functionality from a CDN (external Content Distribution Network).  In addition, I have a google drive JavaScript folder  with selected online JS manuals and  the example html files below . These examples can also be viewed here.

Wednesday, January 8, 2014

Numerical Sorting with the Bash Shell

This post will  explain the use of the sort utility while in the Bash shell.  The Sort utility can be used with output or on a text file. Open up an X11 terminal and make sure you are at a Bash shell prompt (type 'bash'). Use the man command to look at the following commands:

sort : Cygwin, Linux, BSD and MAC
seq : Cygwin or Linux only
shuf : Cygwin or Linux oly
jot : BSD or MAC only
awk : Cygwin, Linux, BSD and MAC

Tuesday, January 7, 2014

Sorting Algorithms and All That Jazz (Part I)




Above: visual sorting algorithms with sound. Beneath: Brian Morgans from WWU brought us sorting in Java Script for this weeks Computer Club!
Thanks to Brian Morgans for bringing us not only a Bubble Sorting lesson but a brief JavaScript lesson!  To pursue his exercises please download a capable text editor like TextMate or Notepad++. Alternatively, you can simply use Xed or Visual Studio.  An excellent first step in understanding sorting might be to run 'info sort' or 'man sort' from your X11 prompt.

Friday, November 22, 2013

K&R C SE Lesson 1: Introducing K & R C Programming SE

(Post Under Construction)
 Kernighan and Ritchie "The C Programming Language" Second Edition is an classic interpretation of the C language in the same way as Strunk and White "Elements of Style" is a classic interpretation of the English language or Wolfgang Pauli's lecture on "Wave Mechanics" is a classic representation of the math of physics. This does not mean that all of the programming in K&R C is useful today or even the best representation of the use of C (1, 2).  A paraphrased statement of Pauli's famous belief about untestable physics applies to engineering software as well: If your code can't be proven wrong by someone, you have probably not produced anything of much value. 

Software engineering languages have variability, flexibility and polymorphism  by design  There are always multiple solutions to any given problem. Without honoring this fundamental nature of exploratory science; the power and endurance of any one language is limited. There are a number of  K&R solution sets provided on the web. Below is a selection of solutions to  the Fahrenheit-Celsius converter code discussed in Chapter 1 of  "The C Programming Language" as provided by Richard Heathfield.   A C language reference is available from the GNU Project. It is particularly important to read the while and do statement sections. A number of third party GNU C tutorials are also available. Use the google search term: 'filetype:PDF gnu c programming tutorial'. Learning GNU C is one such.

This post is primarily about understanding the logic and control structures of C. The implementation of C library functions (e.g. printf) are left for another discussion. -RMF

Thursday, November 21, 2013

K&R C SE Lesson 2: Introducing printf, the 'for loop', and gdb

(Post Under Construction)
This post uses an example from the first chapter of  K&R C Programming Second Edition. After discussing the use of the printf function, K&R C SE demonstrates alternate code for printing a Fahrenheit-Celsius conversion table. The specific and compact use of printf arguments allows for the appropriate formatting of the results returned by a compact conversion routine inside of a for loop. This code is more compact and more accurate than the first example in Lesson 1 using the while loop:

#include <stdio.h>
/* print Fahrenheit-Celsius table */
main()
{
int fahr;
for (fahr = 0; fahr <= 300; fahr = fahr + 20)
        printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32));
}

Tuesday, November 12, 2013

XCode, Text Editors, Peanut Butter

I want to wish a big thank you for the guest lecture from software engineer and WWU statistics instructor Brian Morgans who taught a fascinating class on program instruction debugging; all with a loaf of bread, some peanut butter and a knife! I think the students had a great time!  In conclusion, Brian talked about sorting algorithms which are an excellent introduction to developing algorithms in programming.  I recommend the Wikipedia article and links on sorting algorithms. For a fun (but noisy) visualization of sorting algorithms, see here.

We will meet again in the first two weeks of December. I have installed Xcode 3.0 on many of the MACs in the lab and will soon install the entire lab. This allows you to use the gcc and g++ commands from your bash prompt. There will be a graphical interface to XCode 3.0. More on that later. In using the Xcode installation, there may be path issues for libraries you need to address. Read The Fine Manual and e-mail me any questions. The GNU gcc and g++ manuals are here.

Tuesday, October 15, 2013

Resources and Text for the Class

Although there are no mandatory assignments for this course, learning to programming is no different than any other skill. The more research and practice the student puts into the subject, the more he will learn. Programming requires practices and research to master as a skill. My lectures are simply not enough.

I have stored texts that could be useful  to this class on my google drive and shared them publicly.  I will add to the folders as the course continues:

https://googledrive.com/host/0B9RoDKQADMNGLXdxM0VqMjUzZ3M/ C_Programming
https://googledrive.com/host/0B9RoDKQADMNGM1o3dTlqNVF4amc/ C++
https://googledrive.com/host/0B9RoDKQADMNGZ2xvenI5MnFITkk/ Shell Programming
https://googledrive.com/host/0B9RoDKQADMNGUWFGUno5d3Niakk/ UNIX_Administration

For C Programming, we will be using the  Kernighan and Ritchie classic "C Programming" Second Edition. The ISO C Standard has been updated to C11. A previous draft of that standard ('n1570')  is available for free. Both documents are available as PDFs  in the C_Programming folder. For UNIX Administration, I found a PDF copy of the classic Evi Nemeth work "UNIX Administration".  It can be found in the UNIX_Administration folder .  Other PDFs on Shell Programming are available. I recommend reading all three of these works for this class. Evi Nemeth's work is particularly good background.

Additional reference manuals on C Programming can be found in the C_Programming  folder. The GNU C reference manual is particularly appropriate when you simply need to look up a reference on how a keyword or operator is used . Two wikibooks on C are also helpful:

http://en.wikibooks.org/wiki/C_Programming
http://en.wikibooks.org/wiki/A_Little_C_Primer