First pas2js public release

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

First pas2js public release

Michael Van Canneyt

Hello fellow Pascal enthousiasts,

It is with great pleasure that I can finally announce the first publicly
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow) development.

pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser, and
in Node.js.

It is open source, and part of FPC/Lazarus.
This makes Free Pascal a full-stack development environment for Web Development:
You can use it to program the server and the browser alike, all from within
the environment you love so much :)

What does pas2js include ?
--------------------------

* On the language level:

It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.

This is just the first version, we of course want to add the same language
features that exist in Delphi and FPC today.

* On the runtime level:

Beside the compiler itself, there is a basic Object Pascal RTL,
and several units from the FPC Packages are also available:

system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp

* Debugging:

Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.

* Demoes ?

The package has several demoes, including FPReport, TDataset, JQuery and
Bootstrap.

* Documentation  ?

As befits an open source project, docs are lagging behind :/

But a WIKI page has been started, it will be expanded as time permits:

http://wiki.freepascal.org/pas2js

* Sources ?

The pas2js compiler sources and RTL sources have been checked in in FPC's
subversion repository. The page describes where to find it in SVN.

* Binaries ?

A snapshot is available:
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip

* Reporting bugs ?

The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.

* Can you help ?

Yes, of course. There is still a lot of work to be done.
Feel free to contact me or Mattias Gaertner with questions.

What about Lazarus ?
--------------------

Lazarus "understands" the extensions to object pascal (for importing Javascript
classes) that were borrowed from the JVM version of the compiler, so the
code completion will continue to work.

Using the pre-compiler command, CTRL-F9 just works. On error, you will be
shown the error location etc.

Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration.
Later on, a real widget set for the browser can (and hopefully will) be created.

But that is not all !
---------------------

In the very near future, a major Delphi component vendor will announce a
complete package for RAD web development in the Delphi IDE.
The expectation is that later on, the exact same components will be usable
in Lazarus. In essence, the component developer has created a complete browser
widgetset. More than 100 controls are available.

Using this, you can design a web application as you design a desktop app;
Fully RAD, as you are used to. But even more, you can bind controls on a
form to existing tags in a web page, thus preserving the style in the web page.

The first demoes for a selected audience have evoked very positive feedback
indeed.

All this is based on pas2js.

As soon as I receive permission, I will announce here where it becomes
available.

Lastly!
-------

On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
finishing what has been started a long time ago.

Without him, none of this would have been possible.

The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more years to
finish this.

It is - for me - a long standing dream finally come true.

Enjoy !

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

codz
good news & thanks for the effort

is it similar to Emscripten ?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Free Pascal - General mailing list
Am 17.12.2017 08:01 schrieb "code dz" <[hidden email]>:
good news & thanks for the effort

is it similar to Emscripten ?

Not really. Emscripten (and WebAsm) has the goal to convert native programs that rely on pointers. It is essentially an assembly language in JavaScript. Pas2JS is on the other hand a transpiler and does not - as Michael explained - support native features like pointers. Also if you look at the generated code you can still understand it without much effort. 

Regards, 
Sven 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Michael Van Canneyt


On Sun, 17 Dec 2017, Sven Barth via fpc-pascal wrote:

> Am 17.12.2017 08:01 schrieb "code dz" <[hidden email]>:
>
> good news & thanks for the effort
>
> is it similar to Emscripten ?
>
>
> Not really. Emscripten (and WebAsm) has the goal to convert native programs
> that rely on pointers. It is essentially an assembly language in
> JavaScript. Pas2JS is on the other hand a transpiler and does not - as
> Michael explained - support native features like pointers. Also if you look
> at the generated code you can still understand it without much effort.

Completely correct.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Snorkl e
Wow, nice job 😀

On Dec 17, 2017 2:29 AM, "Michael Van Canneyt" <[hidden email]> wrote:


On Sun, 17 Dec 2017, Sven Barth via fpc-pascal wrote:

Am 17.12.2017 08:01 schrieb "code dz" <[hidden email]>:

good news & thanks for the effort

is it similar to Emscripten ?


Not really. Emscripten (and WebAsm) has the goal to convert native programs
that rely on pointers. It is essentially an assembly language in
JavaScript. Pas2JS is on the other hand a transpiler and does not - as
Michael explained - support native features like pointers. Also if you look
at the generated code you can still understand it without much effort.

