9 ms·
Tcl Ported to Go
- pipologist 4y agoYou should examples to the repo.
- stephen_g 4y agoTcl examples? I assume it's just a standard Tcl interpreter, so should run standard Tcl code. So you should be able to find examples anywhere online... e.g. https://www.tcl.tk/about/language.html https://www.tcl.tk/about/language.html
- JohnDeHope 4y agoI know TCL has an interesting story about how the syntax is basically all embedded strings, or something. Does anyone know if it has a recursive structure, as in lisp? Maybe it's more of an "everything is an X" structure, as in forth where everything is a "word".
- catach 4y agoI find this is a good explainer: https://wiki.tcl-lang.org/page/everything+is+a+string https://wiki.tcl-lang.org/page/everything+is+a+string
- tyingq 4y agoThe page on the lack of "null" kind of goes with that as well: https://wiki.tcl-lang.org/page/null https://wiki.tcl-lang.org/page/null
- tptacek 4y agoLots of people say Tcl is homoiconic. It can feel pretty lispy if you want to code that way, since evals and uplevels work a little like macros.
- RHSeeger 4y agoIn my mind, Tcl _is_ a lisp. Admittedly, it's pretty far out on the family tree branches, but the overall structure feels very lispy to me.
- onedognight 4y agoThe entire grammar is spelled out in the tcl(n) man page[0]. It’s amazingly concise and easy to learn from just this. To answer your question, it’s “as if” everything was a string, but the implementation is reasonably efficient and doesn’t convert all the time. [0] https://man.archlinux.org/man/Tcl.n.en https://man.archlinux.org/man/Tcl.n.en
- deleted 4y ago[deleted]
- wernsey 4y agoYes, in Tcl everything is basically a string, but has Lisp-like recursive structures: An expression like `{foo {bar baz}}` evaluates to the string "foo {bar baz}" at first, but then that might be split into two strings "foo" and "bar baz" by the interpreter. I recall Tcl being described as a Lisp without the parenthesis many years ago, which I still think is somewhat apt. Antirez' article "Tcl the Misunderstood" [0] is well worth a read if you want to know more. He also has an interpreter, Picol [1], in 500 lines of C code that is very easy to read and to understand. [0] http://antirez.com/articoli/tclmisunderstood.html http://antirez.com/articoli/tclmisunderstood.html [1] http://oldblog.antirez.com/post/picol.html http://oldblog.antirez.com/post/picol.html
- mftb 4y agoLooks like they are avoiding Tk altogether? Anybody know if that's the plan going forward?
- blondin 4y agohttps://gitlab.com/cznic/tk https://gitlab.com/cznic/tk
- mftb 4y agoAh cool, ty. Now I kinda wish I'd been aware of these projects sooner.
- donio 4y agoI was wondering how this was done entirely without CGO since hooking up the transpiled code to a native Go X client like xgb sounds really hard. Apparently it uses a transpiled version of libX11 and freetype. Which seems pretty crazy but I guess there is no reason it couldn't work once you have a robust translator.
- tr33house 4y agorefreshing to see a port to a language other than rust for a change. Not saying that rust isn't a good language, just good to see some diversity
- blondin 4y agoa little bit of variety here: https://wiki.tcl-lang.org/page/Tcl+implementations https://wiki.tcl-lang.org/page/Tcl+implementations. new, old, maintained, etc. some don't care about the "in $lang" branding.
- stjohnswarts 4y agowait til they transpile it to rust!
- benhoyt 4y agoIs "ported" the right term here? It know the repo's README says "CGo-free port", but this is the C version of TCL transpiled from C to Go (see the ~13MB .go files per platform in the "lib" directory). Which is a very cool idea, and the author has done the same thing with SQLite, to avoid CGo (https://gitlab.com/cznic/sqlite https://gitlab.com/cznic/sqlite). Here's a link to his C to Go translator: https://gitlab.com/cznic/ccgo https://gitlab.com/cznic/ccgo
- svnpenn 4y agowhoa you weren't joking, what the hell: https://gitlab.com/cznic/tcl/-/blob/master/lib/tcl_windows_amd64.go https://gitlab.com/cznic/tcl/-/blob/master/lib/tcl_windows_a...
- Grimburger 4y agoNothing says "easily maintainable" like a 298,000 line go file. Gitlab is struggling to render it for me.
- CodeSgt 4y agoCan't lose context if you never leave the file.
- omegalulw 4y agoCan't have context if the file never loads.
- MobiusHorizons 4y agoSounds like you need a better editor :) But seriously, I would expect most editors to handle large files relatively gracefully, even if they aren’t as fast as vim for example. Browser based code viewers on the other hand, I grant you, aren’t generally up to the task.
- 4y ago
- ccakes 4y agoWould love to find some kind of write up by CZNIC about why they're doing this. Tcl can still be found in a few places powering some pretty critical infrastructure, I know a few networks running with significant automation being driven with Tcl
- sensitivefrost 4y agoOpenBet use it quite a lot as well, so it powers a large number of the world's most popular gambling sites.
- barsonme 4y agoHe’s doing SQLite too, and SQLite uses TCL extensively in its tooling.
- keyle 4y agoMy first exposure to TCL was for writing IRC bots in the 90s. Thankfully that was my last exposure to TCL.
- hoosieree 4y ago
- loeg 4y agoEggdrop? Me too.
- VectorLock 4y agoTCL for many people begins and ends at Eggdrop. Thanks Robey.
- shric 4y agoYup, eggdrop[1] and expect[2] for me [1] https://www.eggheads.org/ https://www.eggheads.org/ [2] https://core.tcl-lang.org/expect/index https://core.tcl-lang.org/expect/index
- sandos 4y agoMe too. Or not bots but I did script some IRC client with it and it was a lot of fun.
- nrclark 4y agoThey were so preoccupied with whether they -could- that they didn't stop to think about whether they -should-. Pithy joke aside, TCL is an underloved language and I'm always happy to see it in projects. Nice work!
- KerrAvon 4y agoAll they need is to port Go to Python for a garbage language trifecta. Good god. (I am somewhat joking. Somewhat.)
- deleted 4y ago[deleted]
- jepler 4y agoNow will someone please implement Tk in Qt or maybe Electron...?
- svnpenn 4y ago> or maybe Electron...? I just physically shuddered. Tk with GDI was a work of art. Electron is... not that.
- stjohnswarts 4y agoJust imagine something as light and expressive as tcl put into an electron frankenstein gave me a good chuckle :D
- musicale 4y agoHaha, indeed - I also greatly prefer Tk to Qt or Electron. Some things I love about Tk: - adds a cool 1990s retro aesthetic - usable in X11 tunneled over an SSH connection - doesn't consume all available CPU and memory resources - the Tk canvas is a beautiful thing
- mhd 4y agoI always considered Electron and Qt/QML doing the inverse, just with more BCPL-ish languages.
- reillyse 4y agoOne of my first jobs was in Tcl and I still wake up with night sweats about it. Some languages were just meant to die. I have no idea why anyone would be interested in using it in 2022.
- adonovan 4y agoMy first job too! So true. Everyone knows how easy it is to make serious quoting mistakes in a Bourne shell script, but Tcl takes the risk to a whole new danger level. But any harm done by Tcl is more than redeemed by its creator being the author of one of my favorite of all programming books, A Philosophy of Software Design.
- RHSeeger 4y agoSome of my graduate level work was in Tcl, and my first job used a lot of Tcl. I have fond memories of the time, and Tcl is one of my favorite languages to this day. It's power and flexibility are fantastic.
- TillE 4y agoI had to use Tcl/Tk for some computational chemistry circa 2005. I'm sure it seemed amazing in the early 90s for quick GUI apps, but 10 years later it was just an absolute nightmare compared to powerful languages like Python.
- masklinn 4y agoTcl was definitely powerful, and didn't fall short of Python on that front. It's on most of the other fronts that it did.
- stjohnswarts 4y agoI wrote some small scripts in it for VHDL projects but I can't imagine writing any large project in it, that is very cringe.
- protomyth 4y agoTcl (expect) was joyous compared to my time with IBM JCL.
- metadat 4y agoDoes this mean it can run an eggdrop? Otherwise, in my eyes, it's not real Tcl.
- lanstin 4y agoCool, this is excellent. AOL embedded TCL interpreters attached to a listener on the network for all the services, so you could telnet in and see in memory what was going on and change config and what not. A tcl command is just a CS 1 program with argv and argc, so even pretty junior people could safely add commands. The framework was event based, no threads, so while the tcl was running nothing else was being done, so you could rearrange memory and it was cool as long as you finished before the end of the command. If would be pretty simple to add in a control port thing to Go. The advantage of TCL with its simple syntax is most commands are just cmd arg1 arg2 arg3 but if you have some general logic, you can express that as.
- xyzzy_plugh 4y agoThis is horrifying. Thanks for the nightmare fuel. > while the tcl was running nothing else was being done, so you could rearrange memory and it was cool as long as you finished before the end of the command My mind immediately springs to all the ways this can go horrifically wrong.
- hnov 4y agoThis is how most high performance networked software is written, it’s mostly fine, when you’re running on the event loop, nothing else is.
- dkfellows 4y agoTcl uses a memory model internally where each piece of memory belongs strictly to the thread that allocated it, with this enforced in lots of places. There are a few loopholes past it (for process-wide concepts such as the current working directory cache, or for inter-thread messaging) but by and large you write what appears to be single-threaded code. There's support for deep coroutines and non-blocking I/O so it isn't limiting. You only really need multiple threads when dealing with compute-heavy code or a particularly crufty API.
- RHSeeger 4y agoWhat server are you talking about? I distinctly remember naviserver/aolserver being multithreaded and being able to share information between threads using a specific set of nsv_* commands.
- vkaku 4y agoTranspiled should be treated separately from ported. This sort of code isn't readable, idiomatic nor maintainable. https://gitlab.com/cznic/tcl/-/blob/master/lib/capi_windows_amd64.go https://gitlab.com/cznic/tcl/-/blob/master/lib/capi_windows_...
- zasdffaa 4y agoISWYM but > This sort of code isn't readable, idiomatic nor maintainable isn't really fair. The original code is hopefully readable, idiomatic and maintainable, and if the transpiler does a correct job, who cares about the output any more than I care about the ugliness of the ASM in my object code when I compile it from source.
- AlecSchueler 4y agoIt seems fair to me. They only said that it should be seen as something separate than a port, not that it was bad. Honestly I think you're both right. Yes, it's true that it doesn't matter if you only want to get the code running in a Go environment for whatever reason. But anyone wanting to learn about TCL or idiomatic Go by reading the source code for this project will be disappointed, and that struck me as the main appeal of this when I saw the headline.
- randomdata 4y agoIf a program was classically built for x86 and was ported to ARM, the compiled output wouldn’t be any more readable. I’m not sure transpiled, which is just compiled by another name, is significant.
- masklinn 4y agoThe point of GP is to differentiate porting from compiling, whether you call that compiled or transpiled is immaterial, the goal is to differentiate between a codebase which is idiomatic, understandable, and maintainable, and one which is a compiler artefact. A port would imply and independent maintenance. Here you wouldn't maintain that codebase, instead you'd fix the upstream or the compiler, and recompile.
- 1B05H1N 4y agoWhy though? Glad I don't need to write iRules anymore tbh.
- fithisux 4y agoI would be more interested if it was ported to D. Also I think it needs a change of surface syntax to something Lisp-like.
- teleforce 4y agoPlease check this TCL inspired command language in D [1]. I also share the same sentiments [2]. [1] A command language on top of D: https://til-lang.github.io/til/ https://til-lang.github.io/til/ [2] Tcl-inspired command language on top of D: https://news.ycombinator.com/item?id=27167762 https://news.ycombinator.com/item?id=27167762
- fithisux 4y agoThank you very much
- jhoelzel 4y agoI was really disappointed when i opened the project. I believe its transpiled and also drastically missing documentation. "hey this can do everything tcl does, but we are not going to show you, you just will have to find out yourself"
- dis-sys 4y agoSo we know this is transpiled, wondering what is the usual approach to determine the quality of the transpliation output? Any systematic work into this aspect?
- acatton 4y agocznic (aka modernc.org) again… This person or this collective have been transpiling C projects into Pure Go projects, like sqlite[1], libx11[2], xcb[3], and much more[4]… They use their own homegrown transpiler from C99 to Go.[5] I can only have respect and admiration for whoever is behind this effort :) [1] https://modernc.org/sqlite https://modernc.org/sqlite [2] https://gitlab.com/cznic/x11 https://gitlab.com/cznic/x11 [3] https://modernc.org/xcb https://modernc.org/xcb [4] https://gitlab.com/users/cznic/projects https://gitlab.com/users/cznic/projects [5] https://gitlab.com/cznic/ccgo https://gitlab.com/cznic/ccgo
- shp0ngle 4y agocz.nic is a Czech domain registrar. (CZ NIC...) Even as a Czech, I have no idea if they are owned/governed by state, or not. I need to look into wiki for that. edit: oops it might be entirely unrelated. Sorry! edit2: my confusion is understandable, as cz.nic has some open-source projects, too! https://www.nic.cz/page/2049/projekty-pro-odbornou-verejnost/ https://www.nic.cz/page/2049/projekty-pro-odbornou-verejnost... For example open source routers Turris https://www.turris.com/en/ https://www.turris.com/en/
- acatton 4y agocznic or modernc.org is just a name clash, AFAICT. They have nothing to do with cz.nic.
- shp0ngle 4y agohe actually was employed by cz.nic according to some public record.
- jimsmart 4y agoBased upon info in an AUTHORS file [0] for a different project by the user cznic, I think there may indeed be some kind of connection with nic.cz ...? But I believe, based upon my membership on the GoNuts group / mailing list, that this is mostly the work of one individual, Jan Mercl (he is quite active in GoNuts) — as also stated in the previously mentioned AUTHORS file, and in the AUTHORS file for the port of Tcl that is the subject of the OP [1]. I have used some of his non-transpiled code/projects in my own Go projects in the past. He seems to be a very solid coder, often happy to share his views in GoNuts, and also frequently reviews others' code too. [0] https://github.com/cznic/golex/blob/master/AUTHORS https://github.com/cznic/golex/blob/master/AUTHORS [1] https://gitlab.com/cznic/tcl/-/blob/master/AUTHORS https://gitlab.com/cznic/tcl/-/blob/master/AUTHORS
- shp0ngle 4y agoI am not sure what is the point of this? (of course except for "because you can", which is a good reason to do things, sure) Why be cgo-less, when in the end, it is just transpiled, with unsafe.pointer everywhere? Do you gain some portability, that was not in the original C? Is there a speed gain, or ease to build gain? Maybe the end "consumers" have it simpler, because they don't need to worry about cgo, but then it's harder to compile in the first place.