PHP on the client side of the browser

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

PHP on the client side of the browser

Post by yacahuma »

For a long time I've been asking myself this question. It something that seem possible but no one talks about it.

Why do we keep using javascript? It is a terrible language in my opinion.

Isn't it posible to have somekind of browser plugin that hooks to the browser and allow it to execute any language(one plugin per language)? There could be a php plugin, a java plugin, etc,etc.

Then when coding web applications you only use one language, instead of two.

Anyone know why is this not possible? It will sure makes coding easier not having to use javascript.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That would just make things even more tricky to develop for. You're just adding new dependencies and points for security exploits. For the most part, what you're saying is already doable apart from the PHP one though. You can execute Java applets in the browser and you can use Flash. These things at the end of the day are provided through plugins.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
The Phoenix
Forum Contributor
Posts: 294
Joined: Fri Oct 06, 2006 8:12 pm

Re: PHP on the client side of the browser

Post by The Phoenix »

yacahuma wrote:Why do we keep using javascript? It is a terrible language in my opinion.
Because it is installed on 95% (+) of browsers, it is standard, and it enables a tremendous amount of functionality. Its tested, understood, and has been in wide use for over a decade. What makes it a terrible language in your opinion?
yacahuma wrote:Isn't it posible to have somekind of browser plugin that hooks to the browser and allow it to execute any language(one plugin per language)? There could be a php plugin, a java plugin, etc,etc.
Not exactly, no. Java is a client *and* server-side language, so there is a plugin for it. PHP, on the other hand, is a server-side language, and as such can't run via a plugin (as far as I know). Client-side languages definitely can, and there are plugins for virtually all of them (one plugin per, as you specified).
yacahuma wrote:Then when coding web applications you only use one language, instead of two.
You use THREE languages. PHP, HTML, and Javascript. Four if you add in Flash. Five if you add in Java. Six.. you get the idea.

Each language is designed for something specific. PHP isn't a client side language, so couldn't do many of the things that javascript does.
yacahuma wrote:Anyone know why is this not possible? It will sure makes coding easier not having to use javascript.
You don't have to use javascript. You may choose to because it makes some things possible that aren't possible in other languages.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

java applet and flash are something different

Post by yacahuma »

d11wtq

java applets and flash run on their own environment. What I mean is more of a complete javascript
replacement, so you still have you client side stuff and your server side stuff.

I cant imagine why will it make thing harder since your are using just one language.


volka,

I will take a look. But it seems to work only in windows. The idea is that it could be use anywhere just like javascript.
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Re: java applet and flash are something different

Post by iknownothing »

yacahuma wrote:I cant imagine why will it make thing harder since your are using just one language.
Some things need to be client side, some things need to be server side, using one code, how would you distiguish the two? One way or the other, even the same language, will turn into two anyway. Someone will come along at a later date, add something to one, without the other, stuff up backwards-compatibility, and you'll come to two entirely different languages.

PHP and Javascript are very similar in many ways anyway.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

JavaScript is not a necessity. It is the accepted and standardized way to handle client-side scripts, and doesn't require any user plugins. It is the least invasive, and the most reliable. You've noticed that so many people refuse to download a different browser to get rid of IE (or even download IE7 to get rid of IE6), so how many people do you think change their mind once they discover than a plugin is necessary?

Also, I can't agree on your notion that it is a terrible language. It has come a long way and I feel that it is a very powerful language. JavaScript can bring a lot of the desktop features to the web browser in a portable manner.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

php scripts

Post by yacahuma »

I am going to change the question a bit. What if javascript will look and feel like php. Same function names, same way of creating classes.
Dont you think that will be easier??


Why javascript have to be the only client side language. Who decided that for now to eternity we have to develop client side scripts using ONLY javascript? I am not saying javascript does not make application easier for the user. What I am saying is why only one language? Why it cannot be changed?


We have many languages, ada,basic,cobol,perl,c,c++,c#,java, php,ruby,etc, etc. You use the one you feel more confortable for the application. But when it comes to web development, javascript is the only one. This is what I dont agree. I am not saying that is bad or wrong , what I am trying to say is why the restriction??

