Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-09

[ANN] Xavier for XML — Compatible with FPC and Delphi

26 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote
Hi, I'm working in my new "pet project" called Xavier. Xavier is an object-oriented library for work with XML.

I don't understand the 'why' ?
Should I understand that you consider the DOM units not object-oriented ?

Michael.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
Michael Van Canneyt wrote 12 lines
On Wed, 20 Sep 2017, Marcos Douglas B. Santos via Lazarus wrote: > Hi, > > I'm working in my new "pet project" called Xavier. > Xavier is an object-oriented library for work with XML. I don't understand the 'why' ? Should I understand that you consider the DOM units not object-oriented ?

Yes and no.

Michael, with all my respect, that depends of your view about Object thinking. Yes, DOM uses classes and objects, but IMO Objects is more than that. Objects are more close to Functional programming than most people think. If can code classes but if you are implementing (all) in an imperative way, I mean line by line telling the computer how to do something instead of code what you just want, you may not are thinking in terms of Objects. Your class, in these cases, is just a "bucket of data and procedures".

In a perfect design, we may only connect all objects to work in a "task", call "run", and "they" will know what to do. They (Objects) will decide how to do. Not the programmer (the "controller"). Just objects sending messages for each other.

Yeah, looks so philosophical... :)

I've been writing a blog about this for two years
http://objectpascalprogramming.com/

...and I use these same concepts in production code, of course.

Best regards,
Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 20 lines
On Wed, Sep 20, 2017 at 4:31 PM, Michael Van Canneyt via Lazarus wrote: > > > On Wed, 20 Sep 2017, Marcos Douglas B. Santos via Lazarus wrote: > >> Hi, >> >> I'm working in my new "pet project" called Xavier. >> Xavier is an object-oriented library for work with XML. > > > I don't understand the 'why' ? Should I understand that you consider the DOM > units not object-oriented ? Yes and no. Michael, with all my respect, that depends of your view about Object thinking. Yes, DOM uses classes and objects, but IMO Objects is more than that. Objects are more close to Functional programming than most people think.

As I understand it, objects are exactly the opposite of functional programming, in that they encapsulate state, and functional programming wants to avoid state (variables, if you want).

Show quoted text 5 lines
If can code classes but if you are implementing (all) in an imperative way, I mean line by line telling the computer how to do something instead of code what you just want, you may not are thinking in terms of Objects. Your class, in these cases, is just a "bucket of data and procedures".

Yes. That's what an object is.

In a perfect design, we may only connect all objects to work in a "task", call "run", and "they" will know what to do.

Ah. You just replace methods by objects.

You should be programming Java:
https://steve-yegge.blogspot.be/2006/03/execution-in-kingdom-of-nouns.html

I prefer imperative programming. (verbs, if you want). It comes more natural.

Well, each his own style. But, if you allow me: the post on the lazarus forum and the Xavier page should really explain what you mean by OOP. I guess most people will be confused, as I am.

Thanks for explaining.

Michael.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines

Nah... most of them know nothing about true OOP.
They believe that an object is a "record" with getters and setters... anyway.

Show quoted text 6 lines
I prefer imperative programming. (verbs, if you want). It comes more natural. Well, each his own style. But, if you allow me: the post on the lazarus forum and the Xavier page should really explain what you mean by OOP. I guess most people will be confused, as I am.

As you said, each his own style. What is more important is keeping this excellent community united, around that great language called Object Pascal.
And indeed is a good tip. I'll improve the README. Thank you.

Thanks for explaining.

You're welcome.

Best regards,
Marcos Douglas

Reply by email

leledumbo
to Marcos Douglas B. Santos: I'm working in my new "pet project" called Xavier. Xavier is an object-oriented library…

Free Pascal - Lazarus mailing list wrote

Show quoted text 7 lines
Hi, I'm working in my new "pet project" called Xavier. Xavier is an object-oriented library for work with XML. The motives and announcement is on the forum: http://forum.lazarus.freepascal.org/index.php/topic,38343.0.html

