#1 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-06-11 01:53:11

Well, I downloaded the samples via GIT, but, when I tried to compile it, I got:

[Error] SynSQLite3Static.pas(228): File not found: 'sqlite3fts3.obj'

I had no time to try to solve it, however, I could understand how it works, because I analized the sources. My greatest interest in this partnership would be to create a possibility to port everything to Free Pascal and try to reuse it, and maybe publishing this work in Free Pascal communities. However, if you think that doing this will let the code slower, without logging (remember that even Brook and Free Pascal have automatic logging), but it's OK, I'm not insisting with ideas or suggestions anymore.

Right now, the only sample that I have with REST is the one that already follow the Brook since the release of 3.0 version:

https://github.com/silvioprog/brookfram … os/db/rest

But is the same fallacy: you will continue thinking mORMot is all that a web programmer needs and Brook a just a 'toy'. :-)

Well, now my focus will be to implement RIA in Brook, because some people are asking that. A friend and I will create the expected BSP (Brook Server Pages) and, finally, I will start the development of BrookScript, an idea that I had to implement in Brook 3.1 and it has already been accepted successfully by the key members that follow the project.

Despite everything, I wish you good luck in cross-compiler implementation, it is not a simple task! :-)

#2 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-06-01 01:53:09

AB, sorry for my delay to answer, I'm concluding the semester in the college, I had many works to deliver.

You got me wrong. When I said "bureaucratic", it was about you want to do everything in a single project. I use design patterns, I develop in MVC, and my layers are separated, but I dont put everything in single framework, I prefer to separate tasks into smaller projects. For example, Brook does not have persistence, it use a third party project, called dOpf (https://github.com/silvioprog/dopf). Brook does not send e-mail, it use a third party project, the XMailer (https://github.com/silvioprog/xmailer). And so on. Brook has plans to use JCore (https://github.com/jcmoraisjr/jcore) in a broker, that is a high level OPF project.

Brook can also use tasks of mORMt. If you want, I can help you to port some parts of mORMt for Free Pascal and, after that, we can write a "BrookmORMtBroker" broker. We could put our knowledge together and make a fusion between these two great projects, bucause porting code from Delphi to Free Pascal isn't an easy task.

I have a simple question, but first I would like to know if you can help me. It's about creating a simple example of CRUD with REST in mORMt, where I could compile in Dephi 7 (I have it here), and access a simple table in PostgreSQL.

This is the table:

create table person (
  id serial not null primary key ,
  name varchar ( 30 ) not null unique
);

And this is the object that I want to persist at the table above:

TPerson
  Id Integer
  Name String

If it does not take you so much time, could you make this example and send me the sources? My environment:

. PostgreSQL;
. Delphi 7;
. Windows XP 32-bit;
. Google Chrome with Advanced REST client extension.

If you agree, I will do the same example in Brook, and send you the sources for you to evaluate, finally, we could see in what aspects mORMt could help Brook to improve its persistence layer and if you accept it, I would implement the mORMt broker as I mentioned.

To make sure that I'm not in a competition, you can count with my help whenever you need to port mORMt for Free Pascal. It was nice to talk to you about those things, you are a great developer, who knows a lot about Object Pascal and also defends your work with all your strength, and has a sense of humor similar to mine! :-)

#3 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-05-30 04:20:45

I read and finally understood what 'Convention over configuration' is. I see, after all our discussion, we use different approaches to web development. And, if you allow to make a comment, you are more bureaucratic, and I'm more practical. I'm not saying you're wrong and I'm right or vice versa, we just use different aproaches to reach the same goal: professional web development.

And more, you can be ahead in some things, or may even have already produced more code in mORMot, however, Brook is much younger than it, ie, it has prioritized the development of parts that can't miss to produce applications for distribution in production. Can I use a layer of third log, as Log4D, so how can I use the system of log Free Pascal, together with Brook, supplying the current lack of logging it. On the other hand, the log layer is already being implemented in some days, reusing the existing code in the FCL, ie, not being necessary to reinvent the wheel.

About the development of layers for persistence using the REST architecture, I've tried to do an automatic as you mensioned in the articles that you showed me, however, I got a serious problem of maintainability. Anyway, I changed part of the core code, and the change reflected in all other parts, in short, the code was becoming coupled due to do several automation. This may be fine for some people, but I personally don't like this approach, because at the end of it all, in some more specific parts, I end up using the good and old 'join' of SQL. And more, it doesn't mean that Brook doesn't automate more usual codes as CRUDs. Brook has a very strong power of inheritance in your persistence layer where the entities are present, so I can make a class with everything I want to automate and then immediately descend the parts to be automated of this layer. Without mentioning that the use of generics helps this activity because I can specialize entire classes, most of the time, creating simple things on a single line of code.

I would really like you to show me what aspects Brook could become prone to errors about implementing SOA.

Well, about the part how we develop, there really is not much to discuss , because it is clear that we follow different approaches. :-)

