135 points · by fogus · 13y ago · 57 comments
This is used regularly in UX labs with two-way mirrors and cameras watching how users interact with design -- why should it not be useful to programming as well?
(ann my-inc [Number -> Number])
(defn my-inc [n] (let [internal-number (Integer/parseInt "1")] (+ n internal-number)))
one could write this:
(defn ^Number my-inc [^Number n] (let [internal-number (Integer/parseInt "1")] (+ n internal-number)))
...and then run a type checker that reads and analyzes the hints?
Of course, the core.typed annotations could preserve whatever information they need in the compiled output, whereas the type hints aren't preserved past the compile phase (as far as I can tell.) Is that the limitation that requires defining type information in separate annotations?
https://github.com/steveshogren/deft
Right now it only checks maps for a set of keys, the idea longer term is to add in other types of "type" checking.
I haven't yet tied into the built-in annotations, just because those didn't appear to check anything but valid Java types. If it is possible, I would be really interested in seeing how.
Project is still young and in an early phase, but definitely promising.
Upper case symbols are variables, as in Prolog. The others are literal matches.
I hoped that in 2020 Racket will be around 5th position in "the most popular language" rankings with Clojure in the first ten too. Now it looks like Clojure is taking the lead - maybe Racket2 will change this again.
But hey, either way that's a popular, mainstream Lisp! That's unprecedented!
My own hope is that Clojure will open many more eyes to Lispy ways (including reducing paren-phobia) --- and then many of those people will go on to discover and love Racket, too. Indeed already I see people who seem to appreciate and use both Clojure and Racket. I expect that will increase.
As you say, if Clojure's success helps Racket adoption, then I have no complaints at all. It would be great if people used both Racket and Clojure, one for (almost) seamless interop with C and custom DSLs, the other for interop with Java and concurrency - for example.
I still have hope and believe that Racket will become a successful language. I love Racket and prefer it to Clojure, that's true, but I really hope for Clojure's success too. As I said, they're both Lisps, and having even only one of them "succeed" (in terms of mainstream adoption, they're greatly successful as it is already in their niches) will make me happy. I will be a bit more happy if the one to succeed will be Racket, but I will be overcome with joy when they succeed both. :)
My introduction to Lisp, some years ago, was reading The Little Schemer, which I loved. Afterwards, I was very disillusioned when I needed an array and learned the canonical solution was to use mutable arrays and set! (as if adding a bang after its name made it less of a sin). I understand why it's like that: persistent data structures are tricky to implement efficiently, and Scheme emphasizes simplicity of implementation. But it still bums me out.
See: https://news.ycombinator.com/item?id=6300845
Also, yes, there are generic "sequence" operations which you can use to abstract away a type of a collection you use. There are lazy sequences too, although they are not the default. There is also a set of very powerful "for" forms, which are an alternative to recursion when traversing sequences (and can function as sequence comprehensions, too).
> and Scheme emphasizes simplicity of implementation. But it still bums me out.
There is a reason why Racket name was changed from PLT Scheme. Racket outgrow Scheme some time ago and continues to grow still. It is "Scheme with batteries included", which means it's not Scheme anymore. But it makes it a great language for practical applications. It's not that great for embedding, though, while normal Schemes are.
Anyway, I find Racket to be the most impressive language I've seen until now. It could use some more developers working on it, but that's all it needs to become on par with Clojure - or any other language for that matter. This makes it's design truly impressive, in my opinion at least.
http://docs.racket-lang.org/reference/data.html
Additional datatypes (including imperative queues, growable vectors, orders and ordered dictionaries, splay trees, skip lists, interval maps, binary heaps, integer sets, bit vectors, etc.):
Sure, you could implement all of this in Racket, I'm not saying you couldn't; the advantage with Clojure is that these things are standard and that everybody else's libraries make use of this stuff.
This is probably the biggest advantage with starting any new programming language: you get a chance to redo the standard library (and tie it into some syntactic sugar) without worrying about compatibility.
It may be true that the type-checking phase of every typed programming language is, in this respect, lint-like. A typed language's implementation is obviously not required to stop with ensuring that the types check out. It can use the information so derived to do further things, including introduce optimizations.
Insofar as Typed Racket does optimizations based on types it's hard to see how it can be completely orthogonal to type checking, on pain of the optimizations being potentially incorrect; insofar as the optimizations are based on types, it's a use of a type system beyond what Typed Clojure currently offers.
I don't think will ever see a Lisp in the top 5 most popular rankings (assuming we can measure actual use, which, somewhat roughly, we can).
In 2020 we'll probably see imperative and functional imperative hybrids topping the charts.
C: 1972
C++: 1983
Objective-C: 1983
Python: 1992
PHP: 1995
JavaScript: 1995
Ruby: 1995
Java: 1995
C#: 2000
Of course, these rankings are skewed by existing codebases, but they're still topping the charts. In 2020, the languages at the top of the charts will surely have existed in 2010 -- what imperative-functional hybrid that is presently in use did you have in mind?
Honestly, I wouldn't be very disappointed if it proved to be like this. All these languages are interesting and in 7 years time could become true "languages of the future". However, despite hoping so, I don't believe it will come true.
Most probably some languages will just move slightly higher with others moving a bit lower. Java will remain in the first 3, at the very least. Maybe Objective-C will swap places with C++ and Python or Ruby (or both) will come close to PHP. That's all I think will change, although it would be nice to see Rust instead of C++ for example or Clojure in place of (Visual) Basic.
Also, all the currently most popular languages are this young because there was a major paradigm shift from imperative to OO in the '80. Without similar shift happening sometime soon we will be stuck with Java not just to 2020, but to 2040 at least :)
[1] http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
I was referering to stuff in the current trend of imperative languages with added functional capabilities (from first class functions to closures to macros) and used with a dash (or several) of functional idioms.
So stuff like C#, Scala, etc would qualify. Javascript and Ruby too. And Rust, if it hits off.
And I also had in mind how those and their libs would evolve more "functionaly" going forward to 2020.
That said, some libraries start out typed too (e.g., the Racket math library[2]) and do benefit from type-driven optimizations and type-checking.
[1]: http://docs.racket-lang.org/ts-guide/ [2]: http://docs.racket-lang.org/math/
The domain is the inputs of a function and the range is the output. I assume that if there were multiple arguments to the function it would git you the other ones too.
BTW compare it to the haskell version of the same:
> 1 + "1"
No instance for (GHC.Num.Num [GHC.Types.Char])
arising from a use of `GHC.Num.+'
Possible fix:
add an instance declaration for (GHC.Num.Num [GHC.Types.Char])
The shirt looks significantly less hairy in clojure :-) Prelude> 'a' : 'a'
<interactive>:3:7:
Couldn't match expected type `[Char]' with actual type `Char'
In the second argument of `(:)', namely 'a'
In the expression: 'a' : 'a'
In an equation for `it': it = 'a' : 'a'I've been wanting to get into clojure (mainly for the web aspect of it) for a while, but as someone who hasn't done much lisp and really loves Haskell's type system I've been hanging back a bit.
I'm assuming that clojurescript will also work fine with this?
I claimed that Typed Clojure doesn't get you the expressive power of Haskell's type system. I understand that Typed Clojure has some sophisticated facilities for refining types, and (e.g.) tracking what keys a map has, and lots of other neat stuff. This does not seem to me to increase the expressivity of the language, whereas Haskell's type system does (well, since I don't think one can separate Haskell into the language on the one hand and its type system on the other, it's misleading to talk about Haskell's type system increasing its expressivity). (I just about plotzed when I saw the definitions for `eval` and `view` in <http://okmij.org/ftp/tagless-final/course/Intro2.hs>.)
Everyone who writes a monad library for Clojure, for instance, has to take special measures to implement a properly polymorphic "return", or punts and doesn't do it. If Typed Clojure let me annotate `(return 5)` [ETA: or annotate something dynamically enclosing `(return 5)` with something that would force the given interpretation of the return call] with the type list of integer, or maybe integer, or whatever, and have it actually evaluate to [5] or #<Just 5>, or whatever, that would be great. AFAICT, it doesn't do that.
Specifically, I'd recommend changing
font-family: Monaco,Bitstream Vera Sans Mono,Lucida Console,Terminal;
to font-family: Monaco,Bitstream Vera Sans Mono,Lucida Console,Terminal,monospace;
The "monospace" at the end is generic and will always produce a fixed-width font.Great post anyway, thanks!
https://groups.google.com/d/msg/clojure-dev/ryYzI1Bj0p0/uWdE...