6 ms·
BLisp: A Statically Typed Lisp Like Language
- tines 5y agoSince the point of s-expression syntax/homoiconicity is macros, I'm surprised to not see any mention of them in the feature list linked here. Does BLisp support macros? If so, what kind? Also, is there an example of the type inference working?
- andyferris 5y agoAnother reason for "code as data" is to enable (safe) remote code execution via RPC. For example you may want to query a database with a custom filter predicate function. If you pass one of BLisp's `Pure` functions across the wire, the database could execute the function with relative safety (compared with using `eval` with a string, or whatever). I find it frustrating that almost all popular languages lack any safe facility for this, so people have to create some limited query schema (with it's own custom wire encoding and mini-interpretter), or instantiate a sandbox for a non-pure language like Lua and eval a string, or else invent their own fully-blown programming language along the lines of BLisp.
- bvrmn 5y agoI don't see a difference between (eval s-expression) and eval("some code"). `eval` is inherently insecure without special restricted runtime. Pureness doesn't guarantee security.
- elcritch 5y agoOne side benefit of wasm appears to be enabling this scenario, but across many languages. The client gets to use almost any language they want, it's fast, and the wasm engines let's the service define a very specific api surface.
- bmitc 5y ago> Since the point of s-expression syntax/homoiconicity is macros I don't equate S-expressions with macros. S-expressions make many things easier, including: simple and regular but expressive syntax, expressive function and variable names with basically any character sequence allowed, copy and paste-able code that just works, easy automatic code formatting.
- valenterry 5y agoI always feel that for lisp-like languages it's just not a good idea to make them statically typed. Their power is derived from macros and the fact that code is data and the other way around. For statically typed languages, they only feel ergonomic to me if they have highly specialized syntax and if they really leverage the type-system (which is often in conflict with macros and runtime flexibility).
- threatofrain 5y agoHow do you feel about typed Racket?
- valenterry 5y agoI have never used racket, but what I have seen so far is pretty cool. But for typed Racket, I don't have a good feeling about it either. In particular because it is gradually typed, which kind of defeats the purpose, even though it might be practically useful. But I prefer to have actually compiler guarantees and not just best-effort help.
- samth 5y agoThis might be a confusion about what "gradual typing" means. Typed Racket is a sound type system, and not just best effort. You get real compiler guarantees.
- valenterry 5y agoI don't think so. Here's an example: https://docs.racket-lang.org/ts-guide/typed-untyped-interaction.html https://docs.racket-lang.org/ts-guide/typed-untyped-interact... What that means is: I might call a function that tells me it will give me type X but instead it blows up. It's good that it blows up btw - that is the best thing a language with gradual typing can do for these cases. But it's not something I would be satisfied with. Now, you can say that "blowing up" is part of any function anyways, but then my response would be that this severely hurts my ability to reason about how code will behave when run, so I'm giving up a huge benefit of a static type-system in general.
- xixixao 5y agoWhy require Pure to be an annotation - why not make that the default without annotation - no effects? (Same as in Haskell)
- endgame 5y agoAll functions in Haskell are pure: the function `putStrLn :: String -> IO ()` returns the same IO action for the given input.
- kreetx 5y agoBut you don't need to annotate that, i.e `putStrLn :: Pure (String -> IO ())` (or as in the OP lisp: `Pure (-> String (IO ()))`)
- nonsince 5y agoBecause it’s an effect system, it’s not returning monads. It’s a different kind of type system with different restrictions and benefits. You could make every function implicitly pure, but that would be syntactic sugar, as opposed to Haskell where pure-as-default is a consequence of how the type system is structured.
- didibus 5y agoI wasn't fully able to tell if this was interpreted or compiled? In any case, it looks neat, I think the intersection of static types and Lisps is a space that needs more experimentation with, so I'm happy to see that. I hope eventually it gains more effects as well, with only Pure and IO, you can't do much of the cool things that effect systems bring.
- anentropic 5y agoIt seems to be embedded in Rust: https://github.com/ytakano/blisp#how-to-use https://github.com/ytakano/blisp#how-to-use so I would guess interpreted
- moonchild 5y agoIs this a lisp? It looks like an ml with s-expressions.
- hajile 5y agoLisp isn't necessarily just CL or Scheme. Further, if I recall correctly, ML started out as a lisp that later adopted infix syntax.
- lispm 5y agoNot really. ML was developed as a new statically typed functional programming language for the LCF theorem prover. It was implemented in "Stanford Lisp". It did not have Lisp's s-expression based syntax.
- nudpiedo 5y agoFinally. I hope to get some time to see whether there are persistent data structures and how errors are reported and how dynamic the runtime is (in order to pass/evaluate s-expressions on runtime). My understanding is that it compiles directly to rust, so some compilation to web assembly, and almost direct C interop should be possible, right?
- ytakano 5y agoI'm an author of BLisp. Thank you for your interest and discussion. I'm now designing macros, but I cannot spend sufficient time to do. Anyway, macros will be implemented in the near future. This language is being implemented for bare-metal or no_std environments in Rust. This is often called shell. I don't want to control OSes or devices by YAML or unsafe scripting languages.