Re: Typed PHP!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Tim-Hinnerk

There are some things you have to keep in mind when using Hack (and some of
those were the reason why I haven't used it until now):

You can decide in every file if you want to use Hack or not. Just use
"<?hh" for files, you want to use Hack and use "<?php" or start with
non-code for all other files. There are some limitations on that when these
two files have classes or interfaces implemented in the other language.
Please read more here:
http://docs.hhvm.com/manual/en/install.hack.conversion.php

Here are some characteristics of Hack:
* To promote best practices, you cannot mix Hack with HTML (or other
non-code text)
* All hack files must start with <?hh
* There is no closing tag for hack files
* Hack also has multiple modes
* XHTML can be embedded using XHP, which makes XHTML tags into language
constructs
(Source: https://blog.engineyard.com/2014/hhvm-hack-php#file-semantics it
may changed in later versions)

You can use every PHP framework that is supports HHVM 3.0 or later (Hack
has been included in HHVM since then).
Here's a list of popular frameworks and how good HHVM supports them:
http://hhvm.com/frameworks/

The limitations for me were the lack of extensions. Here's a list of PHP
extensions that have been ported to HHVM:
https://github.com/facebook/hhvm/wiki/extensions There may be some not
listed here, but this is the most complete list I could get hands on ;)

Hope this helps you to decide if Hack is something for you :)

Bye,
Simon

On Tue, Sep 8, 2015 at 6:20 AM, Tim-Hinnerk Heuer <tim@xxxxxxxx> wrote:

> Yes, of course! Thanks! Came across HHVM a while back but didn't remember
> this, sorry. Does this mean that existing PHP code and frameworks can be
> used with Hack? If yes, it would mean it's exactly what I am looking for.
> Does hack provide type definition files like TS?
>
> It seems like transpilation is not exactly what Hack does though.
>
> On Tue, 8 Sep 2015 at 16:12 Muddsar Jamil <mjamil114@xxxxxxxxx> wrote:
>
> > Check out http://hacklang.org/ - I think it has what you're looking for.
> >
> > On Mon, Sep 7, 2015 at 9:06 PM, Tim-Hinnerk Heuer <tim@xxxxxxxx> wrote:
> >
> >> Hi there,
> >>
> >> The single most annoying feature about PHP I find is that there are no
> >> optional types for variables. Otherwise, I think PHP is great: great
> >> community, lots of code and contributors etc.
> >>
> >> Just out of curiosity, do you think it would be possible and feasible to
> >> design a Typed PHP similar to TypeScript in JavaScript? So, a super set
> of
> >> PHP that is optionally typed and can be compiled/transpiled to normal
> PHP?
> >> I think this should be quite possible and possibly a great addition to
> the
> >> language. It would need to not break the current syntax but provide
> better
> >> tooling in IDEs and editors. Someone has already had a similar idea:
> >> https://github.com/krakjoe/strict
> >>
> >> However, I would propose a technology that transpiles to "normal" PHP.
> The
> >> types would be solely there for better tooling support and YES, better
> >> auto
> >> complete! An extension wouldn't be required. Typed PHP would just be a
> >> super set of normal PHP and all existing code could be re-used just like
> >> in
> >> Type Script. You could also have .d.tphp files, similar to TS and
> annotate
> >> existing libraries for better auto complete. I have come across Type
> >> Script
> >> not so long ago and it is really good in my opinion. People can still
> >> develop in the not strictly typed language while others more inclined to
> >> use strict types can use them but do not have to.
> >>
> >> Similar to TS you could have .tphp files that compile to readable .php
> >> files without having to re-engineer PHP or write extensions. The
> benefits
> >> should be obvious: Maximum code re-usability while providing better code
> >> maintenance and tooling.
> >>
> >> I think the exact syntax can be discussed and should be to not break
> >> anything while having a terse syntax, that is readable and writable. I
> >> could propose some syntax ideas that would be similar to TS syntax, but
> >> wanted to put the idea out there first. Maybe you will say this is
> >> absolutely crazy and cannot be done, but I challenge this belief.
> >>
> >> Kind regards,
> >> Tim
> >>
> >
> >
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux