We just finished our Be-Delphi 2014 sessions and drank our last beers, so
here we are.
I published some slides for this great event.
2014-11-20
2014-11-20. Open Source › mORMot Framework
We just finished our Be-Delphi 2014 sessions and drank our last beers, so
here we are.
I published some slides for this great event.
2014-11-14
2014-11-14. Open Source › mORMot Framework
Up to now, the TSQLRecord.ID
property was defined in
mORMot.pas
as a plain
PtrInt
/NativeInt
(i.e. Integer
under
Win32), since it was type-cast as pointer for TSQLRecord
published
properties.
We introduced a new TID
type, so that the ORM primary key would
now be defined as Int64
.
All the framework ORM process relies on the TSQLRecord
class.
This abstract TSQLRecord
class features a lot of built-in methods,
convenient to do most of the ORM process in a generic way, at record level.
It first defines a primary key field, defined as ID:
TID
, i.e. as Int64
in mORMot.pas
:
type TID = type Int64; ... TSQLRecord = class(TObject) ... property ID: TID read GetID write fID; ...
In fact, our ORM relies now on a Int64
primary key, matching
the SQLite3 ID
/RowID
primary key.
This primary key will be used as RESTful resource
identifier, for all CRUD operations.
2014-11-14. Open Source › mORMot Framework
Working with objects is pretty powerful, but requires to handle manually the
created instances life time, via try
.. finally
blocks. Most of the time, the TSQLRecord
life time would be very
short: we allocate one instance on a local variable, then release it when it
goes out of scope.
If we take again the TSQLBaby
sample, we may write:
function NewMaleBaby(Client: TSQLRest; const Name,Address: RawUTF8): TID; var Baby: TSQLBaby; // store a record begin Baby := TSQLBaby.Create; try Baby.Name := Name; Baby.Address := Address; Baby.BirthDate := Date; Baby.Sex := sMale; result := Client.Add(Baby); finally Baby.Free; end; end;
To ease this pretty usual pattern, the framework offers some kind of
automatic memory management at TSQLRecord
level:
function NewMaleBaby(Client: TSQLRest; const Name,Address: RawUTF8): TID; var Baby: TSQLBaby; // store a record begin TSQLBaby.AutoFree(Baby); // no try..finally needed! Baby.Name := Name; Baby.Address := Address; Baby.BirthDate := Date; Baby.Sex := sMale; result := Client.Add(Baby); end; // local Baby instance will be released here
2014-11-05
2014-11-05. Open Source › mORMot Framework
We have enhanced our SynProject Open Source tool, so that it is now able to generate its documentation as HTML, in addition to doc/pdf documents. You can take a look at this web page. It contains the whole SAD 1.18 content. The pdf is more than 16 MB, whereas this html page is only 6MB. Note that […]
2014-10-24
2014-10-24. Open Source › mORMot Framework
We almost finished implementing a long-standing feature request,
introducing MVC / MVVM for Web Applications (like RubyOnRails) in mORMot.
This is a huge step forward, opening new perspectives not only to our
framework, but for the Delphi community.
In respect to the existing
MVC frameworks for Delphi, our solution is closer to Delphi On Rails (by the
convention-over-configuration
pattern) than the Delphi MVC
Framework or XMM.
The mORMot point of view is unique, and quite powerful,
since it is integrated with other parts of our framework, as its ORM/ODM or interface-based services.
Of course, this is a work in progress, so you are welcome to put your feedback,
patches or new features!
We will now explain how to build a MVC/MVVM web application using
mORMot, starting from the "30
- MVC Server" sample.
First of all,
check the source in our GitHub repository: two .pas
files, and
a set of minimalist Mustache
views.
This little web application publishes a simple BLOG, not fully finished yet
(this is a Sample, remember!).
But you can still execute it in your desktop browser, or any mobile device
(thanks to a simple Bootstrap-based responsive design), and see the
articles list, view one article and its comments, view the author information,
log in and out.
This sample is implemented as such:
MVVM | Source | mORMot |
Model | MVCModel.pas |
TSQLRestServerDB ORM over a SQlite3 database |
View | *.html |
Mustache template engine in the Views sub-folder |
ViewModel | MVCViewModel.pas |
Defined as one IBlogApplication interface |
For the sake of the simplicity, the sample will create some fake data in its own local SQlite3 database, the first time it is executed.
2014-08-05
2014-08-05. Open Source › mORMot Framework
By default, interface-based services of a mORMot server will always
return a JSON array (or a JSON object, if
TServiceFactoryServer.ResultAsJSONObject
is
true
).
With some kind of clients (e.g. if they are made by a third party), it could be
useful to return XML content instead.
Your mORMot server is able to let its interface-based services return XML context instead, or in addition to the default JSON format.
2014-06-22
2014-06-22. Open Source › mORMot Framework
Since most CRUD operations are centered within the scope of our
mORMot server, we implemented in the ORM an integrated mean of
tracking changes (aka Audit Trail) of any TSQLRecord
.
In short, our ORM is transformed into a time-machine, just like the good old
DeLorean!
Keeping a track of the history of business objects is one very common need
for software modeling, and a must-have for any accurate data modeling,
like Domain-Driven Design.
By default, as expected by the OOP model, any change to an object will forget
any previous state of this object. But thanks to mORMot's exclusive
change-tracking feature, you can persist the history of your objects.
By default, change-tracking feature will be disabled, saving performance and
disk use.
But you can enable change tracking for any class, by calling the following
method, on server side:
aServer.TrackChanges([TSQLInvoice]);
This single line will let aServer: TSQLRestServer
monitor all
CRUD operations, and store all changes of the TSQLInvoice
table
within a TSQLRecordHistory
table.
2014-05-25
2014-05-25. Open Source › mORMot Framework
Cyclic Redundancy Check (CRC) codes are widely used for integrity checking
of data in fields such as storage and networking.
There is an ever-increasing need for very high-speed CRC computations on
processors for end-to-end integrity checks.
We just introduced to mORMot's core unit
(SynCommons.pas
) a fast and efficient
crc32c()
function.
It will use either:
Resulting speed is very good.
This is for sure the fastest CRC function available in Delphi.
Note that there is a version dedicated to each Win32 and Win64 platform - both
performs at the same speed!
In fact, most popular file formats and protocols (Ethernet, MPEG-2, ZIP,
RAR, 7-Zip, GZip, and PNG) use the polynomial $04C11DB7
, while
Intel's hardware implementation is based on another polynomial,
$1EDC6F41
(used in iSCSI and Btrfs).
So you would not use this new crc32c()
function to
replace the zlib's crc32()
function, but as a
convenient very fast hashing function at application level.
For instance, our TDynArray
wrapper will use it for fast items
hashing.
2014-05-18
2014-05-18. Open Source › mORMot Framework
Since Delphi 2010, the compiler generates additional RTTI at compilation, so
that all record
fields are described, and available at
runtime.
By the way, this enhanced RTTI is one of the reasons why executables did grow
so much in newer versions of the compiler.
Our SynCommons.pas
unit is now able to use this enhanced
information, and let any record
be serialized via
RecordLoad()
and RecordSave()
functions, and all
internal JSON marshalling process.
In short, you have nothing to do.
Just use your record
as parameters, and, with Delphi 2010 and up,
they will be serialized as valid JSON objects.
Of course, text-based
definition or callback-based registration are still at hand, and will be
used with older versions of Delphi.
But you could be used to by-pass or extend the enhanced-RTTI serialization,
even on newer versions of the compiler.
2014-05-18. Open Source › mORMot Framework
We have just added a new "25 - JSON performance" sample to benchmark JSON process, using well most known Delphi libraries...
A new fight
featuring
mORMot vs SuperObject/XSuperObject/dwsJSON/DBXJSON
On mORMot side, it covers TDocVariant
, late binding,
TSQLTable
, ORM, record access, BSON...
We tried to face several scenarios:
On average and in details, mORMot is the fastest in almost all scenarios (with an amazing performance for table/ORM processing), dwsJSON performs very well (better than SuperObject), and DBXJSON is the slowest (by far, but XE6 version is faster than XE4).
2014-05-07
2014-05-07. Open Source › mORMot Framework
I just wrote a small sample program, for benchmarking Mustache libraries: native SynMustache vs mustache.js running on SpiderMonkey 24...
And the winner is ...SynMustache, which is 10 times faster, uses
almost no memory during process, and handles inlined
{{>partials}}
natively (whereas we have to handle them manually
with mustache.js)!
Who says that Garbage Collection and
immutable
strings in modern JITted runtimes are faster than "native" Delphi
applications?
Are you still preferring the "NextGen"
roadmap?
2014-05-07. Open Source › mORMot Framework
Here are some benchmark charts about MongoDB integration in mORMot's ORM.
MongoDB appears as a serious competitor to SQL databases, with the potential benefit of horizontal scaling and installation/administration ease - performance is very high, and its document-based storage fits perfectly with mORMot's advanced ORM features like Shared nothing architecture (or sharding).
2014-05-07. Open Source › mORMot Framework
MongoDB (from "humongous") is
a cross-platform document-oriented database system, and certainly the best
known NoSQL database.
According to http://db-engines.com in April
2014, MongoDB is in 5th place of the most popular types of database
management systems, and first place for NoSQL database management
systems.
Our mORMot gives premium access to this database, featuring full
NoSQL and Object-Document Mapping (ODM) abilities to the
framework.
Integration is made at two levels:
SynMongoDB.pas
unit;mORMotMongoDB.pas
unit.MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), which matches perfectly mORMot's RESTful approach.
This second article will focus on integration of MongoDB with our ORM.
2014-05-07. Open Source › mORMot Framework
MongoDB (from "humongous") is
a cross-platform document-oriented database system, and certainly the best
known NoSQL database.
According to http://db-engines.com in April
2014, MongoDB is in 5th place of the most popular types of database
management systems, and first place for NoSQL database management
systems.
Our mORMot framework gives premium access to this database,
featuring full NoSQL and Object-Document Mapping (ODM) abilities to
the framework.
Integration is made at two levels:
SynMongoDB.pas
unit;mORMotMongoDB.pas
unit.MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), which matches perfectly mORMot's RESTful approach.
In this first article, we will detail direct low-level access to the
MongoDB server, via the SynMongoDB.pas
unit.
2014-05-02
2014-05-02. Open Source › mORMot Framework
There was a long-standing request from customers, about putting all our source code repository to GitHub.
We like a lot our self-hosted Fossil repository, and will continue to use it as our main system, including issue tracking and wiki, for our official web site.
But we created a repository on GitHub, on https://github.com/synopse/mORMot
2014-04-28
2014-04-28. Open Source › Open Source libraries
Mustache is
a well-known logic-less template engine.
There is plenty of Open Source implementations around (including in JavaScript,
which can be very convenient for AJAX applications on client side, for
instance).
For mORMot, we created the first pure Delphi implementation of it,
with a perfect integration with other bricks of the framework.
In last part of this series of blog articles, we will introduce the
Mustache library included within mORMot source code
tree.
You can download this documentation
as one single pdf file.
2014-04-28. Open Source › Open Source libraries
Mustache is a well-known
logic-less template engine.
There is plenty of Open Source implementations around (including in JavaScript,
which can be very convenient for AJAX applications on client side, for
instance).
For mORMot, we created the first pure Delphi implementation of it,
with a perfect integration with other bricks of the framework.
In this second part of this series of blog articles, we will introduce the
Mustache syntax.
You can download this documentation
as one single pdf file.
2014-04-28. Open Source › Open Source libraries
Mustache is a well-known
logic-less template engine.
There is plenty of Open Source implementations around (including in JavaScript,
which can be very convenient for AJAX applications on client side, for
instance).
For mORMot, we created the first pure Delphi implementation of it,
with a perfect integration with other bricks of the framework.
In this first part of this series of blog articles, we will introduce the
Mustache design.
You can download this documentation
as one single pdf file.
2014-04-07
2014-04-07. Open Source › mORMot Framework
As we already
stated, we finished the first step of integration of the
SpiderMonkey engine to our mORMot framework.
Version 1.8.5 of the library is already integrated, and latest official
revision will be soon merged,
thanks to mpv's great contribution.
It can be seen as stable, since it is already used on production site to serve more than
1,000,000 requests per day.
You can now easily uses JavaScript on both client and server side.
On server side, mORMot's implementation offers an unique concept, i.e.
true multi-threading,
which is IMHO a huge enhancement when compared to the regular node.js mono-threaded implementation,
and its callback hell.
In fact, node.js official marketing states its non-blocking scheme is
a plus. It allows to define a HTTP server in a few lines, but huge server
applications need JavaScript experts not to sink into a state a
disgrace.
2014-03-29
2014-03-29. Open Source › mORMot Framework
For several units of our framework, we allow late-binding of data
values, using a variant
and direct named access to
properties:
- In SynCommons, we defined our TDocVariant
custom
variant type, able to store any JSON/BSON document-based content;
- In SynBigTable, we use the TSynTableVariantType
custom
variant type, as defined in SynCommons;
- In SynDB, we defined a TSQLDBRowVariantType
, ready to
access any column of a RDBMS data result set row;
- In mORMot, we allow access to TSQLTableRowVariantType
column values.
It's a very convenient way of accessing result rows values. Code is still very readable, and safe at the same time.
For instance, we can write:
var V: variant; ... TDocVariant.New(V); // or slightly slower V := TDocVariant.New; V.name := 'John'; V.year := 1972; // now V contains {"name":"john","year":1982}
This is just another implementation of KISS design in our framework.
Since Delphi XE2, some modifications were introduced to the official
DispInvoke()
RTL implementation:
varUStrArg
kind of parameter has been defined, which
will allow to transmit UnicodeString
property values;/ WideString /
varOleStr
variants to the invoked variant type;Those modifications are worth considering...
And we may have discovered two regressions: one about speed, and the other
about an unexpected logic bug...
« previous entries - page 2 of 7 - next entries »