"Apps can be written in any language"?

I just read this on here: “Apps can be written in any language, although JavaScript / Node.js is best supported at this stage.”

Huh? Any language? How is that possible? I can’t use PHP, can I? How would that work? Then SAFE Browser would have to be bundled with a PHP runtime (and all other runtimes in existence)! While I would love PHP support, since I’m “native” in that language, it sounds like a real nightmare security-wise and also size-wise. Especially if you add support for “any” language…

2 Likes

The reason why it said any language because it was written in Rust.

Rust has FFI. And for that reason, any language can use it.

So yes, you can use PHP. The downfall is… you have to write it from scratch, and point it to Rust FFI.

5 Likes

It’s not really referring to web apps. SAFE can be used for mobile and desktop apps also. If you have some app written in PHP, you could make a SAFE SDK for using SAFE as storage. The backend code for a site written in PHP could for example use SAFE to store backups or whatever.

If you wanted to write a web app that would run in the SAFE browser in another language than Javascript you would have to use webassembly, just like on the current web.

5 Likes

Can’t say I understand this… How exactly is PHP being executed without a server?

PHP has to be executed on a machine, just as JavaScript, Rust, Java, etc. The SAFE network does not know these languages.

JavaScript/NodeJS are best supported at the moment because bindings have been made to the FFI of the SAFE client libraries. When you would want to use PHP, you’d have to create these bindings yourself. These bindings to the FFI mean you can use the underlying library to communicate with the network. From an application developer’s point of view, the network is merely a collection of data to be interfaced with.

PHP is a traditional server-side language, meaning it offers a lot of ways to interface with server software like databases and such. Because of that, it is not sensible to implement PHP as a client-side language in the SAFE browser. Your confusion arises from this fact, I think.

So, when you would want to use PHP, it will be outside of the SAFE browser (similar to e.g. a NodeJS application). Indeed, as PHP is usually run on the server, you will probably still want to run it on a server. In that case a logical example of an application is given by @intrz. Your PHP server could still be accessible on the ‘regular internet’, and could communicate with the SAFE network internally. As such, it could form a ‘bridge’ between both networks.

6 Likes

There goes the whole “serverless” point…

It is serverless. Logic will be executed on client side. Therefore, no servers.

3 Likes

He just typed that above you.

No you may want to run PHP on a server. That server maybe within the APP running on your machine.

In any case PHP is not an ideal language to write APPs in. Be it on phones, windows or other platform that run APPs.

Anything said by @bzee does not mean that SAFE is not serverless. Obviously if someone wants to run a server to serve up content to APPs then they can take that backward step if they want. But it still doesn’t make SAFE a server technology

3 Likes

Obviously “any language” has “conditions”. Some languages will be easier than others and obviously doesn’t include English.

PHP is a scripting language and there are interpreters for it to run on a standalone machine. But as I said before it would not be a good language to use for APPs, the same as it is not a good language to use for APPs on your phone or in windows etc.

It would be best to consider the more traditional single computer languages as better choices.

Yes this will be potential stumbling block for websites using PHP as their main scripting language to speedily rewrite their sites as APPs or safesites.

Why do you make a distinction between “APPs” (is the spelling consciously different from “apps”?) and “safesites”?

APPs/apps/Apps === Applications which are programs. They can written in script or procedural complied or otherwise languages.

The Apps can be stand alone programs that perform tasks (eg games, spreadsheets or whatever) or an App can be script embedded in a webpage.

Some people here adopted “APPs” form to distinguish them from the programs making up the SAFE protocols, nodes and vaults. These things are programs and some may think of vaults as an application. So APPs is a way to denote the applications that will be running above the protocol layer and written by anybody as opposed to the SAFE network software.

I guess this is simply following on from the way companies have adopted the term “App” for the programs that run on phones, then windows/ios

3 Likes

Well, as long as these “APPs” will be few and only released by MaidSafe for SAFE-related things rather than some sort of “app” that anyone can make which is much more trusted and has much more power than a “normal SAFE site”…

APPs will be written by anyone for whatever reason. Just like your phone has upteen thousands of Apps to choose from.

The security will come from your log in credentials what permissions you give Apps and common sense to only run Apps that you can trust.

1 Like

OK. Then I have no clue how SAFE works, once again.

1 Like

Have a look at some of the documents here particularly the ones around public key infrastructure and self-authentication. They helped clear the fog for me.

3 Likes

I spent weeks reading and scratching my head as I got more and more confused. Don’t worry, it does take a while to get your head around. Most people come to SAFE with an understanding of crypto, or an understanding of internet architecture and they try to apply what they know to what they see and read. SAFE is a total paradigm shift though. Forget all that you think you know and start from scratch reading the docs. The penny will drop eventually and your eyes will widen in wonder as you start to see how it all fits together and how it all works. It is highly esoteric, you really have to start at the beginning and put all of your technical assumptions aside. If you assume you understand the basics and then start looking at the functionality you’ll probably give yourself a bald-patch with all the head-scratching :stuck_out_tongue_winking_eye:

7 Likes

Understanding exactly how the network works isn’t really necessary in order to understand how to access it. Just think of the network as a big datastore. To write to it or read from it you need to follow a protocol. MaidSafe have implemented a Rust library that does this. This library can be used as a dependency by an application that wants to access the network. The network doesn’t care what language the program is written in or what platform it is running on. So the network can be accessed by a web app running in the SAFE browser (where the web app itself is served by the SAFE network), by an application running natively on a PC, or by an application running on a server. It makes no difference.

2 Likes