Pharo and Namespaces

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

Jan Vrany
On 27/06/12 18:05, Sean P. DeNigris wrote:
>
> Germán Leiva wrote
>>
>> OT: Late binding rocks!
>>
>
> Yes, and the latest binding would be to lookup at runtime. I have no idea
> what the performance hit would be, or if we would use all that power, but
> the idea is exciting :)

With proper caching at VM level, the performance overhead would be
negligible.

Typically, when a class is accessed, something like PUSH_GLOBAL insn
is generated. One may change semantics of this insns to do a proper
message send back, effectively doing something like (for instance)
   self class resolveGlobalByName: globalName

This is very flexible and allows for very nice tricks.

This can be further performance-optimized. One may use a sort of an
inline  cache keeping a pair - function pointer to a function that
returns desired value and a "cached data".
Initially, the function would be initialized to a function that calls
back smalltalk code like the one above. However, the smalltalk
code __may__ decide that the resolution is "stable" (i.e., next time the
code runs, same class should be returned) and fill the cache. The
standard smalltalk resolve method then would look like

resolveGlobalByName: globalName cache: cache
    | v |
    v := Smalltalk at: v
    cache bindTo: v

where the cache is Smalltalk reflection object representing this
kind-of-inline cache.
When properly JITed, the cost of global access would the same as
before (except of the very first one) - ideally just one memory
fetch.

Cheers, Jan

>
> --
> View this message in context: http://forum.world.st/Pharo-and-Namespaces-tp4636635p4636978.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

Sean P. DeNigris
Administrator
Jan Vrany-3 wrote
With proper caching at VM level, the performance overhead would be
negligible.
Good to know. Thanks!
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

Igor Stasenko
In reply to this post by Jan Vrany
Late binding, yes. But please stop using "Global" word :)

The Global word pins you to a little piece of dust floating in
gazillion times bigger space.

Think about it every time you think you found solution, which requires
having some "global" state/functionality in your model.
:)

On 27 June 2012 19:47, Jan Vrany <[hidden email]> wrote:

> On 27/06/12 18:05, Sean P. DeNigris wrote:
>>
>>
>> Germán Leiva wrote
>>>
>>>
>>> OT: Late binding rocks!
>>>
>>
>> Yes, and the latest binding would be to lookup at runtime. I have no idea
>> what the performance hit would be, or if we would use all that power, but
>> the idea is exciting :)
>
>
> With proper caching at VM level, the performance overhead would be
> negligible.
>
> Typically, when a class is accessed, something like PUSH_GLOBAL insn
> is generated. One may change semantics of this insns to do a proper
> message send back, effectively doing something like (for instance)
>  self class resolveGlobalByName: globalName
>
> This is very flexible and allows for very nice tricks.
>
> This can be further performance-optimized. One may use a sort of an inline
>  cache keeping a pair - function pointer to a function that
> returns desired value and a "cached data".
> Initially, the function would be initialized to a function that calls back
> smalltalk code like the one above. However, the smalltalk
> code __may__ decide that the resolution is "stable" (i.e., next time the
> code runs, same class should be returned) and fill the cache. The standard
> smalltalk resolve method then would look like
>
> resolveGlobalByName: globalName cache: cache
>   | v |
>   v := Smalltalk at: v
>   cache bindTo: v
>
> where the cache is Smalltalk reflection object representing this
> kind-of-inline cache.
> When properly JITed, the cost of global access would the same as
> before (except of the very first one) - ideally just one memory
> fetch.
>
> Cheers, Jan
>
>
>>
>> --
>> View this message in context:
>> http://forum.world.st/Pharo-and-Namespaces-tp4636635p4636978.html
>> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>>
>>
>
>
>



--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

Igor Stasenko
I want to second Stef's word.
Coming from C++ world with namespaces at some point i felt like i
really miss that.
But my practice shows that what i miss is not a mere syntactic sugar
or tool support of having multiple namespaces.
No.

What i miss is the true modular system, where modules are first-class
components of it and know how to connect and interact between each
other.
If you look at the problem at this angle, you will see that being able
to define own binding of some name(s) local to the module scope is
just a tiny bit of a larger picture.


--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

View from an outsider [was Re: Pharo and Namespaces]

Patrik Sundberg
In reply to this post by Stéphane Ducasse
On Jun 27, 2012; 4:27pm, Stephane Ducasse wrote:

> On Jun 27, 2012, at 4:44 PM, James Foster wrote:
>
>> Stef,
>>
>> I'm sorry to hear about your burnout and I understand that you are not prepared to seriously discuss the issues that others have raised. I hope when the issue is raised again (it does seem to come up every year or so!) we can correct some of the misunderstandings that exist.
>
>yes we are discussing regularly that topic and Camille is writing a master where all the points are discussed and summarized with pros and cons.
>Now for 20 we should finish all the open tracks we have.
>
>Stef

Hi,

A comment from a complete outsider:

I've been following pharo on the side for the last year or so and am very impressed by both smalltalk as a language and pharo as an implementation. I am not trying to even voice an opinion of what's right to focus on for pharo project since that's not my place having nothing invested in it (so far, gearing up to add some pharo parts to my world). It did strike me that it could be interesting to hear the view from an outsider on what would draw interest and more users/developers to the project. Be it inspiration for pharo 2.1 or 3.0 or 4.0 :)

I'll first state a belief: I believe that the explosive growth of ruby and python communities to some extent depended on good package management systems making it very easy for people to publish/share/collaborate on packages. A killer app to kick it off, but one needs easy collaboration to grow.

On the back of that I'm very excited to see the following pharo efforts being close to coming together into something great:
1. Stripped down core kernel and bootstrap project
2. Fuel for fast serialization and deserialization (can be used for binary packages)
3. FileTree
4. Metacello scripting API
5. Metacella Git/Github integration
6. Tools such as Versionner on top of Metacello for ease of use
7. Namespaces/Environments

In terms of getting a lot of people much more comfortable diving into the image world I think that list have great promise. If one can easily start with a minimal kernel, have some simple tooling such that one from e.g. the commandline can bootstrap it via Metacello configurations that pulls in both the parts of the base system one needs and project/application dependencies to get a working image for both development and deployment (via metacello groups for example) it has 2 benefits:
1. Reproducible process which means automation and testing a lot easier for projects (jenkins etc for applications), as well as deployment
2. It's a workflow that's quite similar to how one would for example work with ruby, rubygems and bundler (on a high level). Familiarity draws in more people - it shouldn't be at the cost of a good system, but if one can get both it's a definite positive.

Once project/appliation bootstrapped like that and one is working in the image tools like Versionner and Metacello with git/github intregration will provide an excellent workflow for collaboration (push/pull/merge/branch/etc). Again I see 2 benefits:
1. Functionally solid (see e.g. the Practical Git for Smalltalk presentation by Dale)
2. It's familiar to outsiders and has a good chance of attracting new people. Even if one has great in image tooling it's very good to be able to be a "lazy" follower of a package/project via e.g. github (RSS feeds for changes, nice diffs accessible from any web browser, pull requests, graphical representation of branches etc etc). I for example would be much more likely to have learnt more on pharo implementation if I could have followed it on github for the last year.

When collaboration increases and people share a lot of packages via e.g. git & github one tend to see exponential reuse and number of new packages created (on the back of what exists), and at least the ruby experience is the average number of package dependencies for a project increases.

