5 ms·
The Shen programming language
- JoachimSchipper 15y agoApparently, this is based on Qi, which tried to update Lisp with, among other things, types (type checking/inference/pattern matching/etc.)
- SamReidHughes 15y agoInstead of lambda expressions, it has slashdot expressions.
- gurraman 15y agoI found this really odd. Any idea what the reasoning behind the "slashdot" is? On a side: I like Haskell's take on lambda syntax (prefix with "\", e.g. \x y -> x + y).
- rads 15y agoIf you squint (a lot), /. looks like a lambda.
- anon_c 15y agoWhy don't we stop fucking around and just use λx y→x+y?
- pavpanchekha 15y agoBecause typing a lambda is not obvious on US keyboards.
- gcr 15y agoA shame, too. At least decent editors make this a tad easier. DrRacket, for example, binds lambda to Ctrl+\. Racket accepts both "lambda" and "λ" as the same thing, so it's up to personal preference.
- pavpanchekha 15y agoI'm well aware of how DrRacket works; nonetheless, telling a newbie to type "lambda" will lead to typing, and telling them to type a lambda will lead to griping. Also, the difficulty of typing lambdas also means that writing blogs about code, or documents, or emails, will require even more pain.
- anon_c 15y agoI use RFC 1345 digraphs in vim to type unicode characteres. In RFC 1234, λ is l* and → is ->. To type the above, I just input l_*x y -_>x+y where _ means backspace. This is easy to learn, fast to type, and covers most of the useful unicode characters.
- deleted 15y ago[deleted]
- wladimir 15y agoI agree. It's sometimes a pity that even with full unicode support nowadays we still resort to 'ASCII art' to express syntax in programming languages, reducing legibility. This is not so much a problem of US keyboards, because code editors could easily support the extra characters as part of the language support.
- tikhonj 15y agoYou can just configure your editor to figure out when \x y -> x + y is equal to λx y→x+y and replace the symbols as appropriate. I have Emacs set up to do this for Haskell, so I really have the best of both worlds (mostly): I can type the former expression but it looks like that latter.
- jstepien 15y agoThe first thing I'd like to see on a programming language's website is a handful of short examples, like on http://ruby-lang.org http://ruby-lang.org. In this case examples are hidden a bit deeper: http://shenlanguage.org/Documentation/Tutorials/Shen-in-15min.htm http://shenlanguage.org/Documentation/Tutorials/Shen-in-15mi...
- michaelcampbell 15y agoI agree with your point, but ruby-lang.org has precisely one: puts "Hello World!" Which I'd say is more someone trying to be cute (or pro-forma) than trying to show off the language to the curious. But, I guess that's subjective.
- djacobs 15y agoWait, but that's not true. It has a full-fledged class definition, instantiation, and method call.
- jstepien 15y agoYes. I believe they're shown randomly and they're cached so we might see different examples.
- michaelcampbell 15y agoD'oh; all I get is the puts statement with 15 lines of comments. Apologies.
- vilhelm_s 15y agoThere are also a few extended examples on his blog: Red-black trees http://jng.imagine27.com/articles/2011-06-28-141124_purely_functional_types_red_black_trees_in_qi.html http://jng.imagine27.com/articles/2011-06-28-141124_purely_f... FFT http://jng.imagine27.com/articles/2011-07-06-164206_purely_functional_fast_fourier_transform_in_qi.html http://jng.imagine27.com/articles/2011-07-06-164206_purely_f...
- ekidd 15y agoThere's a nice introduction here, which is aimed at experienced functional programmers: http://shenlanguage.org/documentation/Tutorials/Shen-in-15min.htm http://shenlanguage.org/documentation/Tutorials/Shen-in-15mi... Shen appears to be a strongly-typed functional language with a Lisp-like syntax. It supports pattern matching: (define sum-list [] -> 0 [H|T] -> (+ H (sum-list T))) ...partial application: (* 3) ; returns (/. X (* 3 X)) ...as well as macros that can alias function names: (defmacro logmacro [log N] -> [log N 10]) There's also an embedded "Prolog" implemenation, though I don't know how complete it might be: http://shenlanguage.org/documentation/prolog.htm http://shenlanguage.org/documentation/prolog.htm However, there doesn't appear to be an object system or a monad library, and the "lazy evaluation" system uses a typical promise/force approach, which every Scheme has had for decades. So Shen may not be well-suited to the kind of fun tricks available in Haskell and (to a certain extent) Scala. Still, it's definitely an interesting language.
- masklinn 15y agoPartial application with a lisp syntax threw me for a loop, it looks weird.
- z92 15y agoAny new language needs the ability to dynamically load and bind with C libraries (so/dll) and once that works seamlessly, then everything is done. Otherwise it will enter the chicken and egg problem regarding availability of libraries.
- riffraff 15y agoin this case maybe not so much. If I recall correctly shen has a pretty tiny core that is designed so it can be ported to existing runtimes, so for example a shen/js could just delegate calling libraries to V8 or *monkey, while shen/scheme can use racket's FFI etc
- Zak 15y agoI'm disappointed that it doesn't seem to stick with Lisp syntax, instead adding a large number of infix operators. I'm reminded of the loop macro, but this is more pervasive since you don't have to use loop. The syntax is important for being able to write sophisticated macros that take advantage of all the language's features and for making things like genetic programming easier.
- Fixnum 15y agoThe infix operations are mostly syntactic sugar - [3 4 5] is the same as (list 3 4 5), [A|B] is (cons A B), and so on. I don't know about '->' for pattern matching and '<-' for backtracking (maybe others), but you can of course replace '->' by conditionals as is usually seen in Lisp programs not employing pattern matching. It's the non-open license (forks seem not to be allowed) which is a bit more disappointing. I guess it's a reaction to historic Lisp fragmentation but I doubt this will help adoption.
- deleted 15y ago[deleted]
- jamii 15y agoFrom the license page (http://shenlanguage.org/license.htm http://shenlanguage.org/license.htm): "Part of our motivation in maintaining a tight spec and a reliable platform is to hold the Shen community together so that we do not splinter our resources on multiple incompatible forks. We do not want multiple incompatible dialects of Shen, multiple compilers, multiple incompatible libraries. We want $free readable libraries that work for all of us and libraries we can pick up and use without worrying about compatibility. Hence the production of derivative non-conforming programs from our source, whether called Shen, Shin, Shine or Shoo, is barred by the license. To give up on this is to give up on the motivation for Shen." Whilst avoiding forking prevents splintering it can also be dangerous. OCaml suffers from a similar restriction which has seriously impeded the development and use of new compiler features like staged compilation (http://www.metaocaml.org/ http://www.metaocaml.org/), type-safe marshalling (http://www.cl.cam.ac.uk/~pes20/hashcaml/ http://www.cl.cam.ac.uk/~pes20/hashcaml/) and delimited continuations (http://groups.google.com/group/fa.caml/browse_thread/thread/d4ca429e7935033c http://groups.google.com/group/fa.caml/browse_thread/thread/...). INRIA rarely accept new features into official distribution and the license prevents anyone else from doing so. Extensions have to be distributed as patches and inevitably bitrot. Tying the long-term viability of a language (or spec) to a single owner rings alarm bells for me. Clearly they want to avoid another Scheme but I've had bad experiences in both directions.
- gruseom 15y agoTarver would be better off letting go of his urge to tinker with licenses and just run with one of the existing options. The risk posed by suboptimal licensing is negligible compared to the risk of his radical new language not getting used at all, and every time people get distracted by nitpicking license terms -- as they invariably do -- a significant portion of the tiny and precious attention budget for Qi/Shen gets blown through. This is a shame.
- Peaker 15y agoWhen someone writes "Shen has the most powerful type system of any existing functional language, including ML and Haskell", I get suspicious. Have they really studied each and every type system out there? What kind of dependent types do they have? How do they compare to Agda, Coq, Epigram?
- chc 15y agoI think this may be kind of a question of definitions. Agda and Coq at least are more like DSLs for constructing proofs than general-purpose functional programming languages. I'm not familiar with Epigram, but assuming it's similar to the other two in the list, I think you're redefining his terms for him, which is a little bit unfair.
- omaranto 15y agoNobody said anything about "general-purpose functional programming languages", the blurb says "existing functional languages". All of Epigram, Agda and Coq are functional and currently exist. :) More seriously, Coq is designed explicitly to be a proof assistant, but Agda and Epigram are meant to be programming languages.
- effn 15y agoThe idea is that Shen has a turing-complete type system, so it shouldn't even be possible to create a more powerful type system (given a specific definition of "powerful").
- andolanra 15y agoTo expand on that idea a little bit: that's a valid definition of 'powerful', but there's another definition of 'powerful' which some people mean when they talk about type systems, and that's "To what degree does this type system prevent errors?" It seems from cursory research that Shen is powerful with respect to the definition, "To what degree can we encode computations in the type system at compile-time?" and Agda and Coq's type systems are powerful with respect to the definition, "How can we limit the class of programs by encoding constraints in the type system such that the resulting programs are provably correct?" Consequently, neither Agda nor Coq are Turing-complete even at the language level, much less the type level, but that accordingly gives them greater power to know information about their programs at compile time.
- Shenglong 15y agoI feel obligated to learn this language, just because of its name.
- shennyg 15y agoSame here!
- muraiki 15y agoI'm trying to go through the longer book (on Qi, which has been updated for the most part for Shen) but I'm having a difficult time reading it because every page is saved as a JPG! Magnifying the text just makes it more unreadable... is this 1990? Edit: The book is quite excellent, including a neat history on why imperative languages are the norm. It's just that my eyes are in pain. :(