4 ms·
Or you can just use GWT which saves you from having to use javascript at all, and lets you write java (along with all its IDEs, type checking, code structure, a
by aliakhtar 12y ago
Or you can just use GWT which saves you from having to use javascript at all, and lets you write java (along with all its IDEs, type checking, code structure, and other benefits) which is compiled to highly efficient javascript: http://www.gwtproject.org/learnmore-sdk.html http://www.gwtproject.org/learnmore-sdk.html
- krapp 12y ago"Java" which "compiles" to javascript is not Java. It's javascript with a ludicrous amount of syntactic sugar applied.
- aliakhtar 12y agoAll the language features of java: generics, inheritance, type safety, interfaces, and soon to come: lambdas and other Java 8 features, are all supported. Plus your code is organized in java packages. So, I'm not sure you've ever tried GWT. Things like multi threading which aren't possible in javascript aren't supported, but a lot of the JRE which is used in most code, does come out of the box. Its a huge improvement over regular javascript, anyway. And client + server code can be shared.
- krapp 12y agoThose are features of the IDE, and of Java, certainly. But type safety doesn't really exist in javascript. Structures like interfaces and classes don't really exist. Inheritance is different. Scope is different. What you have is a javascript framework which emulates the behavior of Java to the degree that javascript permits, but can't really implement it. I'm not saying it isn't a useful tool, or that the javascript it generates isn't far, far superior to anything I could roll on my own - but... >Things like multi threading which aren't possible in javascript aren't supported ...it isn't Java.
- aliakhtar 12y ago>type safety doesn't really exist in javascript. Structures like interfaces and classes don't really exist. Inheritance is different. Scope is different. You are not coding in javascript. You are coding in java, and the code is then converted into highly efficient javascript by a compiler. > What you have is a javascript framework which emulates the behavior of Java to the degree that javascript permits, but can't really implement it. Absolutely not. You are actually coding in java, and its then compiled to javascript. Have you ever used GWT?
- krapp 12y agoI don't think you're seeing my point. You may be coding java, but none of the tangible benefits of java over javascript actually translate, because you're actually writing javascript, with all of the warts and limitations and weirdness therein. The javascript exported will not be truly type safe, because javascript is not, and cannot be. It may appear to act like it, within the context of the code when run as predicted, but this isn't the same thing as an actual strict language in a runtime which expects and enforces those rules. Highly efficient? Doubtless. Optimized to avoid as many pitfalls of the language as possible? Certainly. But anything more capable than bog-standard javascript? No. Because it can't be.
- eklavya 12y agoHmm, so assembly code doesn't have any type safety or high level features. So when I code in a higher level language I shouldn't be able to actually program in it because assembly doesn't support it, all I am doing is writing in a assembly framework and can't really do more than what it permits, right? What a load of crap and the op is down voted!!! You are writing java and barring some features like multi-threading, you CAN write anything you want. How to translate that to JS is the compiler's job, you need not care. Edit: what would you say to this - http://www.scala-js.org http://www.scala-js.org ?
- krapp 12y ago>So when I code in a higher level language I shouldn't be able to actually program in it because assembly doesn't support it, all I am doing is writing in a assembly framework and can't really do more than what it permits, right? Javascript is not the equivalent of assembly. Javascript is, itself, a higher-level language. You're talking about translating from one high-level language to another, and expecting the interpreter for the latter to care anything about the rules of the former. >What a load of crap and the op is down voted!!! The entire thread is downvoted. It's annoying but it doesn't prove anything.
- dragonwriter 12y ago> But type safety doesn't really exist in javascript. Structures like interfaces and classes don't really exist. You know where else none of that exists? In the machine code on which the JVM rests and to which Java code can be JIT compiled by the JVM before execution. So, if you can't have it compiling to JS, you never could have it on the JVM, either.
- krapp 12y agoIt's not the same thing at all. Javascript isn't machine code, and it isn't bytecode. It's its own completely separate high-level language, that executes in an unsafe, unpredictable and highly mutable environment.
- aliakhtar 12y agoYou should tell that to google adwords, inbox, and AWS console, then. All of them are developed with GWT, and haven't functioned in any unsafe, unpredictable, or highly mutable way.
- RobertKerans 12y agoComing soon, JavaScript lambdas! What a novelty!