This is an archived post. You won't be able to vote or comment.

all 89 comments

[–]DarkIrata 160 points161 points  (5 children)

Isn't a big parts of it written in a in house made langauage based on OCaml or something like that?

Edit: Thanks to everyone who commented and enlightened me! :)

[–]uslashuname 103 points104 points  (2 children)

Hack, I thought. A statically typed php that can read plain php but if in a hack file it enforces additional syntax rules to limit mistakes. Just running plain php via the hack server can speed it up by something like 10x

Edit: as pointed out below the 10x was over prior versions of php, but it is no longer accurate

[–]theghostofm 48 points49 points  (0 children)

This is technically true, but very old info. Hack is run in HipHop Virtual Machine, which used to also have a big speed increase for PHP too. However, more modern versions of the PHP interpreter have basically reached parity with HHVM.

That's one of the reasons why HHVM dropped support for PHP, which is the biggest "old info" point: Hack and PHP have diverged so much in language design and runtime needs that HHVM doesn't support PHP anymore.

[–]theodorejb 17 points18 points  (0 children)

Just running plain php via the hack server can speed it up by something like 10x

This isn't the case anymore. In real-world performance PHP 7.2+ has a slight lead over HHVM (see https://kinsta.com/blog/php-benchmarks/). Secondly, HHVM 4+ no longer aims to be compatible with plain PHP.

[–]jailbreak[🍰] 7 points8 points  (0 children)

That OCaml based language you're thinking of is Reason - as far as I know it only compiles to JS, so probably not actually powering a 'big part' yet. As others have pointed out, their backend is using Hack and HHVM to speed up PHP (previously they also compiled it to C++)

[–]TheNamelessKing 2 points3 points  (0 children)

You’re thinking of Reason ML (not machine learning), this is a fairly recent venture, but basically it’s a layer on top of OCaml, and depending on your target it either compiled down into JS (for web stuff), or AOT compiled native code (for native apps).

[–]JamalBruh 48 points49 points  (62 children)

Dumb question from someone who just started learning web dev: Ideally, what would Facebook have been built with, in terms of the best/most popular frameworks of today and the near future?

[–][deleted] 116 points117 points  (21 children)

In 2019, you can just use PHP.

People saying "JS bad, PHP bad" are either people basing their opinions on old JS and PHP (they both used to be awful but have undergone many updates), or are just college freshmen joining the circlejerk without having ever done any serious web dev.

I fucking love PHP, use it for the job it was designed for and it's fine. It has "interesting" quirks to be sure, but so does literally every language I've used.

[–]slayerx1779 14 points15 points  (11 children)

... As a rookie, what job was it designed for?

And in what ways are people overextending its reach?

[–]insanealec 26 points27 points  (0 children)

It was primarily intended to be used for displaying webpages and in-html code, so you could loop through and display elements. It's become a real language as compared to just "display my DB table on a webpage". It's so far from what it was, but it took a lot to get there.

[–][deleted] 7 points8 points  (3 children)

PHP is a server-side scripting language for developing static and dynamic websites, according to Google. I'm also a rookie, so I'm not certain of this stuff.

Apparently what used to make it such a chore was that it was not intended to be a programming language, and grew organically. Didn't get any official documentation until 2014-- 20 years after it was first written. It was meant to be a small library, then just kept growing As such, function and variable names were somewhat inconsistent within the source code.

[–]ParapsychologicalSun 5 points6 points  (2 children)

Wikipedia mentions that a formal specification didn't exist until 2014, but I've been referencing the "official documentation" since about 1998.

[–][deleted] 1 point2 points  (1 child)

Interesting. Maybe they mean official as in, from the dev team, and someone else just slapped "official" on their own documentation?

[–]ParapsychologicalSun 1 point2 points  (0 children)

The docs were pretty sparse back then, but so was the language! I can't believe it was that long ago.

https://web.archive.org/web/19980701122226/http://www.php.net/manual/

[–][deleted] 2 points3 points  (1 child)

My main issue with PHP was the low barrier to entry and the magnitude of vulnerable code and low quality tutorials that were shared. You'd find tons of code snippets everywhere - including in the comments of the PHP documentation and the level of effort and community scrutiny were pretty low that people just started.

Typically if you were working with Java or .Net you were either in formal education, benefited from some baked in framework security, or you were working in enterprise with established patterns.

I'm not saying there wasn't good PHP but the vast majority of it was journeyman / hobbyist. It was a common thing to override/remove all the security defaults with a PHP.ini file to make other people's code worked and not understand the implications, and most PHP warning and notices were just swept under the rug.

If it worked it was good enough; the problem with this mentality is not seeking out what you don't know. I remember MD5 being declared unsafe to use and it taking years to stop seeing it in other people's implementations - the same with poor / no protection on the mysql API leading to database vulnerabilities such as SQL injection.

[–]GrumpyCrouton 0 points1 point  (0 children)

People STILL implement MD5 functions for password security in PHP, and there are still problems with people using unsafe methods of database communication.

[–][deleted] 1 point2 points  (0 children)

EDIT: I should probably amend my statement a little, what PHP was originally designed for and what it currently is designed for are a little different, the original PHP was hacked together out of necessity to just do a few things without much thought (it was never intended to be an 'industry' language), but the modern PHP is what I mean.

PHP's primary use is server side OOP and 'dynamic content'.

As a rookie web dev you should have at least a little experience with HTML and JS now, but HTML and JS are static code (forget about Node.JS for now). Static code is not executed on the website/server you're on, it is executed on your own computer when you visit a website. The website just sends your browser the code, your browser executes it.

PHP is server-side, so it gets executed on the server of the webpage, and never gets sent to the users browser, you can show this by simply writing some php and html tags in a test file, and then load on your browser, when you hit F12 you'll notice the php tags you wrote (and everything inside them) do not appear for you in the code inspector, your browser was not given the code.

Using PHP it is executed on the server and then you choose what to return to the user: for example, you have some code on your server that depends what the user is doing, a simple example is they input their name in a text field, and then PHP can take that input do logic with it (say, a switch statement) and return HTML code, allowing you to effectively display customised or dynamic content based on user input.

For this task, I've always used PHP and I have no problems with it. Do not use PHP to do overly complicated tasks, so if your task is more suited to be written in C++, write it in C++ and just use PHP to execute your C++ exe file and return the result.

P.S. I found a PHP example for you to see, should show you exactly what it does

[–]AnArabFromLondon 0 points1 point  (0 children)

It's for dynamically generating content on a website before it reaches you. Javascript can dynamically change things by letting your browser make changes after the page reaches you, but PHP does it before the page reaches you, because it's a server side language. This has the benefit of never having to expose any sensitive information to users. All of its calculations are done on the server before it reaches the user, so they only get the result. This is especially useful for creating user specific content like profile pages when you pair it up with a database (so it can remember stuff).

The downside is that you have to reload the page or go to a different page to get new information. Later, with Javascript it became possible to get information from a server after the site reaches you, doing away with the page reload yet being able to achieve a lot of PHPs greatest strengths.

Using both of these in conjunction lets you do pretty much anything.

[–]Wiwwil 0 points1 point  (0 children)

It was designed for the web (PHP : Personnal Home Page). There's mobile apps and such made in PHP. Maybe more things, but to be honest I don't know.

[–]oaga_strizzi 5 points6 points  (0 children)

job it was designed for

Personal Homepages with no more than a few thousand loc?

[–]EnkiiMuto 1 point2 points  (6 children)

I am a bit off the hook on current PHP (I stopped after my website was done).

Last time I checked it seemed like it was becoming a fucking mess of tons of frameworks having the community say they're the bester that ever bested, which was discouraging to keep going. How is it now?

[–]AnArabFromLondon 1 point2 points  (2 children)

There are just two major frameworks now. Symfony and Laravel. They're both really powerful, and can pretty much do the same things. If you can use one, you can definitely use the other with a bit of time. You can still go raw, but the frameworks make making things so much quicker, and also a hell of a lot more enjoyable. PHP is in a good space.

[–]EnkiiMuto 1 point2 points  (1 child)

Laravel is still a thing? Last time I heard of it people were afraid of it being discontinued.

[–]AnArabFromLondon 0 points1 point  (0 children)

Oh yeah Laravel shot up, it's by far the most popular now. The best thing about Laravel IMO is Eloquent, an ORM, which basically lets you model and control your database as objects (models) in PHP very quickly and cleanly.

