Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Tcl/Tk Spline Editor (tcl-lang.org)
128 points by blacksqr on Jan 2, 2022 | hide | past | favorite | 18 comments


Hah, that's really nice! I've been working on an editor for setting up Box2D scenes for the last month or so. I know there are a bunch of them out there already, but it seemed like a fun project. No Tcl/Tk for me though. I'm writing it as a web app, but in C++ with wasm/webgl and using NanoVG[1] for drawing.

I saw a comment here about undo/redo and I think it's a must have feature for something like this. I implemented something based on the command pattern first, but ended up disliking the amount of code needed just for undo. I eventually tore all that out and built my state model on the excellent immer[2] library.

[1] https://github.com/inniyah/nanovg

[2] https://github.com/arximboldi/immer


This is the latest book on Tcl (does not cover Tk) by one of the active members of Tcl community.

The Tcl Programming Language: A Comprehensive Guide:

https://www.magicsplat.com/ttpl/index.html


Excuse me for this kind of question, I'm genuinely curious and don't mean to ignite a flame war.

Is TCL worth studying and using when you can just use Tkinter with Python?


As worth studying as any language is. I think Tcl is really neat and would like to use it more at work, but most software comes with Python API's now, so there is an advantage to popularity. Also, Python has the scientific libraries I need without needing to drop down to C with Tcl. Your mileage may vary. I've used a bit of Tcl for some simple things, but Windows isn't exactly a first class citizen and I don't like how the various distributions of Tcl seem a bit less trustworthy than just downloading a Python distribution from the python or anaconda (scientific distribution) websites.

After reading Ashok Nadkarni's book though, I decided I felt the Tcl design was more coherent to me in a lot of ways. The way it sticks so heavily to commands is very consistent, but languages like Python (or something like APL that goes to the absolute extremes) use special syntax to make certain things easier to recall (think of how Tcl uses "lindex" for accessing arrays and Python has dedicated "array[4]" syntax. Neither is better than the other, just different.

Tcl to me is a lot like a Lisp built off of strings rather than lists. Many on HN will point to how this is inferior, but the overall language and ecosystem has been a lot easier for me to pickup.

Edit: I have nearly a decade of regular Python usage under my built for things like process automation and a little scientific computing, but have only read a book on Tcl, read blog posts, and coded a little bit every now and then.


Most of the modern CAD tools for electronics IC design support Tcl and most of the computer networking companies e.g. Cisco has Tcl built-in inside their devices.

SQlite author is an avid Tcl user and he even introduced a small, secure and modern CGI based web application called wapp:

https://wapp.tcl.tk/home


This is largely a subjective thing, but IMO because of its shellscript-style syntax Tk "feels" better when used with Tcl than Python when it comes to writing quick-and-dirty GUI apps.


You can easily make an executable from a tcl script using Freewrap.

Even with Tk, the overhead is just 8MB.

So distributing a Windows executable with GUI is quite practical. You don't require your user to have anything else installed.


Not sure my info is still up to date, but last time I checked, not all the features of Tk could be accessed through Tkinter. To take advantage of Tk's full power, you have to use Tcl.


I bought this back in ~2019. A very good book, kind of like the old cookbooks, but with more background.


How does that book compare to the third edition of Ousterhout's _Tcl and the Tk Toolkit_? (other than that Ousterhout also covers Tk, obviously)


Having known Tcl/Tk only from the common Python tools, I didn't know that Tk could be used to make GUIs that are any good. I feel a bit silly now, this looks neat.


Having been recently converted into a Tcl user, studying this code will definitely help me improve my skill in the language! Thanks for the link


why converting to Tcl? Job related? The joy of learning?


Tcl vaues do not have null and they are immutable - value assigned to a variable cannot change unless variable gets reassigned. Lists are immutable, for one example, even if they can be shared.

These two properties make Tcl much more suitable for programming than most other contemporary scripting languages.

I regularly use Tcl for various peeaonL scripting tasks OR EXPERIMENTS and rarely use Python or bash. The reasons are stated above.


Thanks!


Looks neat though i think it needs some undo/redo functionality. Also zoom should affect stroke width too. And middle-button-drag should be used for scrolling too as it is a very common gesture.


Just a friendly note to 'blacksqr: Feel free to add some more context here. What is it that you found fascinating about this editor?


I'm assuming because the full source is in Tcl and that isn't common for these kinds of tools. Tcl is pretty cool.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: