Cell – A self-driving web app framework
celljs.org
celljs.org
EDIT: To add to this, I need to enable Javascript on celljs.org, then wait 3 SECONDS for the page to load because they use their own "not a framework" to build the page instead of just using HTML.
There are many cases where developers use JavaScript when plain CSS and HTML would do, but there are also many pages that simply do not fit that simple model. And between those two extremes is a large space of application with a mixture of static content and interactivity. Don't focus on a single usecase and ignore the rest.
But yeah, a homepage should probably be a real HTML page with embedded widgets, even if building the whole DOM is a cool use case.
At least let me see what the site is about, even if only a landing page, so I can see the value of enabling Javascript.
True, but how useful is it?
> Easy to reuse: Everything is powered by stateless functions instead of classes and objects, making it extremely modular.
Maybe it's all stateless functions under the hood, but the "hello world" code snippet includes code that mutates the DOM:
onkeyup: function(e){
if(e.keyCode === 13){
document.querySelector("#list")._add(this.value);
this.value = "";
}
}
> Easy to maintain: "Development workflow" doesn't exist. No NPM, No Webpack, No Babel, just vanilla Javascript and 100% based on web standards.Are these tools really the main source maintenance pain for web developers?
In my experience the code I write is the biggest maintenance burden. I'll suffer through complex tooling if it helps me avoid maintenance anti-patterns (like storing state on DOM elements...)
The DOM elements aren't stateless, but they will behave like they are if you update every attribute that can change in the `$update` function.
Really all you're doing is mutating the DOM objects themselves, but one of them is this magic `$update` function that runs every time one of that element's attributes changes I think. The framework just provides a proxy object for accessing the attributes, and every cell is extensible with custom data and functions. For some fun try overwriting `this.$update` in `$update`.
Another thing I totally missed at first is the fact that you can embed a <script> containing a variable with the `$cell` property anywhere in the page and the cell will show up in that part of the DOM, and you can do this as much as you want.
I consider TypeScript (or Elm) support a best practice for "JavaScript" development, so something that brags about not having a development workflow is a non-starter. It's not only not a pain for me, it's a significant missing feature.
If it's something that has to be maintained for more than a month, use Typescript or Flow. Just do it. Everything else is a PITA.
If it's just something you want to whip up quickly and won't be maintained, jumping through all the hoops of npm, building and bundling is just annoying.
Maybe I'm sitting here saying something that sounds like "get off my lawn" to everyone else in the thread, but this thing is amazing.
npm install -g create-react-app
create-react-app my-app
cd my-app/
npm start
type unknown.variable in various files and see how they handle it - there should be a (compile time) stack trace that points you exactly to the right file and line.That alone changes everything about JS.
(True; staticly typed isnt the same as not declared, but still, i think you get my point.)
compare to something like https://github.com/yoshuawuyts/choo which is actually tiny and simple
React is not an ecosystem. React is a library with an extremely simple API. Everyone acts like one must use a flux implementation, a complicated router and everything when you use React. It can't be farther from the truth. Out of the box, React also provides, more or less, whatever cell provides.
It's easy to write a basic web app in one .html file with whatever JS you need inside <script> tags.
This is literally a self-contained file...
Aside from the JSON and a bit of syntactic sugar, it seems really similar to writing plain HTML - which itself was designed to be a high-level markup language for quickly specifying page layouts.
What am I missing? What's the benefit over HTML? I mean, if you want a non-framework why not just, you know, not use a framework?
Interesting concept nonetheless
<p>I will say this <em>emphatically</em></p>
As far as I can tell, Cell doesn’t permit this. If you have multiple child nodes ($components), none of them can be text nodes, so you have to work around it like this: <p><span>I will say this </span><em>emphatically</em></p>
Why not do away with the $text keyword entirely, and treat any strings in the $components list as text nodes? So instead of this: $text: "Buy now!!".
you have this: $components: ["Buy now!!"],
and instead of this: $components: [
{$type: "span", $text: "Buy "},
{$type: "em", $text: "now!!},
],
you have this: $components: [
"Buy ",
{$type: "em", $text: "now!!},
],Hope this helps!
Can you walk an extra mile and implement your version for https://github.com/gothinkster/realworld & https://github.com/tastejs/hacker-news-pwas.
This helps to benchmark how intuitive is the framework for creating complex apps.
I like how this seems to let application logic live as close to the UI as makes sense. That is, there's no barrier, intermediary or anything else that might drive them apart.
Of course, applications have a higher-level structure that isn't just an artifact of the framework, and I'm curious how this system would work out in real life once you start grouping/composing cells and having them communicate to implement that structure. Each cell has a pretty uniform "surface" -- that is, the properties it has and what they mean, so it should be possible to "snap" them together easily and in any configuration. I wonder if it's too flexible, in a sense, meaning you would need to be careful to use higher-level patterns to organize your cells so that your app doesn't become a messy blob of cells.
These are just thoughts after a static reading of it. I'd like to play with it and see if I can get a better feel for it.
One thing I don't like is expressing HTML in JavaScript objects. Seems like we ought to express HTML in HTML! I wonder if "cellHtml" might be a better approach to this than cellJs -- that is, where a cell is expressed in HTML (would still have init and update JavaScript functions, though) I don't know if that's workable, though.
Question for the author: I'm a firm believer that, the more a tool is really good at some things, the more that tool is not good for other things. (A really good drill is also really not good at being a hammer.)
It looks like Cell is really new and interesting and does some things really well; what things does it not do really well, or would you recommend to not use it for (as compared to other frameworks?)
And this is by design because the goal was to create complexity out of simplicity.
I believe this bottom up approach can be much more scalable in the long run than some frameworks that dictate every single detail you need to implement, because all organisms are basically built that way (cells make up body) and they seem to be working fine.
Personally the more I use this the more I find creative ways of using it, which is the beauty.
But I also do realize sometimes it's good to have some sort of "best practice" structure and I think people will figure it out eventually.
TLDR: I think you should be able to build all kinds of sophisticated apps with it because I believe emergence is the best way to construct something. if that's not the case, that doesn't mean the framework is a failure but just needs some tuning, which I believe is totally possible just because the library is so minimal. So please feel free to play with it and share if you run into trouble, we can evolve cell just like cells evolve in the real world.
Thanks for making this, I'm interested to check it out.
The inspiration was from real life cells. It's amazing how small autonomous cells bind and interact with one another to form a complex organism.
Cells have genotypes which manifest themselves into phenotypes. And a nucleus that self-controls the cell cycle.
I thought by creating a completely autonomous structure that mimics how cells work it will be possible to create complexity from simplicity.
i hear a lot of people saying this will never scale because it doesn't look like react or angular, but I think the point is not about what's missing, but what you can do with these by combining these self aware elements. I believe this approach is much more scalable because it builds on top of simplicity.
Again, thanks for the comment!
An example:
(let [greeting [:div {:style {:background "green"}} "hello"]]
[:section#hi-there greeting])
Just a little bit of data!Yes, there are LCS deduplication logic, synchronized DOM update, initializers, reactive updates, storing and mutating states, etc. They're all in there. They're just structured differently because it has a different architecture than existing frameworks.
The whole point of Cell is not trying to match feature by feature of existing frameworks like React/Angular/Ember/etc. And I am aware Cell doesn't look like most existing web app frameworks that follow best practices, because that's the point.
I did my best to explain the rationale behind all the design decisions on the homepage, could you take a look at those and let me know if you have questions? Thank you.
Btw this is a very new framework so everything is a start. So if you have better ideas about dealing with certain problems please feel free to send pull requests or start a thread on github. Thank you!
A better idea to do deal with this? Properties, like in React. You control what you pass down and every component has a clear interface you can interact with, without polluting the context. Incidentally, React has contextes, which are vaguely similar to your inheritance mechanism, but are used to implement "special" behaviours, like implementing theming across the component chains etc.
The whole point of cell is to build the simplest building block you can compose to build complex structures, and a lot of the problems faced by other traditional approaches can be tackled in a different manner using Cell.
From my experience I can build fairly complex apps without having to worry about all the problems you mentioned, they are just structured differently.
If you have time, I really suggest you try playing around with it, If you still don't like it you don't have to use it, but I'm sure it brings some interesting ideas to the table that cannot be experienced by just reading the homepage.
So while telling people to play with it is good, it's even better if you can point to a demo that illustrates and resolves the issue that was brought up.
If cell apps need to be structured differently, how should they be structured? How do you plan to support single source of truth and a large number of third party libraries written with your framework without scope clashes? I appreciate I can avoid using your framework, but that's not the point :I'm trying to express my criticism in order for you use it (or to throw it away, if you like) - I suppose you submitted your software to HN in order to receive honest feedback.
For some reason this made me think of clojurescript, and I think it might make a nice library for use in cljs as well.
But I fail to see which problem this tries to solve or which novel solution it illustrates. It looks a lot like React without JSX (which is not bad).
How it has a different architecture: https://github.com/intercellular/cell#so-how-does-it-work-ex...
What these architectural decisions mean and how they make a difference https://github.com/intercellular/cell#how-does-this-make-a-d...
And when you come from that direction, Cell is a terrible framework that doesn't follow any best practices and does things in a weird way. But the thing is, Cell is fundamentally different from other approaches. That's why a lot of "best practices" don't apply and don't make sense for Cell.
If you go back in history, people hated angular because it went against the general wisdom of "separate view from logic", and react was shunned because it had some weird way of doing things. But I think they solve problems in unique ways that make peoples lives easier in different ways, and that's what matters at the end of the day.
And I am confident that Cell can make people's lives significantly easier in another different way. So I suggest you actually play around with the examples at https://play.celljs.org
Words don't mean anything really because the problem we're trying to solve is come up with a dead simple easy way to build web apps, which is not really easy to grasp when just thinking about theories. Hope this helps!
Real world examples should include at the least a TodMVC implementation so users can compare this to other choices.
Well ... actually ... there IS a way, but this feature is only mentioned one-third of the way into the tutorial – a tutorial that begins with the words “you don't even need to read this tutorial”. So, to someone evaluating Cell, it might as well not exist.
That’s a hint, by the way. :-)
I thought one of the advantages of React/Angular/Vue frameworks is their support for event modifiers, cross-browser support for the events via synthetic events. Or is there a support for these ideas that I am missing.
While I understand that 2-way binding might complicate everything, it is the one feature I need the most when setting up a quick-and-dirty prototype. IMHO this might be the deal-breaker...
I'm using some in-house library I built myself to run the webpage but hadn't realized it fails on an IE. Will fix it!
Second, this is a pretty normal ES5 framework though. It's just declarative, or based on convention, or whatever you want to call that style. And it's component-based. And definitely not JSON because it has functions.
Also yes it is component based but it's a different type of component than other frameworks. Since cell has no classes to inherit (to get rid of dependency) you can write the entire app with stateless functions only. This scales better than class based approaches since functions don't have overhead and you can "componentize" anything.
Hope this makes sense! I did my best to explain these on the homepage but if some of them are not clear enough please let me know, I'll correct them!
Just like you can build spaceships, police station, cars, and all kinds of complex things using lego blocks, you can build complex architecture using the simple building block that is cell.
I myself have been experimenting with different approaches of structuring apps using cell, and there are really a lot of different ways since we become free from having to inherit classes and instantiate objects from them. I don't want to be constraining about how one uses cell so I don't talk much about what a "best practice" is (yet)
But maybe sooner or later people can share some nice approaches for structuring "traditional apps" using cell
Except you cannot have a hierarchy of cells without the top level cell having responsibility of the whole world below in its own scope: that doesn't scale well and limits complexity to maybe a couple of levels.
EDIT: Whoops, it's pretty trivial to nest components and describe a tree of HTML.
FYI your website fails to load in IE11 because the `fetch` function (polyfill?) uses `Promise`
But rest assured, the library itself is 100% es5.
btw could you share the link that's not working on IE11? I will fix it right away. Would appreciate it!
These above just from my few first minutes looking through how i can use this at work.