More complete answer is "it depends". It depends on what you're trying to accomplish; if it involves multiple transactions, lots of calls into different Repository services, performance critical, or needing to be run as the system user, etc. then you'd use Java. Otherwise feel free to use JavaScript if the APIs suit your task.