CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • PHP vs Hack
Pages: [1]

Author Topic: PHP vs Hack  (Read 1487 times)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
PHP vs Hack
November 14, 2014, 01:48:00 am
Facebook's "hack" ( https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/ , http://hacklang.org/ ) is a revision to the PHP language -- it is (approximately) PHP5 with some additional syntax and features. Generally, it aims to provide more type-safety and more built-in sanity-checks.

Personally, I love the idea of hack -- explicit-typing makes it easier to read the code, and (for new developers) the sanity-checks provide better feedback about basic programming errors. That seems quite useful on a large codebase with an open developer community. I'd be all gung-ho for hack in Civi, except that...

To date, the hack language was only available on Facebook's HHVM. Facebook's HHVM sounds awesome (faster and better designed than the traditional Zend PHP), but it doesn't have the same deep market-penetration as Zend PHP (e.g. umpteen linux distros + MAMP + XAMPP + web-hosts). Given Civi's distribution model, that's a huge obstacle.

This week, Facebook made an announcement which may change things:

https://code.facebook.com/posts/398235553660954/announcing-the-hack-transpiler/

If this project pans out, one could write Civi's code in Hack -- but publish *.php versions for use on any PHP 5.4+ system. This might work like the CoffeeScript=>Javascript or SCSS=>CSS transpilers[F1] which became popular for frontend development.

The transpiler is still pretty new, so I'm not proposing any changes today -- just wondering about the sense of the room on the concept.

---
[F1] I hate the word "transpiler," but so many people are using it, and it only takes three syllables, so I guess I better use it, too.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: PHP vs Hack
December 04, 2014, 10:03:02 am
Transpiler sounds like transmogrifier, I like it ;)

So every time you'd change code, you'd need to modify the source in hack, generate the php, and test the transformed version.

IMO, there is a fair chance that randome bugfixer will start to change php directly and submit a patch/PR, that would need to be backported to hack.

Then what about the extensions? I'm assuming most will still be written directly in php, using an interface (api and co) that would be partly automatically generated?

And if the transformation introduces the slightest bug...

I like the idea, but it seems to introduce quite a few moving parts, and hack doesn't seem to have a lot of users outside of FB.
X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Re: PHP vs Hack
December 05, 2014, 01:58:01 am
It seems like a cool idea. My only concern is about having to debug things in two places. I.e. I found this issue, but the Hack looks fine, maybe it's the PHP".

I'm sure that instances of that would be rare, but they could be really hard to debug thanks to the extra layer.

J
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: PHP vs Hack
March 10, 2015, 09:06:18 am
I too like the idea in the abstract but worry about the practicalities. I think it would better to be a fast follower than a bleeding edge adopter here. Let some other big projects like CiviCRM sort through the issues and we can evaluate their experience.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • PHP vs Hack

This forum was archived on 2017-11-26.