TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Addition of 1 and 1 in PHP

158 pointsby gcmallocabout 12 years ago

29 comments

jonascopenhagenabout 12 years ago
Pretty much sums up how I feel about most of the big frameworks (Zend in particular, but also Symfony and CakePHP).<p>The problem of over-engineering isn't just related to the big PHP frameworks - the same problem exists in Python and Ruby.<p>At its core, web development is about taking some user input, validating it, throwing it in a database, and displaying it again (perhaps slightly modified) to users. That's a fairly simple concept, and frameworks should reflect that.
评论 #5348954 未加载
评论 #5348601 未加载
评论 #5349275 未加载
评论 #5348653 未加载
评论 #5349554 未加载
评论 #5348790 未加载
flatlineabout 12 years ago
The only flaw I can see is that the string literal '1' should have been declared as a const somewhere, preferably in another unrelated library, and called something like 'UNITY_VALUE'.
评论 #5348854 未加载
评论 #5349436 未加载
Mahnabout 12 years ago
Reminds me of something I wrote a few months ago on how to detect negative numbers: <a href="http://stackoverflow.com/a/11910993/1329367" rel="nofollow">http://stackoverflow.com/a/11910993/1329367</a> but obviously the one above has much more value add and follows better design patterns.
评论 #5348530 未加载
评论 #5349808 未加载
seanp2k2about 12 years ago
I opened a few bugs to help get this library in a more usable state. I'd really love to see a SOAP API on this as well as result templating, a request router, and a controller.<p>It may also be useful to include a message queue (RabitMQ / SQS are good candidates) implemented using the pub/sub model to allow arbitrary scaling of the compute nodes.<p>I have some other ideas about something like JMX / MBeans here to allow arbitrary instrumentation of methods. This would provide more flexibility than the benchmarking module already included.
laurent123456about 12 years ago
It reminds me of a Zend Framework project I'm maintaining, where the previous dev apparently tried to apply any OOP pattern they've ever head about.<p>To get anything from the db, one needs to get a "service locator" (just a dumb global object but with a cooler name) that will parse a namespace and returns a repository that will call a mapper, which in turn will instantiate an entity, which somewhere deeps in the Zend Framework is going to run an SQL query (going through dozens of classes, just to make stack-traces more readable...) and, maybe, if I'm lucky, I'll actually get some usable data back.<p>Of course, adding a new table is just as much fun - dozens of modules, controllers, repositories, mappers and so on to create, and just as many configuration files to update. And, of course, if something's not quite right, good luck getting any sensible error from the framework.
neyaabout 12 years ago
Welcome to the enterprise world. If you are already working for a typically huge enterprise, you would have realized that this kind of coding (Engineering) is just another day at the office and people actually get paid (more) to over-engineer! Infact, anything done to reduce complexity is <i>actually</i> frowned upon, or will even get you labelled as an ignorant employee.
nadinenglandabout 12 years ago
The functional unit tests made me laugh: <a href="https://github.com/Herzult/SimplePHPEasyPlus/blob/master/tests/Functional/AdditionTest.php#L53" rel="nofollow">https://github.com/Herzult/SimplePHPEasyPlus/blob/master/tes...</a>
评论 #5349191 未加载
babuskovabout 12 years ago
I know a couple of Java programmers that will find this helpful. Thanks.
评论 #5348426 未加载
nicholaidesabout 12 years ago
I'm not familiar with the PHP ecosystem. Is the author making fun something other than obvious over-engineering? Does he or she feel like that's a problem in the PHP ecosystem?<p>I'm criticizing, because it's funny. I'm just trying to figure out if theres some wisdom being conveyed that I'm missing.
评论 #5348452 未加载
评论 #5348468 未加载
评论 #5348453 未加载
sneakabout 12 years ago
Oh, did someone port Twisted to PHP?
venomsnakeabout 12 years ago
I love it.<p>And I hope that after all the types of fad programming (that work almost as good as the fad diets) we will get to the "common sense programming" - use the proper tools and scale for the problem and don't try to fit the problem in your tools and frameworks.
zerovoxabout 12 years ago
The addition operator takes a collection of numbers, and add the first two? Given the lack of documentation, I find this extremely misleading and I couldn't recommend this library.
评论 #5348564 未加载
merinidabout 12 years ago
This is so funny. The author's description is great on github, really fooling you at times. Even if this isn't intended as a joke, the dedication to doing something fun to prove a point got me thinking about over engineering design patterns too.
评论 #5348496 未加载
BjoernKWabout 12 years ago
Hooray for enterprise software 'design patterns'.
runekaagaardabout 12 years ago
What? No dependency injection framework? Pft! :)
评论 #5349384 未加载
alexvrabout 12 years ago
Don't let this get too popular or people (non-HN, of course) might start using it.
michaldudekabout 12 years ago
What if I need to add 2 and 1? Is there a lib for that? Or would this one need to be completely refactored?<p>Also, in what version could we expect ability to handle 2 digit (or more!) numbers?
评论 #5349382 未加载
评论 #5348534 未加载
clyfeabout 12 years ago
From ZF :( <a href="https://twitter.com/_clyfe/status/265588170341625857" rel="nofollow">https://twitter.com/_clyfe/status/265588170341625857</a>
nigglerabout 12 years ago
While we are discussing PHP, why is the ternary operator nesting behavior different from every other mainstream language using "?" and ":" ?
评论 #5348655 未加载
评论 #5348822 未加载
评论 #5348707 未加载
评论 #5351113 未加载
lubujacksonabout 12 years ago
Can't recommend because of a 0 day exploit. If you add 0 you get root via SQL injection.
juskreyabout 12 years ago
An example is pretty good, but I am not sure about scalability and load balancers.
评论 #5348480 未加载
lubujacksonabout 12 years ago
Uh oh, the LOLz have invaded Github. Pretty good one, though.
pestaaabout 12 years ago
Yes this is a good joke until you realize there is no other way to get <i>some</i> level of type safety in PHP other than adding a bunch of unnecessary classes.
评论 #5348597 未加载
评论 #5348493 未加载
评论 #5348501 未加载
futheyabout 12 years ago
WOW I thought I was alone all these years!
refiammingoabout 12 years ago
What about subtraction now?
评论 #5349402 未加载
评论 #5348507 未加载
canibanogluabout 12 years ago
Hilarious!
jordan_clarkabout 12 years ago
Good one.
alexvrabout 12 years ago
points += 500<p>This made my day.
camusabout 12 years ago
while i get the joke , i'm sorry , but serious PHP development means bloated frameworks. You cant avoid it.<p>Frameworks code looks ugly because PHP looks ugly . But has anybody seen Rails source code ?Django's ? or even Sinatra's ? it is bloated too, but because Ruby and Python a well designed , when using them , you dont feel they are bloated.<p>That's why you end up ( in PHP ) writing yaml config files for DI, ORM , etc more than actual PHP.<p>If php looked more like Ruby or Python , using symfony 2 or ZF 2 would be less painfull.<p>Now let's consider something else. in Python you have WSGI , Ruby Rake ,etc ... which are really good stuff , universal in the way you plug into them to write your own framework.<p>Up until now, PHP devs felt they did not really need it. But as the PSR effort improves , we need frameworks to implement the same http kernels so we can plug any middleware no matter what the lib is , that's very important. You cant use raw PHP anymore. You need middleware you can use ACCROSS frameworks.<p>So should php devs use frameworks ? yes. just like Ruby , Python devs dont do raw CGI programming. Should i use guzzle instead of CURL ? yes because it has a beautifull and fluent API , and CURL is just plain ugly. Should i use Silex/Slim/Laravel instead of raw PHP ? yes because your application will scale with these simple frameworks. Writing raw PHP without PSR-0 autoloading , and no framework doesnt scale , period.<p>PHP has a real problem. I admit. It needs a real deep , breaking redesign, a clear separation between the core and libraries , and fat trimming. But framework designers did a great job trying to correct its flaws and making PHP development bearable.
评论 #5349213 未加载