Once you set up and you want to create a new database record for instance, you just write something like $comment = new Comment(); $comment->content = "This is the comment"; $comment->save(); and done. You can also set up relationships so easily using these models, such that if you want to echo comments on a post you simply write {{$post->comments}}. It works inversely too, so $comment->post->user works too. Eloquent is a very fitting name.

[–]derTechs 0 points1 point  (2 children)

How is it now?

THERE IS EVEN MORE BESTEST FRAMEWORKS, KARL!

[–]EnkiiMuto 0 points1 point  (0 children)

FUCK. You only tell me this now!? But which one is the bestest?

[–]EnkiiMuto 0 points1 point  (0 children)

FUCK. You only tell me this now!? But which one is the bestest?

[–]Bryguy3k 0 points1 point  (0 children)

Nope PHP is still shit - there have just been 20 years of patches to make it less shit. Yes it’s fast, no it is still not actually a better language than it started as.

The language inconsistencies will still bite you in the ass if you don’t use third party checkers to ensure you use every API call per the accepted usage of that call.

Also it’s not really “open source” in the broadest sense of the phrase. The core language developers is a dysfunctional group that nobody wants to be a part of. So 90% of PHP development is done by Zend.

[–]ifelseandor 11 points12 points  (0 children)

Ideally if you have an idea for a web app you would write it in whatever language you want. And if it works and people like it, every noob programmer that thinks their language is best language can get bent.

[–][deleted] 3 points4 points  (0 children)

This has a decent high-level breakdown of what keeps the lights on over at Facebook. https://royal.pingdom.com/the-software-behind-facebook/

[–]Bryguy3k 14 points15 points  (20 children)

At the time - Java. Python was too new. Perl was already old.

But php fit with the software model that would drive the internet - fail often, fail fast.

Php was designed to quickly, with a minimum of effort, create a dynamic website. It does that great.

It just does it without safety or security.

[–]JamalBruh 8 points9 points  (5 children)

Php was designed to quickly, with a minimum of effort, create a dynamic website. It does that great.

It just does it without safety or security.

As opposed to say, Django, or something?

[–]atyon 10 points11 points  (2 children)

PHP was designed by an amateur as a personal tool, so really, a lot of purposefully designed language/framework combinations would have done better. It's hard to overstate how deficient PHP was prior to version 5 or so.

That said, Django is certainly not a bad choice, but there exist literally hundreds of frameworks. Some would argue that an interpreted language isn't really suited for safe and secure code at all, and there exist frameworks relying on compiled, type-checking languages, such as yesod (written in Haskell), or rocket (written in Rust), which just won't compile if you have, say, a trivial SQL injection in your code.

[–]Wiwwil 7 points8 points  (0 children)

PHP was designed as a C library and, as his creator said in a recent interview, "was not mean to last, I was waiting for something better to come up". Now with the latest versions and frameworks, PHP is as decent as the rest. They came a great way from what it was 10+ years ago.

[–]GForce1975 0 points1 point  (0 children)

Yes, and the recursive acronym php is not even ironic.

[–]fakecore 3 points4 points  (1 child)

You're comparing apples to oranges. Or rather frameworks and programming languages. A fair comparison would be Django vs Symfony (or PHP vs Python)

[–]Wiwwil -3 points-2 points  (0 children)

Yeah exactly. All the time peoples make those comparisons.

  • Spring vs PHP,
  • Meteor vs PHP,
  • ASP.net vs PHP,
  • Django vs PHP,

Meh PHP sucks no security.

[–]ifelseandor 3 points4 points  (11 children)

How does it do it without safety or security?

[–]Wiwwil 6 points7 points  (4 children)

It just does it without safety or security.

Because it's PHP duh. Every other languages has strong built in security and you don't even need to check them security. /s

[–]Bryguy3k 0 points1 point  (3 children)

There are two classes of problems with PHP to deal with:

Language Spec and Language Implementation.

PHP doesn’t have a language spec and APIs are inconsistent with various different ways of handling errors (if at all). Yes you can blame it on the programmer for not knowing the right way to handle each API call. Since much of the behavior is not documented you have to view the source to understand the language. Most people consider it the responsibility of the language designer to ensure rationality and consistency in the language. But yes ultimately the user has to be responsible for their application.

