Posts tagged as:

Smalltalk

This semester I’m going to have my Ruby and PHP classes build a form driven, AJAX-y web application as the final project. This is a bread-and-butter assignment that performs the basic task of storing form data in a database then displaying it. We’ll deal with the ever present Persistence Problem by using a SQLite3 database to store user input, and the AJAX/Javascript layer will be all JQuery.

I’ve created the PHP proof of concept site at http://www.istoasisto.com, and it looks like this:

A classroom project of this size can be completed in four to six weeks, depending on the programming and web skills a student brings to the class. More is always better.

The PHP course will be starting from scratch (no cakePHP, no Drupal, no Joomla), while my Ruby course will be using Rails. I’ll be doing the project in Seaside. When all is said and done, we will count the lines of PHP, Ruby, and Smalltalk to see who get bragging rights for writing the fewest lines of code.

If you want to work along wtih us, your project should have these features:

  • An HTML form.
  • JQuery form manipulation.
  • AJAX via JQuery.
  • Validated form input.
  • Form data stored in a SQLite database.
  • A Recaptcha form.
  • User data safely displayed (potentially harmful characters sanitized).

There are dozens of features we could hang on this skeleton: pagination, search, social features (Twitter, Facebook, Buzz, etc), as well as polls, voting, thumbs-up/down, email, XML export, RSS feeds, Section 508 compliance, and more. I’ll be satisfied if most of my students can achieve basic functionality before semester burnout sets in.

And about that Seaside course—there isn’t one yet. But it is on my TODO list for future courses at CCSF. For the time being, as part of my own Smalltalk education, I’ll take this opportunity to complete the class project using Seaside. Since Smalltalk and Seaside are new to me, I’ll be starting on the same page as my PHP and Ruby students. This will be fun. I’ll be doing this project with Cincom Visualworks Non-Commercial which is free for non-commercial use on Windows, Linux, and Mac OS X.

OK. I’d better get to work on the Ruby part of this project before the Rails team unleashes another new product release just to confuse me.

Happy hacking…

{ 4 comments }

A reserved word in a programming language is a word that is off limits to the programmer. For example, in PHP print is a reserved word. This means that you, as the programmer, cannot create a function named print because PHP owns that word.

Most languages have reserved words, some a few, and some very, very many. Usually the fewer reserved words a language has, the more flexible it is. For example, in the list below, you will see that Lisp has no reserved words. We all know that Lisp is very flexible and powerful.

As you look at the table below, do not think unkind thoughts about PHP—it’s different from the other languages. It is not designed to be a general purpose programming language, though it can certainly do almost anything you want it to do. It is intended for web programming, which explains the existence of so many of the predefined functions and constants. Those are exactly the kinds of items that other languages must implement individually if they want to be as handy with web development as PHP. This is no small task, kids. Just take a look around try to find a web site implemented in C++.

Reserved Words

Language Count Reserved Words
Lisp 0 Lisp has no reserved words. Lisp is written in Lisp. Alan Kay, the creator of Smalltalk, said: “Lisp isn’t a language, it’s a building material.”
Smalltalk 5 self super nil true false
C 32 auto break case chart const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while
C++ ~62 and and_eq asm auto bitand bitor bool break case catch char class compl const const_cast continue default delete do double dynamic_cast else enum explicit export extern false float for friend goto if inline int long mutable namespace new not not_eq operator or or_eq private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq
Ruby 38 alias and BEGIN begin break case class def defined? do else elsif END end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield
Python 31 and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try
Java 47 abstract do if package synchronized boolean double implements private this break else import protected throw byte extends instanceof public throws case false int return transient catch final interface short true char finally long static try class float native strictfp void const for new super volatile continue goto null switch while default assert
PHP 418 __CLASS__ __COMPILER_HALT_OFFSET__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __PHP_INCOMPLETE_CLASS ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7 ABMON_1 ABMON_10 ABMON_11 ABMON_12 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6 ABMON_7 ABMON_8 ABMON_9 ABSTRACT ALT_DIGITS AM_STR AND ARGC ARGV ARRAY AS ASSERT_ACTIVE ASSERT_BAIL ASSERT_CALLBACK  ASSERT_QUIET_EVAL ASSERT_WARNING AUTH_TYPE BREAK CASE CASE_LOWER CASE_UPPER CATCH CFUNCTION CHAR_MAX CLASS CLONE CODESET CONNECTION_ABORTED CONNECTION_NORMAL CONNECTION_TIMEOUT CONST CONTINUE COUNT_NORMAL COUNT_RECURSIVE CREDITS_ALL CREDITS_DOCS CREDITS_FULLPAGE CREDITS_GENERAL CREDITS_GROUP CREDITS_MODULES CREDITS_QA CREDITS_SAPI CRNCYSTR CRYPT_BLOWFISH CRYPT_EXT_DES CRYPT_MD5 CRYPT_SALT_LENGTH CRYPT_STD_DES CURRENCY_SYMBOL D_FMT D_T_FMT DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7 DECIMAL_POINT DECLARE DEFAULT DEFAULT_INCLUDE_PATH DIE DIRECTORY_SEPARATOR DO DOCUMENT_ROOT E_ALL E_COMPILE_ERROR E_COMPILE_WARNING E_CORE_ERROR E_CORE_WARNING E_ERROR E_NOTICE E_PARSE E_STRICT E_USER_ERROR E_USER_NOTICE E_USER_WARNING E_WARNING ECHO ELSE ELSEIF EMPTY ENDDECLARE ENDFOR ENDFOREACH ENDIF ENDSWITCH ENDWHILE  ENT_COMPAT ENT_NOQUOTES ENT_QUOTES ERA ERA_D_FMT ERA_D_T_FMT ERA_T_FMT ERA_YEAR EVAL EXCEPTION EXIT EXTENDS EXTR_IF_EXISTS EXTR_OVERWRITE EXTR_PREFIX_ALL EXTR_PREFIX_IF_EXISTS EXTR_PREFIX_INVALID EXTR_PREFIX_SAME EXTR_SKIP FINAL FOR FOREACH FRAC_DIGITS FUNCTION GATEWAY_INTERFACE GLOBAL GROUPING HTML_ENTITIES HTML_SPECIALCHARS HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE HTTP_CONNECTION HTTP_HOST HTTP_REFERER HTTP_USER_AGENT HTTPS IF IMPLEMENTS INCLUDE INCLUDE_ONCE INFO_ALL INFO_CONFIGURATION INFO_CREDITS INFO_ENVIRONMENT INFO_GENERAL INFO_LICENSE INFO_MODULES INFO_VARIABLES INI_ALL INI_PERDIR INI_SYSTEM INI_USER INT_CURR_SYMBOL INT_FRAC_DIGITS INTERFACE ISSET LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LIST LOCK_EX LOCK_NB LOCK_SH LOCK_UN LOG_ALERT LOG_AUTH LOG_AUTHPRIV LOG_CONS LOG_CRIT LOG_CRON LOG_DAEMON LOG_DEBUG LOG_EMERG LOG_ERR LOG_INFO LOG_KERN LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR LOG_MAIL LOG_NDELAY LOG_NEWS LOG_NOTICE LOG_NOWAIT LOG_ODELAY LOG_PERROR LOG_PID LOG_SYSLOG LOG_USER LOG_UUCP LOG_WARNING M_1_PI M_2_PI M_2_SQRTPI M_E M_LN10 M_LN2 M_LOG10E M_LOG2E M_PI M_PI_2 M_PI_4 M_SQRT1_2 M_SQRT2 MON_1 MON_10 MON_11 MON_12 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 MON_DECIMAL_POINT MON_GROUPING MON_THOUSANDS_SEP N_CS_PRECEDES N_SEP_BY_SPACE N_SIGN_POSN NEGATIVE_SIGN NEW NOEXPR NOSTR OLD_FUNCTION OR P_CS_PRECEDES P_SEP_BY_SPACE P_SIGN_POSN PATH_SEPARATOR PATH_TRANSLATED PATHINFO_BASENAME PATHINFO_DIR NAME PATHINFO_EXTENSION PEAR_EXTENSION_DIR PEAR_INSTALL_DIR PHP_AUTH_DIGEST PHP_AUTH_PW PHP_AUTH_USER PHP_BINDIR PHP_CONFIG_FILE_PATH PHP_CONFIG_FILE_SCAN_DIR PHP_DATADIR PHP_EOL PHP_EXTENSION_DIR PHP_INT_MAX PHP_INT_SIZE PHP_LIBDIR PHP_LOCALSTATEDIR PHP_OS PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END PHP_OUTPUT_HANDLER_START PHP_PREFIX PHP_SAPI PHP_SELF PHP_SHLIB_SUFFIX PHP_SYSCONFDIR PHP_USER_FILTER PHP_USER_FILTER PHP_VERSION PM_STR POSITIVE_SIGN PRINT PRIVATE PROTECTED PUBLIC QUERY_STRING RADIXCHAR REMOTE_ADDR REMOTE_HOST REMOTE_PORT REQUEST_METHOD REQUEST_TIME REQUEST_URI REQUIRE REQUIRE_ONCE RETURN SCRIPT_FILENAME SCRIPT_NAME SEEK_CUR SEEK_END SEEK_SET SERVER_ADDR SERVER_ADMIN SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SIGNATURE SERVER_SOFTWARE SORT_ASC SORT_DESC SORT_NUMERIC SORT_REGULAR SORT_STRING STATIC STDCLASS STR_PAD_BOTH STR_PAD_LEFT STR_PAD_RIGHT SWITCH T_FMT T_FMT_AMPM THIS THOUSANDS_SEP THOUSEP THROW TRY UNSET USE VAR WHILE XOR YESEXPR YESSTR LASS__ __COMPILER_HALT_OFFSET__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __PHP_INCOMPLETE_CLASS ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7 ABMON_1 ABMON_10 ABMON_11 ABMON_12 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6 ABMON_7 ABMON_8 ABMON_9 ABSTRACT ALT_DIGITS AM_STR AND ARGC ARGV ARRAY AS ASSERT_ACTIVE ASSERT_BAIL ASSERT_CALLBACK ASSERT_QUIET_EVAL ASSERT_WARNING AUTH_TYPE BREAK CASE CASE_LOWER CASE_UPPER CATCH CFUNCTION CHAR_MAX CLASS CLONE CODESET CONNECTION_ABORTED CONNECTION_NORMAL CONNECTION_TIMEOUT CONST CONTINUE COUNT_NORMAL COUNT_RECURSIVE CREDITS_ALL CREDITS_DOCS CREDITS_FULLPAGE CREDITS_GENERAL CREDITS_GROUP CREDITS_MODULES CREDITS_QA CREDITS_SAPI CRNCYSTR CRYPT_BLOWFISH CRYPT_EXT_DES CRYPT_MD5 CRYPT_SALT_LENGTH CRYPT_STD_DES CURRENCY_SYMBOL D_FMT D_T_FMT DAY_1 DAY_2 DAY_3