I swear I'll write more examples and make them available online. I'll even think of open source applications that use in production.

I'm really glad for all the explanations you made to me. Your information is important, clear and objective, and they have a lot of technical details, however, every day and mostly in a reality that customers charge me daily new projects, support and problem solution, I end up letting go a bit bureaucracies, and implement quick solutions that solve problems, and of course, that be able to solve the problems of others. Brook came up from an idea between friends, however, as time passed by, the project became very serious, and it is today my main "income" source.

About IOCP, I can not say if Free Pascal supports it. However, I can say without fear of contradiction that the code now implemented in Free Pascal would attend most of the cases with massive requests, I guess, it could attend even in the cluster cases, because the FCL is multi-thread, and Fast CGI with Apache or nginx, I can divide the processing in multiple machines, or creating a cluster.

I don't know if there would be any interest in the mORMot team to partner with Brook and try to make an exchange of ideas, implementing different development approach. Finally, and I believe that most of the current maintainers of Brook would think fondly about it and they would probably accept the idea.

In short, I 'm really amazed with mORMot project. I don't have it as a "threat" in case it comes to Free Pascal, because Brook is specifcly made to Free Pascal , its dependencies are just the FCL, and the code is very lean, because it suports just a compiler. I've thought a lot about porting Brook to Delphi, but I gave up, because Brook focus is the Free Pascal, and the platforms on which it supports. Of course, about what I read, mORMot attend diverse solutions in itself, but Brook focuses more on web prococols, like HTTP(S), leaving other responsibilities (persistence, reports, e-mail etc.) to its plugins, in a brief analogy to Android, Brook would be the Andoid itself, focused on what it does, and the other resources would be applications, focusing other situations.

#4 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-05-30 04:19:17

@edwinsn, thank you for all your comments. They say really our reality. :-)

#5 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-05-29 03:42:06

Hello AB,

It's OK!

>> - lack of documentation and more elaborate examples;

You are right. The documentation is really small, but I have some explanation about this. At first, it was written by me, after that a brazillian friend wrote some more lines, finally, when Brook became public, other people gave more contribuition. However, it's necessary more detailed text and examples. I would be glad, if there were more contribution, nevertheless, in open source projects, lots of times, we have to wait a little more.

>> - In Brook, you have to put define all actions by hand - it is a "configuration over convention" framework;

Not everything. If I could understand what "by hand" means. Cofigurating a Brook action is so simple, that I didn't take time to write more "experts" (wizards). However, it is open to the ones who want to write them. Today, there are some experts to create actions, brokers and even projects.

>> - dopf is not able to create a table, does not know anything about SQL flavors, do not prepare statements, do not handle cardinality;

dOpf has a broker to SQLdb, native Free Pascal library. Therefore, it makes everything that the library and its broker implement. SQLdb, since when I know it, it creates tables dynamically, take a look at: http://wiki.freepascal.org/SqlDBHowto. Sure, today the greatest focus of dOpf it's not only allows a nice sintax to the programmers, but also to make possible the using of objects and native types, persisting in db.

>> - no direct CORS support for AJAX applications.

CORS is "a piece of cake" to configurate. Take a look at this:

  // code suggested by https://github.com/jbsolucoes
  TheResponse.SetCustomHeader('Access-Control-Allow-Origin','*');
  TheResponse.SetCustomHeader('Access-Control-Allow-Credentials','true');

However, today I sent a comment suggesting to implement something that become CORS more simple, as e.g.:

initialization
  BrookSettings.AllowOrigin := '*';

Please see: https://github.com/silvioprog/brookframework/issues/98

------------------------

>> - The whole framework design is pretty abstract, so it is open and extensible, thanks to the "brooker" plugin system;

That's true. This idea is strong of Brook, and it was suggested by one of its authors, João Morais: https://github.com/jcmoraisjr.

>> - There are some regression tests;

:-)

>> - Thanks to FPC, it is cross-platform and use existing libraries.

