News for hackers. Stuff that matters.
Re:I can't believe I'm praising Tcl (2008) by jasomill on Saturday September 05, 2020 @08:55PM (#24388060)
While I like Tcl, which I have used to write substantial portions of a shipping product, the author does make a good point about the difficulty of creating a language that is simultaneously a good programming language and a good scripting language: I love IPython dearly, but I've never seriously considered using it as a bash replacement (nor bash as a substitute for anything but the simplest Python scripts).

As an aside, I have to praise one particular, easily overlooked aspect of Tcl: its comm facility is, from a (non-Tcl) client implementation perspective, the easiest "foreign function interface"[1] I've ever worked with by far, due almost entirely to the simplicity and consistency of Tcl syntax.

[1] Technically, comm was designed as a remote execution facility, but it works just as well locally to run Tcl code from within a non-Tcl program without the hassle of embedding an interpreter.

Re:I can't believe I'm praising Tcl (2008) by kevin_thibedeau on Saturday September 05, 2020 @09:17PM (#24388189)
Tcl is an aw some configuration language. Delete all the commands to make it non-Turing complete. Throw in infix assignment for ergonomics and you have a minimal configuration language that can be enhanced by adding back more commands as needed.
Re:I can't believe I'm praising Tcl (2008) by unixhero on Sunday September 06, 2020 @04:12AM (#24389851)
I think I get this. Would you have any code examples laying around?
Re:I can't believe I'm praising Tcl (2008) by sirn on Sunday September 06, 2020 @08:36AM (#24390928)
MacPorts' Portfile[1], maybe? Portfile is being evaluated entirely within interp[2] with only few functions exposed inside the environment

[1]: https://github.com/macports/macports-ports/blob/master/lang/...

[2]: https://www.tcl.tk/man/tcl8.4/TclCmd/interp.htm

Re:I can't believe I'm praising Tcl (2008) by unixhero on Monday September 07, 2020 @03:46AM (#24397455)
Very decent, that file from the Macports repo looks very clean and sane. Thank you.
Re:I can't believe I'm praising Tcl (2008) by gglitch on Sunday September 06, 2020 @08:45AM (#24390970)
Re:I can't believe I'm praising Tcl (2008) by hobby-coder-guy on Monday September 14, 2020 @11:00PM (#24477500)
Aw some?
Re:I can't believe I'm praising Tcl (2008) by gurjeet on Sunday September 06, 2020 @11:51AM (#24392172)
> difficulty of creating a language that is simultaneously a good programming language and a good scripting language

I bridged that gap recently with GoLang. Below [1] is an example of how I now use GoLang instead of Bash for my scripting needs. The development cycle is essentially just 2 steps, like scripting, 1) Edit file(s) 2) Run the script (./my.go).

This gives the same feeling of writing scripts, but with all the guarantees of GoLang and benefits of an IDE (VSCode). The trick is to have the first line of the file be a script (for the process loader to execute) as well as a comment (so that GoLang infrastructure ignores that line.

[1]: https://gist.github.com/gurjeet/3121b2e373e61873c5a6e96d72b6... (Gist version at the time of submission: v3)

Re:I can't believe I'm praising Tcl (2008) by IggleSniggle on Monday September 07, 2020 @08:38AM (#24399010)
That is one interesting shebang. Nicely done. Can you explain the error handling stuff?
Re:I can't believe I'm praising Tcl (2008) by gurjeet on Friday September 11, 2020 @02:17AM (#24439695)
There are functions in log.go that emit message to stdout (thinking about it, I need to send warnings and above to stderr).

The function err(), in addition to sending a message to stdout, also causes an exit of the process. But it does so only if ExitOnError is turned on; which is on by default, and can be turned off by setting environment variable EXIT_ON_ERROR=true.

I have converted that Gist into a standalone Git repo, and hope to update it to add more improvements (like the stderr change, above) to showcase how to leverage GoLang for scripting.

[1]: https://git.sr.ht/~gurjeet/GoLang_Scripting_Example