The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Misconceptions on Namespaces

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Misconceptions on Namespaces Posted: Apr 18, 2009 10:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Misconceptions on Namespaces
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

The topic of namespaces in Cincom Smalltalk (this now applies to both VisualWorks and ObjectStudio) has come up again. A new blog popped up recently, about the alleged faults of Seaside. Now, I'm not going to claim that Seaside is a perfect web framework - no large body of work is ever perfect, and Seaside, like any such work, has warts. Overall, I think it's a great system, which is why I pushed to have Cincom start supporting it in our Smalltalk products. When you follow the link through though, be aware - while you'll find a few good suggestions, it's hard to keep them in mind given the general level of anger and obnoxiousness on display.

Anyway

A few days ago, this post was made on namespaces in VW, with this assertion:

In VisualWorks accessing classes by their namespaces bindings is very slow!

Certainly that used to be the case; if you go back to the 5i releases, and I think the early 7.x releases, resolving dotted namespaces could be slow. That hasn't been the case for awhile though. Here's a small test I put together, with two classes:


Smalltalk.MySpace defineClass: #MyTester
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: 'value '
	classInstanceVariableNames: ''
	imports: ''
	category: ''


Smalltalk defineClass: #MyTester2
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: 'value '
	classInstanceVariableNames: ''
	imports: ''
	category: ''

I gave them both the same "doWork" method, which takes awhile to run:


value := 10000 factorial

Then, I used another class (in the Smalltalk namespace) to run this test:


	| val1 val2 |
	MySpace.MyTester new doWork.
	MyTester2 new doWork.
	val1 := Time millisecondsToRun: [100 timesRepeat: [MySpace.MyTester new doWork]].
	val2 := Time millisecondsToRun: [100 timesRepeat: [MyTester2 new doWork]].

	Transcript show: 'With namespace: ', val1 printString; cr.
	Transcript show: 'Without namespace: ', val2 printString; cr.

What were the results? The time to run the test using the dotted namespace notation (in milliseconds): 54535. Running the same test without the dotted lookup: 54643.

That's a small enough difference that I can't draw any conclusion beyond this: dotted namespace lookups aren't actually slow, and it makes a lot of sense to use namespaces when working in a Smalltalk dialect that has them - it makes for simpler naming conventions.

This shouldn't be construed as meaning that I want to see the Seaside core team push for namespaces in Squeak and start using them; that's up to them, and I don't really have an opinion on that. My sole point here is to knock down the assertion that namespace lookups in VisualWorks (or ObjectStudio) are slow. They aren't.

Technorati Tags: , ,

Read: Misconceptions on Namespaces

Topic: Dead Tech Previous Topic   Next Topic Topic: Making the Content More Searchable

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use