Apart from not needing to free memory and simpler nodes retrieval, I can't really see any difference with DOM. I was expecting some kind of DSL to work with XML in a declarative way, but unfortunately it still looks imperative.

Reply by email

R0b0t1
to Michael Van Canneyt: As I understand it, objects are exactly the opposite of functional programming, in that…
Michael Van Canneyt wrote 36 lines
On Wed, 20 Sep 2017, Marcos Douglas B. Santos via Lazarus wrote: > On Wed, Sep 20, 2017 at 4:31 PM, Michael Van Canneyt via Lazarus > wrote: >> >> >> >> On Wed, 20 Sep 2017, Marcos Douglas B. Santos via Lazarus wrote: >> >>> Hi, >>> >>> I'm working in my new "pet project" called Xavier. >>> Xavier is an object-oriented library for work with XML. >> >> >> >> I don't understand the 'why' ? Should I understand that you consider the >> DOM >> units not object-oriented ? > > > Yes and no. > > Michael, with all my respect, that depends of your view about Object > thinking. > Yes, DOM uses classes and objects, but IMO Objects is more than that. > Objects are more close to Functional programming than most people think. As I understand it, objects are exactly the opposite of functional programming, in that they encapsulate state, and functional programming wants to avoid state (variables, if you want).

You can think of an object's data as a monad's data, and the methods in the objects in a hierarchy as the various monadic functions which operate on that data.

In a typical functional language the monadic functions and their arguments do not have any hierarchical relation.

Show quoted text 35 lines
> If can code classes but if you are implementing (all) in an imperative > way, I mean line by line telling the computer how to do something > instead of code what you just want, you may not are thinking in terms > of Objects. Your class, in these cases, is just a "bucket of data and > procedures". Yes. That's what an object is. > > In a perfect design, we may only connect all objects to work in a > "task", call "run", and "they" will know what to do. Ah. You just replace methods by objects. You should be programming Java: https://steve-yegge.blogspot.be/2006/03/execution-in-kingdom-of-nouns.html I prefer imperative programming. (verbs, if you want). It comes more natural. Well, each his own style. But, if you allow me: the post on the lazarus forum and the Xavier page should really explain what you mean by OOP. I guess most people will be confused, as I am. Thanks for explaining. Michael. -- _______________________________________________ Lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

Reply by email

Michael Schnell
to Marcos Douglas B. Santos: On Wed, Sep 20, 2017 at 4:31 PM, Michael Van Canneyt via Lazarus Yes and no. Michael,…
Marcos Douglas B. Santos wrote
In a perfect design, we may only connect all objects to work in a "task", call "run", and "they" will know what to do. They (Objects) will decide how to do. Not the programmer (the "controller"). Just objects sending messages for each other.

Is that what the (language construct) "Interface" is supposed to provide ?

-Michael

Reply by email

Anthony Walter
to Michael Schnell

Marcos,

What and where are James.Data, James.Data.Clss?

Have you seen my XML interface at this url?

https://github.com/sysrpl/Cross.Codebot/blob/master/source/codebot.text.xml.pas

It might be helpful to study and/or consider. Example:

var
  D: IDocument;
  N: INode;
  F: IFiler;
begin
  D := CreateDocument;
  N := D.Force('config/settings');
  F := N.Filer;
  F.WriteStr('name', 'Marcos')
  F.WriteInt('@luckyNumber', 7);
  WriteLn(D.Text);
  D.Beautify;
  WriteLn(D.Text);
end;

Output:

<?xml version="1.0" encoding="UTF-8"?><config><settings luckyNumber="7"><name>Marcos</name></settings></config>

<?xml version="1.0" encoding="UTF-8"?>
<config>
<settings luckyNumber="7">
<name>Marcos</name>
</settings>
</config>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170921/8e47f095/attachment.html>

Reply by email

Marcos Douglas B. Santos
to leledumbo: Free Pascal - Lazarus mailing list wrote Apart from not needing to free memory and…
leledumbo wrote 12 lines
Free Pascal - Lazarus mailing list wrote > Hi, > > I'm working in my new "pet project" called Xavier. > Xavier is an object-oriented library for work with XML. > > The motives and announcement is on the forum: > http://forum.lazarus.freepascal.org/index.php/topic,38343.0.html Apart from not needing to free memory and simpler nodes retrieval, I can't really see any difference with DOM. I was expecting some kind of DSL to work with XML in a declarative way, but unfortunately it still looks imperative.

