btwael / mammouth

Unfancy PHP
http://mammouth.boutglay.com
MIT License
214 stars 22 forks source link

mammouth<->PHP #58

Open aolko opened 8 years ago

aolko commented 8 years ago

see http://js2.coffee/

Basically Mammouth -> PHP & PHP-> Mammouth online conversion

coderofsalvation commented 8 years ago

exactly my thought. Without this projects won't be converted to mammouth.

btwael commented 8 years ago

But why you want really to convert PHP to mammouth?

Manaus commented 8 years ago

Maintainability of already written code, I would say (I do it often with js<->coffee)

btwael commented 8 years ago

The problematic of converting PHP to Mammouth, it's that Mammouth is more expressive than PHP, by example loops in Mammouth are used to iterate over arrays, while php ones are used to repeat a peace of instuctions. So even if we implement this PHP to Mammouth, the output mammouth code will be very long compared to a hand-written Mammouth code.

coderofsalvation commented 8 years ago

btwael: Long php code is not a problem. Syntactical lock-in (now) is a problem.

In some eyes coffeescript was a far more superior and readable than javascript. However for the haters, coffeescript was just useless syntactical sugar. So why are there coffeescript files found in so many npm modules? The answer is: Syntactic interoperability, developers can choose between writing .js or .coffee. For every .coffee file, there's an .js file. The collaboration-factor is huge.

As long as mammouth its an one-way converter, the 'sell it to your team/boss'-chance is very low. Create a two-way converter and nobody can argue against mamouth because mammouth would be PHP, and PHP can be mammouth

ps. slightly offtopic, but mammouth's portability could even become bigger if you would add a --coffeescript compatibility flag to mammouth.

CezaryDanielNowak commented 8 years ago

@coderofsalvation

I personally used js->cofee just to limit my work with removing curly brackets and semicolons.

coderofsalvation commented 8 years ago

Hi CezaryDanielNowak. Thanx for stepping in.

Could you be so kind to elaborate below? Thx

It's unlikely to convert js code to coffeescript without breaking anything. Even js generated by coffeescript has some trouble.

Personally I've never heard/experienced trouble with js generated by coffeescript other than reference issues in angularjs (but that's got a workaround, and happens due to angular's [preprocessor] )(https://github.com/Plateful/plateful-mobile/wiki/AngularJS-CoffeeScript-Style-Guide#controllers ). Maybe you're talking about the early days of coffeescript?

pushing transpiled code (written in any language) is bad practice, it is not common practice for sure.

I have no idea what you're trying to explain here.

faitno commented 8 years ago

+1

coderofsalvation commented 8 years ago

bump

aolko commented 6 years ago

dead?

btwael commented 6 years ago

Hey everybody! Your comments and the download statistics in npm, made me rethink about the future of Mammouth, and I just released (after experience developing compilers in C/C++) that I can create something interesting whatever the future of PHP. So I decided to start coding a new version of mammouth that will support different version of PHP (so you can generate code compatible with whatever PHP version) and import and use already written PHP code with efficiency.

How that can affect this issue? An analyser (parser + ...) for PHP will be developed so we can import PHP, once this is done, I can easily create compile PHP to Mammouth.

You can contribute to Mammouth new version in this branch.

You can also support me financially doing so on Patreon.

aolko commented 6 years ago

Are you aware that there's PHP parser in php nowadays? (just checking)

btwael commented 6 years ago

Yes, I am aware PHP parser (written in PHP), but Mammouth is developed in Javascript, so it's better to develop our parser in javascript.

aolko commented 6 years ago

if you say so

btwael commented 6 years ago

I thought you were talking about this one, I will check this one so if it's well compatible with our design concept, we will depend on it, otherwise we will create our parser (the goal is to create a parser that support different PHP versions).

aolko commented 6 years ago

can you also do a gem? (for the people who can't into grunt/gulp/other burnt-out js build system)

btwael commented 6 years ago

Depend on how advanced the job we did, we may create a CLI tool that automates the compilation job.

aolko commented 6 years ago

Ideally a tool that can be used as file watcher (what's that?) would be nice