33 ms·
If you like everything being an expression, check out tcl. A lot of ideas from lisp show up in tcl, especially the idea of everything as an expression. Tcl embo
by mroll 10y ago
If you like everything being an expression, check out tcl. A lot of ideas from lisp show up in tcl, especially the idea of everything as an expression. Tcl embodies this idea while also having the look of an algol-like language. Funny it can pull this off while having basically no syntax.
- qwertyuiop924 10y agoTCL, while it has its warts, is a really cool language. I mean, it even basically has fexprs, something most Lisps put by the wayside years ago. When you don't actually care about speed, you can do some pretty cool stuff.
- mroll 10y agoYeah the level of dynamicness (dynamism?) you can get in tcl is unparalleled as far as I can see. Having no types or syntax and access to the entire runtime at any point in the program opens up all kinds of crazy doors. But you're right, that slows it down. But you might be interested to know there is currently an effort to get Tcl to compile to native/near-native code. Here is a paper on the new techniques being developed and a link to a talk given by one of the lead tcl core team members. http://www.tcl-lang.org/community/tcl2015/assets/talk14/TheTclQuadcodeCompiler.pdf http://www.tcl-lang.org/community/tcl2015/assets/talk14/TheT... https://www.youtube.com/watch?v=RcrqmZV88PY&t=38s https://www.youtube.com/watch?v=RcrqmZV88PY&t=38s
- qwertyuiop924 10y agoPicolisp can match it in dynamism. Seriously, Picolisp is absolutely insane.
- mroll 10y agoI just read a bit of documentation from the Picolisp page. It looks really cool, but can it reach arbitrarily far up the call stack? That's the quality of tcl that I don't see other places. The capabilities of 'upvar' and 'uplevel'. [Edit] I should say "one of the qualities." The other important one is that Tcl has no types. Even all the lisps I know have types.
- vram22 10y ago>The other important one is that Tcl has no types. Is it that it has no types or that everything is a string? asking, not stating.
- mroll 10y agoYes, everything is a string. But you can pass data around anywhere you like without worrying about coercing. A command will receive its data in string representation and treat it however it likes. So when you go to do math with the 'expr' command, 'expr' will treat its arguments as numbers. set x 5 expr { $x + 3 } 'expr' receives x as the string 5 but knows to treat it as an int. I'm not sure that's a great explanation. Maybe a decent summary of the concept of 'no types' is "the language does not presume to tell you how you can or cannot use your data."
- vram22 10y agoThanks. Yes, I get it. I had read part of the Ousterhout book. And also Don Libes' Expect book uses Tcl, since Expect is written in it. Had read a lot of that too. Both very good ones. Didn't get to use Tcl in projects though. I'd read some years ago that Tcl was used heavily in the electronics / EDA industry.
- qwertyuiop924 10y agoThe functions you're looking for are called `up` and `run` in picolisp. And before you ask, yes, picolisp has list interpolation (or quasiquoting, in lisp parlance), so you can control which parts of a certain chunk of code will be run when, and in which contexts. It also includes the `macro` fexpr, which makes interpolation more convenient.
- mroll 10y agoWow, very interesting. Thanks for pointing out picolisp!
- goatlover 10y agoI believe IO lets you do the same. Everything is a prototype with slots, communicating via messages. I guess Self was the same way. Self & Smalltalk also give you access to the entire runtime.
- qwertyuiop924 10y agoBut TCL actually goes beyond that. Most languages of this sort, like Smalltalk, Lisp, and especially slower, more liberal implementations like PicoLisp, allow for compile-time and/or runtime AST transformation, and other sorts of metaprogramming. in TCL, everything is a string. Or at least, everything behaves like a string in the proper context. When you pass code blocks into a command (like if, or while, or whatever), you're not passing code objects: you're passing unevaled strings. This is why expr works in TCL: there's nothing special about expr, it's just actually implementing a DSL (sort of) rather than evaling your code straight up. The practical upshot of this is that unlike smalltalk (I think: Can an ST user actually answer this?), and to a greater degree than LISP and FORTH (;immediate and readtables are a lot more painful to wrangle), you can not only modify the semantics of the language: you can modify the syntax.
- pjmlp 10y agoSmalltalk just like Lisp has very little syntax, almost everything is built on messages, including data type creation, conditionals and loops, among other things. Also you can at any time just completely replace one object by other via the becomes: message. There are also some cool tricks when metaclasses are used, many of each one can see in Python as well.
- qwertyuiop924 10y agoHowever, IIRC, unlike Lisp, ST doesn't have any AST transformation or parsing hooks (macros and readtables, in Lisp parlance), so while ST has a lot of the semantic extension capabilities of Lisp (indeed, it's more semantically extensible than some of the less Object Oriented Lisps), it lacks the syntactic capabilities for extension. However, you know ST better than me. Am I right?
- pjmlp 10y agoYes, I worked on a startup that did pretty much something like Ruby on Rails, but with TCL, inspired by AOLServer. The speed critical parts were written in C and loaded as TCL extensions. Back in the first .com wave. It also taught me to never again use a programming language without JIT/AOT compiler on their standard toolchain for heavy loads.
- qwertyuiop924 10y agoThat's a good idea. Although they've been working on TCL perf (and even compilation) and there have been some improvements, especially when you're not doing metaprogramming. But still, using it on heavy loads isn't a great idea... (I mean, honestly. I'm starting to think picolisp might be faster, and picolisp has 3 types and one data structure. Haven't run the benches yet, though.)
- vram22 10y agoInteresting. There was this company called Vignette (in the same period). They too were doing .com projects for clients, and, IIRC, using AOLServer which I read was in Tcl. Tcl was used for the projects.
- pjmlp 10y agoYep, some of our guys went to work for them in projects across the Iberian Penisula.
- jabl 10y agoHmm, was that the one headed by Phil Greenspun? Arsdigita or something like that...? Back in the day, aolserver w/ TCL + (open)acs + pgsql/oracle was teh awesomeness compared to LAMP that everyone else was doing. Oh well... :(
- pjmlp 10y agoNo, in Portugal. We were eventually acquired by a company doing helpdesk and CRM software.
- jhbadger 10y agoPity that it became so associated with the Tk GUI toolkit -- half the Linux GUI apps in the 1990s were in Tcl/Tk, and when Tk fell out of favor so did Tcl.
- goatlover 10y agoShould have been made available on the web by some browser vendor in the 90s. Netscape invented a language, Sun wanted to embed Java, but went with the applet approach in lieu of Netscape, Microsoft put vbscript in IE.
- qwertyuiop924 10y ago...And with TTK, you can finally have easy-to-write cross-platform UIs that actually look native. Seriously. If you want a decent cross-platform UI system with minimal effort, which has bindings in just about every language, TK is really worth your time now.
- mamcx 10y agoI have looked at it but don't find examples that truly look convincing,and the info in the official page look very sad. http://wiki.tcl.tk/9485 http://wiki.tcl.tk/9485
- qwertyuiop924 10y agoThat's outdated and unofficial. Look at some examples with ttk.
- mamcx 10y agoOk, but where? TTK is something new?
- rogual 10y agoTk UIs will never be acceptably native as long as scrollbars remain a separate control from the thing being scrolled. This stops OSes deciding where the scrollbars should go based on input device and locale. On OSX in particular, Tk UIs always stick out like a sore thumb for this reason, even with TTK.
- vertex-four 10y agoRust also has (almost) everything being an expression - things like this aren't uncommon: let x = if something { foo() } else { bar() } Things which don't have a logical value evaluate to `()` (the empty tuple), I believe.
- qznc 10y agoThe if expression is not a persuasive example. C/Java/Algol/etc all have it as well. x = something ? foo() : bar();
- coderzach 10y agoI see two issues with the ternary operator. One, the syntax is much less readable, and two, the consequent and alternate are both single expressions, so you can't do something like: x = if(something) { a = foo(); baz(a); } else { b = bar(); baz(b); }
- heywire 10y agoI've always read ternary statements to myself as a question. some_condition ? this : that some_condition? then this, otherwise that Typing this, I realize how hard it is to explain without speaking it :)
- lawpoop 10y agoIs the color red? If so, this; otherwise, that. It's a little tricky, because in the above, the `if` keyword appears after the question mark. Is the color red? Yes-- this: no-- that. Trying to make a parsimonious English sentence while maintaining the syntax elements : P
- kbutler 10y ago> some_condition ? this : that Just read it as: IF some_condition THEN this ELSE that
- 10y ago
- dopamean 10y agoCorrect me if I'm wrong but doesn't Ruby have everything (maybe just most?) things be an expression. I always liked x = if condition something else something_else end
- stormbrew 10y agoEverything is an expression in Ruby, yes. Even `class` and `def` and `module`, for example. Though class, as a specific example, returns nil, so it's not terribly useful that it is one.
- junke 10y agoIn Lisp, "def..." macros, like defclass, defun, etc. return the symbol to which is bound the definition. Not essential, but useful at times. I tend to find Lisp is full of details like this.
- kazinator 10y agoWell, Common Lisp! In the Scheme language, many imperative forms have an unspecified result. For instance, see R7RS 4.1.6: "the result of the set! expression is unspecified". Also, a related misfeature is that function arguments can be evaluated in any order.
- junke 10y agoYes, sorry, Common was implied (not claiming it should always be, but here I wrote it without thinking about others). Scheme's unspecified results are annoying indeed.
- qwertyuiop924 10y agoYes, this is one of the things that I really want to punch the SSC for. Assignment should have a useful return value: even C, so often said to do The Wrong Thing, got that right. But for those of you who aren't scheme programmers, it gets worse: because when RnRS says that the result of something is "unspecified" many implementations take it literally. That's right: in many Schemes, `set!` returns the literal value #<unspecified>. I swear I'm not making this up. It's awful. To quote Jonathan Gabriel of Penny Arcade: "Baby, why you always gotta make me hit you?"
- pg314 10y agoTcl does have a lispy feel to it, but s-expressions in Lisp are much more elegant than strings in Tcl, imho. Greenspun called Tcl the Lisp without a brain[1], which can be taken both as a compliment or an insult. [1] http://philip.greenspun.com/tcl/introduction.adp http://philip.greenspun.com/tcl/introduction.adp
- jjnoakes 10y agoTcl commands are lists, not strings. Or more precisely, they are coercible to strings or lists, but a well-formed Tcl command string is always coercible to a well-formed Tcl list (not all Tcl strings are coercible to lists).
- pg314 10y agoThanks for the correction. It's been a while since I used Tcl and my memory of it was incorrect.
- kevin_thibedeau 10y agoIt used to be strings all the way down before the object system was implemented in 8.0. That incidentally is part of the reason why the expr command was created to process infix expressions since it would be too costly to keep converting sub-expressions back and forth from strings to numbers. http://www.tcl.tk/software/tcltk/8.0.html http://www.tcl.tk/software/tcltk/8.0.html
- bch 10y agoYour profile says "Ask me about Tcl". How?