www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Serenity web framework - early feedback wanted

reply Robert Clipsham <robert octarineparrot.com> writes:
Hey all,

I've just uploaded the source code to a pet project I've been working on 
over the past few weeks - an MVC web framework written with D.

https://bitbucket.org/mrmonday/serenity/src

It's by no means ready for production use, I'm posting here primarily 
for some early feedback on how things work/how they should work/any 
issues I'm overlooking.

The primary files to look at are:

  - bootstrap.d: Entry point for the web app - this *is* going to 
change, haven't decided how yet.
  - example/controllers/Home.d: A hybrid Hello world/show some blog 
posts controller
  - example/models/Home.d: The model which the home controller is 
powered by.

Currently features include:
  - A minimal ORM (lots of work needed here, works for the basics though)
  - An HTML document builder - remove the need for ugly/inefficient 
templating systems, and allow output to HTML5/4/JSON/XML/XHTML to be 
easily switched between (only HTML5 currently works, and is slightly 
broken due to laziness, see comments in the implementation)
  - A minimal SQL abstraction layer - currently supports SQLite, 
functions similarly to the HTML document builder

Obviously there's still a lot to do, things that come to mind are 
logging, caching, configuration, security, administration, <insert huge 
list of functionality todays web frameworks have>.

Any feedback on what I have so far is welcome, I'm also looking for 
feedback on future directions, issues I'm likely to hit, ways you think 
it can be improved from what it is now, things you think will be 
important etc.

Thanks,

-- 
Robert
http://octarineparrot.com/
Dec 28 2010
next sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 29/12/10 03:20, Robert Clipsham wrote:
 Hey all,

 I've just uploaded the source code to a pet project I've been working on
 over the past few weeks - an MVC web framework written with D.

 https://bitbucket.org/mrmonday/serenity/src
-snip-
 Currently features include:
Knew I'd forget something - the document builder includes an almost complete method for finding elements using CSS selectors, so you can use doc.find("p.content") to get an array of all paragraph elements with the content class in the current document. I'll also note that it currently only builds/runs on linux with ldc, this is purely because it's my development environment, I do plan to remove this limitation as the project matures. -- Robert http://octarineparrot.com/
Dec 28 2010
prev sibling next sibling parent reply Lutger Blijdestijn <lutger.blijdestijn gmail.com> writes:
Very interesting project, will you commit to D1 or consider supporting D2 in 
the future?
Dec 30 2010
parent Robert Clipsham <robert octarineparrot.com> writes:
On 30/12/10 14:01, Lutger Blijdestijn wrote:
 Very interesting project, will you commit to D1 or consider supporting D2 in
 the future?
I'm not committed, and there is always the possibility of moving to D2 later on. For a small portion of my reasoning as to why I'm not using it at the moment, see my response to Jacob. -- Robert http://octarineparrot.com/
Dec 31 2010
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2010-12-29 04:20, Robert Clipsham wrote:
 Hey all,

 I've just uploaded the source code to a pet project I've been working on
 over the past few weeks - an MVC web framework written with D.

 https://bitbucket.org/mrmonday/serenity/src

 It's by no means ready for production use, I'm posting here primarily
 for some early feedback on how things work/how they should work/any
 issues I'm overlooking.

 The primary files to look at are:

 - bootstrap.d: Entry point for the web app - this *is* going to change,
 haven't decided how yet.
 - example/controllers/Home.d: A hybrid Hello world/show some blog posts
 controller
 - example/models/Home.d: The model which the home controller is powered by.

 Currently features include:
 - A minimal ORM (lots of work needed here, works for the basics though)
 - An HTML document builder - remove the need for ugly/inefficient
 templating systems, and allow output to HTML5/4/JSON/XML/XHTML to be
 easily switched between (only HTML5 currently works, and is slightly
 broken due to laziness, see comments in the implementation)
 - A minimal SQL abstraction layer - currently supports SQLite, functions
 similarly to the HTML document builder

 Obviously there's still a lot to do, things that come to mind are
 logging, caching, configuration, security, administration, <insert huge
 list of functionality todays web frameworks have>.

 Any feedback on what I have so far is welcome, I'm also looking for
 feedback on future directions, issues I'm likely to hit, ways you think
 it can be improved from what it is now, things you think will be
 important etc.

 Thanks,
