46 points · by blacksqr · 5y ago · 40 comments
>>> import tkinter as tk
>>> tk.Tcl().eval('puts {hello, world}')
hello, world
'' >>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directoryIndeed, most linux distro packaging teams decided to split tk in a separate package that is not installed by default. Same for pip and setuptools. Of course, this made getting a congruent python experience extra hard, on a platform with already plenty of gotchas for python setup, but hey, they saved a few Mo.
$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more
information.
>>> import tkinter
>>> tkinter.Tcl().eval('puts {hello, world}')
hello, world
''
>>>
Ubuntu 18.04; but it's not on a machine running 20.04For example, here is a really naive example of implementing a DSL that allows you to write something like
SELECT name age FROM person INTO name age
and have the values of the selected columns be placed in variables specified after the INTO keyword.Implementing that isn't too difficult:
# a pretend database
set language(name) Tcl
set language(created) 1988
set language(created_by) "John Ousterhout"
set language(stable_release) 8.6.11
proc SELECT {args} {
### Lowercase all the args to make things easy
set args [string tolower $args]
set from_index [lsearch $args from]
set cols [lrange $args 0 [incr from_index -1]]
set table [lindex $args [expr $from_index + 2]]
# Get access to the global variable with the value contained in $table
global $table
set into_index [lsearch $args into]
set vars [lrange $args [incr into_index] end]
foreach c $cols v $vars {
upvar $v local_var
set val [lindex [array get $table $c] 1]
set local_var $val
}
}
After that, you could "SELECT created name created_by FROM language INTO x y z" and then puts "$y was created by $z in $x"
>Tcl was created by John Ousterhout in 1988I learned to hate TCL with a passion.
That said, in EDA in general it works well for the most part.
Python was effectively completely stable through all this and gained a critical mass following.
I don’t know what you mean “shot itself in the foot“ here. Some examples?
> Python was effectively completely stable through all this and gained a critical mass following.
I don’t know how much more “effectively stable” Python was than Tcl. Can you expand on this?
I personally see this largely as “luck of the draw”. It seems to me there’s a lot to complain about with Python - the low-fruit classic is the GIL. Despite that huge impediment, it came to be a scientific computing go-to language. Who would have guessed that? We can see things now and say “popular languages are popular”, and that’s about it.
Not luck of the draw, it was because of the OOP craze in the late 1990s and early 2000s. In undergraduate school I took some introductory programming classes for an easy A, as I was already working as a web developer (like many in my generational cohort) for living expenses. (My degree program was entirely unrelated.) In one of those classes I just ended up as something of a [very poor] TA for the professor. At some point he told me that his department was looking to reorganize their curriculum to emphasize OOP and asked what I thought about Java and Python. I had never programmed in either, mostly working with Perl, JavaScript, PHP and ColdFusion. But I told him that Python was becoming popular in the open source space, and the simplicity of the language, including dynamic typing, and freely available tooling would likely make it more accessible.
I don't know if he took my advice, but in any event as I remember things Python eventually overtook Perl partly, if not largely, by riding the OOP wave. People like to say that it was because Python was simpler and more consistent (TOOWTDI instead of TMTOWTDI), but it was really only simpler and more consistent in the context of OOP programming. For quick, top-to-bottom procedural programming tasks Perl has always been simpler, IMO.
Python, on the other hand, felt like it was at version 1.5.2 absolutely forever.
> It seems to me there’s a lot to complain about with Python - the low-fruit classic is the GIL.
Except that, in the late-1990s/early-2000s, it didn't matter. Scripting languages were slow relative to compiled languages. Multiple-threads effectively didn't exist. Hyperthreading didn't hit until 2003--after the DotBomb.
> Despite that huge impediment, it came to be a scientific computing go-to language. Who would have guessed that?
Gee, who could have guessed that a whole lot of scientists and engineers kinda liked Matlab the program but hated Mathworks the company and that providing somewhere for them to jump ship to would be popular? Like ... absolutely everybody?
Of course, just the idea isn't enough. The alternative has to be sufficiently capable.
Thus ... Enthought. Enthought personnel put in a lot of elbow grease and work to make Python a scientific computing go-to language.
As always, the best way to predict the future is to make it.
I'm currently fiddling with TkCAD [3] in order to put a small CNC machine to use here, it needs some small adaptations to work on Linux, but I think it's a nice find!