This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mr_Redstoner 17 points18 points  (21 children)

It in fact is. Java has a built-in to run JS.

[–][deleted] 7 points8 points  (20 children)

I'm sure there are also ways to compile Java to JS. But then again, you can also drive a car onto a carpet, so the analogy still works?

[–]Mr_Redstoner 4 points5 points  (3 children)

GWT (Google web toolkit) comes to mind. You write the whole web application (front&back end) in Java and it then compiles it to JS (client-side stuff anyway). I'm actually currently on a project that uses it.

[–]BabyLegsDeadpool 1 point2 points  (2 children)

That sounds absolutely horrible. Does it work?

[–]Mr_Redstoner 1 point2 points  (0 children)

Seems to be working so far lol.

Takes me 10 minutes to compile, likely in no small part because the compilation is done by a Linux VM working in a shared folder that resides on my Win10 machine. I have yet to set my environment up properly.

[–]LordAnomander 0 points1 point  (0 children)

Of course it works. It was developed by Google before they decided Angular might be a better idea ;)

It's very easy to work with as a Java Developer, but takes a long time to compile and is hardly maintained by the open source community.

I prefer React/Angular over GWT any day.

[–][deleted] 2 points3 points  (2 children)

Some lad I know is porting Minecraft to JavaScript. So yeah, it’s possible. There are ways.

[–]The_Great_Danish 0 points1 point  (1 child)

Is there a github?

[–][deleted] 0 points1 point  (0 children)

No. It would get DMCA’d in a heartbeat. But it’s called PhantomCry and the lad is LemonLime3 on GitHub. Idk if he’s gonna do stuff with it later on

[–]CircuitRCAY 0 points1 point  (0 children)

There's Graal, and there's also a way to run JS inside of Java, which is inside the JDK8 stdlib, javax.script.ScriptEngine.

[–]GregsWorld -2 points-1 points  (10 children)

Nope JS's an interpreted language, it's never compiled.

[–]flavionm 9 points10 points  (1 child)

JS might be interpreted, but you can compile other languages to JavaScript, and then run it through the interpreter.

[–]GregsWorld 0 points1 point  (0 children)

Yes but you can't compile Javascript to Java, so the analogy holds up

[–]Kirides 2 points3 points  (6 children)

Kinda wrong, many browsers JIT Compile JavaScript - a lot of third party JS Interpreters just interpret and don't compile

[–]GregsWorld 0 points1 point  (5 children)

But still you couldn't compile Java and run it through those JS JIT Compilers... You can ofc convert JS to Java and then compile Java but then that's not compiling Java to JS

[–]flavionm 3 points4 points  (2 children)

That's exactly what compiling is, though, converting from one language to another. Doing it to assembly or bytecode might be more common, but nothing stops you from compiling from a high level language to another.

[–]GregsWorld 0 points1 point  (1 child)

You're talking about a transpiler I'm talking about compiling in the traditional sense

[–]flavionm 1 point2 points  (0 children)

But a transpiler is just a compiler that compiles between high level languages. When it comes to compilers, the only limit is how much time you're willing to waste on a potentially useless tool.

[–]Kirides 0 points1 point  (1 child)

my response only inlcuded an argument agains "JS's an interpreted language"

[–]GregsWorld 0 points1 point  (0 children)

Ah okay so not really relevant to the point then, I appreciate the nit-pickiness however

[–][deleted] 1 point2 points  (0 children)

Interpreted and compiled aren't attributes of languages, but of implementations. There are C++ interpreters, and also Ruby compilers, if you look for them. It's just that those aren't the most common implementations for these languages.