I have to say that I'm a bit septic to all/most web frameworks, because in my opinion they're trying to create a Rails implementation in the given language but they all fail due to the language is not powerful enough. But I think you have taken a different route and created an API that doesn't try to be exactly like Rails, which just might be the right solution to create a good web framework in another language than Ruby. I think it looks interesting, a coupe of questions/comments: * In example.models.Home, if I understand things correctly Home is a model and Post is the actual representation of the table? If that's the case, why the separation? * Is it always wise to create a model? * Shouldn't Controller.view return Document instead of HtmlDocument? * You list removing the templating system as a feature but this will loose the separation of the view code (the view) and the code for the logic (the controller) I'm using D1 and Tango but I have to say that I think D2 as some nice features that will make it possible to create an ORM implementation with quite a good API (opDispatch, template this parameter, Variant to mention a few). BTW, how is it working out with doing web development in a statically typed language? -- /Jacob Carlborg
Dec 30 2010
parent Robert Clipsham <robert octarineparrot.com> writes:
On 30/12/10 20:12, Jacob Carlborg wrote:
 I have to say that I'm a bit septic to all/most web frameworks, because
 in my opinion they're trying to create a Rails implementation in the
 given language but they all fail due to the language is not powerful
 enough. But I think you have taken a different route and created an API
 that doesn't try to be exactly like Rails, which just might be the right
 solution to create a good web framework in another language than Ruby. I
 think it looks interesting, a coupe of questions/comments:
That's an interesting opinion - having never used ruby or rails I can't really comment on it, guess I should probably take a look.
 * In example.models.Home, if I understand things correctly Home is a
 model and Post is the actual representation of the table? If that's the
 case, why the separation?
That is correct. The main reason for the separation is that I feel you should be able to use the ORM without having to use the MVC parts of the framework. I guess you could argue either way - it would be possible to expand the functionality to allow models to pose as table schemas, I haven't really thought about it.
 * Is it always wise to create a model?
Nope, which is why there is an additional template, registerController!(MyController), which doesn't require a model - I added in the additional arguement to save a few lines of code for what I forsee being used fairly frequently.
 * Shouldn't Controller.view return Document instead of HtmlDocument?
Possibly. This is a bit of the framework I'm still not complete sure how it will end up being implemented - It will eventually need to be able to return JSON/XML as well, so you're probably right here.
 * You list removing the templating system as a feature but this will
 loose the separation of the view code (the view) and the code for the
 logic (the controller)
I had this very discussion with a couple of people, one of which has written a full MVC framework, and I managed to convince them that there's no need for it - it makes sense if you're embedding markup some how, but I don't see the point of something like: ---- HtmlDocument view() { View v = new View; view.display(model.getPosts()); } ---- All that achieves is an extra class you have to create, and when you're constructing the html etc with code rather than mark up anyway, why bother? Feel free to argue the point though, I'm not completely against it, just seems unecessary to me. (I guess I should probably call it an MC framework rather than MVC?)
 I'm using D1 and Tango but I have to say that I think D2 as some nice
 features that will make it possible to create an ORM implementation with
 quite a good API (opDispatch, template this parameter, Variant to
 mention a few).
D2 does have some nice features indeed. My problem with it is, within a week of starting using D1 again I'd hit several compiler bugs in dmd and ldc (some of which I patched, some I worked around). D2 has a lot more features (a lot of the more useful ones are incomplete), and the one time I did try it hit a lot more issues in the same amount of time. Add to that an incomplete/buggy standard library, the lack of a D2 fastcgi wrapper, the lack of support for anything other than 32 bit architectures (I know, I know, this is changing)... For my own sanity I'm sticking with D1. This isn't to say I'm completely against a move to D2, it's just not worth the effort at this point though.
 BTW, how is it working out with doing web development in a statically
 typed language?
Ask me again in a couple of months when I've got a website powered by it. I've gotta say from what I've done so far it's actually far nicer than web development I've done in dynamically typed languages, we'll see how that works out though. The main thing that's lacking is runtime reflection, which is *incredibly* poor and underpowered, I had a brainwave with respect to this though - I'll see how it works out though. -- Robert http://octarineparrot.com/
Dec 31 2010