xshanow
V2EX  ›  问与答

在线运行代码怎么实现的?

  •  1
     
  •   xshanow · Apr 19, 2018 · 9139 views
    This topic created in 3124 days ago, the information mentioned may be changed or developed.

    如图: 各位大神,有知道这个怎么实现的吗?

    这样:

    https://tool.lu/mine

    15 replies  •  2018-04-28 17:57:42 +08:00
    crazybug
    crazybug
    Apr 19, 2018
    1
    提交的代码在服务器端执行完在返回到浏览器!
    Luckyray
    Luckyray
    Apr 19, 2018
    2
    应该是 1 楼的办法吧,总不能全用 js 写一套解释器,那也太复杂了。
    input2output
    input2output
    Apr 19, 2018
    3
    在云端 sandbox 里运行的;
    hxndg
    hxndg
    Apr 19, 2018
    5
    @input2output
    哈哈哈,不过一般都是在沙盒做的,基本不可能
    tommyZZM
    tommyZZM
    Apr 19, 2018
    6
    服务端运行,然后把 stdin/stdout/stderr 接到前端输入或者显示吧
    kevindu
    kevindu
    Apr 19, 2018
    7
    wshcdr
    wshcdr
    Apr 19, 2018
    8
    比较感兴趣,MARK 一记
    LeungJZ
    LeungJZ
    Apr 19, 2018
    9
    感兴趣,mark 一下。
    holyghost
    holyghost
    Apr 19, 2018❤️2
    10
    实际上就是一个 sandbox,刚好我之前用 namespace 和 cgroup 实现了一个: https://github.com/justice-oj/sandbox

    demo 的地址是: https://www.justice.plus
    honist
    honist
    Apr 19, 2018
    11
    star 了楼上 有空研究一下
    chinvo
    chinvo
    Apr 19, 2018
    12
    和 OJ 的原理一样,后端沙盒运行,捕获输入输出
    dobelee
    dobelee
    Apr 19, 2018 via Android
    13
    后端的虚拟机编译执行一下就 ok 了。
    kaneg
    kaneg
    Apr 19, 2018 via iPhone
    14
    云端跑个 docker 就可以
    xshanow
    xshanow
    OP
    Apr 28, 2018
    15
    没想到这么多人收藏了 。
    我主要研究的是 java,c#,c++的,总结以下吧
    [成功]Java 代码中运行 java 代码,使用 Java-Runtime-Compiler 这个库,好使。https://github.com/OpenHFT/Java-Runtime-Compiler
    [成功]C#环境中有 CSharpCodeProvider\CPPCodeProvider..支持 C#和 VB,不知道啥原因 C++的不支持。
    [未知]linux 下,C++可以使用 libdcompile,https://github.com/Fadis/libdcompile,没测试。

    以上。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   809 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 19:05 · PVG 03:05 · LAX 11:05 · JFK 14:05
    ♥ Do have faith in what you're doing.