JavaScript and PHP two programming languages which design is better (bad)?

Source: Internet
Author: User
JavaScript, which has been learning for a long time, has blurred the pain of the year, and is now learning PHP (see Web + Practice, not reading), which is especially difficult to use. It also reminds me that both JavaScript and PHP are evaluated as poorly designed languages, so I think of this problem.

Reply content:

First of all: I have written two years of PHP, the syntax is still familiar with the core API is always half-baked (because it is too messy to remember), I appreciate PHP's simple and brutal popularity, like PHP's various frameworks, but the syntax of PHP always love not up.

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

Individuals prefer JS syntax and core API, variable name does not need to spend money, function of the first type, API good remember, the most important is that there are rules and regulations.

Of course JS also has slot point, callback hell Bad Point, iterator introduced late point, class syntax is not sweet, and so on, so that JS in some things than PHP easy to use, but fortunately everything can be slowly corrected.

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

PHP was a bad start:

Variable name restrictions, so I see PHP began to love the keyboard;

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

Bad core API naming, worse extension API name, I write PHP that two years, with a PHP Manual, and even the most commonly used string processing methods can not reach the level of proficiency, and always wonder if you should use the underscore name method or hump naming method or simply all lowercase letters, Always wonder if you should use process-style APIs or OOP-style APIs;

Before the introduction of lambda, PHP even simple string.replace (regex, FN) are stumbling, many times I want to pass the function, the result is not to create a function with a string, that is, the function name is written into a string to pass through, the egg hurts very much;

The newly introduced anonymous function is very different from the traditional naming function, the expression and the usage.

Without scope chain, the bad global, the cumbersome closure use, everything is like a lump of excrement to hit the patch, playing so ugly.

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

My view of PHP syntax and APIs is that instead of having such a thick patch, you might as well knock it off again. But can that still be called PHP? JS and PHP have a lot of design errors.

The difference is that JS's evolution fills the old pits, and there are hardly any new pits. PHP, although each version is also in pits, but always fill not clean, but also create new pits.


Added
Even if you look at the original design, JS is certainly better than PHP. Brenden Eich, though it took only 10 days to design, was much higher than Rasmus. Rasmus oneself all say is casually play, not at all is running the design language to go.
Language features, just say a little. JS has a closure, enough to support it in a number of major missing situations, to make a lot of subtle libraries and frameworks. and PHP until now, although the closure, but like a chicken is difficult to use.

"also added"
@ Lu Xiaofe spit out the PHP casing rules, comments that someone said "PHP follows the Unix style, that is, the variables are case-sensitive, the function is not case-sensitive." I'm afraid I've never heard of this "Unix style".
The origin of the PHP casing rules See I wrote this: PHP why the casing rules are so irregular? · Issue #29 · Hax/hax.github.com GitHub Have you evolved into a hole in which you need to be concerned about language? Not only the grammar is not the same? The first version of PHP is a template language ... May be the times different needs are different, the original intention of PHP is to create a rapid production of dynamic Web pages of the language, PHP for the time being to embed code in HTML execution, rather than a spelling string. The founder of PHP could have cracked the skin at the time and had no idea that today's people would be popular with MVC, busy separating the view code from the logic code. PHP at the time to create Dynamic Web page technology, the idea is quite successful, so a cannon and red. PHP itself is created for dynamic Web pages, but also caused by PHP and other languages may be compared to a lot of places, so that PHP every iteration is trying to mainstream general-purpose language development, say good call growth, said not good to hear is called pits bar. One is personal Home Page(Well, even the newest recursive abbreviations are just php:hypertext.) Preprocessor
One is Java Script
From the name you can see their own positioning.

So now JS has become a common intermediate language, PHP can only do the web.

In fact, Brendan Eich in the realization of the first version of JS is still considered design, but PHP, hehe, and did not look out in addition to the promotion version number and patching also considered what.

Of course, HACK/HHVM as a successor, mercilessly hit the PHP community face, but did not promote the use of no eggs.
So now look at PHP, what to have (hack even joined generics and ADT), as a high-end programming language. But what is ugly, like a family not rich ugly forced the second generation of officials.

Then you look at JavaScript, and by the hand of Andres Hejlsberg and Erich Gamma it becomes an artifact.

As for the overthrow again, have you not heard of PHP 6and ECMAScript 4Huh? This is the worst of JS being black. Syntactically speaking, JavaScript wins, especially after the introduction of JSON.
PHP is easier to get started from a near C and Java perspective.

If you throw away all the libraries,
JavaScript is very streamlined and has very few built-in objects, but it can satisfy most programming requirements.
PHP looks bloated, with various built-in functions and names that are not consistent. PHP is the best language in the world! Although I am steadfast PHP black, but the Lord you this black point of no reason, just learn to know PHP is difficult to use? Can you tell me which is difficult to use?
Don't be preconceived when you're learning, PHP's only advantage is that it's quick to get started (I'm a black wave)
is a language complicated like C 艹 you don't understand?
  • 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.