+ 3
Turing Machine or Finite State Machine?
Which machine is better for implementing a simple scripting language? (not very simple . not like command line programs. Something near to js but can intract with jvm via Reflection API) Can finite state machine be useful? How about Turing machine?
14 Respuestas
+ 3
Martin Taylor really thanks.
first one i am using java 7.
secondly i want to do it for practice and fun.
i know it already have been implemented for java 7 by developers, but my target is practice and experimenting new things
Martin , I knew you were answering that question. ROFL
thanks.
+ 3
https://stackoverflow.com/questions/10287700/difference-between-jvms-lookupswitch-and-tableswitch
i found this discussion intersting.
explains difference between tableswitch and lookupswitch very well.
for Sololearn's community
+ 2
Martin Taylor
so i have to improve my skills and study about mentioned domains.
I just have implemented a assembly-like language working with a (call) stack of references and some bytecodes which are like java bytecodes (with some new to interact with Reflection api) .
it was 10 times slower than java in runtime. ROFL.
i even have provided some directives like #define and labels for program counter.
then the program became confusing.
Martin ,how does jvm run switch statement(for enums(int)) .? is it binary search?
or binary tree search?
i only saw tableswitch bytecode in disassembled code
+ 2
Martin Taylor however i don't want to make another slow python. 😂
it's just a practice
+ 2
zemiak thanks for your attention.
+ 2
Martin Taylor great.
i got it now.
thanks.
+ 1
I meant:
switch (c){
case 0:
something
break;
case 1:
something
break;
case 2:
something
break;
case 3:
dosomething();
}
If A is 3, how many comparisons will be made to bring the control to function(dosomething)?
if it's binary search just 2 comparison will be made
if it's linear search . 4 comparisons will be made.
+ 1
mehran do you know groovy?
list of some others scripting:
https://java-source.net/open-source/scripting-languages
+ 1
If you want to learn the theory behind interpreters, I highly recommend this blog https://ruslanspivak.com/lsbasi-part1/
It really blew my mind!
He teaches how to make interpreter from the very start. Tokens, Lexer, Parser, Nodes, AST, Visitor pattern, and much more. He used python, but Its pretty easy to apply the same technics and structures in another languages aswell. Remember it’s not a weekend project. It will take time, but you will gain some useful insight on how stuff works behind the scenes!