Hacker News new | ask | show | jobs
by toraobo 2433 days ago
> Python trying to be Bash, or Bash trying to be Python

The fact that "everything is a string" is cute and odd but the end result is really closer to shell scripting than a real object-oriented language like Python. You routinely have to deal with string/list quoting and constructing complex data structures is tricky if they have to be represented with just strings and hashes.

Sure: it's flexible and you can reimplement all the features of a high-level language but I'd rather use a language which has all the features already.

2 comments

Tcl has native support for lists and dicts, and provides full-featured functions for working with both. You're absolutely right that the feel is "more than Bash, less than Python." But it's not accurate to say that you need to do a bunch of weird string parsing in order to implement a high-level datatype.

And yes - the list quoting rules are weird! No doubt about that.

I tend to call it "bash bitten by a radioactive lisp"
I have an old engineering program that uses tcl as its scripting language... stuck on a version that predates dictionaries.

Without dictionaries complex data structures are quite difficult, and people will abuse the heck out of the language to create them. I was just looking at an example where some poor engineer was inventing a "data structure" by using string manipulation to create & modify variable names. Some of the variable names he derived were also defined as globals, so there was that too.

Prior to dictionaries, tcl only had arrays, which are the least string-like things in the language.

> And yes - the list quoting rules are weird! No doubt about that.

Lists might be "native" in the sense that the interpreter knows how to deal with them but in the data model there is no distinction between a "string" and a "list of strings". A list is just a space-separate string with quoting rules and the difference is entirely in manipulation.

It's easy to make quoting mistakes so a program might start breaking when arguments contains spaces: this almost never happens in languages other than shell.

> A list is just a space-separate string with quoting rules and the difference is entirely in manipulation.

This has not been true since the release of Tcl 8.0 that added the Tcl_Obj subsystem.

Lists in modern Tcl (8.0+, with 8.0 released in 1997) are proper O(1) indexed arrays. Yes, you can still request from Tcl the 'string' representation of the O(1) indexed array, and the result you get is the old (pre 8.0) "space-separate [sic] string with quoting rules" variant that will parse back into the O(1) indexed array later if you want.

But Tcl lists have not been /only/ those strings for a very long time.

Dicts are implemented using hash tables and thus slow on pass to procedure that modify them. I had to switch to Python and then C when I encountered quadratic runtime using dicts.

I hope they will use something like hash-array-mapped trees someday. It will make things much faster.

Thats not quite true since the early 2000s, when dictionary structures came around. Tcl also has strong built in object oriented support since 8.6 (2012) so if you like that sort of thing its there.

If you are dealing with quoting issues that's probably due to you using an older version like 8.3 or 8.4. Give a newer version a shot!