{ 11 comments }

Smalltalk: The Good Parts Blog Is Moving

by doug on January 31, 2010

in Smalltalk

AOTS Olivia Munn
AOTS’ Olivia Munn

The Smalltalk: The Good Parts Blog over at http://smalltalkthegoodparts.com is moving to http://hackingthevalley.com/ and to a new RSS feed. The Slicehost server will still host SmalltalkTheGoodParts.com and my Smalltalk experiments.

I know. It seems like we just got here a few weeks ago. And now we’re moving?? Crazy. Actually, what’s crazy was trying to maintain 4 blogs. In a momentary fit of delusion and megalomania, I had hallucinated that I would be able to teach 4 classes, walk the dogs, prune the damn apple trees, mentor 150 students, and create content for 4 blogs—and watch AOTS (Attack of the Show) every afternoon.

Something had to give, so the blog has to move. There’s no way I’m giving up AOTS.

I’m going to consolidate the PHP, Ruby, and Smalltalk Good Parts blogs into a single new Wordpress blog (HackingTheValley.com), and shut down hackingthevalley.blogspot.com. Fortunately I have only a few posts to import. I can do this in a couple of days.

This blog will be turned off in 30 days and Feedburner will disconnect those who are using the old RSS feed. If you want to transfer to the new feed, click here to add the Smalltalk: The Good Parts RSS feed.

