I often have a doubt how do online code compilers work. Well I know that at the server side they do something with docker containers but i don’t even have a basic idea on to how we can implement it in code. If anyone knows then please share it with if possible real code example. Thanks in advance.
I’m not sure what you are asking.
What i mean to say is that there are online code compilers like jsfiddle codechef ideone. I wanna make one myself.
Unfortunately, we do not know your background. So, recommending resources is difficult.
However, one of the easiest starting points for something like this is the Front End Libraries Projects - Build a Markdown Previewer | Learn | freeCodeCamp.org
If you have not completed the previous lessons before the challenge, it might be too difficult. So, in that case, I suggest starting there.
Hope this helps
Yeah i have already made the markdown project myself. I wanted to basically know how to implement code compilation with c++ python etc. languages ( if possible in docker containers,) . Regarding by background I am an intermediate fullstack vue developer and have a good idea about how most things work.
Ah, well then you are off to a good start.
I am currently busy with a project where user Rust input is compiled. In essence, all you need is a host machine to have the tooling required. For most cases this would be accomplished by setting up a VM with Docker on whichever host you use. It is not too complicated to set up an image with the necessary tools.
In general, the most difficult part is handling the input and output. Dealing with user code input is never a walk-in-the-park, and should be sanitized before execution.
Other than that, this gets complicated with the dev-ops involved in handling more than one user, which goes beyond what I have needed to deal with.
The way I am learning is by taking inspiration from the open-source tools like Rust-playground, and, if you can stomach the volume of code, VS Code. Have a peruse of the repos.
I mean it depends on if you are writing the parser/lexer/compiler or not. If you want to implement your own compiler then it’s hard.
If you just use some code editor (like Code Mirror or Monaco) with support for different languages and the output is just passed into some prewritten libraries, then it’s likely not all that hard (I haven’t played with it much).