It's in that point of view I'm seeing namespaces/environments as an important addition. Prefixing names is doable and at a non-human level you can accomplish most of the same things, but on a human level I see it as important - and it gets more important the more collaboration and reuse of existing packages one accomplishes. A non-technical consideration is that developers these days kind of expects some form of namespacing to exist and not seeing it available is something to deter some possible adopters (rightly or wrongly, many times they wouldn't need namespaces/environments, but many may not reflect too deeply on that). I know I twigged at first seeing prefixing being used instead of some form of namespaces.

From that this perspective (namespaces/environments more important as more people are, reuse and collaboration happens) it seems quite sensible to put it after the other things on the todo list (as long as it doesn't goes away completely).

Hopefully that's of some interest :)

I'll continue my journey towards using pharo more - we shall see how it works out for me!

Regards,
Patrik
Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

jgfoster
In reply to this post by Stéphane Ducasse
Stef,

Thanks for taking time at ESUG to listen and learn more about our namespace proposal. I believe that we have cleared up some of the misconceptions surrounding this complex topic.

James

On Jun 27, 2012, at 8:27 AM, Stéphane Ducasse wrote:

>
> On Jun 27, 2012, at 4:44 PM, James Foster wrote:
>
>> Stef,
>>
>> I'm sorry to hear about your burnout and I understand that you are not prepared to seriously discuss the issues that others have raised. I hope when the issue is raised again (it does seem to come up every year or so!) we can correct some of the misunderstandings that exist.
>
> yes we are discussing regularly that topic and Camille is writing a master where all the points are discussed and summarized with pros and cons.
> Now for 20 we should finish all the open tracks we have.
>
> Stef
>
>>
>> Best wishes,
>>
>> James
>>
>> On Jun 27, 2012, at 12:08 AM, Stéphane Ducasse wrote:
>>
>>> James
>>>
>>> sorry but I'm at home stopped for 10 days because of a burnout (linked partly to pharo and the business I want to spawn for the community).
>>> We talked endlessly about namespaces and so far we lived happily without. Right now I will not talk about that. Read subsystem the paper of wirfs-brock
>>> if you want to see what I would prefer to have. But we need to have a scientific approach to evaluate.
>>> And yes I read the implementation two years ago.
>>> Finally did you see the list of topics that I mention?
>>> - do you want to help in any of them to make pharo better?
>>> because we have to get them first and I need all my energy for them.
>>>
>>> Stef
>>>
>>>
>>> On Jun 27, 2012, at 12:25 AM, James Foster wrote:
>>>
>>>> On Jun 26, 2012, at 12:51 PM, Stéphane Ducasse wrote:
>>>>
>>>>> On Jun 26, 2012, at 9:30 PM, James Foster wrote:
>>>>>
>>>>>> On Jun 26, 2012, at 11:19 AM, Stéphane Ducasse wrote:
>>>>>>
>>>>>>>>>> What happened to the project from Germán Leiva
>>>>>>>>>> http://www.youtube.com/watch?v=n4I7fSVNX2A
>>>>>>>>>
>>>>>>>>> we do not want class level namespace because this is the mess
>>>>>>>>
>>>>>>>> As the sponsor for Germán's project, I have some interest in this topic. Stéphane has said a couple times that it is wrong but has never taken time to explain his objections.
>>>>>>>
>>>>>>> We do not want to have class name resolution at the granularity of a class.
>>>>>>
>>>>>> And are you saying this because you think Germán's implementation does this?
>>>>>>
>>>>>>> Why because it means that in the same package reading the code containing a class Foo could be a different one.
>>>>>
>>>>>>> Why because it means that in the same package, reading the code containing a class Foo could be a different one.
>>>>>  ^^^^^
>>>>>
>>>>> Class level namespace import means that in a given class, a method accessing the variable Foo may end up pointing to another class Foo in a class in the same package importing another namespace.
>>>>
>>>> I still don't understand the definition. What do you mean by "another class Foo in a class." How can a class be in a class? Is Foo defined in two packages? Is the method on the class Foo? Should the name be resolved to the Foo in the package containing the method or to another Foo? Perhaps it would help if you named the sample classes, packages, and methods.
>>>>
>>>> Are you saying that if the namespace is allowed to be defined (or refined) at any level other than the package, then it is lumped into the bucket called "class level namespace import"?
>>>>
>>>>>> I don't understand your example. I don't know what you mean by "package reading the code." Are you describing a package that defines classes Foo and Bar, and a method in a class Bar that references the Foo in the same package? Are you providing this example because you think Germán's implementation does not support this use case?
>>>>>
>>>>> No
>>>>> I just say that changing binding of variables at the class level is not a good granularity. I do not want to have
>>>>>
>>>>> Object subclass: #NameOfSubclass
>>>>> instanceVariableNames: ''
>>>>> classVariableNames: ''
>>>>> poolDictionaries: ''
>>>>> category: 'Bob'
>>>>>>>> environment:
>>>>
>>>> Is it your impression that Germán's implementation requires this? If so, on what do you base that understanding? Have you looked at the code?
>>>>
>>>>>>> I'm saying that since years.
>>>>>>
>>>>>> I agree you have been saying that Germán's implementation isn't what you want. I just don't understand what you don't like about it.
>>>>>
>>>>> because this is a class level import.
>>>>
>>>> I still don't know what you mean by "class level import" or why you think Germán's implementation fits your definition.
>>>>
>>>>>> Name resolution of all variables (including Globals, of which Classes are a subset) should be part of a method compile. At the time a method is compiled, an 'environment' should be provided to the compiler that indicates how global name resolution should occur.
>>>>>
>>>>> Usually this is the class of the method.
>>>>
>>>> By "Usually" do you mean in pre-namespace Pharo? That is, the class is one of the factors that the compiler considers in doing name lookup? Is the "usual" approach good? Would it still be a factor considered by the compiler in an environment namespace regime?
>>>>
>>>>>> This is a tools issue and it should be possible to specify the default namespace environment for the method, for a method category, for a class, for a class category, for a package, and for the system as a whole.
>>>>>
>>>>> no this is a question of language design.
>>>>
>>>> Do you consider packages to be part of the language? I have always thought that one of the nice things about Smalltalk is how little of the development environment is actually part of the language. Being able to augment things through tools rather than changing the language seems to me to be a feature, not a bug.
>>>>
>>>>>> In addition, within a particular method it should be possible to explicitly reference a particular namespace environment, whether through syntax (dot or double colons)
>>>>>
>>>>> No we do not want to have that.
>>>>> We want import to be specified at the border: i.e. during module import. Inside a module the world is flat and as a developer I do not want to know that this Point is from Core when that one is from MyCore.
>>>>
>>>> By "I do not want to know" do you mean "I do not want to be required to specify" or do you mean "I do not want anyone else to be able to find out"? If I want to know (say, to build tools), would that be okay? If I'm willing to let you remain ignorant of a global's source would you be willing to let me be enlightened?
>>>>
>>>>> If I want both, at the module import level I write
>>>>>
>>>>> Import: Point from: core as: CorePoint;
>>>>> import: Point from: dev as: DevPoint;
>>>>
>>>> What object implements #'import:from:as:'?
>>>>
>>>>>> or through message sends (e.g., a Dictionary's #'at:' method). I prefer not to add new syntax and favor GemStone's implementation over that of VisualWorks.
>>>>>
>>>>> I dislike them both.
>>>>> A module should provide a certain level of encapsulation, else naming convention is good enough.
>>>>> Because else having namespace does not prevent you to have to declare that WA is not a namespace somebody else should use.
>>>>
>>>> You say that you "do not want to" allow code "to explicitly reference a particular namespace." Do you mean that arbitrary code should not be able to see a global that is not explicitly imported at package load time and that code should never be able to explicitly look at and manipulate namespaces. Really? This seems to me to be very much contrary to the existing spirit of reflection and introspection in Smalltalk and would make tools much more limited. I suspect that this is not really what you mean.
>>>>
>>>> I believe that a package should be allowed to provide a default environment, but I don't see the need to make it mandatory or exclusive. I believe that a class should be allowed to override the default environment, but I don't think it should be required.
>>>>
>>>> If a class is allowed (but not required) to override the default (provided by the package/module, for example), does that make it a "class level import" (and wrong, in your view)?
>>>>
>>>> What I understand from your statements so far is that Germán's approach allows too much flexibility (namespace can be specified not just at the package level but also at the class level and explicitly in code). You do not want to allow anyone to experiment with different levels of granularity. Is that it?
>>>>
>>>> Thanks for engaging in the discussion.
>>>>
>>>> James Foster
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Pharo and Namespaces

Tudor Girba-2
Great. And what is the conclusion? :)

Doru


On Mon, Sep 24, 2012 at 5:57 PM, James Foster <[hidden email]> wrote:

> Stef,
>
> Thanks for taking time at ESUG to listen and learn more about our namespace proposal. I believe that we have cleared up some of the misconceptions surrounding this complex topic.
>
> James
>
> On Jun 27, 2012, at 8:27 AM, Stéphane Ducasse wrote:
>
>>
>> On Jun 27, 2012, at 4:44 PM, James Foster wrote:
>>
>>> Stef,
>>>
>>> I'm sorry to hear about your burnout and I understand that you are not prepared to seriously discuss the issues that others have raised. I hope when the issue is raised again (it does seem to come up every year or so!) we can correct some of the misunderstandings that exist.
>>
>> yes we are discussing regularly that topic and Camille is writing a master where all the points are discussed and summarized with pros and cons.
>> Now for 20 we should finish all the open tracks we have.
>>
>> Stef
>>
>>>
>>> Best wishes,
>>>
>>> James
>>>
>>> On Jun 27, 2012, at 12:08 AM, Stéphane Ducasse wrote:
>>>
>>>> James
>>>>
>>>> sorry but I'm at home stopped for 10 days because of a burnout (linked partly to pharo and the business I want to spawn for the community).
>>>> We talked endlessly about namespaces and so far we lived happily without. Right now I will not talk about that. Read subsystem the paper of wirfs-brock
>>>> if you want to see what I would prefer to have. But we need to have a scientific approach to evaluate.
>>>> And yes I read the implementation two years ago.
>>>> Finally did you see the list of topics that I mention?
>>>>     - do you want to help in any of them to make pharo better?
>>>>     because we have to get them first and I need all my energy for them.
>>>>
>>>> Stef
>>>>
>>>>
>>>> On Jun 27, 2012, at 12:25 AM, James Foster wrote:
>>>>
>>>>> On Jun 26, 2012, at 12:51 PM, Stéphane Ducasse wrote:
>>>>>
>>>>>> On Jun 26, 2012, at 9:30 PM, James Foster wrote:
>>>>>>
>>>>>>> On Jun 26, 2012, at 11:19 AM, Stéphane Ducasse wrote:
>>>>>>>
>>>>>>>>>>> What happened to the project from Germán Leiva
>>>>>>>>>>> http://www.youtube.com/watch?v=n4I7fSVNX2A
>>>>>>>>>>
>>>>>>>>>> we do not want class level namespace because this is the mess
>>>>>>>>>
>>>>>>>>> As the sponsor for Germán's project, I have some interest in this topic. Stéphane has said a couple times that it is wrong but has never taken time to explain his objections.
>>>>>>>>
>>>>>>>> We do not want to have class name resolution at the granularity of a class.
>>>>>>>
>>>>>>> And are you saying this because you think Germán's implementation does this?
>>>>>>>
>>>>>>>> Why because it means that in the same package reading the code containing a class Foo could be a different one.
>>>>>>
>>>>>>>> Why because it means that in the same package, reading the code containing a class Foo could be a different one.
>>>>>>                                                                     ^^^^^
>>>>>>
>>>>>> Class level namespace import means that in a given class, a method accessing the variable Foo may end up pointing to another class Foo in a class in the same package importing another namespace.
>>>>>
>>>>> I still don't understand the definition. What do you mean by "another class Foo in a class." How can a class be in a class? Is Foo defined in two packages? Is the method on the class Foo? Should the name be resolved to the Foo in the package containing the method or to another Foo? Perhaps it would help if you named the sample classes, packages, and methods.
>>>>>
>>>>> Are you saying that if the namespace is allowed to be defined (or refined) at any level other than the package, then it is lumped into the bucket called "class level namespace import"?
>>>>>
>>>>>>> I don't understand your example. I don't know what you mean by "package reading the code." Are you describing a package that defines classes Foo and Bar, and a method in a class Bar that references the Foo in the same package? Are you providing this example because you think Germán's implementation does not support this use case?
>>>>>>
>>>>>> No
>>>>>> I just say that changing binding of variables at the class level is not a good granularity. I do not want to have
>>>>>>
>>>>>> Object subclass: #NameOfSubclass
>>>>>>   instanceVariableNames: ''
>>>>>>   classVariableNames: ''
>>>>>>   poolDictionaries: ''
>>>>>>   category: 'Bob'
>>>>>>>>>        environment:
>>>>>
>>>>> Is it your impression that Germán's implementation requires this? If so, on what do you base that understanding? Have you looked at the code?
>>>>>
>>>>>>>> I'm saying that since years.
>>>>>>>
>>>>>>> I agree you have been saying that Germán's implementation isn't what you want. I just don't understand what you don't like about it.
>>>>>>
>>>>>> because this is a class level import.
>>>>>
>>>>> I still don't know what you mean by "class level import" or why you think Germán's implementation fits your definition.
>>>>>
>>>>>>> Name resolution of all variables (including Globals, of which Classes are a subset) should be part of a method compile. At the time a method is compiled, an 'environment' should be provided to the compiler that indicates how global name resolution should occur.
>>>>>>
>>>>>> Usually this is the class of the method.
>>>>>
>>>>> By "Usually" do you mean in pre-namespace Pharo? That is, the class is one of the factors that the compiler considers in doing name lookup? Is the "usual" approach good? Would it still be a factor considered by the compiler in an environment namespace regime?
>>>>>
>>>>>>> This is a tools issue and it should be possible to specify the default namespace environment for the method, for a method category, for a class, for a class category, for a package, and for the system as a whole.
>>>>>>
>>>>>> no this is a question of language design.
>>>>>
>>>>> Do you consider packages to be part of the language? I have always thought that one of the nice things about Smalltalk is how little of the development environment is actually part of the language. Being able to augment things through tools rather than changing the language seems to me to be a feature, not a bug.
>>>>>
>>>>>>> In addition, within a particular method it should be possible to explicitly reference a particular namespace environment, whether through syntax (dot or double colons)
>>>>>>
>>>>>> No we do not want to have that.
>>>>>> We want import to be specified at the border: i.e. during module import. Inside a module the world is flat and as a developer I do not want to know that this Point is from Core when that one is from MyCore.
>>>>>
>>>>> By "I do not want to know" do you mean "I do not want to be required to specify" or do you mean "I do not want anyone else to be able to find out"? If I want to know (say, to build tools), would that be okay? If I'm willing to let you remain ignorant of a global's source would you be willing to let me be enlightened?
>>>>>
>>>>>> If I want both, at the module import level I write
>>>>>>
>>>>>>   Import: Point from: core as: CorePoint;
>>>>>>   import: Point from: dev as: DevPoint;
>>>>>
>>>>> What object implements #'import:from:as:'?
>>>>>
>>>>>>> or through message sends (e.g., a Dictionary's #'at:' method). I prefer not to add new syntax and favor GemStone's implementation over that of VisualWorks.
>>>>>>
>>>>>> I dislike them both.
>>>>>> A module should provide a certain level of encapsulation, else naming convention is good enough.
>>>>>> Because else having namespace does not prevent you to have to declare that WA is not a namespace somebody else should use.
>>>>>
>>>>> You say that you "do not want to" allow code "to explicitly reference a particular namespace." Do you mean that arbitrary code should not be able to see a global that is not explicitly imported at package load time and that code should never be able to explicitly look at and manipulate namespaces. Really? This seems to me to be very much contrary to the existing spirit of reflection and introspection in Smalltalk and would make tools much more limited. I suspect that this is not really what you mean.
>>>>>
>>>>> I believe that a package should be allowed to provide a default environment, but I don't see the need to make it mandatory or exclusive. I believe that a class should be allowed to override the default environment, but I don't think it should be required.
>>>>>
>>>>> If a class is allowed (but not required) to override the default (provided by the package/module, for example), does that make it a "class level import" (and wrong, in your view)?
>>>>>
>>>>> What I understand from your statements so far is that Germán's approach allows too much flexibility (namespace can be specified not just at the package level but also at the class level and explicitly in code). You do not want to allow anyone to experiment with different levels of granularity. Is that it?
>>>>>
>>>>> Thanks for engaging in the discussion.
>>>>>
>>>>> James Foster
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>



--
www.tudorgirba.com

"Every thing has its own flow"

12