Page 1 of 3

PHP on the client side of the browser

Posted: Sun Aug 19, 2007 6:45 am
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.

Posted: Sun Aug 19, 2007 7:34 am
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.

Posted: Sun Aug 19, 2007 7:58 am
by volka

Re: PHP on the client side of the browser

Posted: Sun Aug 19, 2007 8:18 am
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.

java applet and flash are something different

Posted: Sun Aug 19, 2007 8:20 am
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.

Re: java applet and flash are something different

Posted: Sun Aug 19, 2007 8:44 am
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.

Posted: Sun Aug 19, 2007 9:36 am
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.

php scripts

Posted: Sun Aug 19, 2007 2:50 pm
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.

Re: php scripts

Posted: Sun Aug 19, 2007 3:05 pm
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.

Re: php scripts

Posted: Sun Aug 19, 2007 3:07 pm
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.

Posted: Sun Aug 19, 2007 4:28 pm
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 ;)

that is a better way to put it,

Posted: Sun Aug 19, 2007 6:21 pm
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.

:(

Re: that is a better way to put it,

Posted: Sun Aug 19, 2007 6:46 pm
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.

what I hate about js

Posted: Sun Aug 19, 2007 6:59 pm
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.

Posted: Sun Aug 19, 2007 7:18 pm
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 :)