Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP beats C++ anytime

Name: Anonymous 2013-07-26 6:12

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.

Can you share you PHP success stories?

Name: Anonymous 2013-07-26 6:22

Too fat. Go away.

Name: Anonymous 2013-07-26 6:45

Why can't PHP "programmers" use a spellchecker?


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: Anonymous 2013-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;';

    public function hackClosure($closure, $inject_start, $inject_end) {
        $reflection = new ReflectionFunction($closure);
        $tmp = $reflection->getParameters();
        $args = array('$that');
        foreach ($tmp as $a)
            array_push($args, '$' . $a->getName() . ($a->isDefaultValueAvailable() ? '=\'' . $a->getDefaultValue() . '\'' : ''));
        $file = new SplFileObject($reflection->getFileName());
        $file->seek($reflection->getStartLine() - 1);
        $code = '';
        while ($file->key() < $reflection->getEndLine()) {
            $code .= $file->current();
            $file->next();
        }
        $start = strpos($code, '{') + 1;
        $end = strrpos($code, '}');
        return create_function(implode(', ', $args), "$inject_start;" .  substr($code, $start, $end - $start) . "$inject_end;");
    }
 
   
    //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: Anonymous 2013-07-26 8:18

we work in PHP with Zend Framework
Shalom, hymie達!

Name: Anonymous 2013-07-26 11:54

>>5

Zend is not a jewish technology, but a technology for all people.

Name: Anonymous 2013-07-26 11:56

PHP blows and not that well either.

Name: Anonymous 2013-07-26 11:59

We also use PHP it is the best language for the web. You cannot deny this.

Name: Anonymous 2013-07-26 12:03

>>8
le egin EGGWING GROSKI LELLLLLLLLLLLLLLLLLLL LLEEEEEEEEEEEEELL EGGWING LEDDIT XD DXDXD /G/ LELLLLLLLLLLLLLLLLLLLLL LLEEEEEEEEEEEEEEELL /g/roksky XD

Name: Anonymous 2013-07-26 12:17

>>8
Yeah it's so great that firms like Facebook had to develop a cross compiler that would convert certain parts of PHP to C.

Name: Anonymous 2013-07-26 12:19

Name: Anonymous 2013-07-26 12:20

I used PHP in one intranet project and didn't shoot me in the head.

That is my success story.

Name: Anonymous 2013-07-26 15:28

>>10

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: Anonymous 2013-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.

Name: Anonymous 2013-07-26 16:08

>>14

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/7E 2013-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/7E 2013-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/7E 2013-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.

Name: Anonymous 2013-07-26 16:16

>>17

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.

Name: Anonymous 2013-07-26 16:16

>>6
Yes, good goy!

Name: Anonymous 2013-07-26 16:17

>>18

Why not try a little bit of chipotle, pancho? Nice burrrrito, latin scum.

Name: Anonymous 2013-07-26 16:17

>>18
I would rather be a retard who is employed as a Software Engineer than a dumbfuck wannabe programmer.
Then these sites will be perfect for you!

http://reddit.com/r/programming
http://hackerne.ws

Name: YoutubeEngineer !12wzVQ1/7E 2013-07-26 16:19

>>19
Yes. I deal BS frameworks like the map/reduce framework for Apache Hadoop and interesting algorithms such as Paxos Algorithm.

Name: YoutubeEngineer !12wzVQ1/7E 2013-07-26 16:19

Now LOOL some more you fucking nigger mental midget.

Name: Anonymous 2013-07-26 16:21

>>24
LOOL LOOL LOOL
Is that enough, or should I LOOL more?

Name: YoutubeEngineer !12wzVQ1/7E 2013-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: Anonymous 2013-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/7E 2013-07-26 16:25

>>27
And you also have no real future as a programmer.

Name: Anonymous 2013-07-26 16:26

>>26

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: Anonymous 2013-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/7E 2013-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/7E 2013-07-26 16:29

>>30
That is apparent in your idiotic posts concerning C++ and PHP.

Name: CloudEngineer !Ep8pui8Vw2 2013-07-26 16:31

>>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.

Name: Anonymous 2013-07-26 16:32

>>32
I already said that was my first post in this thread, can't you fucking read? Both C++ and PHP are utter trash.

Name: YoutubeEngineer !12wzVQ1/7E 2013-07-26 16:34

>>33
Or places like comp.lang.c

Name: Anonymous 2013-07-26 16:35

Was Kodak-kun German all along?

Name: CloudEngineer !Ep8pui8Vw2 2013-07-26 16:36

>>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.

Name: Anonymous 2013-07-26 16:40

>>37

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/7E 2013-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/7E 2013-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.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List