hosting a c compiler on gae

147 views
Skip to first unread message

Mahendra Naik

unread,
Jul 31, 2011, 6:45:37 AM7/31/11
to Google App Engine
Hi,

I am writing a coding website. I want to provide an option to the
users to compile their c,c++ or java code. Basically I want to host a
compiler in my app. Some google links said that it is not possible to
host an external program on gae. Is there any alternative? Like
connecting to a Linode or linking to amazon ec2 ?? Any pointers would
be great.

Thanks and Regards,
Mahendra Naik

Greg

unread,
Aug 1, 2011, 9:54:57 PM8/1/11
to Google App Engine
You could have another server provide a compile service, and have your
Appengine app communicate with it via URLfetch, as you suggest. There
will be inefficiencies here obviously, and you'll have to contend with
the URLfetch size and time limits.

You could also look for pure python compilers, which could run on
Appengine.

Cheers
Greg.

Robert Kluin

unread,
Aug 1, 2011, 11:28:09 PM8/1/11
to google-a...@googlegroups.com
Or compilers implemented in Java. Might be more likely to find those.

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

Mahendra Naik

unread,
Sep 28, 2011, 12:56:34 PM9/28/11
to Google App Engine
Hi,
It looks like I have to move away from app engine if I want to host
a compiler. I did a thorough search and seems no way I can host a
compiler on gae efficiently.
Sad that I will have to rebuild the website again from scratch to the
specifications of another infrastructure. Last hope.. Any alternatives
possible?? Even remote possibilities . Does google provide any
instances??

App engine should provide more features to developers to make
itself as a serious platform for web development.

Thanks and Regards,
Mahendra Naik

On Aug 2, 8:28 am, Robert Kluin <robert.kl...@gmail.com> wrote:
> Or compilers implemented in Java.  Might be more likely to find those.
>
>
>
>
>
>
>
> On Mon, Aug 1, 2011 at 21:54, Greg <g.fawc...@gmail.com> wrote:
> > You could have another server provide a compile service, and have your
> > Appengine app communicate with it via URLfetch, as you suggest. There
> > will be inefficiencies here obviously, and you'll have to contend with
> > the URLfetch size and time limits.
>
> > You could also look for pure python compilers, which could run on
> > Appengine.
>
> > Cheers
> > Greg.
>
> > On Jul 31, 10:45 pm, madmax <mahendra0...@gmail.com> wrote:
> >> Hi,
>
> >>    I am writing a coding website. I want to provide an option to the
> >> users to compile their c,c++ or java code. Basically I want to host a
> >>compilerin my app. Some google links said that it is not possible to

Jeff Schnitzer

unread,
Sep 28, 2011, 2:27:07 PM9/28/11
to google-a...@googlegroups.com
"Host a compiler" is too vague. Even "Host a C compiler" is too vague.

What do you want to compile? What do you want it to compile to? For
what platform?

If you're creating a compile farm, you really want an environment that
can run gcc natively. That will never be GAE for a million very good
reasons. That said, compilation consumes significant cpu and io
resources and is probably not something you ever want to do on a web
frontend unless you want to risk a painful user experience. Farm it
out to Linode or EC2 or whatnot.

I doubt you're going to find a C cross-compiler implemented in Python
or any of the JVM-based languages. If you really wanted to get crazy
you could try to cross-compile gcc to java bytecode, which should
work, but you'll have to abstract out the i/o libraries to work
without filesystems. A sufficiently dedicated (read: insane) engineer
could probably pull this off with enough effort, but why...

Jeff

Ikai Lan (Google)

unread,
Sep 28, 2011, 4:28:51 PM9/28/11
to google-a...@googlegroups.com
I agree with your statement about features, but it does not apply to your use case of hosting a compiler.  

The way you'd probably design this? Use App Engine for the web portion. Save the code to the blobstore, push the job to the task queue pull queue (http://code.google.com/appengine/docs/java/taskqueue/overview-pull.html), then have a compiler running in a Linux instance that pulls this information, downloads and compiles the code, pushes compiled code back to blobstore for serving. Of course, the compiled code isn't guaranteed to run on other platforms, you have to worry about linking libraries, etc ... but those are app specific issues and not necessarily related to App Engine.

--
Ikai Lan 
Developer Programs Engineer, Google App Engine



On Wed, Sep 28, 2011 at 9:56 AM, madmax <mahend...@gmail.com> wrote:

Kaan Soral

unread,
Sep 29, 2011, 8:17:48 AM9/29/11
to Google App Engine
I have worked on this topic before

and let me tell you your requests are childish

what where you thinking while you were writing your coding website on
gae?

other than these, you can easily create a compiling and running
service, which will work asynchronously and notify gae when the
process is finished. you can build it on Amazon for example.

and again, let me tell you, all the coding websites out there works
like this.

so improve yourself a bit, don't expect everything from gae

Mahendra Naik

unread,
Sep 29, 2011, 11:58:18 AM9/29/11
to Google App Engine
@Jeff Schnitzer : My app provide programming tests to users. Users can
code the solutions in c or c++. I am planning to provide a feature
where the users can compile their code and test for correctness.
Obviously they wont be running the code. Have tried many ways to
implement this feature. The obvious solution would be to have a Linode
or EC2 backend and let the compilation be done there. But it would be
more efficient to have something supported on gae. Now i kno there is
no way to do it than source the code to EC2 or Linode.

@Ikai Lan : Thanks for the suggestion and will try the solution .

@Kaan Soral: I know how the coding websites work and have written one
myself. And I don't want to write something which already exists.
Don't you call me childish, I know what I am doing and I assume you
understand that requirements for an app come out of nowhere when you
run a customer centric application. If you are not clear with what I
have written please ask me to clarify , I would be happy to do that.
If you don't have patience for that or don't feel like doing it, well
its ur choice. But don't call me childish.

Jeff Schnitzer

unread,
Sep 29, 2011, 2:55:41 PM9/29/11
to google-a...@googlegroups.com
On Thu, Sep 29, 2011 at 8:58 AM, madmax <mahend...@gmail.com> wrote:
> @Jeff Schnitzer : My app provide programming tests to users. Users can
> code the solutions in c or c++. I am planning to provide a feature
> where the users can compile their code and test for correctness.
> Obviously they wont be running the code. Have tried many ways to
> implement this feature. The obvious solution would be to have a Linode
> or EC2 backend and let the compilation be done there. But it would be
> more efficient to have something supported on gae. Now i kno there is
> no way to do it than  source the code to EC2 or Linode.

If all you want is a compiler frontend (parser, typechecker), you
might be able to get away with porting it to something you can run in
a GAE app. That this code is almost 100% algorithmic and you should
be able to compile it something else, either java (to run on GAE) or
javascript (to run in the browser itself).

I would seriously consider going the javascript route and doing it all
in the browser. Compared to running DOOM in the browser (see
http://www.readwriteweb.com/hack/2011/05/doom-ported-to-javascript-and.php),
running a compiler frontend should be easy. Looks like they used this
tool:

https://github.com/kripken/emscripten/wiki

This actually looks easier (and more fun) than setting up a compile
farm somewhere, plus it would give you a slick user experience. You
could even blog about it and probably get the story picked up by
hacker news.

Jeff

Ronoaldo José de Lana Pereira

unread,
Sep 30, 2011, 8:30:12 AM9/30/11
to google-a...@googlegroups.com
+1 for Jeff's suggestion. Take a look here and you may probably cross-port some of the C compiler to run in the browser: http://repl.it/.

Ikai Lan (Google)

unread,
Sep 30, 2011, 2:25:10 PM9/30/11
to google-a...@googlegroups.com
Holy moly, Jeff that sounds like an amazing project!

--
Ikai Lan 
Developer Programs Engineer, Google App Engine



Gerald Tan

unread,
Oct 1, 2011, 12:50:55 PM10/1/11
to google-a...@googlegroups.com
I have used Janino which does runtime compilation of Java code into java classes that can be loaded into the running VM. If you are willing to work with Java, this is an option you can try.


Reply all
Reply to author
Forward
0 new messages