Imagine that the client side scripting languaje will be completely trasparent., no plugin. I could just say

Code: Select all

<script type="text/php">
echo "Hello World!";
</script>
instead of

Code: Select all

<script type="text/javascript">
document.write("Hello World!")
</script>

No one here would like that? That will be sweet.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: php scripts

Post by feyd »

yacahuma wrote:I am going to change the question a bit. What if javascript will look and feel like php. Same function names, same way of creating classes.
Dont you think that will be easier??
Considering the lack of support for a vast number of PHP's functions simply because of what they do, no, it would be more annoying.
yacahuma wrote:Why javascript have to be the only client side language. Who decided that for now to eternity we have to develop client side scripts using ONLY javascript? I am not saying javascript does not make application easier for the user. What I am saying is why only one language? Why it cannot be changed?
It's not the only client-side language. There are many. .. but only Javascript and the other core languages are supported across most of the board. Why? Well, it was one of the first, it is widely accepted, and it has evolved into a pretty powerful framework. All languages have to start somewhere. If you want to get PHP highly supported, you're going to have to convince a lot of people; developers and users alike.
User avatar
The Phoenix
Forum Contributor
Posts: 294
Joined: Fri Oct 06, 2006 8:12 pm

Re: php scripts

Post by The Phoenix »

yacahuma wrote:I am going to change the question a bit. What if javascript will look and feel like php. Same function names, same way of creating classes.
Dont you think that will be easier??
No, because there are things you *cannot do* at the client side that you can at the server side, and vice versa. You cannot read from a socket across the internet. You cannot get process id's from across the internet.
yacahuma wrote:Why javascript have to be the only client side language.
It isn't the only client side language. Not even close. There is actionscript, java, flash, jscript, and vbscript. You could even argue that vrml is, but thats stretching it a bit.
yacahuma wrote:What I am saying is why only one language? Why it cannot be changed?
It can be changed, but the reality is that users do not change to other languages reliably. As a result, javascript exists and is enabled in 95% of browsers, so most people code for it. You can use Flash, which is at around 80%, but then you are missing quite a few users.
yacahuma wrote:Imagine that the client side scripting languaje will be completely trasparent., no plugin.
That isn't the way web browsing is structured. Because of the security risks of running code from the internet, there have to be very tight controls around what code can do. Javascript is very well understood, and meant for client side use, and yet *still* has issues with security every month.

You need a plugin to enable additional functionality.
No one here would like that? That will be sweet.
No, that would be a security nightmare. I wouldn't like that at all.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Generally I think JavaScript is a great language. I think far more useful would be for a newer generation of JavaScript to be unveiled. At least, each browser to follow some standards (namely IE), then proper classes with proper inheritance. That would be great :)

PHP is not really built in any way shape or form to deal with event handling, multithreading (timer intervals, ajax etc) and all the GUI stuff.

It sounds like what you're really asking is whether we should change the JS syntax to a PHP syntax. To be honest, the JS syntax is more generic for an object oriented language anyway ;)
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

that is a better way to put it,

Post by yacahuma »

yes you can say that. change the syntax to a php syntax like.

I am surprise no one shares my love for php.

Its good to know what others think about the subject. I guess it will be javascript for now to eternity after all.

:(
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Re: that is a better way to put it,

Post by iknownothing »

yacahuma wrote:yes you can say that. change the syntax to a php syntax like.

I am surprise no one shares my love for php.

Its good to know what others think about the subject. I guess it will be javascript for now to eternity after all.

:(
Everyone shares your love for PHP around these parts, but there is only so much a language should/can do. Javascript isn't that bad.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

what I hate about js

Post by yacahuma »

Maybe JS and I started on the wrong foot.

What I hate about JS(not JS fault) is that each browser is different and behaves different. I find it a waste of my time making up for those differences.

The web developer should not have to care about it.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

:) Imagine your dream come trough .. and after that you find that every browser behaves different on your client-side PHP ;) What would you dream about then? ;)

And ... YES! JavaScript is a great language and I've found its OOP approach to be the nearest to what I need it to be :)
Last edited by VladSun on Sun Aug 19, 2007 8:18 pm, edited 2 times in total.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply