Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any work on php for shoco? #5

Open
hwongcom opened this issue Sep 25, 2014 · 3 comments
Open

Any work on php for shoco? #5

hwongcom opened this issue Sep 25, 2014 · 3 comments

Comments

@hwongcom
Copy link

Any work on php for shoco?

@Ed-von-Schleck
Copy link
Owner

Sorry for the delay – been busy.

To answer that: Not really :( I haven't done php for years, and can't remember having done wrapping C code for php, so there's little inclination for me personally to start that. Plus, the concept of shoco kinda implies you include it in your project “as is”, since it requires your compression model to be compiled, so a generic wrapping for other languages may not make much sense.

However, if you know your model, you can train shoco, compile it and create a php extension with it. It'd be purely project-specific, but again, that's the point of shoco. I doubt that it's a lot of work; if you do it, I'd be glad to hear about it!

@hwongcom
Copy link
Author

hwongcom commented Oct 9, 2014

can u give me an idea where to start on writing a pure php implementation of shoco? i would like to help u add it into ur repo.

@Ed-von-Schleck
Copy link
Owner

I'm not sure a pure-php implememtation would make much sense for this project – aside from the algorithm implementation, one would have to re-create the model-generation which creates C-code, and all of this is really tailored for a static, compiled language.

I see two approaches: Try to understand the algorithm by reading the code and the docs, and write your implementation from scratch in php. This would be a different project (phoco, maybe?), and would probably also be orders of magnitudes slower, but that might not be an issue at all.

Second version: Generate a model suitable for your project, then write a php extension.

What's important to realize is: It's not sufficient for both ends of the compression/decompression chain to use shoco – they need to use shoco with the same model. Model usage happens at the compile stage. Shoco is designed for C projects, where the "train model & compile shoco with new model" task is written down somewhere in your Makefiles.

You need to have a clear idea what your use case is: Do you want a generic php version of shoco (which isn't really possible with the current design decisions), or do you have a specific use case (say: a web server) with specific training data (e.g. the html you generate) – in that case I'd say: Go for the second solution outlined above. The result would not be a php wrapper for shoco, but a php wrapper for shoco + a specific model. This could be part of shoco (I'd accept a pull request for out-of-the-box generation of php extensions), but bear in mind that this still requires re-compilation if the model changes, so you'll need least one project specific compile step anyway.

The takeaway is: Be sure about your use case, and how generic it is supposed to be. I'll gladly help you with any issues you encounter, though my php-foo is very limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant