Will FreeBASIC support web?

Game development specific discussions.
angros47
Posts: 2124
Joined: Jun 21, 2005 19:04

Re: Will FreeBASIC support web?

Post by angros47 »

A sub forum would avoid some questions to be asked over and over, and would help to find information that otherwise would be buried. Also, the DOS sub forum by now has very low activity, and seem not to have the issue you described.

Out of curiosity, marcov: for FreePascal, how is Android supported? I have read on the wiki that there is an emitter even for the JVM, and I am surprised, because as far as I know there is nothing similar for C/C++ (that is supposed to have a bigger user base than Pascal)
marcov
Posts: 3388
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Will FreeBASIC support web?

Post by marcov »

angros47 wrote: Nov 16, 2022 16:07 A sub forum would avoid some questions to be asked over and over, and would help to find information that otherwise would be buried. Also, the DOS sub forum by now has very low activity, and seem not to have the issue you described.
Not every historic remnant/coincidence should set a precedent. For general info there is the wiki.
Out of curiosity, marcov: for FreePascal, how is Android supported?
Three or four ways.
  1. The core compiler can compile to native ARM .so's, and you can combine those with a small JVM template to an application (but the various ARM archs complicate that). I'm told that newer Androids have ways to skip the template, but I don't know the details.
  2. The core compiler has a JVM backend.
  3. A separate tool "pas2js" compiles to javascript, and you can use that to build apps based on wellknown javascript frameworks.
  4. Hypothetically you could also go via the LLVM target, but I don't know if that has been used for target android.
I have done neither, but I of course have used the native ARM (for various archs) for Linux based stuff.

In the past, the native target was the most used. Nowadays it is the JVM I guess (but that might also be because of preferences of the main developer supporting FPC/Android). pas2js has afaik been done, but I don't know anything about practicalities.
I have read on the wiki that there is an emitter even for the JVM, and I am surprised, because as far as I know there is nothing similar for C/C++ (that is supposed to have a bigger user base than Pascal)
Maybe if you search more thoroughly you'll find things like https://github.com/davidar/lljvm

But there are some differences, also considering that FPC supports Amiga, PS/2 classic MacOS (now abandoned) and other odd-ball systems, but also that FPC compiled to Windows x86_64 before gcc.

You'd have to ask the C/C++ crowd why, but I can make some observations:
  • FPC has relatively a lot under one roof, enabling a single person to do things. It is one (well two, if you count Lazarus) project, and e.g. for windows has everything under one roof (assembler,linker,debugger(beta) even things like resource compilers and COM importers) E.g. gcc has many minor targets in separate branches.
  • FPC has no corporate linux focussed overlords like GCC and LLVM have, and might be more open to incorporate grassroots ports to minor targets in the core distributions. Minor target support for gcc/llvm often exists but in forks and branches that can be quite long separate. win64 was probably also not a priority.
  • gcc and LLVM break architectural internal interfaces all the time, which makes it really hard to maintain out of tree frontends and backends over major versions.
Last edited by marcov on Nov 26, 2022 21:20, edited 1 time in total.
caseih
Posts: 2044
Joined: Feb 26, 2007 5:32

Re: Will FreeBASIC support web?

Post by caseih »

I've made android apps using C++, kind of. I used QtQuick. While the majority of my code was C++ compiling to native ARM binary, control of the GUI and interaction with the GUI was done through a javascript engine (QML), which probably was being run inside of a bit of JVM code which wrapped everything up. This is about as close to using C++ for mobile development as anyone would probably want to get.

It's too bad it's not easier to use other languages besides Javascript in a web browser. emscripten is neat, but it's a bit heavy and slow loading (not mention requiring a compile step). It's the same story with other projects for bringing languages to the browser, like pyscript.
marcov
Posts: 3388
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Will FreeBASIC support web?

Post by marcov »

caseih wrote: Nov 17, 2022 1:24 It's too bad it's not easier to use other languages besides Javascript in a web browser. emscripten is neat, but it's a bit heavy and slow loading (not mention requiring a compile step). It's the same story with other projects for bringing languages to the browser, like pyscript.
That reminds me, there is a FPC webassembly target too, that could in time be used for Android maybe.
angros47
Posts: 2124
Joined: Jun 21, 2005 19:04

Re: Will FreeBASIC support web?

Post by angros47 »

marcov wrote: Nov 16, 2022 21:12
[*] The core compiler has a JVM backend.
Does it work on Android?
[*] A separate tool "pas2js" compiles to javascript, and you can use that to build apps based on wellknown javascript frameworks.
Separate... like QB64 and QBJS are separated? They support the same language, but don't use the same front-end?

[/quote][*] Hypothetically you could also go via the LLVM target, but I don't know if that has been used for target android.
[/quote]

