Re: [fpc-pascal] Adding Javascript to Pascal
Hi, On Sat, 22 Feb 2025, DougC via fpc-pascal wrote: > Why not? Because it helps a distinctly inferior language design to > perpetuate. > > It used to be said that any programmer that first learned to program > using BASIC was ruined for life. I would say the same thing about > Javascript. We're in the offtopic again, but I really hate this kind of elitism. As a kid I started with BASIC - on various Commodore home computers then also on early IBM PCs - and I hope to think I grew up to be a semi-decent programmer. At least I can fix your Pascal compiler for ya... In fact, in I think nowadays one of the big problems is, we do not really have anything similar to BASIC to teach really young kids. Python, which they usually try to use for this purpose is way too strict in its syntax, and complicated. Just like most modern languages (Pascal/Delphi included). Not to mention, Pascal - originally conceived as a teaching language! - had its own share of abuse from this kind of elitist thinking, it's enough to think about that infamous "Real Programmers don't use Pascal" letter/post from the early eighties. So, yeah. I do not like Javascript, to put it mildly. But also, lets be real for a moment - it's here to stay. So nothing wrong can come out to gain at least some understanding and knowledge of it. Charlie___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding Javascript to Pascal
Den 24.02.2025 09:27, skreiv Karoly Balogh via fpc-pascal: Hi, On Sat, 22 Feb 2025, DougC via fpc-pascal wrote: Why not? Because it helps a distinctly inferior language design to perpetuate. It used to be said that any programmer that first learned to program using BASIC was ruined for life. I would say the same thing about Javascript. [...] In fact, in I think nowadays one of the big problems is, we do not really have anything similar to BASIC to teach really young kids. Python, which they usually try to use for this purpose is way too strict in its syntax, and complicated. Just like most modern languages (Pascal/Delphi included). [...] As a former OS/2 user I find REXX (Regina Rexx nowadays) very versatile and useful - and easy to learn. But you're right, this is off-topic, sorry. -- Best regards Arne Hanssen ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding Javascript to Pascal
Karoly Balogh wrote: > We're in the offtopic again, but I really hate this kind of elitism. As a > kid I started with BASIC - on various Commodore home computers then also > on early IBM PCs - and I hope to think I grew up to be a semi-decent > programmer. At least I can fix your Pascal compiler for ya... It's good to hear some positive voices in this thread :) 1. Let's focus on constructive answers to questions like "how do I integrate Pascal with language X", for any X, *before* we jump into discussion with statements "I hate X". People want such integration also because they like Pascal, not only X. We work in an ecosystem filled with lots of technologies, with devs knowing other languages than Pascal, with www browsers using JS, whether we like it or not. The choice of integrating with JS (or really any other popular language X) may be just reasonable for a given project. 2. I don't have a constructive answer myself, though I know people working on QuickJS integration with Castle Game Engine, see #quickjs channel on Castle Game Engine Discord ( https://castle-engine.io/talk.php ) and https://github.com/castle-engine/quickjs-demo . You can touch with people on that channel, in particular Coldzer0, if you're looking for people familiar with Pascal + QuickJS. 3. Discussions whether language X is good or bad should be an independent discussion, in an independent thread(s), IMHO. Because such talk can quickly go off-topic -- which this thread clearly shows. The poster didn't get any sort of an answer he counted on (feedback about QuickJS + Pascal), instead the thread went into JS and do we like it, and Python, and Lua, and Basic... We can all talk about advantages and disadvantages of various languages, and to be clear I think it can be a constructive discussion, but it should be a separate thread(s). Because we know such discussions can get both lengthy and heated :) 4. Personally, from the "integration with other languages", I'm looking in the future for Python + Castle Game Engine integration, which I described for https://castle-engine.io/roadmap#_python_integration . I documented there the reasons "why" (you can scroll to the "why" section there). Regards, Michalis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding Javascript to Pascal
On 2/21/25 12:04, Anthony Walter via fpc-pascal wrote: [...] Javascript: let data = { name: "James", age: 25 }; function update(name) { data.name = name; } function verify(note) { console.log("received note " + note); console.log("data name is " + data.name); hello(data, " message from javascript"); console.log("table size is " + table.size[0] + " by " + table.size[1]); } Pascal: function JavascriptCallback(Script: IScript; Args: TScriptValues): TScriptValue; begin WriteLn(Args[0].age, Args[1]); // writes 25 message from javascript Result := Nothing; end; var TestScript: IJavascript; procedure LoadScript; begin Script := NewScript(MyScriptText); Script.Global.table.size := [15, 6]; // { table: { size: [15, 6] } } is now available to javascript Here I see one big problem. Pascal needs specific types at compile-time. JS at compile time can only check some basic syntax. An IDE can use some heuristic to guess, what an identifier is referring to, but how should that work with a compiler? Script.Global.hello := Script.DefineCallback(JavascriptCallback); end; procedure CallScript; begin // Call the javascript verify method passing it a note Script.Global.verify("a note from pascal"); // verify will call back out JavascriptCallback function Script.Global.update("Ralph"); end; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding Javascript to Pascal
On 2025-02-24 11:22, Arne Hanssen via fpc-pascal wrote: Den 24.02.2025 09:27, skreiv Karoly Balogh via fpc-pascal: On Sat, 22 Feb 2025, DougC via fpc-pascal wrote: Hi, [...] As a former OS/2 user I find REXX (Regina Rexx nowadays) very versatile and useful - and easy to learn. But you're right, this is off-topic, sorry. FWIW, integration to REXX has already been provided with FPC since more than 20 years ago (for all of OS/2 REXX, Regina and Amiga/AROS REXX implementations). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding Javascript to Pascal
On 2025-02-24 12:44, Michalis Kamburelis via fpc-pascal wrote: Karoly Balogh wrote: . . 3. Discussions whether language X is good or bad should be an independent discussion, in an independent thread(s), IMHO. Because . . ...and a different mailing list (in particular, fpc-other). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal