NetLogo 6.2.2 User Manual: Extension Authoring Introduction

# Extension Authoring Introduction

NetLogo 6.2.2 User Manual

NetLogo supports extensions as a way of adding functionality that it does not already provide. Here are a few common reasons you might want to make an extension:

- There can be hardware you want NetLogo to talk to that it doesn’t already support. Examples of this include the Sound extension and the Arduino extension.
- There can other programming languages that provide functionality you want to use from inside NetLogo code, such as R’s statistical calculations or Python’s machine learning libraries. Examples here are the R extension and the Python extension.
- There can be data structures or algorithms that are hard to support with NetLogo, like matrix manipulation or key/value stores for program data. The Matrix extension and the Table extension are examples that solve these problems.
- You may want to expose NetLogo internal data that’s not otherwise available, or in a different way than the built-in primitives do. Examples here are the Profiler extension, the Reflection extension, and the ExportThe extension.
- You may want to make functionality that works identically between NetLogo desktop and NetLogo Web. For example, the `file-*` prims built in to NetLogo work great for desktop, but they cannot be reproduced in NetLogo Web due to the differences in how web browsers interact with files. So the Fetch extension and the SendTo extension were created to operate identically in both environments.

NetLogo desktop extensions can be easily written in any programming language that targets the Java Virtual Machine (JVM). This includes Java, Scala, and Kotlin, among others.

Here is a very brief outline of the process to get your project setup and producing an extension you can run with NetLogo (see below for technical details):

- Get a dependency on the NetLogo jar file and make sure its on available to your build tool and your IDE (such as IntelliJ) if you’re using one.
- Create an extension manifest file to include in your extension’s jar file.
- Make sure your extension’s packaged jar file name matches the in-code name you’ll be using (so `table` will have a `table.jar`).
- Make sure any dependencies for your extension (libraries besides NetLogo) are included alongside your jar also.
- Create a `ClassManager` for your extension, and create `Primitive` classes for each extension primitive you’re making.

NetLogo and many of its bundled extensions are written in Scala and so use the Scala build tool (SBT). We’ve created a NetLogo extension plugin for SBT that handles many of the above steps automatically, once it’s configured through the `build.sbt` file.

## Technical Details

For more technical information on creating your own extensions, including tutorials and samples, please see this page on the NetLogo repository wiki. It also includes ways to get help or to discuss NetLogo extension development.

## Sharing Extensions with the Extension Manager

To share an extension you’ve made with the built-in Extension Manager, you’ll need to have it added to our NetLogo-Libraries repository. See the instructions on the repository website for more information.