DEV Community

Cover image for Shims in Web Development
Matthew Waddell
Matthew Waddell

Posted on

Shims in Web Development

Introduction

In programming, a shim acts as a bridge between your code and an underlying system, allowing you to use features that might not be natively supported.

Web Shims

There was a time when certain JavaScript methods such as Array.prototype.includes were not readily supported in browsers even though production apps made use of it. To work around this issue, developers began to create scripts that patched in the implementations. The polyfill (shim) acted as a layer between the code and the browser's native functionality. The polyfill provided a dynamic way to detect and address missing features, creating a consistent experience across browsers.

Polyfill Shim

Runtime Shims

As a rubyist, you will need to manage multiple ruby runtime versions on your development machine. You can install each binary manually or you can use a runtime version manager asdf. Asdf allows you to install and switch between different ruby interpreter versions easily. asdf installs the executables using plugins while also creating shims inside ~/.asdf/shims. Running the ruby executable results in running the shim instead. The version of the executable asdf uses is defined in ~/.tool-versions.

Summary

Shims are a handy technique in everyday programming that smooth out compatibility issues between your code and the environment it runs in.

Top comments (0)