. .

st4u

ST 4U 318: Sketching Out a CaseStatement Object

December 7, 2012 12:33:47.791

Today's Smalltalk 4 You sketches out a case statement object in Smalltalk. Not because this is a great idea; generally, you want to use Polymorphism. However, having been asked about such a thing, we have a sketch of how to do it. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Case Statement.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Recently, I was asked about Case Statements and Smalltalk - Smalltalk does not have one (nor does it need one, for the most part) - but it makes for a small, interesting example. I had created one of these in VisualWorks years ago, but it ported pretty cleanly into VA Smalltalk (the only real difference being that #new in VA does not send #initialize to the newly created instance). I have verification that the code works as-is in GNU Smalltalk as well - not a surprise, as it's pretty basic stuff. Here's the class definition:



Object subclass: #CaseStatement
    classInstanceVariableNames: ''
    instanceVariableNames: 'cases '
    classVariableNames: ''
    poolDictionaries: ''

There's a convenience method to create the first case, and the collection of cases is a collection of associations (where the key is the case, the value is the execution block for that case):


case: aCondition do: aBlock
	"answer a new instance with initial condition"

	^self new case: aCondition do: aBlock

There are a few instance methods to hook up the machinery:


switch: aCondition
	"execute block previously stored"

	self switch: aCondition default: [self error: 'No Default Found']

switch: aCondition default: aBlock
	"execute block previously stored"

	| association |
	association := self findOnKey: aCondition.
	association notNil 
		ifTrue: [(self findValue: association) value]
		ifFalse: [aBlock value]

findOnKey: aCondition
	"answer association or nil"

	^cases detect: [:each | each key = aCondition] ifNone: [nil]

findValue: anAssociation
	"answer the value"

	^anAssociation value

You can then see how this kind of thing works:


| caseStatement |
caseStatement := CaseStatement case: 1 do: [Transcript show: 'one'; cr].
caseStatement 
	case: 2 do: [Transcript show: 'two'; cr];
	case: 3 do: [Transcript show: 'three'; cr];
	case: 4 do: [Transcript show: 'four'; cr].

To actually use the statement, you do this kind of thing:


caseStatement switch: 6 default: [Transcript show: 'Could not find case'; cr].
caseStatement switch: 5.


Try that out and see what happens. You can find the code in VRGoodies (Contributed) in VisualWorks, and that code will port cleanly to at least VA and GNU (and I expect Pharo or Squeak as well).

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u318-iPhone.m4v ( Size: 4364936 )]

posted by James Robertson

 Share Tweet This

games

Minecraft is Huge

December 6, 2012 20:27:28.578

Spotted in Joystiq:

The Xbox Live Arcade version of Minecraft is selling at a good clip, shifting between 40,000 and 60,000 copies a week - it's just below Call of Duty: Black Ops 2 and Halo 4 in the weekly Xbox Live activity charts. As of November's end, total XBLA sales are at 4,476,904.

Think about that - Mojang is still a small shop, and the amount of money that has been spent on Minecraft development is tiny compared to any of the other titles mentioned above. There's a lesson in there somewhere for the AAA development shops, but I rather suspect that they'll miss it.

Tags:

posted by James Robertson

 Share Tweet This

smalltalk

Pharo 2.0 Hits Beta

December 6, 2012 19:43:42.632

Pharo 2.0 is now beta:

Today I finished the pending integrations for move to Pharo 2.0. There is still a problem with the VMs (for NB), but that's not a stopper for moving on. What does this means? Starting now, no new changes of API will be allowed, just bug fixes and minor enhancements that does not change the system behavior. We still have a long stabilization path until we can release, but we hope a couple of months will put us in shape

Tags:

posted by James Robertson

 Share Tweet This

js4u

JS 4U 227: Fusion Heatmap with Styling

December 6, 2012 1:15:08.301

Javascript 4 U

Today's Javascript 4 You looks at changing the style of a heatmap using the Google Maps Javascript API. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

heatmap styling

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[js4u227-iPhone.m4v ( Size: 1532767 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 317: Dictionary Variance

December 5, 2012 7:32:02.809

Today's Smalltalk 4 You looks at a small behavior difference in the way things work in VA Smalltalk, Pharo, and VisualWorks, involving strings and IdentityDictionary. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Identoty.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at IdentityDictionary to point out a small difference in how things work in VA, Pharo, and VisualWorks. Consider the following code:


dict := Dictionary new.
dict 
	at: 'one' put: 1;
	at: 'two' put: 2;
	at: 'three' put: 3.
^dict at: 'one'.

You won't be surprised by the answer in any Smaltalk. Now consider this:


dict := IdentityDictionary new.
dict 
	at: 'one' put: 1;
	at: 'two' put: 2;
	at: 'three' put: 3.
^dict at: 'one'.

In Pharo and VA, you get back 1 - the literals are apparently reused, making them safe as keys in an IdentityDictionary. In VisualWorks, on the other hand, you get a KeyNotFound exception. In VisualWorks, the literals are not reused (and, since the introduction of immutability a few releases ago, that behavior is guaranteed).

If you are working on a project that is maintaining code across multiple Smalltalk implementations, this is a useful thing to know.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: ,

Enclosures:
[st4u317-iPhone.m4v ( Size: 2339597 )]

posted by James Robertson

 Share Tweet This

smalltalk

Adventures in Upgrading VW

December 4, 2012 20:34:08.815

I've done a fair bit of the initial changes necessary to update our code from VW 7.6 to VW 7.9, and I was at the point where I wanted to try running the application (to see what else needed fixing). That's when I ran into a curious issue with Oracle, where a stock query we run was failing, with Oracle telling us "not all variables bound".

That seemed strange; the code (which worked fine in 7.6, and did this, more or less:


conn := OracleConnection new.
conn
	username: 'someUser';
	password: 'somePassword';
	environment: 'oracleDB'.
conn connect.

session := conn getSession.
session bindInput: #(1).
session prepare: 'select * from categories where id = ?'.
session execute.
answers := session answer upToEnd.
conn disconnect.
^answers

Now, that code worked just fine in older revs of VW (and, in testing it against Postgres just now on my Mac, it still works fine in 7.9). To get it working against the Oracle, we needed to do this:


conn := OracleConnection new.
conn
	username: 'someUser';
	password: 'somePassword';
	environment: 'oracleDB'.
conn connect.

session := conn getSession.
session prepare: 'select * from categories where id = ?'.
session bindInput: #(1).
session execute.
answers := session answer upToEnd.
conn disconnect.
^answers

Can't spot the difference? The change moves #bindInput: after #prepare:. In the latest VW, the bind values are cleared in #prepare: - so if you do binding first, you end up with.... no binding. I did have a look at the release notes for 7.9.1, and the section on Oracle changes is reproduced here by Cincom - nothing on this change. It's easy enough to deal with; I just wish this had been in the release notes.

Tags: ,

posted by James Robertson

 Share Tweet This

js4u

JS 4U 226: Fusion Heatmap

December 4, 2012 7:40:14.291

Javascript 4 U

Today's Javascript 4 You looks at Fusion Heatmaps in the Google Maps API. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

Heatmap

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[js4u226-iPhone.m4v ( Size: 1119488 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 316: System Reporter in Pharo

December 3, 2012 8:15:59.149

Today's Smalltalk 4 You looks at the system reporter in Pharo. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Reporter

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[st4u316-iPhone.m4v ( Size: 2952287 )]

posted by James Robertson

 Share Tweet This

smalltalk

Sponsoring STIC 2013

December 2, 2012 19:51:51.000

There's more information available for the upcoming (next June) STIC 2013 conference:

The Smalltalk Industry Conference STIC’13 will be held June 9-12, 2013 at the Wigwam Resort in Phoenix, Arizona. The theme is "30 Years of Smalltalk". The Call for Participation is being prepared and will be announced soon.

STIC’13 Call for Sponsors
We are actively recruiting sponsors for STIC’13. Please let me know asap if you have any qualified leads. We are especially interested in companies who were developers or early adopters of Smalltalk in the 1980’s and 1990’s (e.g. Xerox, PARC, IBM, Apple, Microsoft, etc.).

STIC’13 Sponsorship Levels (Preliminary)

  • Platinum $10,000
  • Gold $5000
  • Silver $2500
  • Corporate $1000
  • Academic $500

You can see the sponsors for the previous conference STIC’12 here.

Commemorative Pins
We are planning to make commemorative lapel pins similar to the Smalltalk Balloon pins that Xerox made for me to distribute in the 1980’s. The design for the pins was based on the iconic August 1981 Byte Magazine cover artwork and was approved by the artist Robert Tinney.

  • Xerox Smalltalk lapel pin approximately 1.3” tall circa 1984 (1000 produced)
  • Limited edition 11”x14” print of Byte Magazine August 1981 cover artwork, signed and numbered by Robert Tinney (500 produced)

Please let me know if you have a source for making high quality, low cost hard enamel lapel pins. Also, we may be interested in a sponsor for the new pins, so let me know asap.

Objectively,
Evelyn Van Orden
Director, Smalltalk 30th Anniversary Reunion
STIC’13

Tags:

posted by James Robertson

 Share Tweet This

copyright

Copyright Law is Insane

December 2, 2012 13:29:08.310

You would think that something written by Robert Frost (1874-1963) would be public domain, right? You would be mistaken - the Frost estate is running around enforcing copyrights. How exactly does Frost benefit from this? How does anyone?

The amazing thing is that the same congress critters who tell us that we need a high estate tax will go ahead an extend copyright out for decades (it's now life of the author + 75 years). I guess some pigs are more equal than others. if you build up a small restaurant business, say, it can get mostly taken away when you die. Write a few books that sell well? Your heirs will be set for life.

Technorati Tags:

posted by James Robertson

 Share Tweet This

podcastAAC

IM 105: Skinny (AAC)

December 2, 2012 13:14:06.418

Welcome to episode 105 of Independent Misinterpretations - a Smalltalk and dynamic language oriented podcast with James Robertson and David Buck.

This week we have another recording from the STIC 2012 conference - Travis Griggs (formerly of Cincom) talking about the "Skinny" UI initiative. If you would rather watch the video, head on over to the STIC website.

You can subscribe to the podcast in iTunes (or any other podcatching software) using this feed directly or in iTunes with this one.

To listen now, you can either download the mp3 edition, or the AAC edition. The AAC edition comes with chapter markers. You can subscribe to either edition of the podcast directly in iTunes; just search for Smalltalk and look in the Podcast results. You can subscribe to the mp3 edition directly using this feed, or the AAC edition using this feed using any podcatching software. You can also download the podcast in ogg format.

If you like the music we use, please visit Josh Woodward's site. We use the song Troublemaker for our intro/outro music. I'm sure he'd appreciate your support!

If you have feedback, send it to jarober@gmail.com - or visit us on Facebook - you can subscribe in iTunes using this iTunes enabled feed.. If you enjoy the podcast, pass the word - we would love to have more people hear about Smalltalk!

Technorati Tags: , ,

Enclosures:
[im105.m4a ( Size: 20058650 )]

posted by James Robertson

 Share Tweet This

podcast

IM 105: Skinny

December 2, 2012 13:13:19.227

Welcome to episode 105 of Independent Misinterpretations - a Smalltalk and dynamic language oriented podcast with James Robertson and David Buck.

This week we have another recording from the STIC 2012 conference - Travis Griggs (formerly of Cincom) talking about the "Skinny" UI initiative. If you would rather watch the video, head on over to the STIC website.

You can subscribe to the podcast in iTunes (or any other podcatching software) using this feed directly or in iTunes with this one.

To listen now, you can either download the mp3 edition, or the AAC edition. The AAC edition comes with chapter markers. You can subscribe to either edition of the podcast directly in iTunes; just search for Smalltalk and look in the Podcast results. You can subscribe to the mp3 edition directly using this feed, or the AAC edition using this feed using any podcatching software. You can also download the podcast in ogg format.

If you like the music we use, please visit Josh Woodward's site. We use the song Troublemaker for our intro/outro music. I'm sure he'd appreciate your support!

If you have feedback, send it to jarober@gmail.com - or visit us on Facebook - you can subscribe in iTunes using this iTunes enabled feed.. If you enjoy the podcast, pass the word - we would love to have more people hear about Smalltalk!

Technorati Tags: , ,

Enclosures:
[im105.mp3 ( Size: 14623167 )]

posted by James Robertson

 Share Tweet This

itNews

iTunes 11 - Not that Hard

December 1, 2012 12:37:47.065

In the midst of a long post about how iTunes is (or should be) an outliner, Dave Winer makes it clear that he hasn't really tried anything with it:

Anyway, luckily if you know what pref to turn on, you can get iTunes working again. The way it ships you can't use it to move content onto an iPad or iPod. Not exactly a minor function of iTunes.

Gosh, I plugged my iPad into my Mac a few minutes ago, and - just like any other version of iTunes I've ever seen - it started synching. Backing apps up, and moving music I've bought since the last synch over to the iPad. The preference Winer speaks of seems to involve the way iTunes deals with a device it hasn't seen before, and for that, I'd say "automatic synching" is the wrong answer. The last thing you want is to plug your wife's iPod in to charge, and have her lose all of her music off it when you went on auto-pilot.

Meanwhile, Farhad Manjoo demonstrates that he's not really done more than read other people rant about the software:

Anyway, so iTunes 11 finally hit the Internet today. If you start downloading it immediately, you might be able to get it up and running by the time the ball drops over Times Square. People always wonder why this is—why a simple music player weighs in at around 90 megabytes and requires many long minutes to install and “prepare” your library before it becomes functional. Don’t ask questions—this is just what you get with iTunes. Each new upgrade brings more suckage into your computer.

I'm not about to praise iTunes - it does tend to get bigger and slower with each release. However, this release seems to be a bit different. The installation was fast, and when I started iTunes up, I didn't see the dread "converting library" that I usually see. Instead, my music was right in front of me, ready to play. I get the distinct feeling that Winer and Manjoo dusted off their reviews of the last release of iTunes, slapped a new date on it, and let fly.

Technorati Tags: ,

posted by James Robertson

 Share Tweet This

st4u

ST 4U 315: Writing Collections with Streams

November 30, 2012 10:09:51.520

Today's Smalltalk 4 You looks at using Streams to write collections (not Strings). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Write Streams.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll have a look at writing arbitrary collections via streams. In Smalltalk, streams can be used to write collections of objects (not just strings). For example: here we set up a ByteArray, and then write to it:


collection := ByteArray new: 5.
stream := collection writeStream.
stream nextPut: 10.
stream nextPut: 55.
stream nextPut: 10000.
^collection

If you inspect the results, you'll see the ByteArray #[10 55 0 0 0]. You can also create collections of disparate objects:


collection2 := Array new: 5.
stream2 := collection2 writeStream.
stream2 nextPut: 'one'.
stream2 nextPut: (1/3).
^collection2

Inspecting the results will give you the collection #('one' (1/3)) - the last object, if you look in the inspector, is a fraction.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: ,

Enclosures:
[st4u315-iPhone.m4v ( Size: 2693564 )]

posted by James Robertson

 Share Tweet This