I've just started this project and we don't have the 1.0 version yet. Any ideas could be considered at this point.

Regards,
Marcos Douglas

Reply by email

Marcos Douglas B. Santos
to Michael Schnell: Is that what the (language construct) "Interface" is supposed to provide ? -Michael
Michael Schnell wrote 8 lines
On 20.09.2017 22:09, Marcos Douglas B. Santos via Lazarus wrote: > > In a perfect design, we may only connect all objects to work in a "task", > call "run", and "they" will know what to do. They (Objects) will decide how > to do. Not the programmer (the "controller"). Just objects sending messages > for each other. Is that what the (language construct) "Interface" is supposed to provide ?

No. But Interfaces are very important. There is not true OOP without "contracts" — that is what Interfaces are.
You can use inheritance to provide polimorphism, but inheritance could be evil and should be avoided[1] as much you can. Instead, use composion.
Others languages are using "duck typing", but I believe Interfaces are better.

Regards,
Marcos Douglas

[1] My posts about inheritance https://goo.gl/nzM4Ss

Reply by email

Marcos Douglas B. Santos
to Anthony Walter: What and where are James.Data, James.Data.Clss? Have you seen my XML interface at this…
Anthony Walter wrote
Marcos, What and where are James.Data, James.Data.Clss?

Hi Anthony,

Jame is another project of mine: https://github.com/mdbs99/james I've changed Xavier README a little bit including James as a dependency and some principles.
Sorry about this misudestandy.

Show quoted text 7 lines
Have you seen my XML interface at this url? https://github.com/sysrpl/Cross.Codebot/blob/master/source/codebot.text.xml.pas It might be helpful to study and/or consider. Example: [...snip...]

I know Codebot and Bare.Game for a long time.
Maybe I already told you, but you're a great developer. You code things from the scratch and, even that, the design of your classes is clean and beautiful. I mean, you do not code like a "hacker", but as an architect. Your work have inspired me many times. Thank you.

Unfortunately, I didn't remember about this part when I thought to code Xavier — but it was only a few hours coding with 2 beers. However, I have some principles or own style that prevents me to use Codebot. For example: I don't use functions anymore, only objects (tip: think about put your functions inside classes, see New() methods in Xavier); classes should be short as possible with 5 or less methods, most; no nil/NULL as a valid return; other things. But of course I will study (again) Codebot! For example, I will see how did you code XPath, because I need to know how to do this on Windows too. I can get many ideas from Codebot. Thanks again.

What license did you use in Codebot? You might put a LICENSE file there...

Another thing: You might divide Codebot in some specific libraries. I thought coding everything that I want in James, but I realized that is simpler to new users give just a piece that they want now, not a big library — even with dependencies.

Best regards,
Marcos Douglas

Reply by email

Marcos Douglas B. Santos
to el es
el es wrote 8 lines
On 21/09/17 17:49, Marcos Douglas B. Santos via Lazarus wrote: > > [1] My posts about inheritance https://goo.gl/nzM4Ss > If it only was in English ;) Unfortunately knowing Esperanto (once upon a time) only gets you so far.... as 5% ;)

The blog is written in Portuguese.
Maybe I can be far from readers here, on this list. But remember that Brazil — Portuguese speakers — is a huge country and I have a consider audience. There are others countries that speak Portuguese too, as Portugal of course.

However, the second largest audience in my blog, comes from English speakers. Third comes from Portugal. Believe or not.

So, you can do like them: just use Google Translator. :)

Regards,
Marcos Douglas

Reply by email

Sven Barth
to el es: If it only was in English ;) Unfortunately knowing Esperanto (once upon a time) only gets…

Am 22.09.2017 15:51 schrieb "el es via Lazarus" <

Show quoted text 9 lines
: On 21/09/17 17:49, Marcos Douglas B. Santos via Lazarus wrote: > > [1] My posts about inheritance https://goo.gl/nzM4Ss > If it only was in English ;) Unfortunately knowing Esperanto (once upon a

time)

only gets you so far.... as 5% ;)

Google Translate does a rather good job of translating the articles :)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170923/450b8efc/attachment.html>

Reply by email

Graeme Geldenhuys
to Marcos Douglas B. Santos: On Wed, Sep 20, 2017 at 7:33 PM, Michael Van Canneyt via Lazarus Nah... most of them know…
Marcos Douglas B. Santos wrote
Nah... most of them know nothing about true OOP. They believe that an object is a "record" with getters and setters... anyway.

If I understand you correctly... referring to Java developers, then that is a totally wrong generalisation.

As you said, each his own style. What is more important is keeping this excellent community united, around that great language called Object Pascal.

I love Object Pascal too, and have a real soft spot for it (and always will). But G*D damn, Java is brilliant too. Not just Java the language, but the millions of frameworks and tools built around it too (JPA, Spring Boot, Jenkins, Maven etc). Also the understated Java Annotations are unbelievably powerful and can (and does) reduce the amount of boilerplate code tremendously(*).

FPC doesn't even cover the most basic of things - no decent debugger that can handle all the Object Pascal language features. :-/

* Take a gander at how much Java Annotations reduced boiler plate code using JPA in EJB 3.0 and later vs EJB 2.1 which didn't use annotations.

http://web.archive.org/web/20100731223045/http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 23 lines
On 2017-09-21 04:06, Marcos Douglas B. Santos via Lazarus wrote: > > Nah... most of them know nothing about true OOP. > They believe that an object is a "record" with getters and setters... anyway. If I understand you correctly... referring to Java developers, then that is a totally wrong generalisation. > As you said, each his own style. What is more important is keeping > this excellent community united, around that great language called > Object Pascal. I love Object Pascal too, and have a real soft spot for it (and always will). But G*D damn, Java is brilliant too. Not just Java the language, but the millions of frameworks and tools built around it too (JPA, Spring Boot, Jenkins, Maven etc). Also the understated Java Annotations are unbelievably powerful and can (and does) reduce the amount of boilerplate code tremendously(*). FPC doesn't even cover the most basic of things - no decent debugger that can handle all the Object Pascal language features. :-/

Of course not. FPC is not a debugger, it is a compiler.

But if you put the combined resources of IBM and Oracle at our disposal, we'll quickly catch up.

Show quoted text 6 lines
* Take a gander at how much Java Annotations reduced boiler plate code using JPA in EJB 3.0 and later vs EJB 2.1 which didn't use annotations. http://web.archive.org/web/20100731223045/http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html

That's actually a step backwards.
Because it breaks the separation of object and storage.

Good for some quick and dirty prototyping, but a potential disaster in the long run.

It suffices that the DBA decides to move (part of) the data for storage, and you're dead...

I have to manage an API where the same data can meanwhile come from 1 to 4 different kinds of databases, depending on some (for all practical purposes) random parameter. Luckily, at the start I separated storage and object.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
> FPC doesn't even cover the most basic of things - no decent debugger > that can handle all the Object Pascal language features. :-/ Of course not. FPC is not a debugger, it is a compiler.

Strange then that FPC includes many other tools like documentation generators and such. But something as critical as a debugger has always been brushed under the carpet (low or no priority). A compiler and debugger go hand-in-hand as part of a developer's "toolbox" - think minimum requirements.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
On 2017-09-23 12:36, Michael Van Canneyt wrote: >> FPC doesn't even cover the most basic of things - no decent debugger >> that can handle all the Object Pascal language features. :-/ > > Of course not. FPC is not a debugger, it is a compiler. Strange then that FPC includes many other tools like documentation generators and such.

Touché :-)

A good debugger is indeed sorely missed.

Michael.

Reply by email

Sven Barth

Am 23.09.2017 18:30 schrieb "Graeme Geldenhuys via Lazarus" <

Show quoted text 13 lines
: On 2017-09-23 12:36, Michael Van Canneyt wrote: >> >> FPC doesn't even cover the most basic of things - no decent debugger >> that can handle all the Object Pascal language features. :-/ > > > Of course not. FPC is not a debugger, it is a compiler. Strange then that FPC includes many other tools like documentation

generators and such. But something as critical as a debugger has always been brushed under the carpet (low or no priority). A compiler and debugger go hand-in-hand as part of a developer's "toolbox" - think minimum requirements.

Considering that both compilers and debuggers are considered part of the Holy Trinity of programming (with the third being operating systems) I personally am not surprised as writing any of those three is a hard task, much harder than e.g. a documentation generator and we definitely don't have the manpower for that.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170924/5189758a/attachment.html>

Reply by email

Graeme Geldenhuys
to Sven Barth
Sven Barth wrote
Holy Trinity of programming (with the third being operating systems) I personally am not surprised as writing any of those three is a hard task, much harder than e.g. a documentation generator and we definitely don't have the manpower for that.

Well, some of use have attempted that in the past - myself included. Good progress was made, but little time always being the enemy of open source, and nobody jumping in to help meant many of those debugger efforts has stopped. But that's the joys of open source - people only work on what they find interesting - if they have the time. :)

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Of course not. FPC is not a debugger, it is a compiler. But if you put the combined…
Michael Van Canneyt wrote
That's actually a step backwards. Because it breaks the separation of object and storage.

Of course I would normally agree with that, but if you look at the Java annotations in that article - they are not code per-se, but more like small code comments - enough to tell the JPA backend what to do. And Java's RTTI is chock full of information, so the JPA backend can extract exactly what it needs.

eg:
@Entity
public class Person {
...
}

That's enough to notify the JPA that the Person class can be persisted to a "Person" table.

They also work on the concept that defaults are used. You only add annotations if the defaults should not be used. This again minimise developer effort tremendously.

Good for some quick and dirty prototyping, but a potential disaster in the long run.

No more effort that maintaining an external XML mapping file, or hard-coded CRUD visitor.

It suffices that the DBA decides to move (part of) the data for storage, and you're dead...

That would break all code I can think of, and would require developer effort to resolve no matter what.

Sorry, this is getting a bit off-topic in this mailing list, so I'll stop here.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 6 lines
On 2017-09-24 09:02, Graeme Geldenhuys via Lazarus wrote: > Of course I would normally agree with that, but if you look at the Java > annotations in that article Just curious, I know C# has annotations support too. Does Delphi?

Yes.
It's called Attributes. FPC has it too, but it is not yet in trunk.

Michael.

Reply by email

Marcos Douglas B. Santos
to Graeme Geldenhuys: If I understand you correctly... referring to Java developers, then that is a totally…
Graeme Geldenhuys wrote 10 lines
On 2017-09-21 04:06, Marcos Douglas B. Santos via Lazarus wrote: > > > Nah... most of them know nothing about true OOP. > They believe that an object is a "record" with getters and setters... > anyway. If I understand you correctly... referring to Java developers, then that is a totally wrong generalisation.

Ok, I will rephrase: most that I know, met, or that I read an article or comment on the internet.

Show quoted text 14 lines
> As you said, each his own style. What is more important is keeping > this excellent community united, around that great language called > Object Pascal. I love Object Pascal too, and have a real soft spot for it (and always will). But G*D damn, Java is brilliant too. Not just Java the language, but the millions of frameworks and tools built around it too (JPA, Spring Boot, Jenkins, Maven etc). Also the understated Java Annotations are unbelievably powerful and can (and does) reduce the amount of boilerplate code tremendously(*). FPC doesn't even cover the most basic of things - no decent debugger that can handle all the Object Pascal language features. :-/

Unfortunately, I have to agree about the debugger. :(

Show quoted text 6 lines
* Take a gander at how much Java Annotations reduced boiler plate code using JPA in EJB 3.0 and later vs EJB 2.1 which didn't use annotations. http://web.archive.org/web/20100731223045/http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html

Thanks,

Marcos Douglas

Reply by email