I was a PHP programmer, until I started working in a company where they used C++. I found out some fun facts about C++:
* C++ cannot have different types in one list easily.
* C++ is very inflexible in its syntax.
* C++ hampers the productivity.
* C++ template system is too complex for normal programmers.
* C++ allows multiple inheritance, while everybody knows inheritance is a dead end.
I began converting people now to use PHP. I experimented with rhapsody, which threats C++ as the low level language it is. Productivity went up in several sections of our team. Some people leave, because PHP is shit. But I feel they are not real programmers, because for a real programmer it doesn't matter what language they work in.
Now we work in PHP with Zend Framework, which is a very good combination.
Exemple of singleton that can be used for other class (need phpversion >= 5.3)
<?php
class SingletonModel
{
/**
* Instance of singleton's class
*
* @var array
*/
private static $_instance;
/**
* All constructeur should be protected
*/
protected function __construct(){}
/**
* Singleton method to load a new object
*
* @return HlPwd_SingletonModel
*/
public static function singleton()
{
if (!isset(self::$instance[ get_called_class() ]))
{
$c = get_called_class();
self::$instance = new $c;
}
return self::$instance;
}
/**
* Destroy the singleton
*/
public function destroySingleton()
{
unset(self::$_instance[ get_class($this) ]);
}
/**
* Destructeur
*/
public function __destruct()
{
unset(self::$_instance);
}
/**
* Impeach the clone of singleton
*/
public function __clone()
{
trigger_error('Cloning not allowed on a singleton object', E_USER_ERROR);
}
}
# EOF
you can easyli use it like that
class mySingChild extends SingletonModel
{
protected function __construct()
{
//do important things
}
public function foo()
{
echo 'hello world';
}
}
$t = mySingChild::singleton();
$t->foo();
Name:
Anonymous2013-07-26 7:01
I really like this novel use of closures in php:
When invoking an anonymous function through throughThroughFunction(), all variables are automatically binded to the inner function. In addition, variables created within the anonymous function are also "binded out" incorporating it to the scope where the anonymous function is being created.
Enjoy!
<?php
class ThroughThrogh {
public $to_export = array();
public $to_import = array();
// we eval() these functions in order to cleanup verbosity. Cleaner this way even though we all heard about the nightmares of eval()
const TX_START_X = 'foreach(get_defined_vars() as $k=>$v){$this->to_export[$k] =&${$k};};';
const TX_START_I = 'foreach($that->to_export as $name => &$variable) ${$name} = &$variable;';
const TX_END_X = 'foreach(get_defined_vars() as $k=>$v){if(!isset($that->to_export[$k])) $that->to_import[$k] =&${$k};};';
const TX_END_I = 'foreach($this->to_import as $name => &$variable) ${$name} = &$variable;';
//here is where we invoke the function
public function throughThroughFunction($that, $callback){
$this->to_export["that"] = $that;
$inject_start = self::TX_START_I;// potentially you can add setup code in here
$inject_end = self::TX_END_X;// potentially you can add cleanup code in here
$callback = $this->hackClosure($callback, $inject_start, $inject_end);
call_user_func($callback, $that);
}
//user test
public function test(){
$outscope = "Source External Scope: test... not modified if seen at end of function\n";
$this->test = "Source External Scope: object attribute from outside anonymous function\n";
eval($this::TX_START_X); //required to export all variables from scope
$this->throughThroughFunction($this, function(){
echo "Source Anonymous Function\n";
echo $outscope;
echo $that->test;
$that->test = "Source Anonymous Function Scope: wow! Object attribute modified from inside anonymous function\n";
$outscope = "Source Anonymous Function Scope: yey! Variable Modified from the scope of an anonymous function!\n";
$from_anonymous_function = "Source Anonymous Function Scope: No way! How did you do that?\n";
} );
eval($this::TX_END_I); //require to bring newly created variables from anonymous function into current scope
echo "\nSource External Scope\n";
echo $from_anonymous_function;
echo $outscope;
echo $this->test;
}
}
$demo = new ThroughThrogh();
$demo->test();
?>
Output
Source Anonymous Function
Source External Scope: test... not modified if seen at end of function
Source External Scope: object attribute from outside anonymous function
Source External Scope
Source Anonymous Function Scope: No way! How did you do that?
Source Anonymous Function Scope: yey! Variable Modified from the scope of an anonymous function!
Source Anonymous Function Scope: wow! Object attribute modified from inside anonymous function
Name:
Anonymous2013-07-26 8:18
we work in PHP with Zend Framework
Shalom, hymie達!
But they didn't want to switch, because PHP gives you a superior productivity compared to C or C++. To ail some performance problems they created a VM for PHP. Facebook still uses PHP.
Name:
Anonymous2013-07-26 16:05
>>13
You're a fucking moron who has no future as a programmer. Just accept this fact and then, after that, go help another nigger at you job you idiot.
You are the retard here. Most successful web startups used php. They didn't used JAVA, PYTHON or LISP. Most successful startups didn't even bother checking these pitiful languages out, they just went for the money shot. Something you will never achieve in life.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:13
>>15
Huh? Unlike you, I actually work as a Software Engineer. Now fuck off. You're boring, stupid, and you seem to lack a proper education.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:13
>>15
Huh? Unlike you, I actually work as a Software Engineer. Now fuck off. You're boring, stupid, and you seem to lack a proper education.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:15
>>15
With that, I would rather be a retard who is employed as a Software Engineer than a dumbfuck wannabe programmer. Now go help another nigger you no talent faggot.
LOOL YOU WORK AS SOFTWARE ENGINEER. You are the guy, which wipes my ass then. Though for you I like to eat buritos, my mexican friend. My fucking brown tractor. I will underpay you and laugh in your face, while fapping over the photos of your children in your passport.
>>19
Yes. I deal BS frameworks like the map/reduce framework for Apache Hadoop and interesting algorithms such as Paxos Algorithm.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:19
Now LOOL some more you fucking nigger mental midget.
Name:
Anonymous2013-07-26 16:21
>>24
LOOL LOOL LOOL
Is that enough, or should I LOOL more?
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:22
>>25
Whatever floats your boat you wannabe programmer. Say what you want about me. At the end of the day you're still broke and stupid.
Name:
Anonymous2013-07-26 16:23
>>26
Uh, what? This is my first post in this thread and I replied to your request simply because I'm an African American person with cognitive disabilities.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:25
>>27
And you also have no real future as a programmer.
See how feisty you are, like a real latin home boy, showing all his feathers with pride, but you are still some nigger from the bad part of town in the eyes of others. You cannot hide that. Even with all your nicely colored feathers. Now go to reddit and leave us talking about jews and other grown up problems.
Name:
Anonymous2013-07-26 16:27
>>28
I never claimed to have a future as a programmer.
I do program in my free time, but what kind of retard would take programming as a job?
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:28
>>29
I'm actually German you fucking wetback. Now go make some more uneducated statements about C++ and PHP you fucking annonying mental midget.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:29
>>30
That is apparent in your idiotic posts concerning C++ and PHP.
>>28
I come from /g/, and it looks like you're a fellow /g/entooman.
These people at this shitty spam-ridden board are a bunch of jobless virgin neckbeards with no future. Just ignore them and carry on.
If you want actual discussion, feel free to come to /g/. I also have a Hacker News account and a Stack Overflow account, and I can assure you they're definitely better than this shithole.
>>35
Oh, I don't have a Usenet account, but believe me, anything is better than this cesspool of a board. I feel for you and recommend you to come to a more serious board.
Go away cloudengineer, in my country clouds form themselves, but fuck you are probably from mexico too. Too lazy to be a cloud your useless water.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:41
>>37
Well at least comp.lang.c is dominated by some fairly accomplished Scientists and Engineers. Seriously. The regulars include a retired Math Professor from Pinceton University who now works at a VP at Oracle, An Electrical Engineering Professor at Stanford, two Nokia Software Engineers, a Senior Technical Advisor to Ubuntu Linux, and one of the Chief brains behind the Opera web browser.
Name:
YoutubeEngineer!12wzVQ1/7E2013-07-26 16:43
>>36
Yeah, I believe that I mentioned it before. Let me guess, you missed that post because you were too busy getting a blowjob from your mom.
Sieg heil froom the thai homeboy experience. You enjoy little children, now sign up, and don't have to wait for that thai homeboy experience. Prick them on your poke. 5 dollar.
Name:
Eric Thiel2013-07-27 21:09
dubs
>>check 'em
Name:
Anonymous2013-07-27 21:18
* C++ template system is too complex for normal programmers.
It's too complex for normal PHP programmers.
It's about right for normal C++ programmers.
>>55
As in KodakGalleryProgrammer? Yes, that would be me. Now run along and go scrub another toilet.
Name:
Anonymous2013-07-28 4:37
>>56
It's nice to talk to you again. /prog/ isn't in a very good state right now. I apologize, but we are doing the best we can.
Name:
Anonymous2013-07-28 5:04
>>56
you are not welcome here kodak. go play with your friends mentifex & tdavis.
Name:
Anonymous2013-07-28 5:10
>>58
Hey, I welcomed Kodak. Therefore he is welcome here. The same applies to mentifex and tdavis, although they may have moved onto larger audiences to advertise themselves to.
Name:
Anonymous2013-07-28 9:38
>>59
E
THIS HTREAD IS FVOR SHaarINg PHO PHP EXPERIENCES HOW DonT YOU UNDERSTAND THAT? PHP UNDERSTAND IT DUMBFUCK?
Name:
Anonymous2013-07-28 22:22
From: mentifex@myuw.net Subject: Mentifex AI needs porting to C. Newsgroups: comp.lang.c Date: Sat, 27 Jul 2013 08:56:04 -0700 (PDT)
Recently in 2013 the mentifex-class AI Minds in Forth and in JavaScript have developed the ability to think with automated reasoning by http://code.google.com/p/mindforth/wiki/InFerence or the creation of new knowledge from old knowledge.
Actually, Mentifex here has been proud to post to comp.lang.c since the previous millennium, but is ashamed of any involvement with /prog/ because of the extremely bad behavior there :-(
Goddamnit >>45-san, why did you have to fuck up my newsgroups?
Name:
Anonymous2013-07-28 22:49
>>61
Hehehe, this might be humorous. Let's hope he's persistent.
but is ashamed of any involvement with /prog/
because of the extremely bad behavior there :-(
Riiiiiiiiiiiiight. You know you love us.
Name:
Anonymous2013-07-28 23:30
>>56 As in KodakGalleryProgrammer? Yes, that would be me.
OH FUUUUUUUUUUUUUCK HE GOT A JOB AT KIKETUBE AFTER KODAK'S BANKRUPTCY
I FUCKING MISSED YOU MENTAL GOY FUUUUUUUUUUUUUUUUUUUCKKKKKKKKKKKKKKKK
Name:
Anonymous2013-07-28 23:31
but is ashamed of any involvement with /prog/ because of the extremely bad behavior there :-(
AHAHAHAH HOLY FUCK DID MENTISHIT REALLY SAY THAT