Hacker News new | past | comments | ask | show | jobs | submit login
Little: a tcl-based c-like scripting language (little-lang.org)
101 points by cisstrd on April 19, 2016 | hide | past | favorite | 57 comments



I really, really like that "Why?" explanation page; I feel like many projects could benefit from copying that idea.

Frequently, the first thought I have when I see projects is, "okay, neat, but why does this exist?", and the answer takes some digging. It's wonderful that in this example the answer is made so obvious.


> We (BitKeeper folks) did our GUI interfaces in Tcl/Tk years ago because it meant we could have one gui person and get the same gui tools on Windows, Mac, Unix, and Linux. Yes, somewhat clunky (less so over the years), but as a small start up it was great not having to have a developer for each platform, both for initial coding and for ongoing maintenance.

hey, that describes my very first development job! i wrote a cross-platform tcl-based installer for a desktop application at the first company (a small startup) i ever worked for. it was really easy to write (i was literally 17 years old) and there were fairly solid libraries for doing windows-y registry-ish things and unixey install things too. one of the senior guys on the team took my code and integrated it into their cross-compiled build system and it spat out a very decent product that helped our users install the program on i think 3 or 4 different platforms (win95, linux/X, and solaris, possibly HPUX or some other weird platform). that was my very first significant contribution to any software project.

i seem to remember that at the time the shrinkwrapped installer licenses cost $10's of thousands for commercial use. it probably took about 60-80 hours of my time at $17.50 an hour... clearly a bargain.


> I really, really like that "Why?" explanation page;

Me too. Especially the comparison of tcl to their language:

  set x [expr {[lindex $red $i] - [lindex $blue [lindex $green $i]]}]

  vs

  x = red[i] - blue[green[i]]
I had to work in Tcl early in my career...80 hours a week for a straight year, so I recognized that madness immediately.


Keep in mind that this example was (presumably intentionally) cherry-picked to show off the worst of Tcl's syntax. It's not really representative of how expressive the language can be in the right context, and it doesn't show the benefits that you can get from having a very simple, regularized syntax with little added sugar.

On the topic of expr, though, it can be avoided if desired in favor of Lisp-style prefix operators: http://www.tcl.tk/man/tcl8.5/TclCmd/mathop.htm


That example was contrived but it wasn't designed to show off the worst of Tcl's syntax. There is worse out there.

Little wasn't a slam on Tcl, if you think that then you miss the point. Little is trying to bring people to Tcl. The Tcl ecosystem has a boatload of good stuff, people should check it out.

But many people are put off by Tcl's syntax, it's fine for glue, which is what Ousterhout intended, but it sucks for 300,000 lines of code. If you want to write big programs then perhaps some type checking could help you. And perhaps some familiar syntax might help. Little is for people that have to maintain a pile of code.


Whats the best resource for Tcl ecosystem and getting its main benefits?


http://www.tcl.tk/about/language.html

is decent place to start. Then move on to

http://www.tcl.tk/software/

and there are all the Tk (GUI) APIs and libraries.

If you wade through that, or you get stuck, #tcl on freenode is a great resource.

Edit: #tcl told me to pass on this:

https://core.tcl.tk/jenglish/gutter/index.html


Tcl is fine for big projects. Use OO as does Tk. Use namespaces. And type checking isn't exactly difficult in the language. Some combo of catch {} and scan usually does it for me.


SQLiteStudio developer here. I think it's a project which could be considered big. Version 2.x.x was written entirely in Tcl and the main problem was memory sharing with threads. There's none. Threads can communicate only by messages. Worse than that - each thread has to load very same packages and same procedure definitions (into separate memory segment) for each thread that wants to use them. Threads in Tcl are like processes that can communicate through pipe. It's a major pitfall of this language in context of more complex projects. Besides that it is a very nice language to use and read. Gives quick results with little effort. I still use it almost every day, just not for complex projects.

I'm aware of tsv package (shared variable), but this is just sharing scalar variables or arrays. You cannot share objects, procedures, namespaces, resources, etc - and that is the major reason for sharing memory across threads.


Tcl just totally wants to be event driven and single-threaded. I agree wholeheartedly with your assessment of threading in Tcl - the standard Tcl ideology is "don't use threads." It was a pretty deliberate decision as I recall.


Message passing without memory sharing. Isn't that what Erlang processes are? Is it because having to load the packages into the thread makes it too large? Just curious.


I'm not familiar with Erlang. Nevertheless there are two main issues with this threading model:

1) Application memory consumption grows more than it should, because same extensions have to be loaded several times in the same application, but in separate threads;

2) Resources such as images (or any other kinds), or OO objects, cannot be transferred between threads efficiently, the only way is to serialize them to scalar representation, which then can be passed through either tsv (mentioned above) variables, or through a message to another thread - then deserialize them there. Apart from precious time which it costs, you also make a full copy of resource/object, growing memory consumption even more.


Sockets aren't bad for serialization between threads in Tcl. Generally, a socket opened against localhost in Tcl is pretty smooth running. I have used multicast UDP sockets in anger with Tcl and it ran well.

