"Todos" app madness (-:


#1

Hi again.

I cloned Todos app … looked some files …
And then I ran this command:

 find . -name '*package.js' -prune -o -name '.npm' -prune -o -name '.meteor' -prune -o -name '*.build*' -prune -o -name '*.js' -print | xargs wc -l

2665 lines of code in js files! Simple ToDo app and 2.5 thousand lines of javascript! And I know about tests, etc.

Do really think, what newcomers can understand this?!

I remember being fascinated by a Meteor when I first saw it. To understand the examples was not difficult.

Guys, we all need examples that can be understood for half-hour.
Otherwise we become a closed ecosystem


#2

Why would you need to understand the whole code base of Meteor to write an app? I mean, you don’t need to know everything about a car to be able to drive it.


#3

It isn’t code base. It is example from guide.

And I don’t know about you, but when I learn something new, I need some documentation and code examples.


#4

Ok, I agree with that. But if I’m not mistaken, many of the code used in that app is explained in different pages of the guide.


#5

Yes, I know.
But newcomers need “Hello world” example, not “Special theory of relativity” example (-:

Maybe I am wrong, I don’t know…


#6
  1. some code is repeated

  2. todos is the more complex version of simple-todo, which is the one in the tutorial. Todos is a showcase for the more advanced approaches.


#7

Sorry, I forgot about tutorials


#8

I’m currently rewriting the client files from this example todos app into manuel:viewmodel to make a short tutorial out of it. It makes it use much less lines. :wink:


As for the Todos app itself. If it is an example app for the Guide, it should utilize the best practice and knowledge that we can find in Guide and Docs. Yet, we can find there Meteor.defer() which still isn’t covered in the docs even if the Github issue asking to add it will be 2 years old in May.

That is sad.


#9

To be fair, you have to note that:

  • Todos is not a “hello world” app, it tries to be as complete as possible by implementing routing, server-side methods, account handling and more, so you can learn more from it
  • when you don’t count tests, it’s 2245 LoC. While that’s still a lot to chew on, I personally think it’s managable.
  • if one is looking for a more “hello world” type of example app, there’s always simple-todos which does it’s job perfectly

On the other hand, official Meteor website says:

In fewer than 600 lines of JavaScript, Todos implements all the essential features of a collaborative task management app

Which is misleading right now.


#10

Honestly is there a big benefit of using Meteor.defer over setTimeout(…, 0)?

But I agree that it’s weird that it isn’t covered anywhere.


#11

setTimeout used in this context feels like a hack (or actually is a hack). Meteor.defer() sounds more like there is an official feature for such a use case. I agree there’s no big benefit, but the least is to decide on one way and stick to it both in docs and recommendations like guide or example apps.


#12

That’s a really interesting question. I always wondered what “magic” Meteor.defer() does over setTimeout()?


#13

It uses node’s process.nextTick(funct) on the server, I think.


#14

I put a pull request together for this. https://github.com/meteor/meteor/pull/6629

Maybe Meteor.defer should also be discussed in the Meteor Guide with common use cases for client (wait for dom update) and server (defer async function like send mail).


#15

setImmediate not nextTick!!! (nextTick is the most unhelpfully named function, it doesn’t do what you think).

/rant


#16

Yeah, sorry. My memory got confused by mixing it up with this incident: https://strongloop.com/strongblog/node-js-performance-meteor/


#17

No that incident is exactly what I was obliquely talking about:

The workaround turned out to be surprisingly easy: after Meteor switched from process.nextTick() to setImmediate(), the problem went away entirely


#18

@skirunman just saw the request being pushed and closed, thanks for the hard work! :slight_smile:


#19

@skirunman is killing it with the PRs! So much good stuff.


#20

Thanks @sashko. You’ve got me through the end of this week :grin: and then back to focus on my SF based startup, Clozer.