4 ms·
I thought java was tokenized, not compiled. That's why you need their runtime environment isn't it?
by bastloing 2y ago
I thought java was tokenized, not compiled. That's why you need their runtime environment isn't it?
- wbl 2y agoJava is compiled down to bytecode and there is a bunch that happens in the compiler to make things fast ahead of the JIT.
- noelwelsh 2y agoIt is compiled to Java byte code. The JVM runs the byte code. Tokenization [1] is the process of splitting text into components called tokens. It's usually the first stage of parsing. [1]: https://en.wikipedia.org/wiki/Lexical_analysis#Tokenization https://en.wikipedia.org/wiki/Lexical_analysis#Tokenization
- bastloing 2y agoCompiled means it's a direct executable in machine code. Java ain't that. Heck, if it needs a runtime with a garbage collector built into the runtime it's especially junk.
- noelwelsh 2y agoNo, that is not what compiled means. A compiler is simply a program that translates from one language to another. Hence a compiled language is one that is translated into a different language prior to execution. Java is compiled twice; once to byte code and again to machine code by the JIT compiler. That is unless you compile it directly to machine code using, say, Graal Native Image. You are welcome to your opinion on the utility of garbage collection but the widespread usage of GC suggests the industry as a whole does not share your view nor is such an unnaunced view supported by research (e.g. https://dl.acm.org/doi/abs/10.1145/1094811.1094836 https://dl.acm.org/doi/abs/10.1145/1094811.1094836)
- bastloing 2y agoAs having a masters in computer science I respectfully disagree with you. Would you consider a program that translates C code to FORTRAN a compiler? Nope, it's a translator. A compiler compiles a language into a direct executable. Just like Microsoft Windows has executables, .exe file, there's no runtime required to run those files.
- dtech 2y agoYou should use your CS master skills to read the first line of the "Compiler" article in Wikipedia [1] > In computing, a compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language). And maybe also the second line. JVM bytecode is an object code as referenced there. [1] https://en.wikipedia.org/wiki/Compiler https://en.wikipedia.org/wiki/Compiler
- orf 2y agoNobody calls them “translators”, that’s so silly. It’s a compiler, or transpiler (still a compiler). Avoid using appeals to authority when discussing, it doesn’t make you look good. Even more-so when your authority is relatively mundane and you’re totally incorrect.
- aeonik 2y agoI would call this a transpiler, and it's definitely a kind of compiler. I typically use the word compiler to imply that I'm moving to a lower level representation, and a transpiler as one that does a horizonal translation. There are expections to this general rule of thumb, Cross-compiling is a term used for a horizonal translation. I also watched this video of a PhD project that compiles JavaScript from an input of Visual data and JavaScript. Which is probably one of the more interesting uses of compiler I've seen. https://youtu.be/MQnVmEw6ISQ?si=NYCSuzi3IxG0md_k https://youtu.be/MQnVmEw6ISQ?si=NYCSuzi3IxG0md_k
- shepherdjerred 2y agoWhy would holding a MS make you an authoritative source on… anything? Anyway, there’s no real agreement on the terms and everyone has an opinion. This is as useful as arguing “is a taco a sandwich”
- peeters 2y agojavac does produce machine code. You just don't like the machine.
- SteveSmith16384 2y agoI think it means "compile it into bytecode", which can then be run by the Runtime.
- papichulo2023 2y agoSo like most JIT languages nowadays?
- bastloing 2y agoThat's pretty much the definition of tokenized. I know Oracle would like us to think different, but facts are facts
- deleted 2y ago[deleted]
- peeters 2y agoSince you seem passionate about precise definitions for technical terms, maybe you could point us to third-party definitions which match your understanding? Start with sources for what "compilation" and "tokenization" mean as you understand them?
- orf 2y ago> That's pretty much the definition of tokenized Oh boy. It’s rare to see such confidence mixed with such nonsense.
- peterfirefly 2y agoYou are thinking of the typical design of a BASIC system in the 80's. Keywords were stored as "tokens" (numbers) but expressions were usually stored as space-stripped strings. There would be an edit-time syntax check (combined with the tokenization) to check if the expressions were syntactical and only in places where they were allowed). Some designs did use tokens for the expressions too. There was almost no syntax involved and essentially zero compilation work. Java compilers do a lot more than that. They actually compile to a real (abstract) machine and they do real compiler things (proper parsing, maintenance of namespaces, type checks). They usually don't do any optimization because that will happen at run-time anyway -- but that doesn't make them "not compilers".
- deleted 2y ago[deleted]
- happymellon 2y agoWe used to have Java CPUs https://en.m.wikipedia.org/wiki/Java_processor https://en.m.wikipedia.org/wiki/Java_processor The JVM is just to run the code on other systems, and is the most common way of running compiled Java code.