Completely correct.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Graeme Geldenhuys-6
In reply to this post by Michael Van Canneyt
Well done to everybody involve. This is truly impressive news!

> * Debugging:
>
> Obviously, the browser debugger can be used to debug the Javascript.
> But there is more: the compiler can emit a source map, and this means that
> if the browser finds the source file, it will display the original source
> file instead of the javascript. You can debug Object pascal in the browser.


Now that is impressive and very welcome news.


Good job to all.


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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Ingemar Ragnemalm
In reply to this post by Michael Van Canneyt


This is great news, something that I have been longing for for years! There have been some related efforts but none that really solved my problem. Best Christmas present this year!

After some initial fiddling, I realized that there was a misspelling in the wiki, and Hello World worked once I use -Jirtl.js rather than -jirtl.js. And then I got some of the provided demos running too and managed to write one of my own. So it looks good!

Here is an early result, expressing my feelings for this release:

http://ragnemalm.se/images/santa/santa.html

I couldn't get sound working, but otherwise it seems to work as it should! (I hope it does for the rest of you.)

/Ingemar

Den 2017-12-17 kl. 12:00, skrev Michael Van Canneyt:
From: Michael Van Canneyt [hidden email]
To: FPC mailing list [hidden email],  FPC
	development mailing list [hidden email],  Lazarus
	mailing list [hidden email]
Subject: [fpc-pascal] First pas2js public release
Message-ID: [hidden email]
Content-Type: text/plain; format=flowed; charset=US-ASCII


Hello fellow Pascal enthousiasts,

It is with great pleasure that I can finally announce the first publicly
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow) development.

pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser, and
in Node.js.

It is open source, and part of FPC/Lazarus. 
This makes Free Pascal a full-stack development environment for Web Development:
You can use it to program the server and the browser alike, all from within
the environment you love so much :)

What does pas2js include ?
--------------------------

* On the language level:

It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript. 
Code that relies on this will not work.

This is just the first version, we of course want to add the same language 
features that exist in Delphi and FPC today.

* On the runtime level:

Beside the compiler itself, there is a basic Object Pascal RTL, 
and several units from the FPC Packages are also available:

system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp

* Debugging:

Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.

* Demoes ?

The package has several demoes, including FPReport, TDataset, JQuery and
Bootstrap.

* Documentation  ?

As befits an open source project, docs are lagging behind :/

But a WIKI page has been started, it will be expanded as time permits:

http://wiki.freepascal.org/pas2js

* Sources ?

The pas2js compiler sources and RTL sources have been checked in in FPC's 
subversion repository. The page describes where to find it in SVN.

* Binaries ?

A snapshot is available:
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip

* Reporting bugs ?

The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.

* Can you help ?

Yes, of course. There is still a lot of work to be done. 
Feel free to contact me or Mattias Gaertner with questions.

What about Lazarus ?
--------------------

Lazarus "understands" the extensions to object pascal (for importing Javascript
classes) that were borrowed from the JVM version of the compiler, so the
code completion will continue to work.

Using the pre-compiler command, CTRL-F9 just works. On error, you will be
shown the error location etc.

Further and deeped integration of pas2js into lazarus is expected. 
In the first place, IDE integration. 
Later on, a real widget set for the browser can (and hopefully will) be created.

But that is not all !
---------------------

In the very near future, a major Delphi component vendor will announce a
complete package for RAD web development in the Delphi IDE. 
The expectation is that later on, the exact same components will be usable 
in Lazarus. In essence, the component developer has created a complete browser
widgetset. More than 100 controls are available.

Using this, you can design a web application as you design a desktop app;
Fully RAD, as you are used to. But even more, you can bind controls on a 
form to existing tags in a web page, thus preserving the style in the web page.

The first demoes for a selected audience have evoked very positive feedback
indeed.

All this is based on pas2js.

As soon as I receive permission, I will announce here where it becomes
available.

Lastly!
-------

On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
finishing what has been started a long time ago.

Without him, none of this would have been possible.

The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more years to
finish this.

It is - for me - a long standing dream finally come true.

Enjoy !

Michael.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Mattias Gaertner
On Wed, 20 Dec 2017 12:29:25 +0100
Ingemar Ragnemalm <[hidden email]> wrote:

>[...]
> After some initial fiddling, I realized that there was a misspelling in
> the wiki, and Hello World worked once I use -Jirtl.js rather than
> -jirtl.js.

Fixed.


> And then I got some of the provided demos running too and
> managed to write one of my own. So it looks good!
>
> Here is an early result, expressing my feelings for this release:
>
> http://ragnemalm.se/images/santa/santa.html
>
> I couldn't get sound working, but otherwise it seems to work as it
> should! (I hope it does for the rest of you.)

Beautiful.
Can I add the URL as an example?


Mattias



>
> /Ingemar
>
> Den 2017-12-17 kl. 12:00, skrev Michael Van Canneyt:
> > From: Michael Van Canneyt<[hidden email]>
> > To: FPC mailing list<[hidden email]>,  FPC
> > development mailing list<[hidden email]>,  Lazarus
> > mailing list<[hidden email]>
> > Subject: [fpc-pascal] First pas2js public release
> > Message-ID:<[hidden email]>
> > Content-Type: text/plain; format=flowed; charset=US-ASCII
> >
> >
> > Hello fellow Pascal enthousiasts,
> >
> > It is with great pleasure that I can finally announce the first publicly
> > available version of pas2js. A "beta" version, version 0.8.39.
> > The endpoint (for the time being) of nearly 10 years of (slow) development.
> >
> > pas2js is a Object Pascal to Javascript transpiler. It compiles Object
> > pascal, and emits Javascript. The javascript is usable in the browser, and
> > in Node.js.
> >
> > It is open source, and part of FPC/Lazarus.
> > This makes Free Pascal a full-stack development environment for Web Development:
> > You can use it to program the server and the browser alike, all from within
> > the environment you love so much:)
> >
> > What does pas2js include ?
> > --------------------------
> >
> > * On the language level:
> >
> > It supports basically Delphi 7 syntax, interfaces excepted.
> > Naturally, any memory pointer operation is not possible in Javascript.
> > Code that relies on this will not work.
> >
> > This is just the first version, we of course want to add the same language
> > features that exist in Delphi and FPC today.
> >
> > * On the runtime level:
> >
> > Beside the compiler itself, there is a basic Object Pascal RTL,
> > and several units from the FPC Packages are also available:
> >
> > system
> > sysutils
> > Math
> > strutils
> > rtlconst
> > classes
> > contnrs
> > DB (yes, TDataset)
> > fpcunit testsuite
> > custapp
> > restconnection
> > js (javascript system objects)
> > web (browser provided objects)
> > libjquery (jquery is available too)
> > nodejs (basic node runtime environment)
> > typeinfo
> > objpas
> > browserconsole (support for writeln)
> > dateutils
> > browserapp
> > nodejsapp
> >
> > * Debugging:
> >
> > Obviously, the browser debugger can be used to debug the Javascript.
> > But there is more: the compiler can emit a source map, and this means that
> > if the browser finds the source file, it will display the original source
> > file instead of the javascript. You can debug Object pascal in the browser.
> >
> > * Demoes ?
> >
> > The package has several demoes, including FPReport, TDataset, JQuery and
> > Bootstrap.
> >
> > * Documentation  ?
> >
> > As befits an open source project, docs are lagging behind :/
> >
> > But a WIKI page has been started, it will be expanded as time permits:
> >
> > http://wiki.freepascal.org/pas2js
> >
> > * Sources ?
> >
> > The pas2js compiler sources and RTL sources have been checked in in FPC's
> > subversion repository. The page describes where to find it in SVN.
> >
> > * Binaries ?
> >
> > A snapshot is available:
> > http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip
> >
> > * Reporting bugs ?
> >
> > The FPC bugtracker has now a 'pas2js' project, it can be used to report
> > bugs.
> >
> > * Can you help ?
> >
> > Yes, of course. There is still a lot of work to be done.
> > Feel free to contact me or Mattias Gaertner with questions.
> >
> > What about Lazarus ?
> > --------------------
> >
> > Lazarus "understands" the extensions to object pascal (for importing Javascript
> > classes) that were borrowed from the JVM version of the compiler, so the
> > code completion will continue to work.
> >
> > Using the pre-compiler command, CTRL-F9 just works. On error, you will be
> > shown the error location etc.
> >
> > Further and deeped integration of pas2js into lazarus is expected.
> > In the first place, IDE integration.
> > Later on, a real widget set for the browser can (and hopefully will) be created.
> >
> > But that is not all !
> > ---------------------
> >
> > In the very near future, a major Delphi component vendor will announce a
> > complete package for RAD web development in the Delphi IDE.
> > The expectation is that later on, the exact same components will be usable
> > in Lazarus. In essence, the component developer has created a complete browser
> > widgetset. More than 100 controls are available.
> >
> > Using this, you can design a web application as you design a desktop app;
> > Fully RAD, as you are used to. But even more, you can bind controls on a
> > form to existing tags in a web page, thus preserving the style in the web page.
> >
> > The first demoes for a selected audience have evoked very positive feedback
> > indeed.
> >
> > All this is based on pas2js.
> >
> > As soon as I receive permission, I will announce here where it becomes
> > available.
> >
> > Lastly!
> > -------
> >
> > On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
> > finishing what has been started a long time ago.
> >
> > Without him, none of this would have been possible.
> >
> > The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
> > without his moral and financial help, it would have taken many more years to
> > finish this.
> >
> > It is - for me - a long standing dream finally come true.
> >
> > Enjoy !
> >
> > Michael.  
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Dave Connolly
This is fantastic. Great work everyone.

On 20 December 2017 at 11:59, Mattias Gaertner <[hidden email]> wrote:
On Wed, 20 Dec 2017 12:29:25 +0100
Ingemar Ragnemalm <[hidden email]> wrote:

>[...]
> After some initial fiddling, I realized that there was a misspelling in
> the wiki, and Hello World worked once I use -Jirtl.js rather than
> -jirtl.js.

Fixed.


> And then I got some of the provided demos running too and
> managed to write one of my own. So it looks good!
>
> Here is an early result, expressing my feelings for this release:
>
> http://ragnemalm.se/images/santa/santa.html
>
> I couldn't get sound working, but otherwise it seems to work as it
> should! (I hope it does for the rest of you.)

Beautiful.
Can I add the URL as an example?


Mattias



>
> /Ingemar
>
> Den 2017-12-17 kl. 12:00, skrev Michael Van Canneyt:
> > From: Michael Van Canneyt<[hidden email]>
> > To: FPC mailing list<[hidden email]>,  FPC
> >     development mailing list<[hidden email]>,  Lazarus
> >     mailing list<[hidden email]>
> > Subject: [fpc-pascal] First pas2js public release
> > Message-ID:<[hidden email]>
> > Content-Type: text/plain; format=flowed; charset=US-ASCII
> >
> >
> > Hello fellow Pascal enthousiasts,
> >
> > It is with great pleasure that I can finally announce the first publicly
> > available version of pas2js. A "beta" version, version 0.8.39.
> > The endpoint (for the time being) of nearly 10 years of (slow) development.
> >
> > pas2js is a Object Pascal to Javascript transpiler. It compiles Object
> > pascal, and emits Javascript. The javascript is usable in the browser, and
> > in Node.js.
> >
> > It is open source, and part of FPC/Lazarus.
> > This makes Free Pascal a full-stack development environment for Web Development:
> > You can use it to program the server and the browser alike, all from within
> > the environment you love so much:)
> >
> > What does pas2js include ?
> > --------------------------
> >
> > * On the language level:
> >
> > It supports basically Delphi 7 syntax, interfaces excepted.
> > Naturally, any memory pointer operation is not possible in Javascript.
> > Code that relies on this will not work.
> >
> > This is just the first version, we of course want to add the same language
> > features that exist in Delphi and FPC today.
> >
> > * On the runtime level:
> >
> > Beside the compiler itself, there is a basic Object Pascal RTL,
> > and several units from the FPC Packages are also available:
> >
> > system
> > sysutils
> > Math
> > strutils
> > rtlconst
> > classes
> > contnrs
> > DB (yes, TDataset)
> > fpcunit testsuite
> > custapp
> > restconnection
> > js (javascript system objects)
> > web (browser provided objects)
> > libjquery (jquery is available too)
> > nodejs (basic node runtime environment)
> > typeinfo
> > objpas
> > browserconsole (support for writeln)
> > dateutils
> > browserapp
> > nodejsapp
> >
> > * Debugging:
> >
> > Obviously, the browser debugger can be used to debug the Javascript.
> > But there is more: the compiler can emit a source map, and this means that
> > if the browser finds the source file, it will display the original source
> > file instead of the javascript. You can debug Object pascal in the browser.
> >
> > * Demoes ?
> >
> > The package has several demoes, including FPReport, TDataset, JQuery and
> > Bootstrap.
> >
> > * Documentation  ?
> >
> > As befits an open source project, docs are lagging behind :/
> >
> > But a WIKI page has been started, it will be expanded as time permits:
> >
> > http://wiki.freepascal.org/pas2js
> >
> > * Sources ?
> >
> > The pas2js compiler sources and RTL sources have been checked in in FPC's
> > subversion repository. The page describes where to find it in SVN.
> >
> > * Binaries ?
> >
> > A snapshot is available:
> > http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip
> >
> > * Reporting bugs ?
> >
> > The FPC bugtracker has now a 'pas2js' project, it can be used to report
> > bugs.
> >
> > * Can you help ?
> >
> > Yes, of course. There is still a lot of work to be done.
> > Feel free to contact me or Mattias Gaertner with questions.
> >
> > What about Lazarus ?
> > --------------------
> >
> > Lazarus "understands" the extensions to object pascal (for importing Javascript
> > classes) that were borrowed from the JVM version of the compiler, so the
> > code completion will continue to work.
> >
> > Using the pre-compiler command, CTRL-F9 just works. On error, you will be
> > shown the error location etc.
> >
> > Further and deeped integration of pas2js into lazarus is expected.
> > In the first place, IDE integration.
> > Later on, a real widget set for the browser can (and hopefully will) be created.
> >
> > But that is not all !
> > ---------------------
> >
> > In the very near future, a major Delphi component vendor will announce a
> > complete package for RAD web development in the Delphi IDE.
> > The expectation is that later on, the exact same components will be usable
> > in Lazarus. In essence, the component developer has created a complete browser
> > widgetset. More than 100 controls are available.
> >
> > Using this, you can design a web application as you design a desktop app;
> > Fully RAD, as you are used to. But even more, you can bind controls on a
> > form to existing tags in a web page, thus preserving the style in the web page.
> >
> > The first demoes for a selected audience have evoked very positive feedback
> > indeed.
> >
> > All this is based on pas2js.
> >
> > As soon as I receive permission, I will announce here where it becomes
> > available.
> >
> > Lastly!
> > -------
> >
> > On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
> > finishing what has been started a long time ago.
> >
> > Without him, none of this would have been possible.
> >
> > The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
> > without his moral and financial help, it would have taken many more years to
> > finish this.
> >
> > It is - for me - a long standing dream finally come true.
> >
> > Enjoy !
> >
> > Michael.
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Graeme Geldenhuys-6
In reply to this post by Ingemar Ragnemalm
On 2017-12-20 11:29, Ingemar Ragnemalm wrote:
> http://ragnemalm.se/images/santa/santa.html
>
> I couldn't get sound working, but otherwise it seems to work as it
> should! (I hope it does for the rest of you.)

Awesome - I still have to get my head around this whose Pas2JS
functionality. It seems very impressive thus far. :)

ps:
   I tested your Santa demo under 64-bit FreeBSD with Firefox. Worked
   perfectly.

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Ingemar Ragnemalm
In reply to this post by Michael Van Canneyt


Den 2017-12-20 kl. 13:09, skrev Mattias Gaertner:
On Wed, 20 Dec 2017 12:29:25 +0100
Ingemar Ragnemalm [hidden email] wrote:
And then I got some of the provided demos running too and 
managed to write one of my own. So it looks good!

Here is an early result, expressing my feelings for this release:

http://ragnemalm.se/images/santa/santa.html

I couldn't get sound working, but otherwise it seems to work as it 
should! (I hope it does for the rest of you.)
Beautiful. 
Can I add the URL as an example?

Absolutely, and I don't mind sharing the code. It is in the same folder! Very small and simple program, and all FPC. :)

Although I would like to make some improvements - who doesn't? To be precise, I want to figure out a way to play sounds, and I want image loading directly in the code and not dependent on the HTML. Any ideas about that?

It feels really nice to have my first Pascal web application running! Well, I could do it in Java before but that isn't as universal as JavaScript.

/Ingemar


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Reimar Grabowski
On Wed, 20 Dec 2017 15:14:50 +0100
Ingemar Ragnemalm <[hidden email]> wrote:

> Although I would like to make some improvements - who doesn't? To be
> precise, I want to figure out a way to play sounds, and I want image
> loading directly in the code and not dependent on the HTML. Any ideas
> about that?
First of all I know nothing about pas2js, but...
As your code is running solely in the browser there is no option to load it from file for security reasons.
But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
Once you have the data put it into a blob, create an url and finally use that as you image url.
So you need pascal code that will produce this JS code:

var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
var url = URL.createObjectURL(blob);
var image = new Image();
image.src = url;

But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.

While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).

> It feels really nice to have my first Pascal web application running!
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.

> Well, I could do it in Java before but that isn't as universal as
> JavaScript.
For this concrete project you could have done it with pure JS which would be about 950 lines less of JS code. ;)

Nonetheless, nice work.

R.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Ryan Joseph
In reply to this post by Ingemar Ragnemalm


> On Dec 20, 2017, at 9:14 PM, Ingemar Ragnemalm <[hidden email]> wrote:
>
> Absolutely, and I don't mind sharing the code. It is in the same folder! Very small and simple program, and all FPC. :)

Can you post the code? I haven’t actually seen any examples so I have no idea how it works.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Lukasz Sokol
On 21/12/17 11:53, Ryan Joseph wrote:

>
>
>> On Dec 20, 2017, at 9:14 PM, Ingemar Ragnemalm <[hidden email]> wrote:
>>
>> Absolutely, and I don't mind sharing the code. It is in the same folder! Very small and simple program, and all FPC. :)
>
> Can you post the code? I haven’t actually seen any examples so I have no idea how it works.
>
> Regards,
> Ryan Joseph
>

Code seems to be in http://ragnemalm.se/images/santa/
(there is no 'index' page so it shows files)

-L.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Michael Schnell
In reply to this post by Reimar Grabowski
On 20.12.2017 17:30, Reimar Grabowski wrote:
> Not dissing you or your work or pas2js but I fail to see the web
> application part. There is no communication between client and server.
> Actually there is no server side code at all and there is no
> interactivity.
Rather obviously this would not be a compiler issue ("fpc development"),
but would needed to be provided by the library (e.g. Lazarus or mse) .

There are some post about this in the fpc-devel mailing list (where they
don't belong either, of course).

-Michael

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Michael Van Canneyt
In reply to this post by Reimar Grabowski


On Wed, 20 Dec 2017, Reimar Grabowski wrote:

> On Wed, 20 Dec 2017 15:14:50 +0100
> Ingemar Ragnemalm <[hidden email]> wrote:
>
>> Although I would like to make some improvements - who doesn't? To be
>> precise, I want to figure out a way to play sounds, and I want image
>> loading directly in the code and not dependent on the HTML. Any ideas
>> about that?
> First of all I know nothing about pas2js, but...
> As your code is running solely in the browser there is no option to load it from file for security reasons.
> But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
> Once you have the data put it into a blob, create an url and finally use that as you image url.
> So you need pascal code that will produce this JS code:
>
> var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
> var url = URL.createObjectURL(blob);
> var image = new Image();
> image.src = url;
>
> But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.
>
> While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
>
>> It feels really nice to have my first Pascal web application running!
> Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.

That is one of the points of pas2js. To allow you to program the browser.

There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.

See the browser as a desktop. Your program runs in that desktop.
If need be, this program can contact a server - the classical
client/server model, using HTTP as the protocol - but this is by no means a necessity.

In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Reimar Grabowski
On Fri, 22 Dec 2017 08:53:03 +0100 (CET)
Michael Van Canneyt <[hidden email]> wrote:

> That is one of the points of pas2js. To allow you to program the browser [in pascal].
Fixed that for you.
And yes, that's what most transpilers to javascript are meant for.

> There is no need for a server. You can make e.g. a chess application that runs
> 100% in the browser, using a single HTML file. You can embed the JS and
> images in the HTML itself, and thus your HTML file is the 'executable'.
Really, that's amazing?
 
> See the browser as a desktop. Your program runs in that desktop.
> If need be, this program can contact a server - the classical
> client/server model, using HTTP as the protocol - but this is by no means a necessity.
If you say so.
 
> In that sense, the demo demonstrates this. The server is just there for you
> to be able to download the "program"...
<!DOCTYPE html>
<html>
<head>
<title>Mighty web app</title>
</head>
<body>
</body>
<script>
  alert("I am such a mighty web application");
</script>
</html>

Ok, if this is nowadays a 'web application' I seriously get old.
But whatever, every HTML page with a script is a web app now. Lesson learned.

R.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Reimar Grabowski
In reply to this post by Michael Schnell
On Thu, 21 Dec 2017 15:49:01 +0100
Michael Schnell <[hidden email]> wrote:

> Rather obviously this
<snip>
> would needed to be provided by the library (e.g. Lazarus or mse).
LOL, no.

R.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Ingemar Ragnemalm
In reply to this post by Michael Van Canneyt


Den 2017-12-22 kl. 12:00, skrev Michael Van Canneyt:
On Wed, 20 Dec 2017, Reimar Grabowski wrote:

On Wed, 20 Dec 2017 15:14:50 +0100
Ingemar Ragnemalm [hidden email] wrote:

Although I would like to make some improvements - who doesn't? To be 
precise, I want to figure out a way to play sounds, and I want image 
loading directly in the code and not dependent on the HTML. Any ideas 
about that?
First of all I know nothing about pas2js, but...
As your code is running solely in the browser there is no option to load it from file for security reasons.
But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
Once you have the data put it into a blob, create an url and finally use that as you image url.
So you need pascal code that will produce this JS code:

var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
var url = URL.createObjectURL(blob);
var image = new Image();
image.src = url;

Yes, something like that. I have found JS examples that does this but can't see how to make pas2js do it.

But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.

One reason is to collect information in one place. Making HTML load it gives me two steps to the file instead of one. More chances to do it wrong.

While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).

Ah. They just remained from an example I worked from.

Text flicker is most likely caused by not double buffering. I need to generate an image off-screen. Nothing strange with that, just one more thing to figure out in the JS environment.

It feels really nice to have my first Pascal web application running! 
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
There is no interactivity, and no client-server communication, but this is my *first*, my "proof of concept" for the platform, like Hello World but with some more features (animation, random numbers, graphics elements). Doing *something* with it myself, showing myself the potential, making a kind of "thanks" for it and a Christmas greeting atthe same time. Interactivity is the next step, and the ability to save data somewhere.

That is one of the points of pas2js. To allow you to program the browser.

There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.

See the browser as a desktop. Your program runs in that desktop. 
If need be, this program can contact a server - the classical 
client/server model, using HTTP as the protocol - but this is by no means a necessity.

In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...

Exactly. I get a cross-platform solution with no installations, in a way that users are increasingly used to. And I can write it in FPC, which I am a lot more happy with than a rubbish language like JavaScript! For me it opens a lot of possibilities!

But let me get back to my current problems. I can accept loading images through HTML for now, but how can I load and play sounds? There is an "Audio" API in JavaScript but it seems that pas2js doesn't support it, it can't find play(). I have searched web.pas and a few others for it. Where do I start to fix that?

/Ingemar


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Michael Van Canneyt


On Sun, 24 Dec 2017, Ingemar Ragnemalm wrote:

>>
>> In that sense, the demo demonstrates this. The server is just there for you
>> to be able to download the "program"...
>
> Exactly. I get a cross-platform solution with no installations, in a way that
> users are increasingly used to. And I can write it in FPC, which I am a lot
> more happy with than a rubbish language like JavaScript! For me it opens a
> lot of possibilities!
>
> But let me get back to my current problems. I can accept loading images
> through HTML for now, but how can I load and play sounds? There is an "Audio"
> API in JavaScript but it seems that pas2js doesn't support it, it can't find
> play(). I have searched web.pas and a few others for it. Where do I start to
> fix that?

You go to e.g. MDN, look at the API, and write a series of import classes.

This looks like a good starting point:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_AP

If it was standard on all browsers (it is not on IE), then we could add it to
web.pas. But since IE does not support it,  the classes can then be added
to a new units websound.pas.

The WIKI page of pas2js contains a rudimentary example that explains the
principle of an import class.

There is a demo (democlasstopas) that helps you to create a skeleton definition,
I will add some documentation to the WIKI or maybe make it into a unit.

If you need help, mail me in private and I will do a few sample conversions.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12