Thread: Facebook invents radical new technology... a compiler

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    Facebook invents radical new technology... a compiler

    Facebook open-sources software that writes software - SD Times


    Facebook is open-sourcing a piece of software that is designed to write software
    An amazing feat, truly. If Facebook made their own toilet paper, journalists everywhere would talk about their fantastic new invention.


    Being able to generate code through automated code generation allows programmers to increase the level of abstraction by making frameworks that are declarative and that are translated into high-quality Hack code,” wrote Alejandro Marcu
    Libraries? We don't need no stinkin' libraries, we'll just duplicate boilerplate in all our projects. Yay abstraction. Only people with OCD would worry about silly things like "separation of concerns" and "maintainability"


    Before Hack Codegen, Facebook generated code through concatenating strings, but found it was unable to scale
    Shocking.


    The library includes hack_builder to deal with the concatenation, new lines, indentation, braces, hack keywords, and collections, as well as signed files to regenerate code automatically when a schema is changed
    In other words, their IR is a language that's only a couple years old.
    You might be wondering why they didn't just properly design their new-born language instead, but that's just 'cause you're not cool like Facebook.


    And thank God they patented it. I'm sure companies everywhere are wishing they came up with the idea first.

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Facebook is open-sourcing a piece of software that is designed to write software. Hack Codegen is a library that allows users to generate Hack code, the company’s programming language developed for HipHop Virtual Machine. (HHVM is a virtual machine designed to execute programs in Hack and PHP.)
    Wait... Does this sound oddly similar to Java to anyone else?

    Oracle is open-sourcing a piece of software that is designed to write software. Java is a library that allows users to generate Java bytecode, the company's programming language developed for Java Virual Machine. (JVM is a virtual machine designed to execute programs in Java.)
    Pfft...

    I also lol'd at the "and PHP" part. But then I was like, ha! Even Facebook recognizes the glory that is PHP!

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    PHP is so bad... I don't understand why anyone would want to use it...
    A software to generate code... that's nothing new. It's been done before. Funny how when it is facebook that does it, it enters the headline news.
    Last edited by Elysia; 08-25-2015 at 04:15 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Before Hack Codegen, Facebook generated code through concatenating strings, but found it was unable to scale
    O_o

    I've had to check my calendar several times.

    I really want April 1st to be the date.

    I can't handle the "Hack Codegen" name.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  5. #5
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by phantomotap View Post
    I can't handle the "Hack Codegen" name.
    When you realize that the 'hack' here is onomatopoeic, it kinda makes sense. It does not "hack code", it "hacks up code". Like a cat.

    Look what the cat hack codegen'd up! On the good rug, too. It's your turn to clean it up.

  6. #6
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Elysia View Post
    PHP is so bad... I don't understand why anyone would want to use it...
    A software to generate code... that's nothing new. It's been done before. Funny how when it is facebook that does it, it enters the headline news.
    PHP is... bad?

    PHP IS BAD?!

    * Hulks out *

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by MutantJohn View Post
    PHP is... bad?

    PHP IS BAD?!

    * Hulks out *
    Don't you mean....

    * Hacks out *

  8. #8
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Or.. does he mean..

    *Hacks up Hulk*

  9. #9
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Yarin View Post
    And thank God they patented it. I'm sure companies everywhere are wishing they came up with the idea first.
    Like linked lists?
    Patent US5924098 - Method and apparatus for managing a linked-list data structure - Google Patents

    brb..going to patent some graphs.

  10. #10
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    I do like linked lists.
    Especially the ones that allow concurrent modification and traversal by multiple threads without locking the entire data-structure.

    gg

  11. #11
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Hmm... How does it implement thread safety? Does it just use a mutex per node?

    Edit : I'm trying to think and I like the idea of a mutex per node. You just have to create a lock on the current, previous and next nodes. I think. There might be some more elegant approaches but this is my kneejerk reaction.

    With a linked list, you only mutate the contents if you're adding or deleting a node. To add a node successfully, you can need to lock the two nodes you're going to insert the new node between. So if you have A->B and you want A->C->B, you'd have to lock A and B.

    To delete a node, I think you have to lock all three nodes so to go from A->C->B to A->B, you have to lock A, C and B.

    Is there any more efficient way to do this?
    Last edited by MutantJohn; 08-25-2015 at 02:50 PM.

  12. #12
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Especially the ones that allow concurrent modification and traversal by multiple threads without locking the entire data-structure.
    O_o

    Do you like patents defined so broadly as to attempt to cover any traversal implementation using flagging?

    Is there any more efficient way to do this?
    Obviously. You'll find several if you look.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  13. #13
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    They actually describe this: https://en.wikipedia.org/wiki/Hash_t...h_linked_lists
    Except that the linked-lists are concurrent capable.

    >> How does it implement thread safety?
    Look at Fig. 3a and 3b. These show the insert and remove operations as consisting of a single atomic operation on 22(n)'s Pointer. Given that, a thread traversing the list may or may not walk over a deleted node. Fun details like when to garbage collect are left to the reader.

    gg

  14. #14
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Okay, if I'm understanding Figure 3a correctly, it looks like all they would do is lock 22(n), set the value of the "next" pointer to the newly created element and assign the "next" pointer of the new element to the previous "next" pointer of 22(n).

    The only issue I take with this is, what if there's a thread removing 22(n+2)? 22(n+1) may then in fact contain the address of 22(n+2) but the dereference of that will be problematic because the data was cleared. If a direct call to something like free() was used, the program would instantly crash because it's attempting to access memory outside of the process' scope, right?

    When you say "atomic", what do you mean? I'm not sure of how to perform an atomic assignment of a variable that doesn't use something like std::mutex.

  15. #15
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    >> Fun details like when to garbage collect are left to the reader.
    I take that back. I didn't read the claims.

    Here is a typical atomic operation that may be used: https://en.wikipedia.org/wiki/Compare-and-swap

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. borland c++ facebook api
    By hbfriedman in forum C++ Programming
    Replies: 3
    Last Post: 01-08-2014, 05:09 PM
  2. facebook
    By BobMcGee123 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-20-2006, 04:49 AM
  3. Radical Sign
    By Iceboy152 in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2006, 10:08 AM
  4. rochester institude of technology and wentworth institute of technology
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 02-20-2003, 11:41 AM
  5. radical education reform
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 05-20-2002, 09:20 PM