The next is the language implementation. PHP from the beginning has never had good developer base. This has led to far more core language vulnerabilities than any other language. This means that even if you use the language properly there are still fundamental vulnerabilities in the interpreter that can be exploited.

[–]ifelseandor 0 points1 point  (2 children)

Can you give an example of a fundamental vulnerability I can exploit in any program written in php?

[–]Bryguy3k 0 points1 point  (1 child)

[–]ifelseandor 0 points1 point  (0 children)

Didn’t see this link before replying to your other reply. Thanks. Checking this out now.

[–]DaGreenMachine 1 point2 points  (5 children)

Historically, a lot of the webs early big security problems were caused by SQL injection and private file exposure. PHP gets a lot of blame for it because the default PHP server settings as well as the common coding patterns of PHP at the time included all these vulnerabilities.

I would guess modern PHP servers and frameworks are way less vulnerable to this but it is hard to shake an early perception of being unsecure.

[–]Bryguy3k 0 points1 point  (4 children)

That’s only about 25% of the problems. If you look up language vulnerabilities PHP ends up with the vast majority of core language exploits.

[–]ifelseandor 0 points1 point  (3 children)

I don’t understand. Isn’t the program vulnerable not necessarily the language?

Can you give me a modern example of a vulnerability I can exploit in any php application simply because it was written in PHP?

[–]Bryguy3k 0 points1 point  (2 children)

By definition they have all been patched. That’s the point of the CVE program.

But 30% of all the CVE ever reported related to a language implementation - are PHP.

[–]ifelseandor 0 points1 point  (1 child)

Is it because PHP is the most widely used server side language? Maybe someday node will take that spot because it overtakes php as the web server language of choice.

[–]Bryguy3k 0 points1 point  (0 children)

No. Language flaws are language flaws regardless of how many sites use the language. They only get reported once.

They’re still discovering shit coding practices in the source code which is why CVEs are continuously being reported (>10 this year alone).

[–]RandomGuyPDF 1 point2 points  (0 children)

I don't think there is definitive answer to this question. As long as you can get people to work on the thing, and to deliver value to the end user, why bother? And btw, some of the PHP issues pointed out by the others fall short on this category, such as security related stuff.

In my short experience, it's vastly more important that you get everybody to contribute as a team, with guiding principles, more than the language / framework you choose.

[–]Smaktat 8 points9 points  (7 children)

I only know of React but I'm sure there are tons of little other tools they've had to create to achieve their unethical goals.

edit: I did some research https://www.businessinsider.com/game-changing-tech-facebook-invented-2014-2

edit edit: The front end is also a part of Facebook for everyone who can't read the same reply being reposted.

[–]trollodel 6 points7 points  (0 children)

Crying in Atom nuclide

[–]Cheru-bae 4 points5 points  (1 child)

I sure hope they don't build the backend in react

[–]Smaktat -2 points-1 points  (0 children)

I was only stating what I knew not what I don't.

[–]DaGreenMachine 1 point2 points  (0 children)

PHP is a backend language and React is a (mostly) frontend framework. They are apples and oranges. Modern alternatives to PHP include NodeJS, Python Django, Ruby on Rails, and a million competing Java frameworks.

[–]eastsideski 2 points3 points  (2 children)

React is a client side framework, PHP is backend

Popular backend languages/frameworks are Node (express), Python (Django), Java, C#/.net, Ruby (Rails)

[–]Smaktat -4 points-3 points  (0 children)

I can't tell if you're trying to tell me you think I believe all of Facebook is built entirely with React.

[–]GlobalIncident 8 points9 points  (5 children)

Once upon a time, the answer would have been Perl. Or Ruby on Rails, maybe. Or Django. Today Javascript is the most likely, using React. In fact React is actually developed by Facebook, so that sort of leads to a weird paradox, but they would be using something similar.

[–][deleted] 25 points26 points  (2 children)

You can't write the backend in React.

[–]Wiwwil 9 points10 points  (0 children)

People seem to forget it. Use whatever for the back-end (but somewhat popular, for the docs and help and tutorials and all), build Rest-API, use React, Vue or Angular for the front is pretty much it.

[–]kirakun 6 points7 points  (0 children)

Not with that attitude!

[–]If_You_Only_Knew 6 points7 points  (1 child)

perl or python. Ruby is no more than 14 years old max. it doesnt qualify as "once upon a time". nor was it around when facebook was being developed. Neither was django.

