Cocoa talk at UT on April 13th, 2005



Here is the link to the UT Mac atx group. I'm going to be talking about X-Code and Cocoa programming on the Mac and time permitting, I'll cover other stuff too.

 

Ruby tools vs. Java tools... - History is a guide....



In response to this link: "tools_matter_don_t_handicap"; about Ruby tools not being up to where Java tools are I posted this comment which I thought others may want to read as well. One thing to know is that the first part was an answer to the inference made in his post that you needed static typing to do refactoring tools.

My reply:

Re-factoring has nothing to do with typing and the worlds first Re-factoring tools were created for Smalltalk and actually before that Lisp (those seem to be forgotten by most).

Tools is an area that Java is way ahead in now, but remember, when Java started it had nothing as well and it took 5 years to get to the first really good environments. (First JBuilder and then a few years later Eclipse and IDEA).

Additionally, Ruby is a much more powerful language in terms of features so there are those of us who trade off the tools aspect for the power. Much like Lisp or Smalltalk programmers do. But this is changing. Ruby plug-ins exist for Eclipse, Ruby is gaining more attention from those who lead the charge to Java and are now looking for the "Next Big Thing" and just like with Java, Ruby has the possiblity to grow to encompase things you see as problems now, much as Java has.

Don't lock yourself out of using a great new tool because of it's short term problems, especially if those problems are being addressed and those who have a history of picking the next thing seem to be excited as well.

Java as a technology is mature now and much like C++, you will not see a lot of new things being added to it any more. Not at the language level. Libraries and things, but as a language Java is all but done. That being said, you've reached it's expressive power and as a community you are now adding to it by using meta expressions thru the annotations in 1.5. While flexible, this is not as powerful as actually being able to extend the language. Java tools will continue to get better and frameworks and libraries are continuing to grow, but there is also a trend towards lighter, smallter, faster development. Ruby is in that vein as well. Lighter, faster, smaller. And you will find that there are many powerful tools for writing code and debugging. They just don't have a pretty GUI on top of them.

 

Horizontal Filing & Procrastination - The humor and realities



I was reading on Edward Tufte's site today at this link, Thinking and Paper and I came across this link about Vertical Organizers. It so described how I file things and organize. Oh to feel like your not alone, that there are others who see the world as you do..... This one about procrastination was equally as humorous, but again I identify with it so much.

 

Former supercomputer designer now designing for China



On CNET today I read this article:

http://news.com.com/Have+supercomputer%2C+will+travel/2100-7337_3-5433941.html?tag=nefd.hed


Then I think to myself, "Isn't this stuff not supposed to be exported?", then I think again to myself, "Isn't this treason?"

Wonder what the Justice Department and all the other departments that are supposed to prevent this stuff from getting overseas think?

Makes you wonder about how we are willing to export everything and if this person is a American citizen, why and the heck is he willing to sell to China. Guess citizenship means less than money or history.

 

William Shatner's new Album



Very interesting - very unusual and neat at the same time.

Here it here:

http://www.shoutfactory.com/williamshatner/


Read about it on CNN also:

http://www.cnn.com/2004/SHOWBIZ/Music/10/18/music.william.shatner.ap/

 

Back to the Future



On re-reading my last post to fix spelling errors, etc., I was reminded of the Naked objects approach that some people are trying. Those systems try to give the feel of everything being an object to the users of those systems. They do it in languages environments that don't themselves expose all the objects in the systems nor do they fully reach the full effect of Smalltalk and Lisp in this respect. Naked objects is about a behavioral and instance oriented programming of systems. Instance views are much like the Smalltalk inspectors that also show behaviors that are exposed. While nice and a neat approach, it is a poor substitute for the real thing. It is nice to see many people truly seeing the power of the behavioral approach of design and the power of manipulating instances and not just seeing them as data to be passed to controllers. Anyway, before I go on my rants further, I'll just recommend two books that deal with behavior approaches to design and implementation.

Books

Object Thinking
http://www.amazon.com/exec/obidos/ASIN/0735619654/qid=1093575908/sr=ka-1/ref=pd_ka_1/002-0984446-9300818

Object Design: Roles, Responsibilities, and Collaborations
http://www.amazon.com/exec/obidos/tg/detail/-/0201379430/qid=1093576171/sr=1-1/ref=sr_1_1/002-0984446-9300818?v=glance&s=books

Anyway, both of these books are about behavioral approaches to OO development and both also are very challenging for any programmer OO or not about how to go about doing software design and development. The OO world is slowly recreating the past environments and rediscovering many things. Articles are read again, papers are re-examined by those new to the computing world, saying things like, "I didn't know they could do that then!" We are now recreating what has already been created, relearning what has already been learned... this time though, the lesson of history repeating itself is truly in our favor. Our machines are faster, the learners are more open and many an experiment has proven out that the ways of bygone wizards really were the magic we were looking for. They did know something and they were, "Ahead of there time!"

Truly is a case of "Back to the Future"

Happy reading and till next time, may all your objects be pure....

 

Smalltalk - not like other guys. It's an environment and Everything, Everything is an Object......


Smalltalk is different, everythings an object. It's not file based, you can't just go around defining a function. Learning Smalltalk also means learning the environment. Much like learning Eclipse or NetBeans.

Earlier today I read this weblog:

http://www.mycgiserver.com/~gpiancastelli/blog/archives/000075.html

I repeat: "Smalltalk is different, everythings an object. It's not file based, you can't just go around defining a function," Methods must be attached to a class (or an instance). Smalltalk is different, it's powerful, and foreign to most programmers, because most of us are file oriented and not truely object oriented. We create what is supposed to be object oriented code in a file oriented world. Smalltalk isn't that way. You add methods to real classes that are instances of a Metaclass. Your code is an object and even the text you type in when selected and inspected give an object back and you can ask the editor your using to compile the code, run it and give you back the instances, or you can select parts of the text to see what types of objects they are. 5@5 being an example. Inspect it and you'll find out it's a Point instance. Read more to see how I tried to explain that to someone confused about Squeak/Smalltalk and how I tried to help him realize that OO isn't just a language, but when taken to it's logical extent it is the environment, and everything in it.....

In the post he mentioned:

" First surprise: you actually have to select the code you would like to be executed"

This is true, it is weird at first, but when you look at how everything works in the Smalltalk/Squeak world, you realize, that you always select something, then do something to it. This is 100% object oriented. You select the receiver and then send it a message. In this case you selected some text in the Workspace window. You then send the Workspace window instance a message to "do it". This causes the Workspace window instance to get the selected text, message the Compiler class(es) and then to execute the resulting compiled code and then then to display the result back in the Workspace . All very natural. Tie that to the fact that you can also select any object and 'inspect it', etc. and you can see that you treat everything as an object.

Now when you mentioned in the same article that your always on the lookout for a better OO language than Java, you shouldn't have to look very far. In Java not everything is an object, Java has all kinds of special syntax and constructs that have no known class in the system, etc. In other OO languages that are available, these issues are less so or do not exist at all.

I could go into it further from a language point of view, or a pure OO point of view, but I don't think you may want to read the diatribe that would be the result. But you have found one of the few languages where everything really is an object. Don't write it off b/c it's syntax and operation seem foreign. Believe me, once you get used to letting go what you are used to in terms of special cases and rules and notations, and truly embrace a fully OO system, you will never see the OO world the same way again, nor will you see programming the same way.

Smalltalk is different just as Lisp is different, but they do share something. They are both built on a fundamental base set of elements. Smalltalk - everything is an object, Lisp - everything is a list or atom. Other languages do not have that purity, they try and mix and match competing language paradigms and with them goals and syntactical ideas. This most often ends in large and apparent weaknesses as you try and grow the language. Growth and adoption of new ideas in Lisp and Smalltalk does not tend to cause the core paradigms to falter. This speaks to the power of the languages and to the base with which they were built upon.

Finally, your problems with getting snippets of code to run? Well, in Smalltalk, because everything is an object, you must add methods to classes. You can not just define "foo: n .... " and then select it and run.
You can create some local variables, assign them a instance of the block context object and then call it over and over again with the value: message. To define a method, you must define it on a class to do that, you either use a class browser, and then type the method in the method pane and the accept that method, which will cause it to get added to the class. To see the code for this open a class browser and then look at the 'Browser' class specifically a method named 'compileMessage:notifying:'. In it you will see a message called ' defineMessageFrom:notifying:' which is where the real work gets done. Anyway, you don't define methods/functions without attaching them to a class in Smalltalk. Everything is an object and every method is attached to a class. In Ruby, when you define a method and don't specifiy what class it goes to, it gets defined in the global context, if I remember right, as an annonymous function. Smalltalk doesn't do that.

Now for showing and describing how to do what you wanted to do in the Workspace you had.


Step by step to getting aquainted with the Workspace and the fact that everything is an object.

