Quick Guide for beginners

#1

Hi there,
I must to admit - I LIKE the idea of Mongoose OS - a big KISS(Keep It Super Simple).
As I sayed, only the idea is good. I don’t like the fact that the guide for C language and JS is minimal.
The main idea is awesome but after reading the quick start guide I feel like something is missing, something big is missing. There is a need to more details - not like in the references where is a bit less explanation. I really want to learn more to get more frome it but something is missing.
Help me to understand - I need pre-knowledge of C language and JS? Where I can get more of it?
There is not enough projects on web nor tutorials.
Would like to find more about the basic steps of definnig I/O, Events, RPC and more of the core’s functions.
Thank for the help.

#2

Could you elaborate more on that please?

What kind of documentation / tutorials you would like to see? Can you sketch out a list please?

#3

I’ll try to answer it clearly as much as i can, in my opinion. In my experience to achieve knowledge in programming an Arduino - which require a little bit knowledge in C and C++ and you can get it by following the examples brought to you in a book for starter, to build a Website - which require a basic knowledge of HTML, CSS, JS and even PHP and SQL which brought to you by an amazing website that get deep to details, the w3schools.com site. I got to Mongoose OS by mistake of curiosity (how can i call it in other words?) and fell in love in the idea that came to life with the mos tool and language.

I would like to see a tutorial that explain from scratch the basic steps I should do to program in JS language an I/O pin, a button, an example of basic program of “hello world” which will print out a messege by pushing a button, by changing a value of varriable resistor, by the change of value from LDR attached.
I guess I’m trying to say that the basic tutorils in youtube is too basic. explain more the copy this on this file, copy this on this file and etc. In Arduino it simple to understand that the setup() section is for what running once after boot and the loop() is for all the rest(set, call, print and more).
I think about this kind of list:
*Variables - how to set and use.
*Functions - what the procedure to make one
*Objects - how to define properly and how can I use it
*The difference between RPC and Events - which one to use when? how to use/set/create the handlers?
*The first steps to define RPC and example of call
*The first steps to define Event and example of call

Hope I’m helping in some way.
Sorry if my english is not good enough.

#4

Thank you, appreciated a detailed feedback.

I guess the most confusion comes from the fact that Mongoose OS is an event-based system. Very much like a JS script in a browser, or an old Windows WinAPI program. In this paradigm, a program only registers event handlers and gives control back to the system. System calls event handlers when events occur.

So, Arduino is basically this:

int main() {
  setup();
  for (;;) loop();
}

While Mongoose OS is this:

int main() {
  call_init_js();

  for (;;) {
    event = wait_for_event();
    trigger_user_handler_registered_in_init_js(event); 
  }
}

That’s why a basic Mongoose OS program is very different from the Arduino. For example, a button press handling just registers an event handler an exit - there are no loops:

load('api_gpio.js');

let pin = 5;
GPIO.set_button_handler(pin, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200,
function(x) {
  print('Button press, pin: ', x);
}, null);

Once that main difference is understood, you’ll get your feet on the ground.

See https://mongoose-os.com/docs/mongoose-os/userguide/intro.md , read “main event loop” section.

I hope that makes things clearer.