4 ms·
How many times have you messed up a comma inside an array? And just for looping, this is literally constructing a web page out of it. There is no architectural
by ulisesrmzroche 13y ago
How many times have you messed up a comma inside an array? And just for looping, this is literally constructing a web page out of it. There is no architectural benefit to this, all that's going to happen is that your going to fat finger some shit, and the compiler will complain to no end.
Guys, rule of thumb, architecture === directory names. Performance is an implementation detail.
Frameworks live and die by their APIs. The easier it is to work with, to read and write and reason with, the better it is.
But you know what, this can be easily proved. Someone take a stab at todomvc with this and let me know if it hurt or not.
- jpmonette 13y agoThere's a sample TodoMVC posted here - https://github.com/jpmonette/todomvc-mithril https://github.com/jpmonette/todomvc-mithril. If you have any idea to improve, feel free to send a pull request!
- thefreeman 13y agohttps://github.com/jpmonette/todomvc-mithril/blob/master/js/views/todo-view.js https://github.com/jpmonette/todomvc-mithril/blob/master/js/... Looks pretty painful, but I do think adapting JSX could be a pretty painless solution so I don't look at it as a deal breaker. I am still yet to find a javascript templating solution that I don't have at least 1 or 2 issues with.
- insin 13y agoHere's a JSXified version which assumes the existence of an "mshim" object which adapts tag calls and arguments to what m() expects: https://gist.github.com/insin/9639918 https://gist.github.com/insin/9639918
- ulisesrmzroche 13y agoHonestly, that looks worse than I thought it would. Are you guys familiar with the whole, programs are for humans to read it, and incidentally for computers to execute?
- lhorie 13y agoLooks roughly how I'd expect. Personally I don't find it unreadable, except for the 8-spaces-in-a-tab thing (which is not really relevant anyhow). Anyways, few things I see: - I'm not sure why you're doing `return m("#todo-app"), [...]` on line 15 of the view, it looks like a typo - I would probably have written a keyboard utility function similar to m.withAttr to keep the e.keyCode stuff out of the controller and remove the anonymous function in the view - I generally prefer inline ternary syntax instead of a if statement at the top for the "clear" button. - the pluralize snippet can also be pulled out into a utility method - I also tend to favor this syntax: m("input#new-todo[placeholder='What needs to be done?']") if the value of the attribute is static (line 18)