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

Why not wrap the C lib? #9

Closed
ptomasroos opened this issue Sep 21, 2015 · 9 comments
Closed

Why not wrap the C lib? #9

ptomasroos opened this issue Sep 21, 2015 · 9 comments

Comments

@ptomasroos
Copy link

Whats the purpose of not wrapping the c lib facebook provides?

@chris-ramon
Copy link
Member

Hi @ptomasroos,

Could you link me to the c lib that facebook provides?

@ptomasroos
Copy link
Author

Hey @chris-ramon

This is the library I meant.

https://github.com/graphql/libgraphqlparser

@chris-ramon
Copy link
Member

Thanks @ptomasroos !

Definitely we could had figure-out how and depend on the c parser lib and ofc gain all the advantages that brings it.

I think having no dependencies it allow us to move faster, have light-weight lib, and do not have to deal with c-to-go, go-to-c trips.

And we have already a working parser passing all the tests from graphql-js.

@ptomasroos
Copy link
Author

I think the sad part is that you will loose all the benefits facebook will make to that c library which will receive updates from nodejs, ruby, python and all of the other languages who are doing wrappers around it, plus its a enormous waste of time for you. Not trying to bash on you, its more that:

The moment you loose focus on this the entire community looses because now the entire community stands with a maintainability of something that might accelerate very fast on the source. I've seen this happen to a lot of projects when it comes to specially golang. Where ppl try to port wire formats and do it a "pure-way". CGO is seriously good and one of the biggest benefits i see with golang tbh. The ability to reuse.

What kind of features would ever be needed thats not supported out of the spec? And why wouldnt that be possible to be added on higher level?

There is nothing more reliable and lightweight than a c lib which does memory mgmt in the correct way. I can proove that the lib/pq is 4.000m after the wrapped c library which hasnt been updated for 6 years because there is no errors, no correct fault handling ect.

Its def up to you. But rewriting something will almost never ever make something better if its constrained by the source project anyhow. Just my cents. Not trying to sound like a douche.

CGO is no real problem to day.

@ileitch
Copy link

ileitch commented Sep 21, 2015

@ptomasroos you realize that lib is only a parser, right? Parsers don't change much.

@ptomasroos
Copy link
Author

@ileitch Yes. "only" 6-8K ? lines of code covered with tests. I see that as a big value.

@sogko
Copy link
Member

sogko commented Sep 22, 2015

@ptomasroos brought up some valid points on the benefits of wrapping the c-lib parser.

Right now the implementation of the parser is based on graphql-js parser but it is basically a black-box. The implementation details of the parser can be changed easily (e.g replace it with cgo impementation).

Give it a query string, get an ast struct in return. Simple as that.

I helped @chris-ramon to quickly complete his work on the parser, but I was more interested in writing tests to ensure that it meets the spec, at least in comparison to graphql-js.
Optimizing the parser for memory management and performance could come later, in my mind.

I think right now this project has more parts to it than just the parser i.e, the validator, executor etc, (For me personally, to get a working Relay-compliant server in golang eventually.)

I think if anyone could contribute a PR replacing the parser with a CGO version, that would be awesome. 👍🏻 The tests are already there, so it'll be relatively easy to verify the implementation.

Cheers guys!

@ptomasroos
Copy link
Author

I'm def looking forward to a good implementation in golang, no questions asked! I just hope that someone can get there in a reasonable amount of time before loosing its urge :)

Good luck, guys. Will check back.

@sogko
Copy link
Member

sogko commented Sep 23, 2015

A related update to keep this discussion productive:

Someone just released a golang wrapper for libgraphqlparser
https://github.com/tecbot/c-graphqlparser

Seems legit.

Cheers!

lenaten pushed a commit to lenaten/graphql-go that referenced this issue Nov 2, 2015
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

4 participants