Delphi 2007 Handbook








November 21, 2006

My Ramblings on Delphi and the Web

The rise of AJAX can mean a lot of positive things for Delphi on the web. Here is a (rather long) post with my ramblings... discussing different scenarios and options.

Web development is quite complex and multi-faced, which is why this post cannot be short. Before I start getting to the core let me underline three relevant features of modern web solutions (please, don't make me call them Web 2.0 solutions): (i) separation of code and content, (ii) flexibility in deployment and updates, and (iii) the use of HTML, CSS, and open standards.

Warning 1: I've not provided links to the various technologies mentioned (would have taken hours), Google can help you find out more. Warning 2: I know this post is confused and too dense and skips too many details... but I found no other option.

Many Alternative Options, No Outstanding Solution

The way I see it is that there are many different solutions. None gets close to a perfect, from what I've seen. Here is a categorisation, useful for the following discussion:

1. pure scripting (for example php or asp), where the pages include HTML tags, the script, possibly SQL statements for accessing a database and the like.

2. scripting with a database access layer, providing a clear separation of the database access code. The script creates pages using “server side objects” (java, php plug-in, COM objects) for data processing and database access.

3. scripting with a full component layer, mostly to simplify the generation of the HTML and user interface management (for example, asp.net). In this model not only data access, but also HTML generation is based on server side objects, often compiled. The development tool helps creating pages, but separating the programmer's work from the designer's work becomes more problematic. An alternative option is to have a more traditionally compiled application.

4. scripting with an integrated management of the user interface and of the database access layer (like ruby on rails and its various “clones” written in other scripting languages). The idea is to match the database structure, possibly an object persistent framework, with an MVC like user interface architecture.

5. script (or other solutions) that generate xml data structures: a common solution in the past was to use xslt or a similar layer to generate the user interface, but another option these days is to separate the AJAX/JavaScript driven UI from the REST-based backend.

Where Does Delphi fit? Delphi can be used (at least partially) in many of these scenarios. You can write server side objects for models 2 (asp, php) and 3 (asp.net). You can also create complete stand alone applications, with IntraWeb or WebSnap, still part of model 3. It seems to me that Delphi fits best in both scenarios of model 5.

Which is the Best Approach?

I don't think there is a clear-cut answer. In the first model the code easily becomes unmanageable. Most of the models lack a clear cut separation of content from code (with, in my opinion, 2 and 3 being particularly troublesome in this respect). If scripting requires compiled objects, their upgrade and deployment might become far from trivial. Using xslt makes data entry complex and requires a super-expert graphic designer (as most tools cannot even manage correct XHTML).

What about performance? I've been told Ruby and other scripting solutions suffer, and make sites not so scalable on average hardware. But I don't know much in this respect.

What can Delphi Offer?

Delphi's strong point are well known:

  • Multiple very good data access layers.
  • Good integration with other web protocols and web services of various types (this is very handy for intergrating multiple sources of information, creating mashups).
  • Optimized compiled code for Win32, .NET, and Linux.
  • Object/relational mapping libraries, including Instant Objects and ECO.
  • Excellent computing power, XML and string processing capabilities, and memory management.

But how can Delphi offer these features? Purely compiled code seems too troublesome to me. I think Delphi needs a client side layer (AJAX) or a server side scripting layer to be used for assembling different commands. There are multiple scenarios I can see:

1. Create Delphi objects that provide services to other solutions (asp.net, php) putting Delphi in a very limited role.

2. Define a native scripting layer (not necessarily in a Pascal dialect) or a configuration layer that calls into Delphi objects for the processing and produces either plain XML (for REST/AJAX solutions) or goes through an XSLT layer for direct HTML (or PDF) generation.

I can say I like solution 2, because it is very close to what I'm using for creating tens of different web sites these days (including this blog). Our choice was to implement (in Delphi/Kylix) an XML-based scripting language, a decision I don't regret. At the moment our architecture is not open enough for direct use by Delphi developers, but this could be a possible outcome of our work: we only need to allow dynamically loaded packages with extra commands provided by users.

AJAX and Delphi

A specific area, part of the second approach above, would be the use of AJAX, CSS, HTML, to define the front end of a Delphi-powered application. Delphi's classic Internet Express (do you remember it, it was way ahead of time!), is an interesting example of database and JavaScript driven pages. In any case, creating JavaScript client UIs and writing server side applications to provide the proper XML (using a REST approach) makes a lot of sense. What is lacking, though, is a proper graphical/RAD tool. Even better, you'd need a tool (an IDE, a wixard...) binding the client side code and the server side architecture. If CodeGear will invest on AJAX, I hope they do this with (also) a Delphi backend in mind. This can easily beat Ruby on Rails and similar approaches, and would be better than directly cloning them...

So why not add to the roadmap a new BDS personality, JavaScript, and make it the UI generator for the server side processing code, to be compiled with Delphi for Win32 or with Delphi for Linux (even with a cross-compiler...). This vision, properly executed, could make Delphi stand out as one of the best web development tools. The current scenario is far from being stable (if you think so, notice how AJAX and Ruby on Rails turned the tables over) and is still open for new ideas and proposals. I hope CodeGear has one. I hope they keep Delphi in the picture. If not, let's try to build something ourselves...





 

9 Comments

My Ramblings on Delphi and the Web 

 Clever, those chinese:

http://219.153.35.21:8080/website_en/demo/webshop20demo.htm

Too bad they don't care too much about respecting the
intellectual property of others...

Anyway, I think you are thinking about what I've been
thinking about for many years; I'm of the opinion that
interpreter 'stuff' should be handled at the client;
let the client handle it's own script-interpretation.

Persist your HTML & Script code in a database (I've
done this - works great!) and code the 'in-between'
layer in efficient, multi-threaded compiled code. The
fastest web page systems work this way (see
http://www.href.com)

For example using Kylix I coded some Apache DSO's that
acted as AstaIO clients to a linux-based AstaIO
server. Between the AstaIO client & server I handled
stateful session management & security and
'constructed' pages on the fly by combining HTML
stored in dataset descendants in memory; when a
request came in I would query the db for relational
data, then combine the in memory HTML with the data
and ship it out to the browser. Works great, secure,
and very fast. All compiled code.

Websnap has some great features that make up the
bricks and mortar for some great high-performance
dynamic web based systems.

I was on a project that got canceled at the point
where I was coding my own TAstaIOHTTPServerWire; I had
decided to eliminate the middle man; take an Indy
TIdHTTPServer and make it run on an AstaIO server. You
have everything else you need; security,
multi-threaded stateful session management,
multi-threaded database pooled sessions etc.

I think far too little has been done to exploit the
power of the Delphi/Kylix web capability. I do agree
that it would be nice to be able to have a great IDE
to design & test scripts and pages and I think
CodeGear could find that a good long term goal, to
finally straighten that mess all out. Incorporate
AJAX, ROR and other stuff into the designer, make some
of those snappy components that abstract the
complexities and help you build your pages and scripts
on the fly etc.

But as for server side scripts, they will never be
able to compete with the performance capabilities of
the above mentioned approach; I've seen efforts to
make high-volume transaction based systems with
interpreters like .NOT & Java; there isn't enough
hardware on the planet to make server-side scripting
efficient enough to be used in a high volume system.

My $0.02 says keep the scripts in the browser, persist
them in the DB, make the in-between scream at asm
speed. And crank out some nice, slick components for
dynamic script and page design/creation in the IDE.
Comment by David Keith on November 21, 06:00

My Ramblings on Delphi and the Web 

Let's face it, now there are two major standard in the
world to do web application: Java and Php.

Do you have to serve users at millions? Or you have to
do webapplications in a afternoon (and still have some
spare time to chatter at coffee machine)? You will go
to Php.

Do you have to give access to the company database?
You have unlimited cpu power and ram memory to waste,
but you don't want scalability limits? You'll stick
with Java.

If Delphi want to be successful in this arena it has
to be far superior to the two above both in power and
in easiness to use. Something like Delphi 1.0 was
superior to CA Visual Object and MS Visual Basic.
Some halfbaked effort, like Borland did previously
(Charlotte anyone? *)  will not make the day.


(*) the fate of charlotte:
http://homepages.borland.com/abauer/2004/05/charlottes-web.php?show_id=108509470991637507#bk_108509470991637507
Comment by Uberto on November 21, 10:55

My Ramblings on Delphi and the Web 

Bravo, Bravo! Good post.

Marco, you are exactly correct about the need for a
RAD IDE tool for AJAX Web client development.  It
should be back end agnostic in true AJAX fashion.  It
should have an integrated JavaScript debugger and the
ability to trace into backend code using a remote
debuggers.  CodeGear can provide hooks for Developers
Studio, JBuilder, and whatever they do with the
"active" languages like PHP, Python and Ruby.

If CodeGear does not go this way, lead us and I will
follow.  I will contribute whatever I can. 

Comment by Tom Wilk on November 22, 07:50

It already exists! 

Is it not the approach used by the Morfik team?

Server-side compiled exe (which use Delphi code as 
far as I know), and Ajax client-side code?

The JavaScript Synthesis Technology (JST) creates 
Javascript code directly from Delphi-Style code.

The "Express Edition" is free, and should be 
convenient for most users. 
Comment by AB [http://www.morfik.com/] on November 22, 10:01

My Ramblings on Delphi and the Web 

Morfik's price of $5,000 per professional license is 
ridiculous.  I will look at the free one to see if it 
has any value.  
Comment by Tom Wilk on November 22, 16:50

My Ramblings on Delphi and the Web 

Marco,

I realize this is Java based and not a CodeGear 
product, but you should investigate the IntelliJ IDEA 
6.0.2 IDE.  It says that it supports AJAX.  Check out 
the demo => 
http://www.jetbrains.com/idea/training/demos/AJAX_demo
.html

I have not tried it yet, but it is VERY interesting. 

Tom
Comment by Tom Wilk on November 22, 17:51

Where is the future headed? 

Do we ever even hear of Win32 app development any 
more?  Has it been stopped?  For this, Delphi is the 
best.

AJAX has many implementations, and I'm sure there is 
a lot of "bad" AJAX that will be replaced in a year 
or so.

What is the future of Web development?  For 
developers, it's about leveraging the popular 
environment with the best tools available, and this 
is where Delphi 1 came in.  CodeGear will need to do 
something similar now.  The current enviroment 
(VS2005) is powerful, yet somewhat cluttered and 
unfocused in my opinion.  Give the developers a 
better, more powerful C# environment, and they will 
build.
Comment by Steve [http://www.lastisawyou.com] on November 22, 19:05

My Ramblings on Delphi and the Web 

 There's an interesting post about the same argument 
in delphi.non-technical, titled "RAD web-
development". Maybe Marco could give his 
contribution? 
What seems clear to me is that web development is far 
more complicated than windows development. In the 
windows arena, after Visual Basic came Delphi, and 
then few other minor competitors (Powerbuilder, 
Visual Objects, Gupta..), because the "model" was 
more or less the same. On the contrary, for web 
development there's a plethora of different tools, 
commercial and open source, as you can see reading 
the post cited above in b.p.d.non-tech. This probably 
means that noone is really a "winner" not only as a 
product, but also as a "winning" root, like the 
visual-basic drag-a-component-and-write-event-code 
was for windows. 

There's room for a winning solution, and this could 
be an interesting root for codegear, and maybe for 
delphi also, even if being practically limited to 
intel win32 or .net platform only is a big problem in 
server-side internet arena! As the author of the post 
in ng say, "Must be able to target linux servers. 
Here in Brazil noone uses 
windows web-servers", and I think this is not limited 
to Brazil!!
Don't tell me about kylix, who can start something 
serious using kylix *today*?? 
Ok ok, I know, this forum is developed in kylix... <g>
Comment by Roberto Icardi [] on November 22, 19:18

My Ramblings on Delphi and the Web 

Found this interesting IDE, 
http://www.aptana.com
Until CodeGear can deliver something, I guess will
have to fish around for alternatives.
Comment by Tom Wilk on December 1, 07:20


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.