core icon indicating copy to clipboard operation
core copied to clipboard

Support multipe modules on run.dlang.io

Open JinShil opened this issue 7 years ago • 12 comments

This is a feature request to add support to run.dlang.io for editing/compiling multiple modules/files.

JinShil avatar Jan 29 '18 04:01 JinShil

Thanks a lot for the request, Mike!

However, I'm inclined to close it as a WONTFIX. Here are my thoughts

  • it's would be a lot of work to change the frontend and backend to do so

  • it would be hard to support this in the frontend without adding visual baggage

  • run.dlang.io doesn't try to be an IDE, just a convenient way to play with D code

  • there aren't that many advantages I see of having multiple files - except for (1) testing and showing how module imports work, (2) using advanced D features like string imports, (3) find/test import bugs in DMD and (4) if your file is so large that it needs to be split up into multiple modules for better visibility

  • (1) there are a few examples on the D specification where this would be nice, but apart from that I have never found the need

  • (2) instead of `import("myFile.txt") the text can be inlined. D supports delimited strings.

  • (3): there's active WIP to fix the import bugs

  • (4): it's the active won't fix category

  • there are existing, sophisticated web IDEs

  • for "bigger" things I personally prefer to have my vim ...

Please see my NG thread about the D boilerplate template. It can be used as a template for the awesome WebIDE Cloud9 - simply use https://github.com/wilzbach/d-bootstrap as a template (or clone it in an existing workspace), hit make and your D code runs automagically. Imho we will never be as good as Cloud9 which has an entire development team and can utilize the AWS infrastructure directly.

What is your use case?

wilzbach avatar Jan 29 '18 11:01 wilzbach

My use case is for sharing code and ideas with others. So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately. Or to illustrate concepts such as visibility from one module to another. This can be useful for demonstrating features and bugs on the forum or in Bugzilla. I also think there are a use cases in the documentation where it would be useful to teach concepts.

Perhaps I could make use of Cloud9 for such things; I've never tried.

I will say that this is a luxury and not a necessity. It's your call. No hard feelings if you choose not to implement it, I promise.

JinShil avatar Jan 29 '18 12:01 JinShil

Well, I agree that's "generally useful", but not many click & run platforms I know of/have used, support this:

  • http://jsbin.com
  • https://play.golang.org/
  • play.rust-lang.org
  • https://jsfiddle.net/ ...

Actually https://godbolt.org is the online platform that supports this that comes to my mind and it's windowing framework looks rather complicated.

Perhaps I could make use of Cloud9 for such things; I've never tried.

If you use the micro instances, the first year is for free. Though I think you need to explicitly add people to the workspace

So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately.

That's actually a good use case - think ... we could "hack" that in though. We already support import from GH's gist, so in theory something similar to DUB single file format could work, e.g.

# add object.d from https://gist.github.com/anonymous/451a0fb778381b11ed80078d5e0b6653
void main() {

}

Well that would be a simple start and it's left optional whether the frontend actually needs to support multiple files.

Well if you or someone else want to take a go at this, it would require the following adjustments:

  1. Allow to pass multiple files to the Docker container https://github.com/dlang-tour/core-exec (maybe simply as additional arguments). Currently STDIN can be passed as $2, but an environment variable like DOCKER_COLOR or DOCKER_FLAGS would work too.
  2. Modify the ExecProviders to accept multiple sources: https://github.com/dlang-tour/core/blob/master/source/exec/iexecprovider.d
  3. Modify the invocation of the docker image to pass on the additional files https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L133
  4. Modify the REST API to accept multiple files: https://github.com/dlang-tour/core/blob/master/source/rest/apiv1.d

As mentioned I don't need this, so I won't work on this in the foreseeable future, but I'm happy to merge PRs.

wilzbach avatar Jan 29 '18 12:01 wilzbach

Initial HAR support is now live: https://run.dlang.io/is/ZHm2Xe

It's still experimental and most of the buttons don't work, but it should be enough to judge whether it's useful in this form.

And also we can start integrating it into the DTour + dlang.org where these buttons don't exist anyways.

wilzbach avatar Feb 20 '18 18:02 wilzbach

Tried a minimal runtime test with this: https://run.dlang.io/is/rrhgJL

[email protected](105): Option -o- currently not supported by rdmd

I'm not sure what that means.

JinShil avatar Feb 21 '18 01:02 JinShil

I'm not sure what that means.

I initially tried to use rdmd for multiple files because -run is terribly broken (see e.g. https://github.com/dlang/dmd/pull/7927), but well it turns out rdmd isn't a good choice for this either.

Anyhow I just pushed a fix and it should be deployed in a few minutes:

https://github.com/dlang-tour/core-exec/pull/36

wilzbach avatar Feb 21 '18 02:02 wilzbach

It works now: https://run.dlang.io/is/UwoLSC

wilzbach avatar Feb 21 '18 04:02 wilzbach

So cool!. Thanks. I'm OK to close this issue if you consider it solved.

JinShil avatar Feb 21 '18 04:02 JinShil

Ah wait!. This gave me a strange error: https://run.dlang.io/is/gHkwbJ

/sandbox/object.d(1): Error: found `EOF` when expecting `}` following compound statement

JinShil avatar Feb 21 '18 04:02 JinShil

Hmm it goes away if I remove the comment: https://run.dlang.io/is/7k0KLk

wilzbach avatar Feb 21 '18 04:02 wilzbach

For reference, this was a bug in har. An updated version of har has been deployed: https://run.dlang.io/is/KBOVEb

wilzbach avatar Feb 21 '18 04:02 wilzbach

the main function doesn't seem to be found when using HAR right now.

However if you add -i -run app.d to the dmd arguments, you can work around this issue

WebFreak001 avatar May 07 '20 11:05 WebFreak001