Type in the following code in the Workspace (don't include the dashed lines)
------------------------------------------

| s block |

s := 1.
block := [:i | s := s + i].

block value: 4.

------------------------------------------

Now select all that code. Now click on your middle mouse button (this can vary depending on your OS and number of mouse buttons. (Smalltalk assumes a 3 button mouse and if you don't have that, it uses ctrl, alt and meta/option keys with the mouse buttons that you do have to simulate 3 buttons) Anyway, the popup menu you are looking for will have these items: 'do it, print it, inspect it' as well as others.
You want to choose 'print it'. This will cause the code you selected to be compilied and run and the result printed at the point in the workspace where the end of your selection was. You should see the number '5' as your result.

Now replace the '4' with an '8' so that the last line reads:

'block value: 8'.

Again, select the all the code and 'print it'. You should see '9'.

Now I want you to replace that last line with this line of code:

(1 to: 10) collect: [:each | block value: each].

So that the code looks like so: (again, not the dashes)
------------------------------------------
| s block |

s := 1.
block := [:i | s := s + i].

(1 to: 10) collect: [:each | block value: each].
------------------------------------------

Select the code and then do a 'print it'.
You should see this:
#(2 4 7 11 16 22 29 37 46 56)

You've just run the block over and over again and collected the results in an array instance.

Select the code again (just the code not the array it printed out for you) and this time choose 'inspect it'. Now you can see the array instance object. Now I'd like you to just select the code '(1 to: 10)' and 'inspect it". You will see that it is an instance of the Interval class. Pretty cool. Even cooler, select '[:each | block value: each]' and inspect it. You'll see this is a BlockContext object. This is the equivalent of a Lisp lambda function or a block in Ruby.

Type in this:

--------------------- (not the dashes)

Float

---------------------

Select that and do a 'inspect it' on it. Now you are looking at the Float class instance. Classes are instance of another type of class in the system. In the Float class you can see the instance variables that instances will have when created, methods that that class has, etc. Pretty cool.


Things get ever better. You can open up a Browser by choosing 'open' off the 'Desktop' menu. In the Browser, you can add a class and etc., etc., etc. You can see the Compiler class, MetaClass class, etc. Note too, that the class that bootstraps Object, Class, MetaClass and ClassDescription classes all together is the Behavior class. It and those previously mentioned classes do and are the core of Smalltalk at the language level, but again, because everything is an object, there is so much there to explore.

You were very right when you stated that Smalltalk was an environment. It is not file oriented like most all the other stuff you are used too. (as is 99% of the programmer base), but once you get used to the fact that you are in a world where everything is an object and everything is oriented to select something and do something to it, etc. it really is powerful. Some people never get used to it though on there own and it requires someone to mentor them to help the find stuff or to just say, this is how you do it. When things are different it is always like that, programming languages as well as other areas of life.


You may also want to look at this tutorial. Smalltalk for Java programmers is what it was under on Google.

http://daitanmarks.sourceforge.net/or/squeak/squeak_tutorial-2.html#ss2.2

Final Thoughts

Having experienced the joy in programming in both the Lisp and Smalltalk worlds, it is very easy to get used to the power of being able to view, inspect, browse and change everything in the system. One of these days, I hope to see the OS's that we have begin to come close to what we had in the past with Lisp machines and Smalltalk systems. Once OS's include dynamic languages in the core and expose everything as real objects that those dynamic languages can work with in a concrete way, we will be close. The power is unbelievable and allows so much. It is very great to see the current trend of the old guard of C++ and type safety starting to really embrace dynamic systems and to admit that unit testing and test-driven development really are just as stable in reality and have quicker turn-around time and more power per code unit. This brings our future closer to where those in our past have already been. Kay, McCarthy, Moon, Kaehler and all those who used and pushed dynamic languages and systems have seen and invented the future, and that future is fully dynamic.

Thanks for reading and come back soon!

 

Thu - August 26, 2004

Now working at DFS full-time and other thoughts!



I'm now at Dell full-time. Doing some good stuff and enjoying my work very much. I'm the proud father of a first grader and am excited to see him learn throughout the new school-year ahead.

Hey to all my friends – Susan, Dick, Blaine, Bill, Kevy, Lisa, Wayne, Norman, Arval, Sunny, Stacie, Geoff, and others for whom my memory is slipping as I write this at 2:22 am.

Vote - participate in democracy - steer your country.

Pay it Forward!

and remember – "You are your brothers keeper" To be able to do that as a country, we need to vote, we need to work together and we need to have goals and work together, because more and more people don't like us no matter whether we are Democrats or Republicans. We are Americans and we need to band together as one.

Posted at 02:25 AM    

Fri - July 9, 2004

Been awhile


Long time since I wrote... been busy...

I've finally moved. New apartment is very big. 1500 sq. ft. for a me alone most of the time is big. But when my son is over, he's got his own room, a play room and he really likes it that he doesn't have to pick up his train or army men when we go out. They are just the way he left them when we get home. I like that too. He has his area....

Finished up my contract at Tivoli and am now working a contract at Dell Financial Systems doing WebLogic 8.1 developement and some .NET coding as well in C#.

Have had quite a few people tell me I should write a book the past 2 months. I'm seriously considering it. Several topics come to mind. For those of you who know me, give me feedback on what you think I may be best at writing about....

So much news from last few months to Rant about, but my son has just told me he wants to go outside and play. I took the day off for just that purpose, so now is a good time. He was watching a cartoon. Will write more later....

Sam

Posted at 01:51 PM    

Sat - April 17, 2004

Moving into new apartment.....


Moving in but still need to get phone, cable, etc. But I'm taking my time.

Moving in but still need to get phone, cable, etc. But I'm taking my time. Mostly because work is so busy and so are my extra projects.

More soon....

Posted at 06:44 PM    

Prototypical OO System implementation via Class based OO language????


Can a class based OO language be used to implement a prototypical OO system?

A friend of mine was wondering about Prototypical OO based systems. He asked what was different about them than class based systems and other things.

His Blog is at:
http://www.blainebuxton.com/weblog/blogger.html

Here's my answer(s)


First off, it is possible to use a class based OO system to implement a
prototypical OO system and vice versa. One of the very first Smalltalk
programs created at PARC was a prototypical OO system. ThingLab used
prototypical objects in it's domain space to do it's work, but it itself was
implemented with classes and prototypical objects at the same time. Part of
the SELF research idea to use prototypical objects was derived from the SELF
team having seen the ThingLab work. Link to ThingLab papers and version
ported to Squeak, including the original PARC paper:

http://www.2share.com/thinglab/ThingLab%20-%20index.html
http://www.cosc.canterbury.ac.nz/~wolfgang/NewHome/cosc414/projects/thinglabFolder/html/thinglab.html
http://minnow.cc.gatech.edu/squeak/607
http://portal.acm.org/citation.cfm?id=357147&jmp=references&dl=GUIDE&dl=ACM&CFID=11111111&CFTOKEN=2222222

As for what a prototypical OO language gives you that you don't get in a
class based one is conceptual purity and all messaging is based on
delegation. Classes are really about type definition and organization of
the instances of that type. With prototypes, you don't have a class. You
just create one instance that you clone over and over again. And all the
instances made from it know it. Your parent is whomever you cloned from.
Your parent has methods that you may not have, so instead of looking to a
class as something different or special, you end up with just the object you
cloned from. No differentiation is made.

In a prototypical world, you start with one bootstrap object that knows how
to add/remove/run methods on itself and how to delegate to it's parent if it
has one. From that, you can clone it (call it c1), add new attributes to
the new cloned object, add methods to that new cloned object, clone c1 to
make c2, etc. Now when you do cloned to get c1, c1's parent was the
bootstrapObject, when you cloned c2 it's parent was c1. So when you send a
message to c2, if it doesn't have it, it delegates the lookup to c1 which
then will delegate it to bootstrapObject if needed, etc.

There is no need for classes in this model. It is much more like nature.
All mammals share traits that they inherited by being fertilized from an egg
and sperm, but there really is no 'class' of mammals. That is a man made
idea for our organization to show that we saw that the DNA is common and
they have common traits, etc. From the outside it looks like that you are
inheriting from the class of mammal that you are (human lets say), but what
really happens in the reproduction process is that the DNA from the mother
and father are cloned by the RNA bands and combined together in a process.
This makes a new specific kind of instance much like if I had a multiple
parents clone, which is possible in a prototypical OO system as well.

I hope all this makes sense.... Let me summarize....
Prototypical OO systems are based on cloning and delegation. A much simpler
model based all in instances.

He followed up with this ?:

> I've got a question....How do you deal with cloning? For example, we have an
> object Poo with elements a,b, and c. Now, let's say they are all different
> other prototypes. When I ask for a new copy of Poo, does it do a deep copy
> or shallow? Or should I not have data elements in my prototypes? And have
> them dynamically generated by the instance on creation? I could see where
> prototypes could easily get mixed up and used as real objects. How do you
> prevent that?

I then answered with this:

Each prototypical language does this differently but at the core they do the same thing, just syntax is different really, but the just of it is, that when you clone you are creating a new empty object that points to the parent. You then can set any values you want. Your initial object is empty, but if you ask it for its' name, it will go to it's parent and see if that object has a name attribute, if so, it'll return that value. If you want your instance to have a different name, you set the name value and in your instance, a name attribute will be created and next time you ask for it, it will be found in you and returned.

So the clone, creates a blank instance that has it's parent ptr set. Now you can create shallow and deep copy methods for prototypes, so that when you 'copy' one you will get the same values already initialized. But that idea is different than cloning.

Cloning is giving you a new instance with the same shared values. Like a shallow copy, but you don't even have the attribute slots in your clone as long as you don't change them. The only thing you hold onto in your clone is what is different, what you want not to change if your parent changes, or what is new/special to you.

For example if you cloned from 'Jill' and you wanted to make sure that your pay rate would not change if her pay got increased, then when you cloned, you would make sure and set a pay rate attribute on your instance, such that when the lookup happened, it would find that value in you and not go over to 'Jill' to find the pay rate. Also, if your method of computing your taxes is different than Jills, then you would put a new taxCalc function on your instance.

Clones are the ultimate 'Flyweight' instances....

And to your last point, prototypes are real objects. Any real object can be a prototype. I don't create an object unless I'm going to use it. For example in a running system, I wouldn't create an Employee instance unless I was going to use it. Employee has a parent of Object. I create an Employee and it is empty except for it's parent pointer. I then set it's name to "Bob", it's age to "23" and so on. When I'm done I've got an instance of Employee. I can then add methods to this instance... Etc.

Now, with that said, is there such a thing as something similar to a class? Yes, you can have that and JavaScript in it's implementation of prototypical objects has this idea. That you have a prototypical object that all instances of a particular type/class are created from. JS bridges the two worlds with this concept and has made it easier for people to learn. It also allows them to add attributes to all instances existing instances after the fact. This is neat and you would probably want that in your prototypical system and "Self" can do this and so could NewtonScript, but it is not a requirement. You can have a very, very simple system like I've described and that is the basis of what these other ones do.

Here is my favorite book on Prototypical OO development:

http://www.amazon.com/exec/obidos/tg/detail/-/3540564691/qid=1063996822/sr=1-2/ref=sr_1_2/002-6293176-8376007?v=glance

That idea of a Prototypical object behaving like a class and you cloning from it and not using it as an instance is how JavaScript exposes prototypes. This gives the illusion of classes. And like I said, you can use that illusion to go and add an attribute to all the instances. You do so by adding it to the prototype that they all cloned from.

This is exactly what I told you. You add the attribute to the parent where you want all the instances to have it. The parent can be any object. JavaScript just shows it as being something more like a class. In part, b/c they have a special constructor which does the clone and initialization at the same time.... But notice it's a function.... The function creates an instance of object and then sets variables.... No parent..... (See second link) To set the parent in JS you have to set the instances prototype attribute.... (See third link and read code carefully)

So for JS to give you what I've talked about, you use a constructor (clone and init) and set your prototype attribute (parent). And attr/functions can be added to anyone.


JavaScript 1.5 reference
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/obj.html#1008302

A good reference for JS and in particular Object (*** Make sure and look at this ***)
http://javascript-reference.info/#object
http://javascript-reference.info/#oop

http://research.sun.com/research/self/release_4.0/Self-4.0/Tutorial/Language/Prototypes/Prototypes.html

Read from that page for the next few pages and it discusses it very well.

Posted at 06:39 PM    

One of the most important things anyone has ever said to me.



A friend of mine (Dick Norton) told me this once and another friend (Susan Estringle) said it in another way but to the same meaning.

I won't go into why this was important, but just that it has been several times in life when I've faced tough times or needed to look at myself in the mirror to see "What or Who is this man in the mirror?"

Anyway, the quote....

"Your self worth should not be based on what others think of you and what you do, but on what you think of you and what you can do or will do!"

Needless to say, it challenges you when you think about it, b/c it places the responsibility for how you feel about yourself on you and allows no room for you to derive worth from what others think or do concerning you. Either you like you or you don't and if you don't, change it.

In the end, if you like yourself, you will find that others like you too, maybe not all of those you hoped, but enough. But the biggest thing of all is that you've not sold yourself out, but found yourself. Many people and religions strive to do this. This is not to say that religion doesn't matter or God isn't real, but even God doesn't force you to like yourself. It's your choice, your quest if you will (innate as it is, I've not known to many people who don't want to find themselves and what there here for....)

Anyway, here's to Dick and Susan for telling me something so important and something that was life changing for me....

With humility....

Sam

Posted at 06:33 PM    


©