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

feat: accept javascript programming language #546

Closed
wants to merge 7 commits into from

Conversation

kadeksuryam
Copy link
Contributor

@kadeksuryam kadeksuryam commented Oct 22, 2023

Resolve #439

For now, I choose to use Node.js version v18 as the Grader Runtime.

Local Testing:
image

Example submission file for the A+A problem:

"use strict";
 
process.stdin.resume();
process.stdin.setEncoding("utf-8");
 
let inputString = "";
let currentLine = 0;
 
process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
 
process.stdin.on("end", (_) => {
    inputString = inputString
        .trim()
        .split("\n")
        .map((string) => {
            return string.trim();
        });
 
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
function print(data) {
    console.log(data);
}
 
function main() {
    let n = Number(readline());

    print(n*2);
}

Copy link
Member

@fushar fushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Really appreciated it.

However, we currently are punting the initiatives of adding language support for "non-CP" languages (JS, TS, PHP). This is because for it to be effective, we need to support "function-style" submission. By this I mean contestants can just fill a skeleton and submit it:

function add(a, b) {
  return 0; // complete here
}

without actually reading the inputs from stdin, which is not really convenient and intuitive.

The current infrastructure still does not support this.

We may revisit this in the future, but I'll keep this PR open. 😄

@kadeksuryam kadeksuryam requested a review from fushar October 22, 2023 05:42
@kadeksuryam
Copy link
Contributor Author

kadeksuryam commented Oct 22, 2023

Thanks for the contribution! Really appreciated it.

However, we currently are punting the initiatives of adding language support for "non-CP" languages (JS, TS, PHP). This is because for it to be effective, we need to support "function-style" submission. By this I mean contestants can just fill a skeleton and submit it:

function add(a, b) {
  return 0; // complete here
}

without actually reading the inputs from stdin, which is not really convenient and intuitive.

The current infrastructure still does not support this.

We may revisit this in the future, but I'll keep this PR open. 😄

Hi @fushar , when you say 'keep this PR open,' do you mean to keep it open until the infrastructure supports functional-style submission or until I have resolved the previous comments?

Btw, platforms like Codeforces also support Node.js (https://codeforces.com/contest/1881/submission/229061225). Maybe keeps both functional-style and input-output submissions? This PR is for handling the input-output submission. Wdyt?

Copy link
Member

@fushar fushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fushar , when you say 'keep this PR open,' do you mean to keep it open until the infrastructure supports functional-style submission or until I have resolved the previous comments?

Until the infra supports.

Btw, platforms like Codeforces also support Node.js (https://codeforces.com/contest/1881/submission/229061225). Maybe keeps both functional-style and input-output submissions? This PR is for handling the input-output submission. Wdyt?

I'm sorry, but I'd delay it until the infra supports / there is use case. Reasons:

  1. JavaScript is not still popular for CP,
  2. we are increasing the Docker image size of the grader without justified reason.

🙏

@kadeksuryam
Copy link
Contributor Author

Okay, I will reopen this PR, but on a different branch. I accidentally used my master branch as the base branch, so I cannot contribute next time until this PR is merged.

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

Successfully merging this pull request may close these issues.

Accept Javascript programming language
2 participants