News for hackers. Stuff that matters.
Re:The software ecosystem isn't dry by babyrainbow on Sunday July 09, 2017 @06:03PM (#14731963)
>For any line of python, there's a line or two of PHP to accomplish the same thing (same with javascript).

Python decorators? What is the counterpart of that in Php?

Re:The software ecosystem isn't dry by alexandercrohde on Sunday July 09, 2017 @06:20PM (#14732040)
The syntactic-sugar form isn't there with the @, but it can still be done in a single line.

https://coderpad.io/RWTYEFY3

<?php

// DEFINE DECORATOR

$decoratorFunction = function($orig) { print "decorating $orig"; return function() use ($orig) { $params = func_get_args(); print "\nCalling a function with: " . count($params) . " arguments"; return call_user_func_array($orig, $params); }; };

// DEFINE A FUNCTION TO DECORATE

function someFunction($a, $b) { return $a + $b; }

// CREATE NEW DECORATED FUNCTION(s)

$decorated = $decoratorFunction("someFunction");

$decorated2 = $decoratorFunction("printf");

echo "\noutput: " . $decorated(1,2);

echo "\nOutput: " . $decorated2("\n%s", "cool"); }

Re:The software ecosystem isn't dry by babyrainbow on Monday July 10, 2017 @12:30AM (#14733376)
>The syntactic-sugar form isn't there with the @..

But those things are differences, right? Certain languages makes certain things easy and idiomatic. The differences in languages are all about that...

Re:The software ecosystem isn't dry by alexandercrohde on Monday July 10, 2017 @12:39AM (#14733398)
So there are two options:

1. Join the languages (so PHP would get that syntatic sugar too) [or preferably never have so many in the first place]

2. Be where we are now, where we have redundant libraries, frameworks, languages, package-managers, version idiosyncrasies, and IDEs for mere syntactic sugar.

Re:The software ecosystem isn't dry by babyrainbow on Monday July 10, 2017 @03:18AM (#14733968)
Eh? Two options for what? I was talking about how languages are different...