Sunday, 16 August 2020

[Question] I need some help in order to better understand how node works

Hello,​Nine months ago I started a project with a friend, which was meant to take only two months by our estimation when first started, but as time passed we decided that this project needed more time because we kept introducing new things and from an easy and funny it grew into a whole ecosystem with synced servers and node instances as right now. It grew to such point that it needed its own programming language(crazy right?).Since the beginning, this project was 100% based in NodeJS(and it is right now) with the future implementation of C/C++ addons. I know many of you might think that using only NodeJS might be foolish because of many reasons, starting from performance and security and ending with memory leaks and so on, but for us worked perfectly.When we first started with the design of this programming language (called Pulse(.pls)) we wanted a language to look and behave like Javascript, because it comes with a relatively easy to understand syntax. This whole development stage started a month ago, the designing part took about 3 weeks since we had to decide the reserved words, built-in functions, variable and constant declaration, loops, and logical operations. This week we got from the "FRONTEND" of the language to the backend and after 2 days of research, we got the list of things to do from lexing to parsing and so on. We ended up with some good results:​Code:study()​var data = input({title : 'Data Source',type : source,defval : close})​var lenght = input({title : 'Periodi',type : int,defval : 14,minval : 1})​const fema = 2const sema = 30​var mom = abs(change(data, lenght))var volatility = sum(abs(change(data)), length)​if(volatility != 0) {er = mom/volatility} else {er = 0}​Tokens:[{"lexame":"study","type":"identifier:prototype"},{"lexame":"(","type":"separator"},{"lexame":")","type":"separator"},{"lexame":"var","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"(","type":"separator"},{"lexame":"{","type":"separator"},{"lexame":":","type":"separator"},{"lexame":"'Data Source'","type":"literal:string"},{"lexame":",","type":"separator"},{"lexame":":","type":"separator"},{"lexame":",","type":"separator"},{"lexame":":","type":"separator"},{"lexame":"}","type":"separator"},{"lexame":")","type":"separator"},{"lexame":"var","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"(","type":"separator"},{"lexame":"{","type":"separator"},{"lexame":":","type":"separator"},{"lexame":"'Periodi'","type":"literal:string"},{"lexame":",","type":"separator"},{"lexame":":","type":"separator"},{"lexame":",","type":"separator"},{"lexame":":","type":"separator"},{"lexame":"14","type":"literal:int"},{"lexame":",","type":"separator"},{"lexame":":","type":"separator"},{"lexame":"1","type":"literal:int"},{"lexame":"}","type":"separator"},{"lexame":")","type":"separator"},{"lexame":"const","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"2","type":"literal:int"},{"lexame":"const","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"30","type":"literal:int"},{"lexame":"var","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"(","type":"separator"},{"lexame":"(","type":"separator"},{"lexame":",","type":"separator"},{"lexame":")","type":"separator"},{"lexame":")","type":"separator"},{"lexame":"var","type":"keyword"},{"lexame":"=","type":"operator:store"},{"lexame":"(","type":"separator"},{"lexame":"(","type":"separator"},{"lexame":"(","type":"separator"},{"lexame":")","type":"separator"},{"lexame":")","type":"separator"},{"lexame":",","type":"separator"},{"lexame":")","type":"separator"},{"lexame":"if","type":"keyword"},{"lexame":"(","type":"separator"},{"lexame":"!=","type":"operator:store"},{"lexame":"!=","type":"operator:logical"},{"lexame":"0","type":"literal:int"},{"lexame":")","type":"separator"},{"lexame":"{","type":"separator"},{"lexame":"=","type":"operator:store"},{"lexame":"/","type":"operator:arithmetic"},{"lexame":"}","type":"separator"},{"lexame":"else","type":"keyword"},{"lexame":"{","type":"separator"},{"lexame":"=","type":"operator:store"},{"lexame":"0","type":"literal:int"},{"lexame":"}","type":"separator"}]Now that I'm coding the parser, all its rules and targets to follow(BTW it a TOP-DOWN PARSER) I have all this questions in mind, becouse as some of you might know, when you run the first tests its better to use something simpler that the code above, such as a simple sum or easy mathematical expression.At this point I was wondering about:how the compiler will behave if you only introduce a string of text or a mathematical expression ?how does it returns it back if there is no keyword or method to return data in the input string ?will it store it, and if yes where it will go ?​**The main problem is that I don't know very well about how node as a processing environment (don't have any deep knowledge about its behavior and its core), how it works or behaves in such a situation because from my point of view is easier to deal with variables and function rather than this simple statements such as: "1 + 2", "hello world", are they stored when, how and why?Can someone give me some advice or help me better understand these concepts and how node works?​Thank you for your patience and time.

Submitted August 16, 2020 at 09:37PM by condrove10

No comments:

Post a Comment