Any thoughts?
-Peter
I second smaller more focused guides.
Sent from my iPhone
Disagree. Runloops come up the minute you have an observer that does
something wrong because it accesses a bound value which is
inexplicably stale even though you clearly *just* set the other side
of the binding. (One might argue that a good developer will architect
code to have this problem only rarely. But the guides are *for*
newbies.)
Runloops also come up the minute you write a test or spec. And
certainly we don't want to discourage test-minded developers.
Cheers,
--Richard
Not to worry, I don't mean anything quite so exotic as an SC bug.
Sorry if I was unclear.
I was just referring to something I tripped over a few times when I
first started with SC.. Observers fire immediately. Bindings sync at
the end of a runloop. During a single runloop, you might set the far
side of a binding, then set a value which fires an observer. When
observer get()s the near side of the binding, it will obtain a stale
value because the binding sync has yet to happen.
Simple example in the console:
a = SC.Object.create({b: "old value"});
c = SC.Object.create({ bBinding: 'a.b' });
SC.run();
a.addObserver('d', null, function () { console.log("a.b is %s; c.b
is %s", a.get('b'), c.get('b')); });
c.addObserver('b', null, function () { console.log("c.b changed to
%s", c.get('b')); });
SC.run( function () { console.log('begin'); c.set('b', 'new value');
a.notifyPropertyChange('d'); console.log('end'); } );
console.log("a.b is %s", a.get('b'));
yields:
begin
c.b changed to new value
a.b is old value; c.b is new value
end
a.b is new value
It's well worth noting that this difference was a source of confusion
for me when I started, and is likely to be for others as well.
--Richard
Sorry, that's just nonsense. Every SC developer is better off being
introduced to the run loop from day one. It is fundamental to what
makes SproutCore a *framework* and fundamental to it's correct and
efficient usage.
Best,
Erich Ocean
SproutCore Training and Mentoring
http://erichocean.com/training/index.html
http://erichocean.com/mentoring/index.html
It sounds like you are suggesting that I am somehow directly
responsible for SproutCore's current low adoption rate. Interesting.
I do not find the run loop complex, and knowing that SproutCore
buffers things until particular times *IS* fundamental to
understanding SC and developing with it. Hell, Yehuda gave an entire
talk about this a few weeks ago (posted the slides on Twitter).
Sorry you find them so complex. I personally haven't fielded a single
question about them after spending 5 minutes explaining what they are
and how they work. I do field problems and misunderstandings related
to the run loop if I don't, as others on this thread have helpfully
pointed out. You seem to want to keep me gainfully employed. :)
There simply is no such thing as a 100% transparent run loop unless
you intend to never buffer anything. If you intend to buffer, you have
to tell people you're doing it. The "run loop" is the class in
SproutCore that does so (and bears only a passing resemblance to
NSRunLoop in Cocoa, for those of you talking about Cappuccino and why
it's not discussed there).
So fine, if you don't want to say the phrase "run loop", at least
explain that SC buffers bindings, drawing, etc. until later. That's
all the run loop is anyway.
Sent from my iPhone
So we agree. How do you explain this then:
http://api.rubyonrails.org/classes/ActionController/Base.html
Specifically, the first sentence:
> Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either render a template or redirect to another action. An action is defined as a public method on the controller, which will automatically be made accessible to the web-server through Rails Routes.
Here's the equivalent version for SproutCore:
> Run loops are the core of browser event handling in SproutCore. They consist of one or more responder methods that are executed in response to a browser event and then either data is updated, views are updated, or both. A responder method is a public method (for example, 'mouseDown') on a view which will automatically be called by SproutCore when the corresponding user event on that view occurs.
I simply do not believe that this is inappropriate information for a
SproutCore developer. I think Rails has the right level of detail, and
I think SproutCore should too. We don't need to be "simpler" than
Rails.
Furthermore, I'm all for making SproutCore easier to use, but
pretending that SproutCore apps are not event-driven systems, or that
SproutCore doesn't call responder methods in response to browser
events, is not helpful to anyone.
We're talking in this thread about including a discussion that
SproutCore does this in an *Advanced Guide*, and apparently, this is
considered to be such an amazing complication to application
development that we should omit the information entirely. Guys, I'm
baffled here that here is *any* opposition at all.
*sigh*,
On Fri, Apr 22, 2011 at 8:29 PM, Gregory Moeck <gmo...@gmail.com> wrote:
> The chart in your training where you have a circle that dispatches the DOM
> events to the view layer and is labeled as the "Run Loop" is great, and
> extremely helpful. It's an abstraction that explains that there is some "Run
> Loop" that takes the events of the DOM and gets them to my view.
Something at the level of that diagram is all that I am lobbying for.
It's all I've ever taught anyone about the run loop in my classes, or
when mentoring.
From my perspective, Tom Dale is arguing that a SC developer should
not even know that there is such a thing as a run loop – that
SproutCore registers for browser events automatically and dispatches
them to views. More to the point, he seems to be arguing that
information like that should not be in the SproutCore Guides, even in
an "advanced" section, because he somehow has the idea that if we tell
people that information (and it helps them write "correct",
"efficient" code), that we've somehow "failed."
I think that's wrong: people *are* coming from jQuery, where you *do*
register for browser events. That's a fundamental difference between a
toolkit like jQuery and a app framework like SproutCore. I haven't had
even a single person tell me after my SproutCore class (which, as you
all know, talks about the run loop on the VERY FIRST SLIDE) that
everything I taught was great, but if I had just left out the run loop
part, they felt the complexity would have been much lower. Not one. If
you did, now is your chance to set me straight.
(For the record: I've taught hundreds of people new to SproutCore
and/or application development over the last 3.5 years, so I feel
pretty confident that the conceptual existence of the run loop, or the
idea that SC register for events and dispatches them to views, is not
something that is a barrier to adoption in SproutCore.)
On the other hand, I've also seen some astoundingly horrific
SproutCore code. You know what fixes it 80% of the time ? Walking a
developer through the slide with the run loop on it (it also includes
the "V" property). 10 minutes of discussion, problem solved, crisis
averted. (The other 20% is giving some frank advice on how to write a
view. Spoiler: use HTML and CSS.)
It's sad to think how many projects have failed (or nearly so) because
we as a community have some philosophical opposition to describing how
an event is handled in a SproutCore app. It truly mystifies me why the
run loop has suddenly become the source of all SproutCore's adoption
problems.
[sarc]
If event handling is something we need to hide from even developers
wanting advanced SproutCore information, why don't we try and abstract
the browser (DOM/CSS) altogether? There are many people (not me) who
want to do that, and there's even an entire app framework (Cappuccino)
dedicated to doing so. And JavaScript? Too difficult, let's use
CoffeeScript and abstract that out to to something we're more familiar
with, something that looks more like ruby. After all, prototype
inheritance is "new" and "web developers" can't be bothered to learn
about that stuff. They just want to put HTML on the screen. And CSS?
Again, too hard. Let's generate CSS from some ruby-like DSL instead.
Maybe SproutCore will take off like gangbusters when SC code reads
like backbone.js even though the library weighs ten times as much, but
those pesky "events" are gone for good. Yeah, that's the ticket.
Remove that abominable "run loop" and we're golden. Next: profit!
[/sarc]
Best,
Greg, thanks for your detail replies. I think we have the same goals,
just different views about how to get there. Rails developers are not
my target audience; application developers are. But when a member of
the Rails core team is also leading the SproutCore core team, it's
pretty obvious which developers become important, and you don't have
to be a genius to see which ways the wind is blowing...
On Fri, Apr 22, 2011 at 8:29 PM, Gregory Moeck <gmo...@gmail.com> wrote:Something at the level of that diagram is all that I am lobbying for.
> The chart in your training where you have a circle that dispatches the DOM
> events to the view layer and is labeled as the "Run Loop" is great, and
> extremely helpful. It's an abstraction that explains that there is some "Run
> Loop" that takes the events of the DOM and gets them to my view.
It's all I've ever taught anyone about the run loop in my classes, or
when mentoring.
From my perspective, Tom Dale is arguing that a SC developer should
not even know that there is such a thing as a run loop – that
SproutCore registers for browser events automatically and dispatches
them to views. More to the point, he seems to be arguing that
information like that should not be in the SproutCore Guides, even in
an "advanced" section, because he somehow has the idea that if we tell
people that information (and it helps them write "correct",
"efficient" code), that we've somehow "failed."
I think that's wrong: people *are* coming from jQuery, where you *do*
register for browser events. That's a fundamental difference between a
toolkit like jQuery and a app framework like SproutCore. I haven't had
even a single person tell me after my SproutCore class (which, as you
all know, talks about the run loop on the VERY FIRST SLIDE) that
everything I taught was great, but if I had just left out the run loop
part, they felt the complexity would have been much lower. Not one. If
you did, now is your chance to set me straight.
(For the record: I've taught hundreds of people new to SproutCore
and/or application development over the last 3.5 years, so I feel
pretty confident that the conceptual existence of the run loop, or the
idea that SC register for events and dispatches them to views, is not
something that is a barrier to adoption in SproutCore.)
On the other hand, I've also seen some astoundingly horrific
SproutCore code. You know what fixes it 80% of the time ? Walking a
developer through the slide with the run loop on it (it also includes
the "V" property). 10 minutes of discussion, problem solved, crisis
averted. (The other 20% is giving some frank advice on how to write a
view. Spoiler: use HTML and CSS.)
It's sad to think how many projects have failed (or nearly so) because
we as a community have some philosophical opposition to describing how
an event is handled in a SproutCore app. It truly mystifies me why the
run loop has suddenly become the source of all SproutCore's adoption
problems.
[sarc]
If event handling is something we need to hide from even developers
wanting advanced SproutCore information, why don't we try and abstract
the browser (DOM/CSS) altogether? There are many people (not me) who
want to do that, and there's even an entire app framework (Cappuccino)
dedicated to doing so. And JavaScript? Too difficult, let's use
CoffeeScript and abstract that out to to something we're more familiar
with, something that looks more like ruby. After all, prototype
inheritance is "new" and "web developers" can't be bothered to learn
about that stuff. They just want to put HTML on the screen. And CSS?
Again, too hard. Let's generate CSS from some ruby-like DSL instead.
Maybe SproutCore will take off like gangbusters when SC code reads
like backbone.js even though the library weighs ten times as much, but
those pesky "events" are gone for good. Yeah, that's the ticket.
Remove that abominable "run loop" and we're golden. Next: profit!
Rails developers are not
my target audience; application developers are. But when a member of
the Rails core team is also leading the SproutCore core team, it's
pretty obvious which developers become important, and you don't have
to be a genius to see which ways the wind is blowing...
From my perspective, Tom Dale is arguing that a SC developer should
not even know that there is such a thing as a run loop – that
SproutCore registers for browser events automatically and dispatches
them to views. More to the point, he seems to be arguing that
information like that should not be in the SproutCore Guides, even in
an "advanced" section, because he somehow has the idea that if we tell
people that information (and it helps them write "correct",
"efficient" code), that we've somehow "failed."
I think that's wrong: people *are* coming from jQuery, where you *do*
register for browser events. That's a fundamental difference between a
toolkit like jQuery and a app framework like SproutCore. I haven't had
even a single person tell me after my SproutCore class (which, as you
all know, talks about the run loop on the VERY FIRST SLIDE) that
everything I taught was great, but if I had just left out the run loop
part, they felt the complexity would have been much lower. Not one. If
you did, now is your chance to set me straight.
On the other hand, I've also seen some astoundingly horrific
SproutCore code. You know what fixes it 80% of the time ? Walking a
developer through the slide with the run loop on it (it also includes
the "V" property). 10 minutes of discussion, problem solved, crisis
averted. (The other 20% is giving some frank advice on how to write a
view. Spoiler: use HTML and CSS.)
It's sad to think how many projects have failed (or nearly so) because
we as a community have some philosophical opposition to describing how
an event is handled in a SproutCore app. It truly mystifies me why the
run loop has suddenly become the source of all SproutCore's adoption
problems.
Something at the level of that diagram is all that I am lobbying for.
On Fri, Apr 22, 2011 at 8:29 PM, Gregory Moeck <gmo...@gmail.com> wrote:
> The chart in your training where you have a circle that dispatches the DOM
> events to the view layer and is labeled as the "Run Loop" is great, and
> extremely helpful. It's an abstraction that explains that there is some "Run
> Loop" that takes the events of the DOM and gets them to my view.
It's all I've ever taught anyone about the run loop in my classes, or
when mentoring.
(For the record: I've taught hundreds of people new to SproutCore
and/or application development over the last 3.5 years, so I feel
pretty confident that the conceptual existence of the run loop, or the
idea that SC register for events and dispatches them to views, is not
something that is a barrier to adoption in SproutCore.)
-C
Ironically, every discussion of statecharts describes the "superloop",
the non-SC equivalent of the run loop (which is just SproutCore's
in-built event-dispatch loop).
IMO Every SproutCore developer from minute one should be told that SC
is a high-performance, event-driven system, that each event is
run-to-completion, and that views redraw after the event has been
handled and all data has propagated through the app. That's essential
what the first slide of my SproutCore Training video is all about.
Perhaps the best solution here is for me to do a "SproutCore for
Absolute Beginners" on my website that in one page, teaches what I
think should be taught. People can google that if they want to learn
SC the way I teach it.
I'd lobe to see this as a guide as oppose to being posted on your personal site.
The reason I suggest this is because when I first started working with SproutCore I found it troublesome to search for things online. The guides help ones learning efforts to be focused on the material instead of goggling for information.
Kind Regards,
Chad Eubanks
Sent from my iPhone
I think Erich's point is that the way he wants to teach it differs from the way those on the
Core Team would like to teach it. While it would be ideal if we can come to an agreement,
the second best option is to both have our own way of explaining it. As long as we aren't
telling people contradictory things then the existence of multiple approaches isn't likely to
do any harm.
-Peter