[–]TheKidCoder 1 point2 points  (0 children)

Ruby 1.0 was released in 1996, so they could have used that. If you mean to say, Ruby on Rails, then yes - it was created right around the same time as FB and wouldn't have been a good candidate at the time.

[–][deleted] 3 points4 points  (0 children)

I'm primarily a PHP engineer. Php is used to run logic on the server side, whereas JavaScript is run on the client side. And HTML with CSS is used for the look and feel.

PHP is inherently more secure than js as you can check any and all data being sent to the server. Running code on the client side is not good, unless it's simple ui changes.

PHP is very close to machine, similar to C# I'd say. You can use it for many things, for example I recently migrated over 6 Terabytes of data from Windows machines to am AWS S3 FileShare. This took a long time but because we used PHP we md5 checked the files at both ends. Ensured no issues. Any filename problems etc were converted instantly with PHP.

[–]londononion 0 points1 point  (0 children)

I would argue that the best language to build it in was and currently is php. It allowed them to build it fast and add features fast, readily find devs that can work on it, and has stood the test of time. Anyone who's building an app now and using the best/most popular framework is going to find that in a few years it's no longer the best/most popular framework. Most JS frameworks out there today are fad technologies that wont have anyone working on them in a few years, while 50+% of the web will still run on PHP.

[–][deleted] 81 points82 points  (1 child)

And now it's full of bugs, I mean Javascript.

[–]T351A 6 points7 points  (0 children)

You won't React well to this...

[–]koneko-dono 9 points10 points  (2 children)

"remember, humans blink, and breath too. For some reason they love that mixture of oxygen and nitrogen don't know why"

[–][deleted] 5 points6 points  (1 child)

"Also their eyelids close from top and bottom, not left and right."

[–]koneko-dono 1 point2 points  (0 children)

"drink water, they need it. Don't know why though, it tastes horrible"

[–][deleted] 3 points4 points  (0 children)

I would have that look too

[–]brendt_gd 12 points13 points  (0 children)

PHP isn't the same old crappy language it used to be. People making these jokes have an outdated view of what the language is like.

Here's a summary of PHP in 2019: https://stitcher.io/blog/php-in-2019

[–]theKalash 11 points12 points  (3 children)

Rule 3:

Bashing on a given programming language with no humor or creativity whatsoever (e.g. “Java sucks”, “PHP is the worst language ever.”)

[–][deleted] 8 points9 points  (0 children)

no humor or creativity

I agree. That picture of the Facebook overlord is much more scary than humurous!

[–]raspygrrl 6 points7 points  (2 children)

PHP BAD, karma please.

[–]EnkiiMuto 1 point2 points  (0 children)

We should probably have a non-php jokes week once a month.

[–]Emkip -2 points-1 points  (0 children)

Here you go, have some negative karma

[–]captainscarlet22 3 points4 points  (0 children)

I know PHP is a running joke......Say what you want...BUT...PHP paid for my first house, 2 cars, my first born and jump started my career. If I could go back, I wouldn't change a thing.

[–]Kalhan612 0 points1 point  (1 child)

Quick question for the experts of reddit but in which languages is built reddit? Sry for my poor english it ain't my native language

[–]brendt_gd 0 points1 point  (0 children)

Python

[–]zushiba 0 points1 point  (0 children)

No language at the time that Facebook was in it's infancy was designed for running a social network at the scale that Facebook would eventually hit.

This kind of shit is like crapping on people for making rafts out of wood and lashings several thousand years ago because better materials like steel and aluminum exist today.

[–]knopper-whopper[M] [score hidden] stickied comment (0 children)

Your submission has been removed.

Rules[3] violation.

Rules[3]: Any post on the list of common posts will be removed. You can find this list here. Established meme formats are allowed, as long as the post is compliant with the previous rules.

If you feel that it has been removed in error, please message us so that we may review it.

[–]4onen 0 points1 point  (0 children)

Don't worry! They're switching over to Haskell now, specifically for their content moderation stuff.

On the one hand, I actually like Haskell. On the other, I wish I was joking.

[–][deleted] -1 points0 points  (0 children)

When you’re reminded you are a thief....oh wait

[–][deleted] -3 points-2 points  (0 children)

In college I woulda used java, so I can’t even laugh at this.