Scripting for the .NET CLR


This post documents the pros and cons of some of the popular scripting options for the .NET Common Language Runtime (CLR).

CS-Script

  • Scripts are ECMA-compliant C#
  • Script is precompiled before execution, execution is as fast as compiled C#
  • Runs on .NET CLR and Mono
  • Provides capability to compile a script to DLL or executable
  • Can be embedded in a .NET application to provided scripting capability

CsharpRepl

  • Built on top of the Mono.CSharp library
  • C# syntax
  • Scripts are interpreted, not as fast as compiled code
  • Readily available on most Linux distributions (mono-complete package on Debian based distributions)

IronPython

  • Scripts are written in Python (2.7)
  • Useful if you already know Python
  • Can be embedded in a .NET application to provided scripting capability
  • As per established benchmarks, it performs better than CPython [aosabook.org]

Other language options

Emulating Bluetooth LE Peripheral on Mac OS X Mavericks


This post documents some interesting Mac OS X Bluetooth LE peripheral examples I have found.

Arbitrary Bluetooth Peripheral

Clone example from https://github.com/sandeepmistry/osx-ble-peripheral.

An issue is that it duplicates peripheral services after Bluetooth is turned off/on. Calling removeAllServices of CBPeripheralManager, fixes that.

You can also use IOBluetoothDevice API to iterate through connected Central devices. We found situations when after starting the peripheral app, the central app running on an iPhone would not establish Bluetooth LE communication. We were able to use IOBluetoothDevice to force disconnect all connected devices at app start on the Mac, to skirt the issue.

Advertising an iBeacon

Clone example from https://github.com/mttrb/BeaconOSX. Appears on the LightBlue app, but need to actually use it as an iBeacon. Check author’s blog at http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/ for further details. On a side note, you can create an iBeacon using a Raspberry Pi and an off-the-shelf USB dongle.