5 ms·
> With proper engineering, PHP can be quick, cheap, AND good This is true for any language. It is also true for any language that poor engineering can make thi
by fragsworth 15y ago
> With proper engineering, PHP can be quick, cheap, AND good
This is true for any language. It is also true for any language that poor engineering can make things really bad. PHP is in a unique position, though - it is so easily accessible to non-engineers that they begin writing applications without the slightest idea what they're getting themselves into.
This results in lots of improper engineering, and people blaming the language for the world's problems.
Javascript and Actionscript have this problem too. They get a lot less flack, though, because I think client-side scripting isn't held to the same standards.
- Domenic_S 15y agoI agree with all that, and I think the logical question is - isn't the accessibility a good thing? A lower barrier to entry for programming... that sounds like a great thing to me. Like in any industry, some people will improve with time and some will stay n00bish and produce weak code -- but lowering the barrier to entry seems like a good thing to me.
- jayferd 15y agoI don't know about ActionScript, but javascript is actually a pretty beautiful language. It's basically scheme with Java syntax. Also, we're stuck with JS for the time being. PHP is easy to ditch by comparison.
- zbuc 15y agoTry running [] + {}, then {} + [] in a JS interpreter sometime.
- jayferd 15y ago...yeah, it's got its warts (see wtfjs.com), but it's built on a very solid foundation. It does get a bad rap because of the poor (and inconsistent) design of the DOM, but if you play within its rules it can be very expressive and powerful.
- zbuc 15y agoWell, that was a language inconsistency, not an issue with the DOM. I like working with JS but I don't know why the two operands aren't commutative in my example. The DOM is a headache but luckily smart people have made plenty of libraries to abstract that away. What we're left with is a language with a very expressive and powerful core like you said, but there are still some oddities.
- silentOpen 15y agoNo TCO makes it very much not scheme or lisp or anything fp.
- viscanti 15y agoHaving lambda expressions, closures, and being able to construct higher-order functions makes it pretty "functional" in my book. Having to be careful about recursion is a negative, and TCO would be a welcome addition. It's really a hybrid language. You can do a lot functional stuff with it if you'd like. You can also do a lot of the OO thing with it. Neither is perfect, but if you stick to the "good parts", it's a strong language.
- silentOpen 15y agoLambda expressions implies currying because lambdas take only a single argument unless you think of function application as implicitly constructing a tuple of arguments (but JS lacks tuples and only offers maps and arrays). Javascript has first-class anonymous functions, not lambdas. Closures in JS are broken due to everything being a reference cell by default. This causes closures to be annoying to construct correctly and more expensive than they should be. "Functional" languages typically treat mutation as a side-effect and require reference cells to be explicitly declared. This helps enforce function purity and referential transparency -- functional-ness. "Being careful about recursion" is like being careful about looping except recursive expressions are a superset of succinct iterative expressions making Javascript weak when it comes to, say, describing state machines. Lack of TCO makes Javascript a terrible compile target as CPS is impossible. Javascript is an ambiguous, unsafe, difficult-to-analyze language. It supports some constructs that look like constructs in functional languages but because it does not enforce any functional or type systemic restrictions, these features are mostly cargo. If you write a recursive algorithm in Javascript, you pay like O(n) for stack frames. The same iterative algorithm costs O(1) for stack frames. Thus, many developers eschew recursion in favor of iteration. This means that the logical code that developers write could be both mathematically sound and run efficiently on the machine but instead developers must either resort to temporal reasoning or perform recursion -> iteration transforms in their heads. This is broken. Just because Javascript is ubiquitous doesn't mean it's good. I don't understand Javascript evangelists -- they seem to be spreading half-truths.