~charles/cdaniels.net

8b143c8c4ecc3f2b61742a89e9a0b7f8d65edc9a — Charles Daniels 8 months ago 0209447
added tcl slides
2 files changed, 61 insertions(+), 0 deletions(-)

A src/assets/tclslides.md
A src/assets/tclslides.pdf
A src/assets/tclslides.md => src/assets/tclslides.md +61 -0
@@ 0,0 1,61 @@
# TCL, C, FFI, and You

*Charles Daniels*

*SuperComputing 2019, Denver CO*

# Links

**Slides:** `http://cdaniels.net/talks.html`

**Code:** `https://github.com/charlesdaniels/teaching-learning/`

**Real project:** `https://github.com/HeRCLab/nocsim`

# What is TCL

* Tool Command Language
* Interpreted, garbage-collected
* Origins in 1988
* Of tk/tkinter fame
* Imagine the best of shell & Python
* Easy to embed, and to embed things in
* FFI from C to Python via `tkinter`
* Everything is a string

# Who is using TCL
* Embedded systems
	* Lightweight, few dependencies
* EDA toolchains
	* Xilinx Vivado
	* Intel Quartus
	* Mentor Graphics ModelSim
* FlightAware

# Why TCL?

* Same skills script tools you already know
* Easy to integrate with existing C/C++ code
	* And others...
* Easy to embed in existing C/C++ applications
	* And others...
* Rich standard library
* Tk for GUIs!

# C $\leftrightarrow$ TCL FFI In a Nutshell

* Wrap standard C functions & `Tcl_CreateObjCommand()`
* Run TCL from C with `Tcl_Eval()`
* Link variables with `Tcl_LinkVar()`
* Read/write variables with `Tcl_GetVar()` / `Tcl_SetVar()`

# C $\leftrightarrow$ Pitfalls

* "Legacy" API uses strings for everything, lots of existing code / docs
	* New code should use "object" API
* Reference counting
	* Careful when re-using pointers
* Create a package, don't embed an interpreter
	* If you can

# Questions, Comments, Concerns, etc.

A src/assets/tclslides.pdf => src/assets/tclslides.pdf +0 -0