Which of the two programming languages JavaScript and PHP are better designed (poor?

Source: Internet
Author: User
Tags what php
Javascript, which has been intermittently learned for a long time, has blurred the pain of the year. now I am learning php (reading web pages and practices, not reading books), and it is particularly difficult to use php. I also think that javascript and php are both regarded as poorly designed languages, so I think of this problem. Javascript, which has been intermittently learned for a long time, has blurred the pain of the year. now I am learning php (reading web pages and practices, not reading books), and it is particularly difficult to use php. I also think that javascript and php are both regarded as poorly designed languages, so I think of this problem. Reply content: First, I declare that I have been writing PHP for two years. I am still familiar with the syntax and have never been familiar with core APIs (because it is too messy to remember). I appreciate the simple and rude popularity of PHP, I like various PHP frameworks, but I still cannot love PHP syntaxes.

==================

I personally prefer js syntax and core APIs. variable naming does not require money. function 1 is the first type. API is easy to remember. The most important thing is that there are standard game rules.

Of course, js also has a slot, callback hell is a little bad, the introduction of iterator is a little late, the class syntax is not sweet enough, and so on, so js is not as easy to use as PHP in some things, but fortunately, everything can be corrected slowly.

======================================

PHP was terrible at the beginning:

Variable name restrictions make me feel bad about the keyboard as soon as I see PHP;

Is the variable name case insensitive, or is the function name case insensitive?

Bad core API naming, worse extension API naming, I wrote a PHP Manual with me for the past two years, even the most commonly used string processing method cannot reach the level of proficiency. I always doubt whether I should use the underline naming method or the hump naming method or simply use all lowercase letters, I always doubt whether I should use procedural APIs or oop APIs;

Before lambda is introduced, PHP connects to a simple string. replace (regex, fn) is all stumbling. many times I want to pass the function. The result is not to create a function using a string, but to write the function name to a string and pass it in, it hurts a lot;

The newly introduced anonymous functions are very different from the traditional naming functions in terms of performance and usage;

No scope chain, bad global, complicated closure use, everything is like patching on a piece of excrement, playing so ugly.

======================================

My opinion on PHP syntax and API is that, rather than making such a thick patch, it is better to reinvent it? But can it still be called PHP .. JS and PHP both have many design mistakes.

The difference is that the evolution of JS fills in the old pitfalls, and there is almost no new pitfalls. While every PHP version is also filled in, but it is always not clean, and it will generate new pitfalls.


[Supplement]
Even with the initial design, JS is certainly better than PHP. Although brden Eich only took 10 days to design and implement it, it is much higher than Rasmus. Rasmus himself said that he was casual and did not go to the design language.
In terms of language features, just a little bit. JS with closures is enough to support many subtle libraries and frameworks when there are many major missing ones. However, although the closure has been added to PHP, it is as difficult to use as it is.

[Supplement]
@ Lu Xiaofu threw out the PHP case-sensitivity rules. someone in the comments said, "php follows the unix style, that is, variables are case-sensitive and functions are case-insensitive ". I have never heard of this "unix style ".
For details about the case sensitivity rules of PHP, see my article: Why are the case sensitivity rules of PHP so irregular? · Issue #29 · hax/hax.github.com · GitHub Have you evolved to be concerned about language pitfalls? Isn't it just syntax? The first version of PHP is a template language... Maybe the different requirements of the times are also different. The original intention of PHP was to create a language for fast production of dynamic web pages. PHP embedded code into HTML for execution, rather than making strings. At that time, the founder of PHP may have lost his mind. now, people will be engaged in MVC and busy separating View code from logic code. In the technology of making dynamic web pages at that time, PHP was quite successful, so it was a hit. PHP itself is born for dynamic web pages. it also makes PHP more alternative than other languages, so that every iteration of PHP is trying to develop to mainstream general-purpose languages, it's nice to talk about growth. if it's not nice to talk about it, just fill it in. One is Personal Home Page(Well, even the latest recursive abbreviation is PHP: Hypertext. Preprocessor.
One is Java Script.
From the name, we can see their own positioning.

So now JavaScript has become a common intermediate language, and PHP can only be used for Web.

In fact, Brendan Eich still considered the design when implementing the first JS version. However, PHP, huh, didn't see anything besides upgrading the version number and patching.

Of course, Hack/HHVM, as a successor, beat the PHP community's face, but it is useless if it is not promoted.
So now let's look at what PHP wants (Hack even joins Generics and ADT) and it looks like a high-end programming language. But what is ugly? it's like an ugly second generation with little money in the family.

Then, when you look at JavaScript, the hands of Andres Hejlsberg and Erich Gamma become artifacts.

Have you ever heard of PHP 6And ECMAScript 4Ah? This is the worst time JavaScript was hacked. in terms of syntax, JavaScript won, especially after the introduction of JSON.
From the perspective of C and Java, PHP is easier to get started.

If you leave all kinds of libraries aside,
JavaScript is very simple, and only a few built-in objects can satisfy most programming requirements.
PHP is bloated, and various built-in functions are named differently. PHP is the best language in the world! Although I am an uncertain php hacker, I have no such reason as the subject, so I can learn how difficult php is to use? Can you tell me what is difficult to use?
Should I do not take the lead when I study php? the only advantage of php is that it is easy to get started (I am black again)
Isn't it hard for you to understand a language that is complex like c ++?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.