As far as I understand, the LLVM code can be compiled under NDK, that is more or less equivalent to the first option, compiling to native ARM code
Maybe if you search more thoroughly you'll find things like https://github.com/davidar/lljvm
Last updated in 2010... Android has changed a lot since then, so I doubt it would still work


Your answer was pretty detailed, and precise. Do you think that Emscripten could be a viable solution, for Android development? From what I have read around, PWA seems to gain a lot of attention, and I personally think that smartphone apps should have always been like that (since most of the "native" apps are just native ports of websites)
caseih
Posts: 2044
Joined: Feb 26, 2007 5:32

Re: Will FreeBASIC support web?

Post by caseih »

Yes emcripten can be used to build a PWA. A quick search reveals things like:
https://www.barcoderesource.com/pwa_web ... mbly.shtml
In that page they introduce something I've never heard of before, "WebComponents." I guess these are kind of self-contained widgets that you place in html or something.
https://developer.mozilla.org/en-US/doc ... /C_to_wasm

And Google has built a complete PWA app with it:
https://chromeos.dev/en/posts/developing-cursive

Emscripten has a bunch of C header files that would need to be translated to FB, and a bunch macros.

Even still, PWAs require skill in HTML, CSS, and Javascript. I've always found developing web apps to be very daunting.
marcov
Posts: 3388
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Will FreeBASIC support web?

Post by marcov »

angros47 wrote: Nov 17, 2022 20:16
marcov wrote: Nov 16, 2022 21:12
[*] The core compiler has a JVM backend.
Does it work on Android?
Afaik it is the most used for Android now.
angros47 wrote: Nov 17, 2022 20:16
[*] A separate tool "pas2js" compiles to javascript, and you can use that to build apps based on wellknown javascript frameworks.
Separate... like QB64 and QBJS are separated? They support the same language, but don't use the same front-end?
Yes. Pas2js grew out of the parser of the documentation tool.
angros47 wrote: Nov 17, 2022 20:16
[*] Hypothetically you could also go via the LLVM target, but I don't know if that has been used for target android.
As far as I understand, the LLVM code can be compiled under NDK, that is more or less equivalent to the first option, compiling to native ARM code
I meant in the FPC context. The LLVM support is mostly in the Apple centric corner.
angros47 wrote: Nov 17, 2022 20:16 Your answer was pretty detailed, and precise. Do you think that Emscripten could be a viable solution,
I've no experience with it, but from what I hear it depends on your apps. For relative simple stuff it is ok, and probably gets better every year as phones get heaver. And you sidestep the binary per architecture issue.

I have had some requests for mobile and tablet apps to compliment our offerings, and did some research, but since they were mostly remote UI for some cloud app I would have low code sharing. Thus I would have made mobile apps in the vendors tools (android studio) for maximum compatibility and migration aspects.

But every time we add it to a quote, it gets struck down by customer's accountants. Every customer wants, no customer wants to pay. Corporately managed phones (and not being easy to install on them) are also a factor.
for Android development? From what I have read around, PWA seems to gain a lot of attention, and I personally think that smartphone apps should have always been like that (since most of the "native" apps are just native ports of websites)
Yes that is my impression too. Barcode scanners, glorified websites and media consumption. Little real application intelligence (and if there is, it is usually in the backend and not the app). And in my specific case, it would have essentially been a bluetooth remote ;-)
coderJeff
Site Admin
Posts: 4014
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Will FreeBASIC support web?

Post by coderJeff »

marcov wrote: Nov 18, 2022 9:44 But every time we add it to a quote, it gets struck down by customer's accountants. Every customer wants, no customer wants to pay.
An acute situation with respect to open source where the currency is typically free time, imho. Your insight is appreciated, as always. Thank-you.
marcov
Posts: 3388
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Will FreeBASIC support web?

Post by marcov »

coderJeff wrote: Nov 26, 2022 16:11
marcov wrote: Nov 18, 2022 9:44 But every time we add it to a quote, it gets struck down by customer's accountants. Every customer wants, no customer wants to pay.
An acute situation with respect to open source where the currency is typically free time, imho.
Ah, I should maybe qualify that the "we" in this thread is not Free Pascal (Core) but the company I work for, a small (two head) machine building outfit specializing in vision applications, mostly for container glass (e.g. beer bottles and jars). We use a mix of Delphi and Lazarus/Free Pascal.

The requests for mobile apps are mostly stats overview apps for monitoring purposes, and kind of remote controls (to adjust the machine while standing next to the specific part of the machine). The first is heavily complicated by the need for some backend (which always costs money annually), the second is relatively low grade, as most of the per product adjusting only happens in the lead-in period.

p.s. Not all code made with open source tools is open source. Runtime libraries typically have a more permissive license. A lot of reusable code of our company is released as open source though, the business specific code not.
Post Reply