liveBook · Manning

JavaScript runtime

As explained in Modern C, Third Edition

A runtime environment is the software and system context that provides resources and services while a program executes.

A runtime environment is the software and system context that supplies resources and services while a program executes. In C, main connects the application to the runtime system and follows standard entry-point rules. section 7.2

The C library supplies portable interfaces for common runtime services. An API can separate compiler implementations from library implementations, allowing combinations such as gcc or clang with different C libraries. section 8.0

Runtime-facing services include:

  • Program startup and termination: main returns EXIT_SUCCESS or EXIT_FAILURE, while exit terminates execution without returning to its caller. section 7.2
  • Environment access: programs read name-value pairs such as HOME, PATH, LANG, and LC_ALL through environment functions. section 8.7
  • Locale control: programs inspect or change language, numeric, time, and character-handling settings with setlocale. section 8.7

A portable program boundary

Use one of the two standard forms: int main(void); or int main(int argc, char* argv[argc+1]);. Reaching the end of main is equivalent to returning EXIT_SUCCESS. section 7.2

void printenv(char const name[static 1]) {
  if (getenv(name)) {
    char value[256] = { };
    if (getenv_s(nullptr, value, sizeof value, name)) {
      fprintf(stderr,
              "%s: value is longer than %zu\n",
              name, sizeof value);
    } else {
      printf("%s=%s\n", name, value);
    }
  } else {
    fprintf(stderr, "%s not in environment\n", name);
  }
}

This listing demonstrates checking for an environment variable, copying it into a bounded buffer, and reporting an oversized value. section 8.7

How Modern C, Third Edition covers it

How deep it goes
Explains entry points, status propagation, environment access, and locale categories, but does not describe JavaScript engine internals.
Examples
Uses main prototypes, EXIT_SUCCESS, exit, getenv_s, bounded buffers, environment variables, and setlocale categories.
What it assumes
Assumes familiarity with C library functions and formatted output while defining environment variables, locales, and runtime boundaries.
What you can do after
Operate runtime-facing C interfaces to return status, terminate programs, read environment values, and configure locale behavior.
How it connects
Connects runtime behavior with the C standard, C library, application programming interfaces, environment variables, locale, and program termination.

Also explained in

Compare how 4 books explain JavaScript runtime →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.