At the very least it'd make more sense to invert the expectation. {{<html>}} instead of {{php}}html{{php}}.
The way around php has it is both annoying, since most php is not mere template anymore, and error-prone, thanks to the potential problems from trailing whitespace.
I'm aware you're supposed to leave out the closing ?>, but a lot of people don't. In fact, the example on the front page of this project doesn't leave out the trailing }}, either, incidentally.
As for your little snippet, inverting does make sense:
<?php
// ... 1000 lines of php
...?><p><?=$message?></p><?...
// ... 1000 lines of php
?>
But tacky little examples aside, there's nothing stopping <?= tags from working just as they always have once you've escaped into html.
I don't see the benefit of this, it basically seems to strip out semicolons, dollar symbols and a different function syntax.. I suspect it's very limited (for example I see no object support, let alone traits, generators, etc) and could further complicate deployment. Can you summarise the benefits and strategic goals of the project?
Well I suppose this is very early days for the project, and syntax improvements have not been added as yet, but I see this as a worth-wild exercise if it does have some influence over php in the future like coffeescript did to the javascript world.
I think you judging it on a premature release. Maybe he is looking for your suggestions before going down the improvement path.
Assuming it continues to develop, I could see the appeal. When you consider how widely available PHP is and how one of the biggest complaints is the inconsistency in the design of the language, it makes sense to take advantage of a cleaner way to interact with the ecosystem.
Or it could make the php bugs and corner cases impossible to access, and produce far more reliable PHP code.
Edit: As child post asked: That is the purpose on making something like this or coffeescript. We may all know the edge cases and bugs and know how to write pure php that gets around this, but why should we? Shouldn't our tools serve us and not the other way around? Something like mammoth might actually bring me productivity and enjoyment - which I think in the end is what drives developers.
But, as with Coffeescript/JS, wouldn't the better alternative be to learn those bugs and edge cases and code it up properly in the original language to begin with?
I don't know about productivity, if you look at the side-by-side comparisons, the savings are generally one or two lines at most.
There's nothing in there that actually helps with the idiosyncrasies of PHP -- for example, returning a sane default when accessing nonexistent array elements.
Also, PHP 5.4 already has the JS-style array notation.
And I really have to wonder about the enforced breaks in their implementation of switch/case, because there are times when you do want to fall through to the next case.
Its too early to judge that it makes no improvements, because it does not claim to yet! It currently is only slightly reducing the weight of the code - it doesn't even support classes yet!
I am sure if it matured, you would start to identify way in which it could improve PHP by hiding PHP gotchyas, and doing all the boilerplate to get around them.
I think it was about time someone does this. Not sure what will come out of this, but coffeescript was radical for js, maybe this can also have that influence on php.
I agree. I had considered making something like this before, but didn't know where to start. I think things like this are a boon for the php community.
I think you are missing the point of this. Similar happened when coffeescript was created, people didn't understand what is use-case. This is not to say this will do the same thing as cs.
How come you guys compare with it CoffeScript? Compiling to JS makes sense because that’s how the code should be distributed. That’s what browsers understand. But why should a new language come to compile to PHP? Why not build a first-class language?
CoffeeScript took off because that was the best way to write client-side code with a cleaner language/syntax. But for server-side, if someone wants a better language/syntax, there are a lot of options to choose from and you don’t have to continue with PHP if you don’t like it.
PHP is still the only option on many, many shared hosting services. Less common over time, but imagine the amount of legacy code that requires PHP libraries or frameworks. If newcomers wanted to ease their development with a more concise language, that holds the same opportunities and difficulties anyone chosing CoffeeScript, Scala, etc. in development has made.
I agree at first glance you could see how it would seem to be a waste of time, but I think you underestimate how big of a foothold PHP has for building websites and applications. There are A LOT of php developers.
Ease of deployment with PHP, and the run anywhere on any shred hosting service really is a game changer for people learning how to code on the web.
I think this project has the ability to build a language that could hide allot of the things developers do not enjoy about PHP while still keeping the huge platform already existing for cheap hosting and integrating with existing code bases.
Previous replies had great points, but I also imagine it would be useful for developers who are extending existing PHP codebases. I have to write Drupal and Wordpress plugins/themes pretty often and I get frustrated at simple things like starting variables with dollar signs when I have to switch into PHP mode. Not sure if I would use this, but it is interesting.
I feel like the biggest problem with this, aside from questions of how much it actually improves things, is that it's written in js. It's a bit of a smell issue that you need to install a whole other runtime environment to use it. It suggests a lack of faith in the engine of the language itself, and that's not a good thing.
I don't see it that way. This is a good example of using a tool that is proven to do what it does well (coffeescript) and also assists adoption by allowing someone to play with it easily in the browser. You dont need a whole other runtime to run the outputted PHP either, its a developer tool - are you saying if all of your developer tools are not written in the same language your programming in that is a slight to your work? I use jetbrain's rubymine to write rails apps, should I think it is a smell that my ide is not written in ruby?
Why would you compile to PHP when you could compile to native machine code, or run directly in a VM? This isn't the browser where we have a constrained environment.
If you already have a project that uses php and can't migrate it all to a more favorable language. You can use some language that compiles to php and just include this compile into your build step.
comparatively how feature complete is it to snowscript?
if you wanted to use this in say laravel4 blade templates, how do we make sure we dont lose the speed of the "im using previously genereated opcodes" cacher (is that thing even always on or is it part of Zend idk), i dont want a speed hit there.
46 comments
[ 3.6 ms ] story [ 96.0 ms ] threadExample:
$shared;Created: https://github.com/btwael/mammouth/issues/1
The way around php has it is both annoying, since most php is not mere template anymore, and error-prone, thanks to the potential problems from trailing whitespace.
You are supposed to leave out the closing ?> in the PHP file - then you don't have that problem.
Inverting doesn't really make any sense:
The HTML is primary, the PHP is used to output whatever is needed.As for your little snippet, inverting does make sense:
But tacky little examples aside, there's nothing stopping <?= tags from working just as they always have once you've escaped into html.* Edit: I just remembered PHP's "barewords".
I think you judging it on a premature release. Maybe he is looking for your suggestions before going down the improvement path.
Edit: As child post asked: That is the purpose on making something like this or coffeescript. We may all know the edge cases and bugs and know how to write pure php that gets around this, but why should we? Shouldn't our tools serve us and not the other way around? Something like mammoth might actually bring me productivity and enjoyment - which I think in the end is what drives developers.
There's nothing in there that actually helps with the idiosyncrasies of PHP -- for example, returning a sane default when accessing nonexistent array elements.
Also, PHP 5.4 already has the JS-style array notation.
And I really have to wonder about the enforced breaks in their implementation of switch/case, because there are times when you do want to fall through to the next case.
I am sure if it matured, you would start to identify way in which it could improve PHP by hiding PHP gotchyas, and doing all the boilerplate to get around them.
CoffeeScript took off because that was the best way to write client-side code with a cleaner language/syntax. But for server-side, if someone wants a better language/syntax, there are a lot of options to choose from and you don’t have to continue with PHP if you don’t like it.
Ease of deployment with PHP, and the run anywhere on any shred hosting service really is a game changer for people learning how to code on the web.
I think this project has the ability to build a language that could hide allot of the things developers do not enjoy about PHP while still keeping the huge platform already existing for cheap hosting and integrating with existing code bases.
why would you need shared hosting?
For example, if I had Wordpress site running and needed to write a plugin or an extension I'd rather do it in something other than PHP.
I've not used Mammouth so I don't know if plays out nicer than just plain PHP, but I like the idea.
comparatively how feature complete is it to snowscript?
if you wanted to use this in say laravel4 blade templates, how do we make sure we dont lose the speed of the "im using previously genereated opcodes" cacher (is that thing even always on or is it part of Zend idk), i dont want a speed hit there.
And why is it that some of the case values in the documentation are followed by "then", and some are not? It seemed random.
What if you want to do:
It's a very nice way to write code since it's very clear.