So the moral of the story is, one blog per mere mortal.

Happy hacking…

Doug

{ 0 comments }

My Collection of Vintage Smalltalk Books

by doug on January 27, 2010

in Smalltalk

Every time I’m swept up in an new project I gird my loins by gathering a phalanx of books around me. I start by downloading all of the free PDF’s I can find. Stephane Ducasse, author the the Robots books, has an exhaustive list of free out-of-print Smalltalk books. So I got them all. I don’t know how many of these books I’ll ever read, but I feel good having them there, just in case.

Smalltalk PDF's

I like real books, so I scoured the used book list on Amazon and was able to find paper copies of many of my free PDF’s.

Most of these books were first published in the 80’s and 90’s, with a few of the Squeak books arriving after 2000.

Of all of these books, my favorite is SMALLTALK-80 by Adele Goldberg and David Robson (1989). Though the book’s cover gives it a quaint vintage look, the content is contemporary and the writing admirably clear—perfect for a student like me.

I like this book so much that I carry it with me on my walks around San Francisco and read it while I sit in Starbucks eating pastries and drinking espressos. Now and then some generic dude will see my antique book and comment, “Damn. Is that language still around? Why would you want to learn that when you could learn Java?”

I also have a soft spot in my heart for Squeak: Learn Programming with Robots by Stephane Ducasse, which I’ve mentioned previously. This book is good-spirited and all about having fun with programming. It’s an absolutely painless, fun introduction to Smalltalk. A kid can handle this book easily—even an adult kid.

My buddy Bill G. observed me collecting these dusty, out of print tomes. Back in the 80’s he did some Smalltalk programming in The Valley. He said, “There used to be an all-Smalltalk books store in Palo Alto on University Avenue, right down the road from Xerox. That’s how hot Smalltalk was in those days.” He paused. “I think that place is a Starbucks now.”

That’s cool with me. I need a clean, well-lighted place to hang out and read my books and get hassled by Java programmers.

Happy hacking…

{ 4 comments }

My Collection of Vintage Smalltalk Books

by doug on January 26, 2010

in Smalltalk

I have a new post about my mania for collecting vintage computer books. Check it out on Smalltalk: The Good Parts.

{ 0 comments }

Which Flavor of Smalltalk Is Right For Me?

by doug on January 25, 2010

in Editorial

Learning two languages at once can be hazardous to your mental health.

Now that I know I can deploy Seaside on my Slicehost server, I can move on to the next step, which is deciding which version of Smalltalk I should learn.

The languages I’m familiar with come in only one flavor: vanilla. With C++, PHP , Ruby, and Python there’s no choice at all: you take what they give you. But there are many varieties of Smalltalk to choose from; they all do great stuff, they all have the great features, and  they’re all just different enough that it’s in your best interest to choose one and stick with it. Some are free and som you have to pay for. Which one do you choose?

I’ll cut the suspense and say that my first choice for learning Smalltalk is Squeak. But my choice was entirely accidental. I didn’t choose Squeak on its merits, and it has many. I simply stumbled upon it.

I was taking a math course and wanted to graph some of the equations we were discussing in the class. I considered using PHP but working with PHP’s low-level GD library had already killed off too many of my brain cells. Then by accident, I happened across a book named Squeak: Learning Programming With Robots. I could see at a glance that I could make this Squeak robot do my bidding. Here’s my first Smalltalk program: drawing a square. In fact, drawing 100 squares.

Here’s a small screencast of how Squeak looks in the hands of a rank amateur.

{ 3 comments }

How to Draw Squares With Squeak Smalltalk

by doug on January 25, 2010

in Smalltalk

I posted my first Smalltalk program on SmallTalkTheGoodParts.com. It’s all about squares. You’ll love it, if you love squares…100’s of them.

Keep hacking…

{ 0 comments }

Today I felt a compulsion to install Smalltalk on my little 256MB Slicehost slice. It was an itch I just had to scratch.

My first step was to admit (to myself) that I don’t know the first thing about deploying any kind Smalltalk anywhere. I can deploy PHP and Rails in my sleep, but I’m clueless about Smalltalk. I would have to do some research.

My first resource was James Robertson’s blog. He’s the Smalltalk evangelist for Cincom Smalltalk and has created countless Smalltalk tutorials and screencasts over the years. I’ve been following his experiences installing VisualWorks Smalltalk on his Slicehost server and noted that he mentioned having a problem running his 32-bit VM on a 64-bit server. He solved that problem by installing the ia32-libs. I anticipated that I would run into the same problem since I am running a 64-bit version of Ubuntu.

My second resource was the Linode.com support library. My original plan was to install both VisualWorks and Squeak, but as time slipped away, I realized that I had dreamed too grandly. I don’t know much about Squeak, but I know nothing about VisualWorks. I realized it would be less painful to go with Squeak. I googled “deploy pharo” and found a nice Seaside deployment guide on the Linode site. I took that path of least resistance and decided to install Pharo and Pier (a CMS written in Smalltalk).

I cut and pasted the Linode commands into the terminal and in 5 minutes I was ready to go. But, when I issued the command to start Seaside, I got the message: “Could not find squeak”. I recalled James Robertson’s gotcha and installed the 32-bit Intel libraries. I’m running Ubuntu, so I used this command:

sudo aptitude install ia32-libs

I won’t post the Linode article here; you can check it out for yourself if you’re interested. I just cut and pasted away as directed. Seaside started up on port 8080 perfectly. I poked around a little, took a few screenshots, then shut it down. It’s completely unsecured, and since I don’t know how to make it safe yet, I don’t want to leave it running unprotected. Right now I’m happy with taking baby steps.

By the way, here’s the command I used to run a squeak without a gui (headless). I’m saving it here for future reference; I had to do considerable digging to find it.

/opt/pharo-vm-15-2/squeak -vm-display-null /srv/www/pier-app-1.2/Contents/Resources/pier.image

My next step is to configure Apache to proxy Seaside. Once I get the proxy working, and learn more about securing the site, I’ll leave Seaside running. By the way, I have proof of life. Cool.

When I saw this page I rewarded myself with a cup of hot chocolate.

Keep hacking…

{ 3 comments }

Seaside and Smalltalk Alive

by doug on January 20, 2010

in Editorial

Today I put up a proof of concept Seaside Smalltalk site…for a few minutes. You can read about it on my Smalltalk blog if you are interested in this nerdy stuff: SmalltalkTheGoodParts.com

Keep hacking…

{ 0 comments }

My current technology preoccupations are PHP, Ruby, and Smalltalk. Over the last month I’ve been putting together blog sites for each of them: PHP: The Good Parts, Ruby: The Good Parts, and Smalltalk: The Good Parts.

I spend most of my time with PHP and Ruby because I teach classes in these languages at CCSF and CSM. After years of teaching both beginning students and experienced professionals I have an accurate sense of what they need to get off to a good start. I’ve written a ton of content for these courses—screencasts, pdfs, projects, exercises, etc. I plan to use the PHP and Ruby blogs to share some of the material I’ve created for my courses.

Smalltalk is a different matter: I’m a complete newbie and I’m climbing the same learning curve that my PHP and Ruby students climb. As I learn Smalltalk I’ll use the blog to document the process. My plan is to turn my experience (blood, sweat, and tears) into a Smalltalk course. I’ve seen Smalltalk in action, and now I want to do it for myself, then show others how insanely great it is.

I’ll be adding content to the blogs as I as fast as I can proof read it and test the code. If you are on the front end of your PHP career, you will find some pearls of wisdom here. I suggest that you subscribe to these blogs to keep informed of new posts as I update these blogs.

It’s going to take time to fill in these pages, and I expect that I’ll make many errors along the way. I appreciate all feedback; if you see something that needs fixing—code errors, spelling errors, or something that’s just plain wrong—please let me know. Feedback is golden.

Keep hacking…

Respect

My good parts blogs are inspired by Javascript: The Good Parts by Douglas Crockford. His cogent little book has taught me to scrutinize programming languages with a pragmatic eye: embrace what works and find a way to deal with the rest.

{ 0 comments }