122 points · by marcuswestin · 16y ago · 51 comments
It's interesting how far we've come, no? PHP-based pages were once considered dynamic.
Building static PHP pages is easy (and is demonstrated in the first block of code). So easy it's hard to beat by a significant margin, especially for small projects like this seems geared towards.
Building dynamic - much less real-time - PHP pages is not-so-easy, and certainly not that easy. At absolute simplest you have to look into JavaScript as well.
But after a few minutes I realized that if you look at it from the client's point of view, the rendered page really is static. It's not always the same between requests, but once it's rendered, it's not likely to change. So you're right in that respect!
What I got a kick out of is that my remark could be taken both with and without its tongue-in-cheek intent. It really is amazing that, once upon a time, PHP was considered dynamic. And now we want more!
Any piece of UI that needs extra care, e.g. a very long list of items, is implemented in javascript with appropriate lazy rendering.
How would you go about reusing code? Could you potentially separate out logic from your template?
I would also like to see how this could be done more unobtrusively. It would also be good to show what the output html looks like after it is compiled to html.
You can declare something akin to a function, which takes arguments and emits HTML. Imagine e.g.
let taskTemplate = template(task) {
<div class="task">
<span class="title">task.title</span>
</div>
}
for (task in tasks) { taskTemplate(task) }
I'm not decided on syntax yet.You can definitely separate out logic from template this way.
Fun outputs javascript, not HTML - the javascript then builds the DOM.
I built a similar language like this powered a site of mine that was actually in production (well, Alpha) - and it was a huge productivity boost, resulting in far more interactive pages. (The site never got out of alpha, and never had designer love, so it's stale, but you can see it at http://www.magnifeast.com - try entering a los angeles address).
The downsides to this approach are compatibility (most libraries won't work out of the box), SEO, and performance problems for generating large pages (particularly in IE).
(BTW: this is a secondary account, I'm normally sshumaker - noprocast rule and all).
A video demonstrating it from this past March's Confoo web conference can be found here: http://www.youtube.com/phpframework#p/c/C102458C2FFD8ACF/7/8...
We're also planning to add a more direct syntax in the future so that you can easily set properties of objects directly to a changing data source without having to handle the assignment in a controlled callback, which we initially mandate due to taking the cautious route, thus allowing you to handle for data and security issues.
Disclaimer: I'm a co-founder of NOLOH
edit: I may be out of the loop a bit, but how does google and other spiders crawl pages like that?
We're sorry about the confusion regarding licensing. Essentially free for anything non-commercial (open-source, educational, non-profit), and development. We offer free hosted sandboxes, in addition to free downloads for developing.
Essentially, you only pay when you go live with a commercial product, and even then we offer affordable options. There will be a comprehensive performance review in an upcoming issue of php|architect magazine. Since the framework is built from the ground-up to be lightweight and on-demand the result is considerable. You can read more about that here: http://www.noloh.com/#/home/&expanded=performance.
In regards to the spidering question, see: http://dev.noloh.com/#/articles/Search-Engine-Friendly/.
You can also read a comprehensive article in this past May's cover story in php|architect, http://www.phparch.com/magazine/2010/may/.
http://github.com/marcuswestin/fun/commit/05870f3f54fda43090...
Some of the ideas such as the state synchronization stuff is neat, but would probably be better suited as part of another framework/template language.
Someone should take the underlying realtime datastore (http://github.com/marcuswestin/fin) and bundle it with mustache or <angular/>!
fin.set(id, property, value)
fin.observe(id, property, function callback(mutation){})
Would be rockin to see if we could hook up fin to js-model!It's 4k of pure ruby art. Check it out.
Reminds me bit of register globals. And generally blurring the line between clientside and serverside processing feels bit scary.
// PHP code
and // Fun code
comments at the top of the code examples. Not great but hopefully helpful :) This was meant to be a high-level intro. I'll be diving into explaining the nitty gritty of the language next month.