Comment by iberator

7 days ago

best thing about TCL is easy syntax and that everything is a string :) Unique and simple and easy language with very slow changes.

Something like Python in good old days of 2.x before young internet javasceipt devs started pouring A LOT of new features to the language (feature creep).

Nowadays Python is so complex and flooded with ex C, C++, Java, JavaScript, Haskell programmers adding so many features, so fast that it's impossible to follow and understand them :(

Languages should not evolve on that rate. No time to master it :(

/rant

Tcl has stopped being everything a string with the release of Tcl 8.0 and bytecode engine.

> In earlier versions of Tcl, strings were used as a universal representation; in Tcl 8.0 strings are replaced with Tcl_Obj structures ("objects") that can hold both a string value and an internal form such as a binary integer or compiled bytecodes.

http://www.ira.inaf.it/Computing/manuals/tcl/man-8.0/Changes...

I remember this quite well, because as part of the core team tasked with writing native C extensions, the migration to Tcl 8 had quite an impact on our code.

I learned Python with version 1.6, and have a few O'Reilley books proving the point the language wasn't really that simple, those that never bothered reading the reference manuals end-to-end though it was.

  • There have always been attempts at caching non-string values in Tcl for performance gains, but the semantics are the same. The value’s types are whatever the operator requires and an error when not compatible. If, internally, $x is an integer, and you pass it to a string function, well, $x gets temporarily turned into a string. Dynamic with “weak” types.

There's certainly something to be said for stable, uncomplicated and minimalist tooling that wont evolve out from under you and leave you with something that won't just-work five years from now.

I guess that's why Tcl is so popular in the EDA arena. I can stick some custom JTAG tooling in a Cyclone II design and talk to it by Tcl-scripting the 15-year-old software - and be confident that the same code (both in the FPGA and on the host computer) would work with the latest software and a current device.

Having said that, Tcl's not entirely free of compatibility and fragmentation frustrations: I sometimes wish that OpenOCD used full-fat Tcl rather than JimTcl, just so that I could make use of Tk. Being able to plot a histogram of data collected from the FPGA or make clickable buttons to trigger events is very useful.

> best thing about TCL is easy syntax and that everything is a string :)

What? That's the worst thing about TCL.

  • I love it. Living proof that languages doesn't need forced types.

    Data is Data. It's kinda object programming as visioned in the 70".

    So easy and trivial language.

    • > Living proof that languages doesn't need forced types.

      The opposite surely? TCL is practically dead, and only lingers on in the EDA industry (which has zero taste). Virtually every successful language today has at least a few different basic types for numbers, arrays, strings, maps and so on.

      6 replies →

  • It's only the interface that is of a string. An array is a list of strings with space between, but only for the programmer. The runtime is free to use an actual array.

    • I'm aware. It's awful because of the implications for the programmer, not the runtime.

  • It depends on the use case. For instance you open a socket, write there any value you have without serialization, read it in the other side, data transfer done.

    • The convenience of not having to marshal data over a network is certainly a use case. But I'll admit that two of the worst programs I ever saw were written in Perl and TCL. Somehow just a big jumble of inscrutable regexes.

      When "everything is a string" then you have no choice but to literally treat everything as a string. Painful. Very cool project though.

      3 replies →

The worst thing about tcl is that it exists... and it's still the language of choice for EDA tools.

  • I'd be curious to know what your experiences with Tcl have been, to better understand why you feel this way.

    • It's a combination of cumbersome syntax and the vendor's poor API design and execution environment.

      For a syntax example, compare python to Tcl. In python, there's a compact array lookup operator, and dictionaries allow string keys:

        mydata["channel"][2]
      

      Tcl, however, requires a function call to access an array index, resulting in nested function calls with magic numbers for the simplest expressions:

        lindex [lindex $mydata 35] 2  # Tcl 
      

      Then there isn't any static type checking so you have to run code to see if it would work; the shape of a return may surprise you. Connecting to hardware may be your only opportunity to exercise certain code paths.

      So for any non trivial task, Tcl becomes effectively write-only.

      Some tools allow you to export Tcl scripts that automate tasks like project creation to help you avoid tracking intermediate objects in source control, but because the Tcl cwd path can change throughout a script, they export every source path as a hard coded absolute path, including whatever developer's home directory it might be residing in. This is not suitable for source control (because it would preclude building on any other machine) so then you have to post process these scripts before tracking them. But since it's Tcl there aren't good scriptable tools for programmatic Tcl AST manipulation, so you have to modify these files with some sort of a state machine, looking for various sentinels to trigger the various string replace behaviors you need. It's not all Tcl's fault, but if a vendor is only using Tcl for automation and you need automation, you have a battle ahead of you.

      Outside the language, you'll often find that your runtime tool locks the UI thread to run your scripts, so long running operations are impossible to pause or cancel. And I've never seen a vendor expose adequate objects to allow full control, so often, the critical actions you hoped to automate are only possible through the GUI.

      In the 90s, an integrated Tcl interpreter was a good sign that your vendor cared about developers. Today it's more a sign of neglect.

      2 replies →

    • My experience with Tcl is 30 years of using EDA tools, all of them equipped with this language from hell. Luckily, I've been to restrict the scripting part to the minimum. I'm sure that if you know the language well, you can see the foundational model that's behind it, but for occasional users, there's nothing predictable about it.

      I couldn't tell you exactly all the thing that are wrong with it. Let's just say that a language where this is ok:

      puts "Hello"

      But this is not:

      puts "Hello" # A comment

      shouldn't exist.

      1 reply →

  • Would you prefer dc-shell scripting?

    (I still remember the excitement of EDA tools _starting_ to support TCL and replacing the custom scripting engines they used to have)