You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Sylvain Wallez <sy...@apache.org> on 2004/03/22 11:34:22 UTC

Less is more... or less? (was Re: v2 forms flowscript example)

Vadim Gritsenko wrote:

>>> Sylvain Wallez wrote:
>>>
>>>> Why is there a need to have a different API for widgets when used 
>>>> from JS than when used from Java? IMO, this is arbitrarily limiting 
>>>> the features available in flowscript.
>>>
>
> But isn't this our design approach? If I remember correctly our FOM 
> discussions, "less is more", right?


Well, time for a bit of rant on this.

I'm personally not that happy with "less is more" as it was applied to 
FOM. Although I agree that bloated APIs should be avoided, restricting 
the Cocoon core APIs (the environment) in some specific area of Cocoon 
(flowscript) seems to me an arbitrary constraint.

Yes, not that many people have asked for more of the Java environment 
APIs to be visible. But why so? Simply because people (and I talk about 
what I've seen in real customer projects) often end up writing a simple 
Java class that allow them to access the real Java object and therefore 
use the *full* environment API in their flowscripts. This leads to 
clumsy constructs that overcomplexify the flow scripts.

That's why I don't like the JS-specific APIs, except those that allow 
shorter notations through properties.

Furthemore, this makes learning more difficult, as people have to learn 
*two* APIs to know what is (or is not) available in flowscript. And as 
we have no explicit auto-generated documentation for the flowscript 
APIs, this is a lot of trial and error. We had IDL, which was abandonned 
because it wasn't maintained. I won't blame anyone for this as I'm the 
first one to dislike writing docs, but I do write javadoc in the code. 
Javadoc *is* the reference for our APIs, and where users dig to find 
what's available, even those who don't write a single line of Java but 
use only flowscript. Imagine how frustrating it is to see some feature 
you need available on the Java object, but not on the JS one...

So less is less when you have more on the *same* object accessed 
directly in Java.

WDYT?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: Less is more... or less? (was Re: v2 forms flowscript example)

Posted by Sylvain Wallez <sy...@apache.org>.
Tim Larson wrote:

>On Mon, Mar 22, 2004 at 11:34:22AM +0100, Sylvain Wallez wrote:
>  
>
>>Vadim Gritsenko wrote:
>>    
>>
>>>>>Sylvain Wallez wrote:
>>>>>          
>>>>>
>>>>>>Why is there a need to have a different API for widgets when used from JS than when used from Java? IMO, this is arbitrarily limiting the features available in flowscript.
>>>>>>            
>>>>>>
>>>But isn't this our design approach? If I remember correctly our FOM discussions, "less is more", right?
>>>      
>>>
>>Well, time for a bit of rant on this.
>>
>>I'm personally not that happy with "less is more" as it was applied to FOM. Although I agree that bloated APIs should be avoided, restricting the Cocoon core APIs (the environment) in some specific area of Cocoon (flowscript) seems to me an arbitrary constraint.
>>    
>>
>
>I agree with "less is more" in designing API's, but when we have what should be *one* API exposed in two environments it should be the *same* API, modulo environment-specific ease-of-use enhancements. In short, I think everything that is public in the Java API should also be directly available in the JS API.  I interpret "less is more" to mean expose-in-both or expose-in-neither, otherwise we create confusion.
>  
>

+1000. That's exactly my point.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: Less is more... or less? (was Re: v2 forms flowscript example)

Posted by Tim Larson <ti...@keow.org>.
On Mon, Mar 22, 2004 at 11:34:22AM +0100, Sylvain Wallez wrote:
> Vadim Gritsenko wrote:
> >>>Sylvain Wallez wrote:
> >>>>Why is there a need to have a different API for widgets when used 
> >>>>from JS than when used from Java? IMO, this is arbitrarily limiting 
> >>>>the features available in flowscript.
> >
> >But isn't this our design approach? If I remember correctly our FOM 
> >discussions, "less is more", right?
> 
> Well, time for a bit of rant on this.
> 
> I'm personally not that happy with "less is more" as it was applied to 
> FOM. Although I agree that bloated APIs should be avoided, restricting 
> the Cocoon core APIs (the environment) in some specific area of Cocoon 
> (flowscript) seems to me an arbitrary constraint.

I agree with "less is more" in designing API's, but when we have what
should be *one* API exposed in two environments it should be the *same*
API, modulo environment-specific ease-of-use enhancements.
In short, I think everything that is public in the Java API should also
be directly available in the JS API.  I interpret "less is more" to mean
expose-in-both or expose-in-neither, otherwise we create confusion.

--Tim Larson

Re: Less is more... or less?

Posted by Antonio Gallardo <ag...@agssa.net>.
Sylvain Wallez dijo:
> An example: last week, a customer of mine (I do mentoring for them and
> they're not subscribed to users@) asked me "I get a "no such property or
> method" error when calling context.getRealPath() in my flowscript.
> Why?". I answered that this method isn't available in flowscript and
> provided a 10-lines workaround involving looking up the sourceresolver
> and resolving a "context://" URL.

Can you provide more info about this issue? We had the same problem some
weeks ago and solved in a total diferent approach. Maybe our solution can
help you too.

I remember the old discusions about why block some parts of the API. The
overall idea was to avoid abusing of flow (javascript) to write all the
code there.

But thinking about why flow exists: As a controller. I realize the
controller must be able to solve paths in order to delegate.

So I am +1 in reviewing what we have avaliable and what not in FOM.

Best Regards,

Antonio Gallardo.

Re: Less is more... or less?

Posted by Sylvain Wallez <sy...@apache.org>.
Stefano Mazzocchi wrote:

> Sylvain Wallez wrote:
>
>> So less is less when you have more on the *same* object accessed 
>> directly in Java.
>
>
> Sylvain,
>
> less is more when all the things that you removed were not helping, 
> not always.
>
> The "less is more" design approach is a process, not a solution.


Sure, and I totally agree with that. I should have reminded in my post 
the quote that's on my weblog: "perfection is achieved not when there's 
nothing more to add, but when there's nothing left to remove" (Antoine 
de Saint-Exupéry).

> Instead of putting everything in FOM and deprecate bad ideas later, we 
> opted for a process where we start small and add thing incrementally.


Yeah, but the question is what is the FOM? Is it the objects that are 
made available, or the APIs on these objects? I know your answer: 
"both". But why do we have *two* different APIs in Cocoon for the exact 
same object, one being a subset of the other? This is really confusing 
to users.

An example: last week, a customer of mine (I do mentoring for them and 
they're not subscribed to users@) asked me "I get a "no such property or 
method" error when calling context.getRealPath() in my flowscript. 
Why?". I answered that this method isn't available in flowscript and 
provided a 10-lines workaround involving looking up the sourceresolver 
and resolving a "context://" URL.

Sure I could have started a vote to add getRealPath() to the FOM. But 
the customer needed it right now, and not in 2.1.5, and the 
workaround... well, just works even if ugly and slower. But it is a 
workaround.

> It might result that we end up making FOM a java clone of the java 
> APIs we provide. If the community requires so, great, wonderful.


That's where I see a limitation of the community dynamics and a proof 
that this API reduction is a bad thing, as it's faster to provide a 
workaround using a Java class and Cocoon's official APIs than discuss 
and vote some changes that will be available in the next release.

Also, the fact that the workaround uses the official Java APIs (and not 
clear violations of the public contract like 
CocoonComponentManager.getCurrentEnvironment()) clearly shows IMO that 
constraining the API of objects exposed by the FOM is useless.

> The point is that it has been done with a process that made it appear 
> why we needed that, instead of just cloning over.
>
> This means: if you think there is something missing in FOM or has to 
> change, ask for a vote to add it, at that point, you'll find 
> resistance and people might suggest better ways to do what you had in 
> mind, or not.
>
> Doesn't matter the outcome, it's the community process that counts.


Ok. I'll check what has been hidden from the environment API and start a 
vote on this. I do agree with the fact that not all objects should be 
exposed (although most of them actually are), but not with the reduction 
of the API.

Ah, and what about the FOM if/when we'll have a Java version of 
flowscript? Will we have a FOMRequest Java interface that will be subset 
of Request? That sounds totally silly...

> In *that* regard, less is always more.


Yep. Less APIs in JS than in Java for the same object is more confusion ;-)

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: Less is more... or less?

Posted by Stefano Mazzocchi <st...@apache.org>.
Sylvain Wallez wrote:

> So less is less when you have more on the *same* object accessed 
> directly in Java.

Sylvain,

less is more when all the things that you removed were not helping, not 
always.

The "less is more" design approach is a process, not a solution.

Instead of putting everything in FOM and deprecate bad ideas later, we 
opted for a process where we start small and add thing incrementally.

It might result that we end up making FOM a java clone of the java APIs 
we provide. If the community requires so, great, wonderful.

The point is that it has been done with a process that made it appear 
why we needed that, instead of just cloning over.

This means: if you think there is something missing in FOM or has to 
change, ask for a vote to add it, at that point, you'll find resistance 
and people might suggest better ways to do what you had in mind, or not.

Doesn't matter the outcome, it's the community process that counts.

In *that* regard, less is always more.

-- 
Stefano.


Scripting Languages (was Re: Less is more... or less? (was Re: v2 forms flowscript example))

Posted by Christopher Oliver <re...@verizon.net>.
Sylvain Wallez wrote:

> Vadim Gritsenko wrote:
>
>>>> Sylvain Wallez wrote:
>>>>
>>>>> Why is there a need to have a different API for widgets when used 
>>>>> from JS than when used from Java? IMO, this is arbitrarily 
>>>>> limiting the features available in flowscript.
>>>>
>>>>
>>
>> But isn't this our design approach? If I remember correctly our FOM 
>> discussions, "less is more", right?
>
>
>
> Well, time for a bit of rant on this.
>
> I'm personally not that happy with "less is more" as it was applied to 
> FOM. Although I agree that bloated APIs should be avoided, restricting 
> the Cocoon core APIs (the environment) in some specific area of Cocoon 
> (flowscript) seems to me an arbitrary constraint.
>
> Yes, not that many people have asked for more of the Java environment 
> APIs to be visible. But why so? Simply because people (and I talk 
> about what I've seen in real customer projects) often end up writing a 
> simple Java class that allow them to access the real Java object and 
> therefore use the *full* environment API in their flowscripts. This 
> leads to clumsy constructs that overcomplexify the flow scripts.
>
> That's why I don't like the JS-specific APIs, except those that allow 
> shorter notations through properties.
>
> Furthemore, this makes learning more difficult, as people have to 
> learn *two* APIs to know what is (or is not) available in flowscript. 
> And as we have no explicit auto-generated documentation for the 
> flowscript APIs, this is a lot of trial and error. 

Well, the JS Flowscript API is documented: 
http://cocoon.apache.org/2.1/userdocs/flow/api.html.

Although I agree with you that there should not be unnecessary 
limitations in the JS API  as compared to Java, nevertheless I think 
it's unavoidable that there will be some differences. This seems to be 
the case more generally with any Java scripting language. For example, 
JS String and java.lang.String do not have the same API:

   var length = "Hello".length;
   var length = new java.lang.String("Hello").length();

Compare also JS DOM versus Java DOM. I really don't see how such 
mismatches can be avoided completely. You'll run into the same thing 
with Jython, Groovy, etc. The net result of this is that, yes, the user 
will have to learn two API's (although similar).

Nevertheless, at least in my experience the combination of a scripting 
language and a system programming language has always been a winning 
combination. At my previous company, we developed tools for the abstract 
syntax language ASN.1. We provided a mapping to C++ classes, but we also 
implemented an ASN.1 API for the TCL scripting language. In constrast to 
JS/Java, TCL syntax is drastically different from C++. So the API's were 
not identical but however provided equivalent functionality in their own 
way. With the close similarity between JS and Java syntax it's tempting 
to try to make the API's identical, but there are important features 
only in JS (first class functions, closures, etc) that can and should be 
exploited.

My opinion is that any Cocoon JS API's should be developed to provide 
the best possible JS programming environment for the user. If this 
results in a different API than that provided in Java, so be it 
(although I think we should strive to make them the same where possible).

Chris