And more, Free Pascal has the FCLWeb, a mature library and much powerful to web development with pure Pascal. And thanks to FCLWeb, the main Brook plugins are:

BrookFCLCGIBroker - Allows CGI application development;
BrookFCLFCGIBroker - Allows Fast CGI application development;
BrookFCLHttpAppBroker - Allows own HTTP(S) application development (i.e., it doesn't depend on Apache and nginx);
BrookFCLHttpDaemonBroker - Allows own HTTP(S) application development, being able to install as Windows service or Linux daemon;
BrookFCLHttpClientBroker - Allows to make requests in external servers, as example, downloading a content of another site.

>> When I look at Brook, I'm very tempted to use FPC in addition to Delphi for my libraries.

Here I can say that, not only look at Brook as a mirror to reflect FPC, look at Brook as a sorce of ideas for you. ;-) Then, with more free time, see as Brook treats routes, dynamic variables etc. Until then, I promise that I will make more illustrative examples.

[cut]
>> You can easily implement a full web site with method-based services and Mustache logic-less templates. And also much more than this, like a full SOA multi-tier architecture, with SQL or NoSQL persistence.

The main idea of Brook is to facilitate the creation of online APIs, using modern architecture of web development like RESTful. However, Brook also allows the development of layers with codes legacy, even for those who write XMLs and/or HTMLs mixed with Pascal. There are plans to be developed the Brook Server Pages (BSP), however, although the project has been started, we had to pause it because of a memory leak found in Pascal Script, and until today it has not been fixed.

About Mustache, I don't know it deeply, I learned about it after someone comments on issues of Brook (https://github.com/silvioprog/brookframework/issues/91). If I understand correctly, it looks like the AngularJS (today maintained by Google). But, I don't use this approach, because in practice development, I use libraries like Kendo UI, Easy UI, jQuery UI and JTable, and these projects make easier my life to develop the back-end part, providing just links to access for these libraries. In this control panel, for example, I just used jTable and Bootstrap:

https://duallsistemas.com.br/api/cpanel - private area

Take a look at some pictures:

1 - http://imagebin.org/312085 (login page)
2 - http://imagebin.org/312086 (menu)
3 - http://imagebin.org/312087 (generating keys for direct access to the Dropbox via my own API)
4 - http://imagebin.org/312088 (registration pages)
5 - http://imagebin.org/312089 (small editing form)
6 - http://imagebin.org/312090 (popup)
7 - http://imagebin.org/312091 (reports)

So, that's all. Sorry for the long text. I don't have much time because I'm teaching web development (via video) with Brook here in Brazil. I have some plans to translate the final material and perhaps provide for the whole world. If it happens my dream would come true! :-)

#6 Re: mORMot 1 » Could you help to comment on the Brook framework ? » 2014-05-28 05:11:32

Hello, it is my first post here.

I think an exaggeration to say which Brook is a toy.

I see nothing more simple, sleek, intuitive and flexible as this:

. My simple object (descending of any class, like TObject, for example) and my specialized OPF: https://github.com/silvioprog/brookfram … person.pas

. My web action, specialized with same object specialized in OPF: https://github.com/silvioprog/brookfram … /unit1.pas

Without SQL, decoupled code, fast (2890 requests by secound, vs PHP and Java, which only reached 2690 and 2610 respectively, in a httperf test). It is wonderful, extremely clean:

procedure TPersonRESTAction.Post;
begin
  Entity.Validate;
  FOpf.Add(Entity);
  FOpf.Apply;
end;

The 'Entity' property represents my HTML form and implements my BO (business object). I just write:

	<form action="/person.add" method="post">
		<input type="text" name="id" />
		<input type="text" name="name" />
		<input type="submit" />
	</form>

... and after request, I can:

  Write('ID: %d, Name: %s', [Entity.id, Entity.name]);

... without the archaic architectures like 'Entity.FieldByName('id').AsInteger', or 'Fields['name'].AsString' etc.

Not to mention that Brook is maintained by developers around the world, Brazil, Russia, Spain, Portugal, China, Indonesia ... ie, is a constantly evolving project, and will survive for a long time.

Therefore, say which Brook is a toy, tendentiously you have not tested it and spoke on impulse! I'm using Brook in production for some time. I'm already profiting through this project, creating private APIs for Brazilian companies.

Sorry for my english which is no good, and congratulations for mORMot, I tested it, and it is (but not unique) a very nice project!

Board footer

Powered by FluxBB