Re: [fpc-devel] First pas2js public release
On Fri, 22 Dec 2017 14:21:20 + Alfredwrote: > Thanks for a very nice tool ! > > Small problem: AFAIK, the rtl.js is missing from SVN ?! > https://svn.freepascal.org/svn/projects/pas2js/trunk/src/rtl/ The rtl.js is currently in the compiler svn: https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/utils/pas2js/dist/ Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] First pas2js public release
Thanks for a very nice tool ! Small problem: AFAIK, the rtl.js is missing from SVN ?! https://svn.freepascal.org/svn/projects/pas2js/trunk/src/rtl/___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Thu, 21 Dec 2017, Michael Schnell wrote: On 21.12.2017 08:51, Michael Van Canneyt wrote: I know. But I believe such people are completely on the wrong track. This is, because seemingly for you (and many others), the User Communication is a most important part of the project and needs to be crafted in the best possible way regarding look and feel. OTOH, for me (and some others), the User Communication is just a means to tell the program what to do and to watch if it works as expected, while the stuff the program in fact is provided for, does not do any user communication at all. Hence, for the application programmer, it's desirable, that the IDE provides means to create a GUI that fits to the wherabouts of the development phase and final project with as little effort as possible. Clearly, you see the GUI as an add-on to the core software. Then I don't understand why you don't program it as such: a browser page that communicates with the core business "server". That we provide the means to make this communication as easy as possible is of course well understood and we'll do everything to make this so. I see this as no different from programming a system that runs as a system service in windows: it is simply not allowed to have a GUI. There also, you must find a way to communicate with your "service". This is no different. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Thu, 21 Dec 2017, Michael Schnell wrote: On 21.12.2017 08:52, Michael Van Canneyt wrote: because I consider it a misguided approach, Could you elaborate why you think so ? Because it will only work for simple scenarios. As soon as things become moderately complex, this approach fails, as you will need to do the communication manually. That is why I think approaches as extpascal, extgui and - in its days - intraweb are failures. What I have in mind is: - Do a common project for both "business" and the "GUI near" code. - The IDE provides some means to define which parts of the codes are to go where (in an Object Pascal system supposedly based on classes). The IDE may try to decide this for a 'simple' hello world, but for a general application, this is simply impossible. What's more, most applications I have seen mix business and GUI code - exacerbated by RAD, of course - making this separation impossible. By forcing people to clearly separate client and browser, this split between business code and GUI code is automatic. - With that, interfaces are provided for the communication (e.g. procedure calls; in an Object Pascal system supposedly class based procedures, properties and events). Creating a huge overhead in the process: The browser communication is done asynchronously. The code needed to make it look like your code runs synchronously will simply block the browser. - The IDE compiles the code appropriately with acknowledging separates definitions for both parts to be runnable where. - The communication between the parts is implemented accordingly: if it's a "local" GUI, just a normal executable is created, if the GUI is Browser based: this part is implemented with pas2js, and the loading and communication is implemented accordingly (if the main part is stand alone, including a built-in web server, if the main part is to be run behind a web server doing it as a cgi). I do see that this is unlikely to happen, but IMHO just because lack of dev time, not because of bad concept. Well, we clearly disagree. I do think it is a really bad concept, and of course then I will not spend dev time on it :) Michael.___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Thu, 21 Dec 2017, Michael Schnell wrote: On 20.12.2017 11:36, Michael Van Canneyt wrote: (Nothing stops really the server-side-native binary (e.g. written in Pascal) from sending a pas2js transpiled program to the browser as a part of a 'html page'/script, You could do so. But I don't think you should. How else should the Java Script code reach the browser ? You just place it on the server as a file, so the HTTP server (Apache, NginX, IIS) sends it. The server side native binary doesn't need to provide it. But this could be done. In fact, there is a demo that does this: the server program is a HTTP server which has the compiler built-in, and using 3 special URLS you can request a recompile (hotreload). It can even watch the project directory on the server and automatically recompile. The browser polls for updates and when an update is available, reloads the page. A classical mechanism when doing web development in react, angular or vue, now also available in FPC. But next week I will properly document this in the wiki. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 21.12.2017 08:51, Michael Van Canneyt wrote: I know. But I believe such people are completely on the wrong track. This is, because seemingly for you (and many others), the User Communication is a most important part of the project and needs to be crafted in the best possible way regarding look and feel. OTOH, for me (and some others), the User Communication is just a means to tell the program what to do and to watch if it works as expected, while the stuff the program in fact is provided for, does not do any user communication at all. Hence, for the application programmer, it's desirable, that the IDE provides means to create a GUI that fits to the wherabouts of the development phase and final project with as little effort as possible. This results in the request for allowing to do a GUI that without any additional effort runs on multiple targets. -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 21.12.2017 08:52, Michael Van Canneyt wrote: because I consider it a misguided approach, Could you elaborate why you think so ? What I have in mind is: - Do a common project for both "business" and the "GUI near" code. - The IDE provides some means to define which parts of the codes are to go where (in an Object Pascal system supposedly based on classes). - With that, interfaces are provided for the communication (e.g. procedure calls; in an Object Pascal system supposedly class based procedures, properties and events). - The IDE compiles the code appropriately with acknowledging separates definitions for both parts to be runnable where. - The communication between the parts is implemented accordingly: if it's a "local" GUI, just a normal executable is created, if the GUI is Browser based: this part is implemented with pas2js, and the loading and communication is implemented accordingly (if the main part is stand alone, including a built-in web server, if the main part is to be run behind a web server doing it as a cgi). I do see that this is unlikely to happen, but IMHO just because lack of dev time, not because of bad concept. -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 20.12.2017 11:36, Michael Van Canneyt wrote: (Nothing stops really the server-side-native binary (e.g. written in Pascal) from sending a pas2js transpiled program to the browser as a part of a 'html page'/script, You could do so. But I don't think you should. How else should the Java Script code reach the browser ? -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Greet work !! now i am playing with demos. waiting for the components. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Wed, 20 Dec 2017, Michael Schnell wrote: On 20.12.2017 11:36, Michael Van Canneyt wrote: You program both separately, this is natural. Obviously ! But this is not necessarily the end of what might be provided by (e.g.) Lazarus. As I wrote in another reply: I will never spend time on that, because I consider it a misguided approach, but if people want to: it's a free world :) Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Wed, 20 Dec 2017, el es wrote: Hi, On 20/12/17 10:36, Michael Van Canneyt wrote: On Tue, 19 Dec 2017, Lukasz Sokol wrote: On 18/12/17 08:59, Michael Schnell wrote: Great ! Thanks a lot to all who enabled this fantastic enhancement to the fpc system ! I have been dreaming of being able to "simply run" Lazarus projects (and legacy Delphi-) ) in a server and have the GUI displayed in a browser. This seems to get in reach right now :) :) :) . (OK, splitting the project in a server and a browser part and communication between the parts will not be automatically done in very near future, but who knows ) ^ I think I should have underlined this ^^^ because my entire response was triggered by this line... [...] You program both separately, this is natural. But as you see from the underlined, not for everybody :) I know. But I believe such people are completely on the wrong track. I will never spend time on such an approach. Don't let me stop you from trying, though :) Michael.___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 20.12.2017 11:36, Michael Van Canneyt wrote: You program both separately, this is natural. Obviously ! But this is not necessarily the end of what might be provided by (e.g.) Lazarus. -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 19.12.2017 10:40, Lukasz Sokol wrote: If I Understand This Correctly, pas2js treated program would run in a browser, client side only ? And does not care what the server is, because it does not run on server ? That is of course correct and it is why I offered the sentence in brackets. Right now it's completely up to the application programmer to do the two parts of the application and to mange the communication between them. But it would be a viable task for Lazarus (ow whomever) to provide a "standard" Methodology / Library / IDE integration to allow for splitting a "normal" application in such parts. I understand that Microsoft (quite promising but finally rather unsuccessfully) had this in mind with Silverlight (C# running seamlessly in a browser). -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Hi, On 20/12/17 10:36, Michael Van Canneyt wrote: > > > On Tue, 19 Dec 2017, Lukasz Sokol wrote: > >> On 18/12/17 08:59, Michael Schnell wrote: >>> Great ! >>> >>> Thanks a lot to all who enabled this fantastic enhancement to the >>> fpc system ! >>> >>> I have been dreaming of being able to "simply run" Lazarus projects >>> (and legacy Delphi-) ) in a server and have the GUI displayed in a >>> browser. >>> >>> This seems to get in reach right now :) :) :) . (OK, splitting the >>> project in a server and a browser part and communication between the >>> parts will not be automatically done in very near future, but who >>> knows ) >>> ^ I think I should have underlined this ^^^ because my entire response was triggered by this line... [...] > You program both separately, this is natural. But as you see from the underlined, not for everybody :) > > >> For communication between the browser end and the server end, >> there are ways covered (AJAX ?) not much different than the usual >> (js in browser <-> java/php/perl/python/server side js in server > > Yes. Normal Ajax works, see the demos. > > But we went a step further. TDataset and REST works out of the box. See also > the demos. > > Michael. Can't wait to try it out... but the holidays are likely to get in the way ;) -L. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Tue, 19 Dec 2017, Lukasz Sokol wrote: On 18/12/17 08:59, Michael Schnell wrote: Great ! Thanks a lot to all who enabled this fantastic enhancement to the fpc system ! I have been dreaming of being able to "simply run" Lazarus projects (and legacy Delphi-) ) in a server and have the GUI displayed in a browser. This seems to get in reach right now :) :) :) . (OK, splitting the project in a server and a browser part and communication between the parts will not be automatically done in very near future, but who knows ) If I Understand This Correctly, pas2js treated program would run in a browser, client side only ? And does not care what the server is, because it does not run on server ? Yes. (Note that you could write a Node.js program using pas2js, so you would have a pas2js program on the server, and one on the browser) For 'server' side you then write 'as usual' e.g. cgi or other way available (server-native binary) Yes. (Nothing stops really the server-side-native binary (e.g. written in Pascal) from sending a pas2js transpiled program to the browser as a part of a 'html page'/script, You could do so. But I don't think you should. but the line of separation is pretty clear here : this is like doing Graeme's favorite GUI to non-gui portion separation ';) but still YOU are doing the separation manually - you need to write BOTH portions separately) Yes. HTTP is client server. You program both separately, this is natural. For communication between the browser end and the server end, there are ways covered (AJAX ?) not much different than the usual (js in browser <-> java/php/perl/python/server side js in server) LAMP stack does. Yes. Normal Ajax works, see the demos. But we went a step further. TDataset and REST works out of the box. See also the demos. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Tue, 19 Dec 2017 09:40:48 + Lukasz Sokolwrote: >[...] > pas2js treated program would run in a browser, client side only ? > And does not care what the server is, because it does not run on server ? Yes, in fact it does not need a server. A browser only needs some HTML and the pas2js generated js, which could be on your local disk. See here: http://wiki.freepascal.org/pas2js#for_the_browser Note that with Node.js you can run pas2js programs on the server too. > For 'server' side you then write 'as usual' e.g. cgi or other way available > (server-native binary) > > (Nothing stops really the server-side-native binary (e.g. written in Pascal) > from sending a pas2js transpiled program to the browser as a part of a 'html > page'/script, > but the line of separation is pretty clear here : this is like doing > Graeme's favorite GUI to non-gui portion separation ';) > but still YOU are doing the separation manually - you need to write BOTH > portions separately) > > For communication between the browser end and the server end, there are ways > covered > (AJAX ?) not much different than the usual (js in browser <-> > java/php/perl/python/server side js in server) LAMP stack does. Yes, see the demoxhr.lpr example in: https://svn.freepascal.org/svn/projects/pas2js/trunk/demo/rtl/ Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On 18/12/17 08:59, Michael Schnell wrote: > Great ! > > Thanks a lot to all who enabled this fantastic enhancement to the > fpc system ! > > I have been dreaming of being able to "simply run" Lazarus projects > (and legacy Delphi-) ) in a server and have the GUI displayed in a > browser. > > This seems to get in reach right now :) :) :) . (OK, splitting the > project in a server and a browser part and communication between the > parts will not be automatically done in very near future, but who > knows ) > If I Understand This Correctly, pas2js treated program would run in a browser, client side only ? And does not care what the server is, because it does not run on server ? For 'server' side you then write 'as usual' e.g. cgi or other way available (server-native binary) (Nothing stops really the server-side-native binary (e.g. written in Pascal) from sending a pas2js transpiled program to the browser as a part of a 'html page'/script, but the line of separation is pretty clear here : this is like doing Graeme's favorite GUI to non-gui portion separation ';) but still YOU are doing the separation manually - you need to write BOTH portions separately) For communication between the browser end and the server end, there are ways covered (AJAX ?) not much different than the usual (js in browser <-> java/php/perl/python/server side js in server) LAMP stack does. (I sincerely hope I understand this right). -L. > -Michael ___ fpc-devel > maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Great ! Thanks a lot to all who enabled this fantastic enhancement to the fpc system ! I have been dreaming of being able to "simply run" Lazarus projects (and legacy Delphi-) ) in a server and have the GUI displayed in a browser. This seems to get in reach right now :) :) :) . (OK, splitting the project in a server and a browser part and communication between the parts will not be automatically done in very near future, but who knows ) -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Mon, 18 Dec 2017 20:16:03 +0100 Benito van der Zanderwrote: >[...] > But recently I have started to change everything to pointers. > > For example when you have an array and want a subrange without the first > element of the array, you can either copy almost everything in a new > array, or just use a pointer to the second element. > > Or in my XQuery interpreter I used interfaces to get ref counting, but > at many places the ref counting was too slow, so I replaced it with > pointers to interfaces. js has different runtimes. Some things are slow some things are simple and fast. If you need speed you have to use different tricks than on an assembly target. Your pointers work for some cases, but not for all. They are fast on some browsers, on others not so much. I agree with Michael, that this has low priority. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Hi, Of course not. First of all 10 is ridiculously small and second the above example is probably optimized by the engine. For example under V8 with 1 iterations you get 1.1s and 1.9s. It is not so small or optimized with Firefox. It took around 100ms With 1000, it gives 5479ms and 4814ms, i.e. the array is faster here With 1 the script does not complete, before Firefox ask "do you want to stop the too slow script" Like what? What pointer code do you want to port? I have not looked at any specific. But recently I have started to change everything to pointers. For example when you have an array and want a subrange without the first element of the array, you can either copy almost everything in a new array, or just use a pointer to the second element. Or in my XQuery interpreter I used interfaces to get ref counting, but at many places the ref counting was too slow, so I replaced it with pointers to interfaces. E.g. when iterating over an array of interfaces with an enumerator. for x in thearray do, the array keeps the ref count >= 1, so x is much more efficient as pointer to an interface. Isn't that a contradiction to "port all existing"? Not with full program static analysis Or people could mark the values they need as pointers in other units (by adding an unused public function just accessing it as pointer) Best, Benito On 18.12.2017 17:19, Mattias Gaertner wrote: On Mon, 18 Dec 2017 14:55:53 +0100 Benito van der Zanderwrote: [...] That would be quite a slow down. Is it? I saw no speed difference between var x = 1; for (var i=0;i<10;i++) x++; and var x = [1]; for (var i=0;i<10;i++) x[0]++; in Firefox. Of course not. First of all 10 is ridiculously small and second the above example is probably optimized by the engine. For example under V8 with 1 iterations you get 1.1s and 1.9s. Test with some more real world code. Perhaps more memory usage Pretty sure more memory usage. Isn't speed the main idea of using pointers? It would be to port all existing pascal code Like what? What pointer code do you want to port? Also what if var and @var are in different units? Either it needs full program static analysis, or pointers are only allowed to something that was used with a pointer in its unit Isn't that a contradiction to "port all existing"? You may want to take a look at asm.js, which has a working model for emulating pointers in JavaScript. It would be possible to add a pas2js target for that. But then again there is webassembly as well and it seems to have better support. That model looks like quite a slow down The js engines have some optimizations for that model. Mattias ___ fpc-devel maillist -fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Mon, 18 Dec 2017 14:55:53 +0100 Benito van der Zanderwrote: >[...] > > That would be quite a slow down. > > Is it? > > I saw no speed difference between > > var x = 1; > for (var i=0;i<10;i++) x++; > > and > > var x = [1]; > for (var i=0;i<10;i++) x[0]++; > > in Firefox. Of course not. First of all 10 is ridiculously small and second the above example is probably optimized by the engine. For example under V8 with 1 iterations you get 1.1s and 1.9s. Test with some more real world code. > Perhaps more memory usage Pretty sure more memory usage. > > Isn't speed the main idea of using pointers? > > It would be to port all existing pascal code Like what? What pointer code do you want to port? > > Also what if var and @var are in different units? > > Either it needs full program static analysis, or pointers are only > allowed to something that was used with a pointer in its unit Isn't that a contradiction to "port all existing"? > > You may want to take a look at asm.js, which has a working > > model for emulating pointers in JavaScript. It would be possible to add > > a pas2js target for that. But then again there is webassembly > > as well and it seems to have better support. > > That model looks like quite a slow down The js engines have some optimizations for that model. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Am 18.12.2017 14:56 schrieb "Benito van der Zander": Isn't speed the main idea of using pointers? It would be to port all existing pascal code But that isn't the goal of pas2js. That is what WebAsm is for. You may want to take a look at asm.js, which has a working model for emulating pointers in JavaScript. It would be possible to add a pas2js target for that. But then again there is webassembly as well and it seems to have better support. That model looks like quite a slow down Considering that asm.js and its successor WebAsm can be used to run ordinary computer games (e.g. DOS games running in DosBox, though there are also more modern examples - then again running a VM is no small feat either) I'd say that it works fast enough. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Hi, It seems you want to emulate pointer of integer. Of all primitive types In the JavaScript example there was no more integer typing. That would be quite a slow down. Is it? I saw no speed difference between var x = 1; for (var i=0;i<10;i++) x++; and var x = [1]; for (var i=0;i<10;i++) x[0]++; in Firefox. Perhaps more memory usage Isn't speed the main idea of using pointers? It would be to port all existing pascal code Also what if var and @var are in different units? Either it needs full program static analysis, or pointers are only allowed to something that was used with a pointer in its unit Local pointers (like var arguments) could always be changed to an array when the address is taken, and copied back at the end of scope. And what about pointer of pointer? It becomes an array of arrays with the same construction You may want to take a look at asm.js, which has a working model for emulating pointers in JavaScript. It would be possible to add a pas2js target for that. But then again there is webassembly as well and it seems to have better support. That model looks like quite a slow down Cheers, Benito On 17.12.2017 22:24, Mattias Gaertner wrote: On Sun, 17 Dec 2017 21:43:45 +0100 Benito van der Zanderwrote: Hi, Naturally, any memory pointer operation is not possible in Javascript. Code that relies on this will not work. it would be great, if pointers were added. There are pointers already. For example references to class and arrays. It seems you want to emulate pointer of integer. One trick would be to wrap every variable that is accessed by a pointer in an array (or object). That would be quite a slow down. Isn't speed the main idea of using pointers? Also what if var and @var are in different units? And what about pointer of pointer? You may want to take a look at asm.js, which has a working model for emulating pointers in JavaScript. It would be possible to add a pas2js target for that. But then again there is webassembly as well and it seems to have better support. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Sun, 17 Dec 2017, Benito van der Zander wrote: Hi, Naturally, any memory pointer operation is not possible in Javascript. Code that relies on this will not work. it would be great, if pointers were added. I really don't see the point of that. As Mattias pointed out, pointers to classes exist. Very likely pointers to records will be added (because they are object literals this is relatively easy), but that's about it. Even so, pointer math is not possible, so I really don't see the benefit. The idea is to be able to program the browser using a reasonable subset of Object Pascal, not to port arbitrary pascal code. So if time must be allocated on new features, it most likely will not be on emulating pointers, but rather on more high-level features. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
On Sun, 17 Dec 2017 21:43:45 +0100 Benito van der Zanderwrote: > Hi, > > > > > Naturally, any memory pointer operation is not possible in Javascript. > > Code that relies on this will not work. > > > it would be great, if pointers were added. There are pointers already. For example references to class and arrays. It seems you want to emulate pointer of integer. > One trick would be to wrap every variable that is accessed by a pointer > in an array (or object). That would be quite a slow down. Isn't speed the main idea of using pointers? Also what if var and @var are in different units? And what about pointer of pointer? You may want to take a look at asm.js, which has a working model for emulating pointers in JavaScript. It would be possible to add a pas2js target for that. But then again there is webassembly as well and it seems to have better support. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] First pas2js public release
Hi, Naturally, any memory pointer operation is not possible in Javascript. Code that relies on this will not work. it would be great, if pointers were added. One trick would be to wrap every variable that is accessed by a pointer in an array (or object). The array can then be used as reference. For example: var a: integer; b: pinteger; begin a := 10; b := @a; b^ := 11; writeln(a); writeln(b^); end; becomes var a,b a = [10] b = a b[0] = 11; alert(a[0]) alert(b[0]) For pointer arithmetic or pointers inside array elements, it would need an additional index: For example: var a: integer = 10; ar: array[0..1] of integer = (1,2); b: pinteger; begin b := @a; b^ := 11; b := @ar[1] b^ := 12; dec(b); b^ := 13; end; becomes var a,b,bi,ar a = [10] ar = [1,2] b = a; bi = 0 b[bi] = 11; b = ar; bi = 1 b[bi] = 12; bi--; b[bi] = 13; It does not cover pointers of mixed sizes (e.g. getting a pbyte of an integer, or converting double to int64), but the most common things should work. pchars should probably get special treatment, too. When it is not modified, there is no need to wrap a string in an array, but just keep a string reference plus index. Perhaps there need to be two type of pchars, readonly and writeable. Only writeable need wrapping. And then there needs to be some kind of static analysis that only wraps those variables/fields in arrays whose address is actually taken anywhere. Best, Benito Am 16.12.2017 um 17:36 schrieb 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
Re: [fpc-devel] First pas2js public release
On Sat, 16 Dec 2017 17:36:14 +0100 (CET) Michael Van Canneytwrote: >[...] > * 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. Hint: Passing -Jminclude to pas2js will include the Pascal sources in the map, so you don't need to worry about paths. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] First pas2js public release
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-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel