News for hackers. Stuff that matters.
Re:PHP: The Right Way by phillmv on Saturday July 07, 2012 @10:02PM (#4213318)
Well… Javascript does suck. No one in their right mind defends the language.
Re:PHP: The Right Way by dlitz on Sunday July 08, 2012 @12:34AM (#4213634)
Javascript is just Scheme with a C-like syntax and a limited number of bad design decisions (like automatic semicolon insertion and the == operator). PHP is a never-ending fountain of bad design decisions, because its core devs continue to make new ones.
Re:PHP: The Right Way by sharkbrainguy on Sunday July 08, 2012 @08:16PM (#4216146)
No, Javascript is not "just scheme" with a few bad design decisions. They have significant differences.

Scheme has:

  call-with-current-continuation http://people.csail.mit.edu/jaffer/r4rs_8.html#IDX509
  Tail Call Optimisation
  A numeric tower http://people.csail.mit.edu/jaffer/r4rs_8.html#SEC50
  A Code/Data equivalence and therefore macros
  Ports
Javascript has:

  Prototypal inheritance
  Every 'object' is mutable bag of string indexed properties
There's a pile of differences, even just at the semantic level before you get into the syntax or the equivalence semantics.

I understand that if you take a specific subset of javascript, you can write code as-though it has some scheme semantics (minus call/cc and TCO), but that's true to a similar extent of any language with lexical scope, closures and anonymous functions.

Re:PHP: The Right Way by wvenable on Sunday July 08, 2012 @01:50AM (#4213798)
What bad design decisions have been made in PHP in the last 5 years?
Re:PHP: The Right Way by ainsomni on Sunday July 08, 2012 @04:57AM (#4214127)
Using '\' as a namespace seperator? Just off the top of my head, there are probably loads more.
Re:PHP: The Right Way by TheBoff on Sunday July 08, 2012 @06:03AM (#4214225)
What makes that explicitly bad?
Re:PHP: The Right Way by wvenable on Sunday July 08, 2012 @12:15PM (#4214893)
I've actually gotten used to it (and I rallied against it heavily). It's really not so bad; it's even somewhat nice it has a file-system like connotation. PHP's design precluded using any existing operators.
Re:PHP: The Right Way by swivelmaster on Sunday July 08, 2012 @06:01PM (#4215869)
Based on how long it took to introduce the ability to say foo()["bar"], I'm guessing it's not the language so much as it's a set of poorly designed parser rules.

Also, magically, I can't use empty(functionResult()); but I can say $result = functionResult(); empty($result);

Re:PHP: The Right Way by wvenable on Sunday July 08, 2012 @06:36PM (#4215944)
> I'm guessing it's not the language so much as it's a set of poorly designed parser rules.

There are poorly designed parser rules but the namespace operator is not due to that. It's due to the fact that a single PHP file will be compiled to byte code without knowing what the symbols represent until runtime. The separate operator is needed because names are resolved before execution begins and before the symbols are known.

> Also, magically, I can't use empty(functionResult()); but I can say $result = functionResult(); empty($result);

Empty is identical to the not (!) operator except that empty() can operate on undefined variables, undefinted array keys, or undefined properties. empty(functionResult()) doesn't make any sense because functionResult() can never be an undefined variable. You just use !functionResult().

Re:PHP: The Right Way by batista on Sunday July 08, 2012 @04:22AM (#4214079)
really? add: floating point everywhere, objects that act like hashes but not exactly, fucked up scoping rules including global by default, the braindead Dom API, a severiously limited standard library, and brain damage coersions to the list...
Re:PHP: The Right Way by VMG on Sunday July 08, 2012 @06:50AM (#4214300)
I'd leave the DOM API out of it, that's not really the languages fault.
Re:PHP: The Right Way by batista on Sunday July 08, 2012 @08:40AM (#4214436)
Well, its the first one hat offered it, isnt it?
Re:PHP: The Right Way by wilmoore on Monday July 09, 2012 @04:34PM (#4220250)
It is actually a very strong language with a few very well known warts (like every other language on the planet has). The problem is that people try to use it as if it were Ruby, PHP, Python, Java. One can do that, but just know that it is an exercise in futility. It will cause frustration and one will come to the conclusion that JavaScript sucks when in fact, it is just that most people don't really take the time to _understand_ JavaScript.

JavaScript could stand to be a bit less verbose (look into CoffeeScript for some relief if you value your sanity and time) in some areas and type coercion should just go away; but if you use strict mode and strict equality, a huge amount of pain is alleviated.

If one take the time to learn about constructor functions, the prototype chain, and own properties; they are 70% there. Most people can get by on just that.