[q-lang-users] Newbie questions and comments
Brought to you by:
agraef
From: Matt G. <ma...@gu...> - 2005-03-13 19:28:53
|
Hello, all-- I have been trying out Q for a few days, and wanted to share my impressions so far (mostly very good). First a bit of background: after working for a while with popular languages like Python and Java, I became very interested in functional programming about 3 years ago. I tried Erlang but didn't like it, then tried Haskell and liked it but didn't understand it ... I was about ready to give up when I found OCaml, which I have been using ever since. I still think OCaml is a great language for implementing a well-thought-out program design (especially when it's a complex design), but the strict type system can be very frustrating for simple projects, and especially for exploratory coding. For that you need a dynamically typed language. Yet, having caught "the FP bug," it's hard to go back to the procedural ugliness of something like Python. Then the other day I ran across Q while browsing the Web for Linux audio software. So I've been playing around with the language and will probably continue to use it. Meanwhile, in no particular order, here are a few thoughts: * First impression: WOW! Though I'm no expert on language design (no CS degree, just some practical programming experience coupled with an interest in how it all works), Q seems to be one of the best-designed languages I have come across: based on good theory, yet not slavishly adherent to the theory like, say, Haskell[1]; compact, yet powerful; and it has a lot of nice little touches, e.g. symbols that are easily converted to and from strings. Overall, Q strikes a very good balance between theory and practice. * So why isn't Q better known? It's not as if I am some corporate JavaBot, sitting in my cubicle just following the patterns and collecting my pay (though the pay would be nice--not enough of that lately ;-)--I've spent much of the last 3 years actively seeking better languages, yet I had never heard of Q until this week. I would say that Q is comparable in many ways to Lua--not, obviously, in syntax or programming paradigm, but I think the two are very similar in size and power, in maturity, and in the problem domains they are suitable for--though Q seems to have a decided edge in usable multimedia libraries. Yet Lua seems to be rapidly gaining popularity, while Q remains obscure. Is it just because Lua is procedural while Q is functional, or is this a problem that could be solved with more or better publicity?[2] * So far, the one thing that I really dislike about Q is the limitations of the interactive interpreter. It would be nice, for example, if you could test a function definition interactively before putting it in a script. Maybe not such a problem if you use Emacs, but there are some strange people like me who really prefer vi. * I see that undefined variables can be a major source of frustration: they can cause expressions not to be evaluated as expected, yet they are not errors so the interpreter doesn't point out your mistake. It would be nice if there were some tool (or interpreter mode) that would find all undefined variables. Or is there such a thing already? I have to confess I'm not in the habit of reading all documentation in advance--I tend to read a bit, try something, read a bit more, and so on ... * A while back I gave a presentation on OCaml to a local Linux users' group. By way of explaining currying, I demonstrated that the following two function definitions are effectively the same: let foo a b c = a + b + c let foo = fun a -> fun b -> fun c -> a + b + c [ "fun ARGS ->" is the OCaml equivalent of "lambda ARGS" ] The OCaml compiler compiles these two to identical byte code. I tried a similar exercise in Q: foo A B C = A + B + C; foo A = lambda B (lambda C (A + B + C)); But if I create two modules, each containing only one of these definitions, and compile them with qc, they produce different byte code. So, assuming the byte compiler is correct, it appears that the first form is not simply syntactic sugar for the second (as was the case in OCaml); there is some substantive difference. Can anyone explain (bearing in mind that I don't have a CS degree) the difference in the two Q definitions? * It seems like Q might be a good language for programming handheld devices (just my intuitive notion--I can't really give a good reason for thinking this). Has anyone thought about porting Q to, e.g., PalmOS? Last but not least, thanks to Herr Gräf for all the good work. [1] In case it isn't obvious, one example of what I mean by this is that in Haskell you have to understand monads in order to write almost any program that does useful work. I believe, because I have been told by some very smart people, that monads are a very useful tool. But the fact that you need to master such a difficult concept for everyday tasks like reading and writing files makes the learning curve prohibitive. [2] I need to play around with the language a bit more before committing to anything, but I will probably be willing to help create some "buzz" for Q. -- Matt Gushee Englewood, CO, USA |