[Pas2js] The goal of pas2js
Michael Van Canneyt
michael at freepascal.org
Sun Dec 30 19:59:46 CET 2018
On Sun, 30 Dec 2018, Michael Van Canneyt wrote:
>> Pas2js should be an full extented feature language; the language can
> support
>> several syntax and features/extensions introduced similar to Delphi Prism /
>> Oxygene / DWScript / FPC, as well as various language extensions, "make
>> pascal resemble Javascript".
>
> Well, it is open source. you are of course free to fork the project.
>
> Some of the things you ask will definitely be done, but not all.
>
> The features that exist in Delphi/FPC will be ported. But we will not enter
> the
> "complete" Javascript syntax world.
>
> But if you want all Javascript features, simply program Javascript.
> With Typescript, you'll have complete javascript and type safety on top.
I am not satisfied with the tone of my reply, it comes across as much harder
than I intended it, for which I apologize.
Let me rephrase and clarify:
The goal of pas2js is to enable to use pascal in the browser.
There is still a long way to go to make this possible. In the first place,
all features available in Delphi/FPC must be suported.
Secondly, the compiler needs optimizations to emit more efficient Javascript.
We just posted a page on the wiki:
http://wiki.freepascal.org/Pas2js_optimizations
The above program is already quite heavy, and will take quite a long time to
complete. Delphi and FPC are also moving targets, no doubt the list will
grow.
I wish to stress the need to focus on (and restrict ourselves to) the above goals.
If we want to convince component developers to port their components to Pascal,
we must first of all offer what Delphi has.
The same is true for Lazarus: the LCL uses generics. If we ever want a real
lazarus LCL widgetset, we must support that.
Adding Javascript-specific features can be cunterproductive:
I don't know if anyone has already tried to work with pas2JS in Delphi
(using TMS Web core) but if you include a unit that is not in the list of stub
units provided by TMS Software, Delphi stops working: no more code
completion, no 'code intelligence' or whatever it is called.
This is simply because we use external classes. Something that Delphi does
not understand. Adding more 'strange' language features will only make this
problem worse.
One could say that Lazarus can be made to understand it, and this is
correct. But delphi does not (yet) and I consider it important that we
keep Delphi people on board.
Adding more Javascripts-pecific features while neglecting Delphi/FPC
compatibility does not fit this purpose.
Lastly, I think it is important that most if not all pascal code is also
usable outside pas2js. This will not work if we start adding Javascript-specific
features.
(yes, I know about modeswitches, but they do not solve this problem)
The motto of Lazarus is code once, compile everywhere. I want to keep this
true as long as possible, and so the goal is: make pascal available on the
browser.
if, in 5 or 10 years, the browser has replaced all other platforms, we'll adjust
out goals obviously, but for the moment, I don't think this is relevant.
Last but not least: I firmly believe that we need lots of libraries instead
of language feature:
Therefor I would like to see a lot of external class definitions for existing
libraries: Bootstrap, Angular, react, underscore, backbone.
Excellent libraries that we should not reinvent.
We already have the language features that we need to make these libraries
available.
So my belief is that we should focus on this, and not lament the lack of
perceived advantages of Javascript language features.
Michael.
More information about the Pas2js
mailing list