In the compiler, what does "implementer" mean?

Viewed 33

I'm trying to figure out the relationship between libsass and node-sass

The official page of libsass reads:

  1. LibSass is a C++ port of the original Ruby Sass CSS compiler with a C API.

  2. LibSass is just a library. To run the code locally (i.e. to compile your stylesheets), you need an implementer, or "wrapper"

I don't know much about the compiler What is a implementer? I wonder how node-sass is compiled

1 Answers

Tl;dr - it wraps something else, like a library or API to make it easier to use (or make it accessible to the current programming language).

Long answer:

It's pretty simple. A wrapper is a library that... well... wraps some other thing, typically to make it easier. Let's take Python... it's a pretty good example, and it has some common examples of this. Let's take an API, for example. Let's imagine I have a JSON API that gets weather data for my current locaition. I give my zip code to it, and I get this response:

{
    "currentTemperature": 70,
    "temperatureUnit": "F",
    "hourlyForcast": [68, 71]
}

Nothing to complicated, right? But... I'd like to use it in Python. I could parse the JSON and manually extract each value. That could work. But I'll use a wrapper:

from weather import get_weather
zip_code = int(input("Enter your zip code"))
weather = get_weather(zip_code)
print(weather.current_temperature)

Basically, a wrapper wraps something else, like another (lower-level) library, or, in my example, an API. But it can also make it more convenient to use. For example, the API might return fahrenheit. A wrapper might take that, and have code to automatically convert it to whatever unit the user wants.

There's many other possibilities. It could:

  • Enable you to do very fast complex math in Node.js by having the wrapper use a highly-optimized C library internally
  • Have a neat and clean interface to an API. Also, imagine tomorrow the API changes. If you have a wrapper, update the wrapper for the change. Otherwise, you have to go manually search through your code to update it... be a shame if you forgot somewhere.
  • Allow you to do fast GPU operations in Python, with a fast CUDA-based backend for the wrapper
Related