For stuff that has to be fast, I generally reach for 'C', so I have not plumbed the depths of performance with sockets in Tcl.

Again, though, I drank the "everything is event driven" Kool-Aid years ago and it works for me.


I'm no expert with Erlang either, and thanks for the explanation. I have to look into Tcl/Tk for #1, but #2 makes sense to me now.


There are things to like about tcl, but lists aren't really one of them.

Not cherry picked, an "official" page describing lindex: http://wiki.tcl.tk/1481 Objectively compare that with most any other language's docs for lists/arrays/whatever. "Everything is a string" does have some downfalls.


I think you might have misinterpreted my point. When I said it was cherry-picked, I did not mean that it wasn't a legitimate example or that lindex is not a real, standard Tcl function. It's a completely fair example and is something that is liable to happen in practice.

All I meant is that it was clear from the context that an example was chosen showing a weakness of the language (relative to standard C-like syntax) and that it's not quite fair to judge the whole language based on that one example.

Tcl's incredibly simple syntax and lack of syntactic sugar are what lead to situations like that example. But those same things are also responsible for making the language Lisp-like and fairly homoiconic. You can do incredible things in Tcl thanks to its simple syntax which is amenable to macros and code generation.


It's really important to use reduction of strength for lindex references:

set j [ lindex $red $i ]

set k [ lindex $green $i ]

set m [ lindex $blue $k ]

set x [ expr $j - $m ]


> so I recognized that madness immediately.

It's just bizarro lisp without the parentheses.


It combines the power of Visual Basic with the readability of PostScript.


Thanks. Given the state of the world we felt that not answering why would just get a pile of "Neat|WTF|Huh - why did you do this?"


I should have also said in the original comment that Little, beyond the website, looks genuinely neat and I'm looking forward to exploring it further.

I just finished skimming through the paper you have linked on the site and liked it quite a bit. It directly answered another question I had, which was what would it take to implement Lisp-style syntax in the same fashion as you did for C-style syntax? I'd normally talk myself out of ideas like that, but your paper is talking me into thinking about it more.

Thanks for sharing all of this!


Our pleasure. We're around on the irc channel or the forum or someplace there is a mailing list (if not, dev@bitkeeper.com gets to all the people that are current hackers).

I'm tickled pink that Little is on the front page of hacker news.


> We (BitKeeper folks) did our GUI interfaces in Tcl/Tk years ago because it meant we could have one gui person and get the same gui tools on Windows, Mac, Unix, and Linux.

Ok, sounds reasonable. Except... now you have to hire another person to do language development/maintenance :)


Now that's a valid point. So it's 2/3rds instead of 1/3rd but the guy doing the language is a languages/compiler guy (used to be professor at Brown) and he loves this stuff. So not a big money win but definitely a big karma win, he's having fun.


Always nice to see Tcl/Tk get attention, it's a language I've often found quite useful. Seems like I'd heard of "L" before in connection with Tcl/Tk, but not sure it was the same thing as Little.

Certainly seems it could be a good alternative, a quick look at the syntax makes me think of it like a kind of typed Javascript. The ability to tap into the underlying language, e.g., event loop, Tk UI, coroutines, should be an advantage.

There probably is a way to install Little when TclTk 8.6 (and extensions) are already installed (there's a warning about trashing the pre-installed binaries), and not have problems due to moving or replacing existing libraries that applications depend on finding in established locations.


Little is L, we used to call it L and got beat up because you can't google it. Supposedly googling little-lang is better.

If you build it with our makefile then it will live next to tcltk 8.6. If you don't then it will want to dynamically link in some libs and it will get the wrong ones and barf.


I remember being interested in L when I read about it a few years ago, so it's great that it's open-sourced now. Should be fun to try it out. I'll give the makefile a whirl.

As for the name, "L" would be hard to Google, though "C" and "Scheme" are too. While I guess "little" would be somewhat easier to search for than "L", it sure isn't as obvious as "Clojure" or "fortran". Outstanding names are hard to invent.


Let us know what you think. This thread will be fleeting, we are on the IRC channel as well as the forum at https://users.bitkeeper.org/c/little-language

The IRC channel seems most active.


That's a shame, since I program in J, and I've tried the free K version. L would have made my PL list quite funny! I'll take a look at it, since I have used tcl/tk in the past.


It's not very clear from the page -- does it work on Windows at all?


It has for years when built as part of BitKeeper, I think there are some issues in how we open sourced it. It's being discussed over on the forum, you might look there.


Banging out GUIs in Tk is a delight when contrasted with developing in whatever javascript framework is popular this hour. Tcl itself is pragmatic to an extreme; a great framework for both organizing large projects and heaping up fast primitives written in C.

Anyway, great job! I hope Little's syntactic sugar gets more people exploring Tcl/Tk. Can't wait to give it a whirl.


You hit the nail on the head. Tcl/Tk doesn't get enough love, it's a really useful system even after all these years, it's gotten much better in terms of looks and it was always great in terms of what it could do. All Little does is make it more approachable for the 9x% of the world that prefers C, types, etc.

When people say Tk looks bad point them here: http://www.little-lang.org/gui.html

Tk can look just fine.


> Firefox vs us on Linux

That's a bit of an unfair comparison. Gtk has lots of nice themes which AFAIK Tk can't use. That dialog doesn't exist on Firefox anymore, but this is what Thunderbird's preferences look like on my machine: https://my.mixtape.moe/fggaex.png

It's true, Tk can look okay on linux, but it will still be out of place when placed side by side with Gtk and Qt apps (Qt can use Gtk themes).


Yup, that's the price you pay for having it cross platform and avoiding C++. If I were making that choice today, might lean towards Qt, but I'm not sure. Tk's widgets are really pleasant to use, the last time I looked at Qt it was a lot lower level (may have gotten better, it's been a while).


Have you ever had to try converting a large pile of pre-existing Tcl/Tk code to L?

Wondering how much work that would be...


It's a rewrite but it can be incremental, you can mix and match Tcl and Little code in the same file.


From the "L Programming Language" PDF:

    “It’s like perl without the nastiest bits.”
I think that really does capture the spirit of what this language looks like. I'm not sure it will reach any kind of general applicability, but it seems like a tasteful nod to the extensible nature of Tcl either way. Curious to see the inclusion of PCRE over Tcl's ARE which I thought was pretty routinely trotted out as a better performing, more limited, RE engine.


"higher performance" depends on the specific case. I think the Tcl RE engine (Henry Spencer's[0], which is also used in PostreSQL[1][2]) does avoid some pathological cases where Perl/PCRE fall down[3], but PCRE does best Spencer's work in other areas. They also simply have a different feature list[4].

[0] http://wiki.tcl.tk/396

[1] http://www.postgresql.org/docs/9.3/static/functions-matching...

[2] http://www.regular-expressions.info/postgresql.html

[3] https://swtch.com/~rsc/regexp/regexp1.html

[4] https://en.wikipedia.org/wiki/Comparison_of_regular_expressi...


BTW, a buried discussion here: https://news.ycombinator.com/item?id=11527154


I haven't tried this yet, I've just looked at the examples in the docs. However, I think this could be pretty cool.

I think the combination of the Perl influences with the possibility (which I'm interested in, but haven't proven yet) of using this with Tclkit (a statically linked version of Tcl that can just be copied over for deployment) might make this a nice cross platform replacement for the kind of things I might otherwise want to do in Awk.

Tcl itself is also certainly a good cross platform Awk replacement, but heavy regex stuff seems like it might be a bit more concise with this syntax than in Tcl itself.


Tclkit should work, we haven't tried though. The tcl folks on #tcl on freenode might be able to help.

Tcl doesn't get enough love, the built ins and the libraries provide a pretty rich environment and then you toss in Tk and all the Tk extensions and you have something.

And now you have it all with a C like syntax, kinda cool.


Looks like a very interesting little language, I enjoyed working with TCL a fair bit due to things like wish being so interactive. It's also interesting that they added pointers to TCL, which solves my biggest gripe with TCL.


Tcl had them already, we're just using upvar under the covers. upvar uses the variable in the stack frame you specify. Which is clever and all but sort of a pain to use so we just did the &this_is_sort_of_a_pointer thing but it's a compiler managed upvar under the covers.


That was actually the original prototype. Little has moved on to have a pointer object type.


Trying to figure out where the code for Little lives - is it in a fork of the Tcl/Tk repo itself?


Yes it is a fork but the core team is already trying to unfork it. We're excited about that and will try and help.


I didn't see a LICENSE file on github. What is this code licensed under?

Edit: Nevermind - it's in the README.


For other people reading here: It is built on Tcl and released under Tcl's license. BSDish.


Well, this is a really well designed and beautiful language, i really enjoyed it.


Congrats on the release!


I...I...still feel like this is a joke, even after reading the "why" section.


Please don't snarkily dismiss other people's work on HN.

Thoughtful criticism is fine, but it should be grounded in respect.


The vibe I got from reading the "why" section was "yeah we had some fun making this, and yeah we think this syntax is a bit better, but isn't it ridiculous our boss thought this was a good idea!" Like a wink at anybody who think this isn't needed.

So to the extent I think its a joke, I think its intentionally a joke --- and whoever made it I respect their comedic talents.


I'm the boss and I wrote the why page, I was poking fun at myself. Perhaps my sense of humor needs an upgrade.


I totally missed that the boss wrote that page. Maybe I wasn't perceptive enough but it came off to me like employees taking a crack at their boss. Not in Dilbert-style disrespect more as everyone turning an eye-rolling issue into a fun project. It was funny.

I just didn't think it was you, though. Maybe sign it "The Boss" or something similar at the end to make sure the rest of us get the full joke.


Oh interesting. Like the above commenter, I didn't think of this at all. Your humor is definitely up to date :).




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: