What do you use L for?

HI all,

I am busy working on a small IDE for an extended version of Tcl (essentially Tcl 8.6 with some syntax sugar including infix support, some support for some scientific workflow DSLs) and starting to look at adding L support. While this is being built to meet my own needs - I would like it to be helpful to other folks.

The way I have been experimenting with L so far is I tend to prototype in Tcl and then write a more typed strict production code version in L. Rather than treat them as distinct languages - i am using L as the basis of a structured typed version of my Tcl DSL with the intent of eventually having the compiler do some additional checking and byte code generation. This gives me the benefit of rapidly prototyping in our Tcl dialect and makes the Tcl code more accessible to some of the C /C# devs i work with which makes code review and integration etc simpler.

I suspect this is a very different workflow to how other folks use L - so hence the following questions:

  • What do you use L for ?
  • How do you work with it today? e.g. What editor do you use today? and how do you currently debug and/or profile your L code?
  • Do you find you mix #lang 's in your code or do you write pure L and rely on L dropping into TCL for some functions?
  • Do you use L with TK?
  • Are you generating HTML interfaces with L running on server (or you combining L with Tcl Rivet) for web apps?

many thanks

p.

Hi Phillip,

All of the things you mentioned and then some. Lately, L has been my goto lang for things I used to do in perl (yeah perl is faster at text processing but L is fast enough for the stuff I do).
I’ve also learned to use all the cpus, if you look at http://mcvoy.com/lm/L/photos.l search for parallel and go until you find the procedure thumbs(). Read that while loop and you’ll see a template for processing each file in parallel using all the cpus. I use that all over the place, L has a handy little function cpus() that (on linux at least) returns the number of cpus.

What you are doing, prototyping in tcl and migrating to L, yeah, I’ve done that (though less and less because I much prefer L, duh), mostly I’ll get frustrated at some main proc we have that doesn’t have getopt processing I like so I’ll rewrite that in L.

It certainly was designed so you can mix and match. Damon or Rob would have to way in but I believe it is like so:

L array is a Tcl list, L hash is a Tcl dict, L structs are a Tcl list as well. So it would be awkward for stuff like structs but you could pass them back and forth to Tcl just fine. L follows Tcl pass by “value” except it is pass by reference but copy on write, the L references are just Tcl’s upvars (though FAIR WARNING: if you pass a struct field {so a list element} by reference we do this horrible gross, but handy thing, where we put the element in a local var, pass a reference to that, and when you come back from the function it assigns the list element the value of the local var. It’s disgusting but it gives you the appearance of pass by reference on struct fields which is not a thing in Tcl).

The other fair warning is that L is based on some old interm 8.5 Tcl, we haven’t merged it forward and we haven’t fixed the Tcl tests that we broke (we use PCRE instead of whatever RE engine that Tcl uses, maybe Henry Spencers?). I can’t remember why but merging forward is a pain in the ass and it’s unlikely we’ll do it unless the user base grows and someone really wants it. Oh, and we completely broke Tcl’s threading model (that I don’t understand) which made the Tcl core team not have any interest in taking our changes back. Their loss?

I completely get the idea of using L so you can push Tcl code through C/C# people, one of our guys hates L because it’s Larry’s pet language and he didn’t see it going anywhere, but there was a commit flying past and it looked so much like C he pointed out a bug in the code without knowing it was L :slight_smile:

Using L with Tk drives Damon nuts, he’s never liked it, we’ve never figured out a way to do it in a pleasant way. That said, it doesn’t bother me, I use it with Tk.

Debug? printf. Rob can maybe weigh in here, there are some tracing features in there that he did. Profile? I just don’t.

Editor: vim

Html - so there is some support for doing stuff with html that Damon did but I’ve never used it. I believe it’s like PHP. Damon?

Anyhoo, glad you are using it, I love L, I wish there was a C dialect that was L compat at least for the none gui stuff. I like C, I can’t stand C++ or Rust or whatever, I’m happy with C’s syntax, I just wish there was a C that picked up stuff like Tcl’s ref counting so I don’t have to do memory management, hashes as a type, all the RE stuff in expressions (and switch statements! It’s about time, right?). Rob loves it too and he’s the guy that did the compiler so it’s not dieing anytime soon, we use it all the time.

–lm

Hi Larry

thanks for the answers.

re: Photos code - thats one of the tests I will be using for syntax highlighting, code folding and function outlining - so getting very familiar with it :-).

re: parallel - i can see why this gets used a lot.

re: C/C# people - lol thats cool.

I prototyped the first version of one our tools in Racket. So after being confronted with a Scheme based language using #lang’s, the Tcl and L combo (specially L side) has been significantly more appreciated.

re: Tcl 8.5 and threads.

Aware of the issues and on my list to dig into after i get the version one of the IDE and some of our other tools done. I know there is a 8.6.5 branch on the Tcl fossil repo to investigate as well. Figure if nothing else - its all good learning and like the IDE - i need it - so its good motivation.

re: using it

thoroughly enjoying using L with Tcl and really enjoying going through the code.

thanks again

p.