News for hackers. Stuff that matters.
Re:Racket v5.3.2 by tikhonj on Friday February 01, 2013 @12:28AM (#5149371)
Well, I haven't used it in production, but I used it for a research project last semester. It was actually pretty good, and there are definitely some very nice features. The standard library was pretty good except it missed some functional features I wanted like immutable vectors (or even just functional operations on mutable vectors).

The language is extremely flexible, and you can take advantage of this to write some really elegant and maintainable code. It's one of the more productive languages I've used--of the languages I've used extensively, it's better than JavaScript, Java or Python.

So I liked it quite a bit over all. However, it doesn't quite clear the threshold where I would use the language voluntarily. I thought it had lackluster support for functional programming, especially from what is supposed to be a functional language. This was evident in the library (e.g. the lack of immutable vectors and the like) and also in the way certain pretty fundamental structures (like ports) worked.

Also, for a dynamically typed language, I thought it had too many different types. It was too easy to get mixed up between bytestrings and strings, for example. It was also not obvious when you should use or expect nil vs #f. That said, the features for creating your own types (mostly structs) were very good--I found they were very lightweight but still flexible enough to be useful.

I am actually a big fan of the syntax. Not just the s-expressions (although, with paredit, they are pretty awesome) but also the reader macros. That said, I'm also rather partial to infix operators, which are obviously not present.

So over all, it's a great language. However, I would still choose Haskell or OCaml over it for virtually any project. The main exception would be projects very heavy on metaprogramming, where Racket really shines.

Re:Racket v5.3.2 by _sh on Friday February 01, 2013 @01:12AM (#5149501)
Racket now has all manner of purely functional data structures (Okasaki and Bagwell) available as a library on Planet:

http://planet.plt-scheme.org/package-source/krhari/pfds.plt/...

Re:Racket v5.3.2 by elibarzilay on Saturday February 02, 2013 @10:10AM (#5156128)
Not just now -- this library has been up for a number of years.
Re:Racket v5.3.2 by chimeracoder on Friday February 01, 2013 @07:44AM (#5150423)
> Also, for a dynamically typed language, I thought it had too many different types. It was too easy to get mixed up between bytestrings and strings, for example. It was also not obvious when you should use or expect nil vs #f. That said, the features for creating your own types (mostly structs) were very good--I found they were very lightweight but still flexible enough to be useful.

You can also used a typed dialect of Racket if that's easier - just write #lang typed/racket at the top of your file: http://docs.racket-lang.org/ts-guide/

Re:Racket v5.3.2 by JadeNB on Friday February 01, 2013 @03:12PM (#5153151)
> > Also, for a dynamically typed language, I thought it had too many different types.

> You can also used a typed dialect of Racket if that's easier

I'm not sure that proposing a move to a typed dialect will solve a problem with too many different types. :-)

Re:Racket v5.3.2 by tikhonj on Friday February 01, 2013 @03:20PM (#5153193)
Actually, I think it would. The problem is not too many types per se, but too many types without a good way of managing them. All a static type system is is a good way to manage types!
Re:Racket v5.3.2 by javert on Friday February 01, 2013 @12:59AM (#5149459)
However, I would still choose Haskell or OCaml over it for virtually any project

This might be off-topic, but I've been thinking about learning one of these two. Can you give me any advice on which to learn first (or which to use for what)?

Re:Racket v5.3.2 by tikhonj on Friday February 01, 2013 @01:20AM (#5149530)
Well, I'm a little biased, but I would learn Haskell. It's the one I learned first--in fact, I learned it during my very first college CS course. (The course, coincidentally, was in Scheme.) If I managed it as a freshman, it can't be all that difficult :P.

Haskell has a couple of very good freely available books: Learn You a Haskell[1] and Real World Haskell[2]. I also found Write Yourself a Scheme in 48 Hours[3] very helpful. When I was learning OCaml, I could not find any terribly good resources. That said, it wasn't much of an issue, so I didn't look too hard--learning OCaml after knowing Haskell is very easy. There is going to be a Real World OCaml book at some point, but I think it's still a work in progress.

[1]: http://learnyouahaskell.com/

[2]: http://book.realworldhaskell.org/

[3]: http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...

I also think Haskell is good because it's more of a departure from languages you're probably used to. You can't sink back into your old habits, because everything is done completely differently. Of course, some people find it helpful to have less of a departure from what they're used to, so perhaps you might prefer OCaml because it's less different from normal languages.

I use Haskell for my own projects (and, this semester, for research), and I used OCaml for an internship this summer. I think that for most tasks, they're roughly equally suited. If you want to do multicore concurrent or parallel code, I think Haskell has the edge, but I have not really done much of that in either language.

OCaml has a very good JavaScript compiler called js_of_ocaml[4]. While Haskell does have some options for JavaScript as well like Fay[5] or UHC[6], I don't think it's quite as nice. I used js_of_ocaml during my internship and was very happy with it. So for web stuff, I'd probably go for OCaml. Both OCaml and Haskell have good backend web frameworks, but I haven't really used any of them.

[4]: http://ocsigen.org/js_of_ocaml/

[5]: http://fay-lang.org/

[6]: http://www.cs.uu.nl/wiki/UHC

If you happen to be on windows, installing OCaml is a pain. Haskell, with the Haskell Platform[7] should be much easier, but I haven't tried it myself.

[7]: http://www.haskell.org/platform/

OCaml has a really good Emacs mode called typerex[8]. Haskell has some alternatives like ghc-mod[9] and scion[10], but I've never been able to get them to work. Admittedly, typerex was not easy to install either.

[8]: http://typerex.org/

[9]: http://www.mew.org/~kazu/proj/ghc-mod/en/

[10]: https://github.com/nominolo/scion

Ultimately, you wouldn't go wrong with either one. Moreover, the core ideas are fairly transferable between the two: you'll find that learning OCaml after Haskell or Haskell after OCaml is relatively easy. I would lean towards Haskell, but it's not a big deal.

I just realized that I've written a whole bunch of paragraphs to say very little: either language is a great choice and I just happen to like Haskell more. Hopefully this is not too much of a deluge of information :P.

Re:Racket v5.3.2 by pjmlp on Friday February 01, 2013 @02:19AM (#5149661)
For Windows developers I would advice to use F# instead.

Being a Microsoft language helps smuggle it into the work environment of the enterprise.

It has become my scripting language for Windows tasks.

Re:Racket v5.3.2 by graue on Friday February 01, 2013 @01:30PM (#5152437)
OK, I'm curious now. Wikipedia says[1] the reference implementation is open-source and cross-platform, which is great, but I never hear of anyone talking about F# outside the Microsoft world.

The compiler has to be compiled from source[2] on Ubuntu, which seems to suggest hardly anyone is using it.

Would there be any compelling reason to use F# if you're not working in a primarily Microsoft environment? What does the language itself offer over Ocaml or Haskell?

[1]: https://en.wikipedia.org/wiki/F_Sharp_%28programming_languag...

[2]: https://fsxplat.codeplex.com/wikipage?title=FSharpLinux

Re:Racket v5.3.2 by stonemetal on Friday February 01, 2013 @02:05PM (#5152660)
From what I understand F# works on mono and the F# MS team actually puts in effort to make sure it does. Though for whatever reason mono just isn't that good at running F# code. Maybe it is a weak GC or lack of ability to optimize the code patterns F# produces, I don't know. It is slower than F# on CLR.

Given that, library access and ability to thread are the two big things it is going to have over Ocaml. Cleaner syntax when compared to Ocaml too. Haskell, not much.

Re:Racket v5.3.2 by pjmlp on Friday February 01, 2013 @06:36PM (#5154270)
The GC was not that great, but the new S-Gen is quite comparable to the CLR one.
Re:Racket v5.3.2 by pjmlp on Friday February 01, 2013 @06:33PM (#5154256)
If you're not on a Microsoft shop, then I think OCaml or Haskell might be a better option.

Queries and type providers are nice features of F# 3.0, but not sure how much it would matter as feature.

Re:Racket v5.3.2 by miloshadzic on Friday February 01, 2013 @08:24AM (#5150544)
For what it's worth, OCaml will somewhat soon have a "Real World" book by the guys who've been using it for very real world work for quite some time.

http://shop.oreilly.com/product/0636920024743.do

Re:Racket v5.3.2 by pjmlp on Friday February 01, 2013 @06:34PM (#5154258)
Looking forward to it.
Re:Racket v5.3.2 by amirmc on Friday February 01, 2013 @02:22AM (#5149673)
For OCaml, check out http://ocaml.org for examples and tutorials. There's also http://try.ocamlpro.org where you can actually try some things out without the hassle of installing. OPAM [1] is new package manager for OCaml which, makes dealing with the libraries a lot easier (gotten v popular quite quickly) - it's available via homebrew which made it v convenient for me.

Also, it's worth being aware of the differences between the languages e.g. Haskell is purely functional whereas OCaml allows imperative and OO.

I'm learning OCaml (slowly), and may have a look at Haskell later on. People I'm working with view OCaml as a much more pragmatic language than Haskell, in terms of building real world systems (e.g. Mirage [2]). However, people make cool things in Haskell too, e.g. pandoc [3]

[1] http://opam.ocamlpro.com

[2] http://openmirage.org

[3] http://johnmacfarlane.net/pandoc/

Re:Racket v5.3.2 by tikhonj on Friday February 01, 2013 @02:39AM (#5149717)
Haskell has HalVM[1], which is sort of like Mirage, I believe.

[1]: http://corp.galois.com/halvm

As far as pragmatism and practicality in general, I think the two languages are about equal.

Re:Racket v5.3.2 by mercurial on Friday February 01, 2013 @08:37AM (#5150591)
I found the idea awesome, though I didn't try it in practice. However, the repo doesn't seem terribly active.
Re:Racket v5.3.2 by gnosis on Friday February 01, 2013 @02:13AM (#5149650)
My experience with modern statically typed languages have been primarily with ML and OCaml.

While they have a lot of advantages over neanderthal languages like C, and it's great that once you've gotten your program to compile, whole classes of bugs will be virtually impossible, I much prefer programming in Scheme.

With ML and OCaml, I really hated spending hours wrestling with the compiler and puzzling over obscure error messages that seem to require taking college level courses in type theory in order to understand.

In comparison, programming in Scheme (and even Common Lisp) is incredibly quick and easy, and a real joy.

True, when I need maximal robustness, I do wind up spending a lot more time writing unit tests in Scheme than I would in ML or OCaml. But for rapid prototyping and programming as I think, Scheme is very hard to beat.

Re:Racket v5.3.2 by pjmlp on Friday February 01, 2013 @02:23AM (#5149674)
I think the best way to see the benefit of languages with static type systems is when you work in large team projects.

I do like to use languages with dynamic type systems when doing quick prototypes or small programs on my own, but I wouldn't dare to advice doing our multi-site enterprise projects in such a language.

Specially given how lax offshore teams write unit tests, if ever.

At least with static type languages the product does run. If it does what is required is another matter.

Re:Racket v5.3.2 by seabee on Friday February 01, 2013 @04:05AM (#5149912)
Infix operators can be emulated thanks to a built-in reader macro. Example:

(i . <= . (length lst))

Which moves the stuff between . to the head of the sexpr.

Re:Racket v5.3.2 by eru on Friday February 01, 2013 @02:05AM (#5149630)
Have you tried using contracts in racket?
Re:Racket v5.3.2 by soegaard on Friday February 01, 2013 @10:55AM (#5151414)
You will be pleased to know, that functional vectors are included in the latest release. Look for "array" in the v5.3.2 documentation.