Turing Machine or Finite State Machine? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

4th Nov 2021, 10:20 PM
Mehran
Mehran - avatar
9 Answers
+ 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.
4th Nov 2021, 10:36 PM
Mehran
Mehran - avatar
+ 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
5th Nov 2021, 3:06 AM
Mehran
Mehran - avatar
+ 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
4th Nov 2021, 11:16 PM
Mehran
Mehran - avatar
+ 2
Martin Taylor however i don't want to make another slow python. 😂 it's just a practice
5th Nov 2021, 1:32 AM
Mehran
Mehran - avatar
+ 2
zemiak thanks for your attention.
5th Nov 2021, 1:33 AM
Mehran
Mehran - avatar
+ 2
Martin Taylor great. i got it now. thanks.
5th Nov 2021, 2:46 AM
Mehran
Mehran - avatar
+ 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.
5th Nov 2021, 1:10 AM
Mehran
Mehran - avatar
+ 1
mehran do you know groovy? list of some others scripting: https://java-source.net/open-source/scripting-languages
5th Nov 2021, 1:23 AM
zemiak
+ 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!
5th Nov 2021, 8:39 PM
Vilhelm