PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Nov 18, 2017 10:39 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Jul 20, 2017 11:20 am 
Offline
Forum Newbie

Joined: Thu Jul 20, 2017 10:22 am
Posts: 4
Hi,

I've just released an open-source tool (Phoenix) which allows to program PHP code with a more concise syntax.

Most of the PHP syntax has been kept unchanged, except for a few "tweaks" :
- dollar signs and 'this' are now implicit (i.e. not needed);
- '..' is used to concatenate strings, and '.' to access class members;
- the foreach loop syntax is 'foreach ( value; array )';
- '<? ... ?>' blocks contain Phoenix statements;
- '<% ... %>' blocks contain expressions to echo;
- '<# ... #>' blocks contain escaped expressions to echo.
- etc...

The main drawback is that you have to declare your local variables, and put your code in files with the '.phx' extension instead of '.php'.

I know that this tool has absolutely zero interest for those who like PHP's current syntax as it is, but unfortunately for me I wasn't one of them...

https://github.com/senselogic/PHOENIX

Syntax: [ Download ] [ Hide ]
function GetMessage(
    string first_name,
    string last_name
    )
{
    global
        hello;
    local
        message;
       
    message = hello .. " " .. first_name .. " " .. last_name .. " !";
   
    return message;
}

class HOBBIT
{
    attribute
        FirstName = "",
        LastName = "",
        RingCount = 0;
       
    static attribute
        HobbitCount = 0;
       
    method constructor(
        string first_name,
        string last_name,
        int ring_count
        )
    {
        .FirstName = first_name;
        .LastName = last_name;
        .RingCount = ring_count;
       
        self::AddHobbit();
    }

    method destructor()
    {
        .RemoveRings( .RingCount );
       
        self::RemoveHobbit();
    }
}

<ul>
    <? foreach ( var dwarf_name; dwarf_name_array ) { ?>
        <li>
            <% dwarf_name %>
        </li>
    <? } ?>
</ul>
 


Last edited by ecstatic.coder on Wed Jul 26, 2017 10:27 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Thu Jul 20, 2017 11:59 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6578
Location: WA, USA
So basically it's not PHP.


Top
 Profile  
 
PostPosted: Thu Jul 20, 2017 2:18 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13443
Location: New York, NY, US
If these kind of syntax issues are that important to you then a preprocessor is the way to go.
ecstatic.coder wrote:
I know that this tool has absolutely zero interest for those who like PHP's current syntax as it is, but unfortunately for me I wasn't one of them...
I think you misunderstand the people you call "those". Most people, myself included, switch between programming languages all day long and just not bothered by the syntax details of those languages. As long as I have programmed, there has always been a very small group of people, like you, who are very dogmatic about syntax. More power to you!

_________________
(#10850)


Top
 Profile  
 
PostPosted: Thu Jul 20, 2017 2:53 pm 
Offline
Forum Newbie

Joined: Thu Jul 20, 2017 10:22 am
Posts: 4
requinix wrote:
So basically it's not PHP.


Let say it's a "diet" version of PHP, with a bit less fat ;)


Top
 Profile  
 
PostPosted: Thu Jul 20, 2017 3:06 pm 
Offline
Forum Newbie

Joined: Thu Jul 20, 2017 10:22 am
Posts: 4
Christopher wrote:
As long as I have programmed, there has always been a very small group of people, like you, who are very dogmatic about syntax. More power to you!


Indeed, I admit it...

I've always had a hard time decoding PHP code, especially with all these dollar signs flourishing everywhere in the PHP expressions.

Hence the Javascript-like syntax, which seems to be a bit more easy on my brain...

But I know that many people don't have any readability problem with standard PHP code.


Top
 Profile  
 
PostPosted: Mon Jul 24, 2017 1:49 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13443
Location: New York, NY, US
Had you started with PHP (or Perl), you'd be struggling with Javascript. And honestly, of the strange languages in the world, Javascript is pretty weird. It is prototype based and there are a bunch of different ways to make objects. It you learned it first, you have a strange perspective on languages. But Javascript is event driven, DOM traversing fun!

_________________
(#10850)


Top
 Profile  
 
PostPosted: Mon Jul 24, 2017 2:44 pm 
Offline
Forum Newbie

Joined: Thu Jul 20, 2017 10:22 am
Posts: 4
Being able to add properties to a class instance (like in JS and PHP) is indeed a fantastic feature, and I regularly miss it when using strongly-typed languages.

I think that if I had learned JS after PHP, I probably would have still preferred the leaner JS syntax, but that doesn't mean I would prefer to use JS over PHP for web development.

I've already used Node.js in the past, and obvioulsy PHP is way easier to use, even compared to Go, Dart, etc.

Rename index.html to index.php, add a few lines of PHP code inside dedicated tags, and you have your first web server up and running. Nothing can beat this approach in ease of use.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group