Live data from Hacker News

A Haskell Programmer Tries to Learn Racket

artyom.me

151–160 of 163 posts

Re: A Haskell Programmer Tries to Learn Racket

#151
post #74
post #10

One note: > Racket's default IDE is better than GHCi and probably on par with Emacs (you almost certainly can configure Emacs to be better than anything, but it's not trivial and people don't bother, while DrRacket provides autocompletion and documentation out of the box). Last I used it (a few years ago), DrRacket was very laggy, so I would find it very hard to use for a serious project. YMMV, maybe it's improved.

I actually found DrRacket very fast and Emacs very slow, on every computer I've tried them on. Why might this be?

Emacs Lisp is interpreted (or byte-interpreted), and (GNU) Emacs is written almost exclusively in it, so startup can be dog-slow. Once it's up and running, though, I've always found it pretty snappy.

Re: A Haskell Programmer Tries to Learn Racket

#152
post #139

Earlier quoted context omitted.

Here are some of the bits I read as inconsistent. "Node is popular because it allows normal people to do high concurrency servers." vs "If my job was keeping Twitter up, of course I'd using a robust technology like the JVM." ==> So Node is not actually good for high concurrency servers? "I want programming computers to be like coloring with crayons and playing with duplo blocks." ==> The wonderful wonderful thing abo…

I guess that I don't feel these so painfully because I don't think Node is necessarily successful at it's goal, though I believe its goal is admirable. CPS might not be the most elegant way to schedule threads, but it is fairly simple which is one kind of boon. I'm also pretty sure that high concurrency means a variety of things allowing a distinction between Node High Concurrency capability and Twitter High Concurre…

I mostly agree with everything you say. I think it's sad that so many in our industry use such poor tools. Racket, for example, is an excellent tool for beginners. The PLT group that produces it has long had a focus on introductory programming and has produced resources such as HtDP (http://htdp.org/) and Bootstrap (http://www.bootstrapworld.org/) yet Racket is far more capable than Node, Ruby, and the like.

Re: A Haskell Programmer Tries to Learn Racket

#153

Earlier quoted context omitted.

Ugh, please let Common Lisp be. There's enough bondage & discipline languages already so it is nice to have CL on the opposite side of the spectrum.

Why would anyone need CL when we have JavaScript?! I think the latter has even less bondage & discipline in it.

And you can even sweeten it with hygienic macros ;) (http://sweetjs.org/)

...but to be honest, in everyday work Javascript feels a lot like a bondage and discipline language, because it lacks so many features and in practice you always use a restrictive "coding guideline" and a linter configured for the maximum strictness you can have, so you end up with a pretty verbose, retarded and restricted dynamic language. In order to keep your sanity and be able to work in a team in Javascript you basically have to throw away the baby and keep the bathwater to work with :)

Re: A Haskell Programmer Tries to Learn Racket

#154

A friend of a friend has considerably code in Scheme, Common Lisp and Clojure, when you ask him which is the true Lisp, guess what will he answer? Haskell! Haskell does really create a big impact on some developers. Just an anecdote ;)

I think it can't be "the true Lisp" without cleaner macros. Of course, that doesn't stop Haskell from being a great Haskell.

I do prefer Racket macros to Template Haskell, but you can do some of the same kind of things in Template Haskell. Go ahead and play with it for it for a bit.

Mostly, you need to have the data-structure it defines for the parse tree, and it's harder to convert than syntax->datum. Also there's the Q monad, to generate new safe names. But it works pretty well.

Re: A Haskell Programmer Tries to Learn Racket

#155
post #38

Earlier quoted context omitted.

Naughty Dog has used Racket as a scripting language in several of their video games for the PS3.

Slightly misleading, they don't actually run Racket on the PS3. IIRC, they created a DSL for game logic in Racket and wrote a special compiler for that DSL. That's still a good example of a "real" program written in Racket, but it doesn't prove that Racket is a good choice for programs that need all the resources they can get.

Ah, I didn't realize that. Very interesting.

Re: A Haskell Programmer Tries to Learn Racket

#156
post #28
post #19

Earlier quoted context omitted.

V8 vs Racket: http://benchmarksgame.alioth.debian.org/u64/benchmark.php?te...

Yeah, but I've basically never seen anybody suggest that Racket is a great language for prod.

Also, Hacker News is written in Arc, which runs on the Racket runtime. It handles quite a bit of traffic every day.

It's an ugly-ass buggy website, but that is largely to do with the implementation and PG's propensity for live-modifying production sites in the REPL and not the runtime itself.

Re: A Haskell Programmer Tries to Learn Racket

#157

Earlier quoted context omitted.

> It's pretty common to want to write something like [. . .] without wanting to destructure a list or use the call-values hack. This makes no sense. You want feature X (the ability to return multiple values) without having to either (a) pick apart a simple structure containing those values or (b) assign names to those values, letting the runtime system pick them apart (or never stick them together, its choice) for yo…

> This makes no sense. You want feature X (the ability to return multiple values) without having to either (a) pick apart a simple structure containing those values or (b) assign names to those values, letting the runtime system pick them apart (or never stick them together, its choice) for you. I was actually aiming for (b) here, just incorporated directly into the normal function call and return syntax. Why shouldn…

I still don't see how you're advocating a solution of anything other than call-with-values under a different name.

I don't know Racket itself, so let me switch to common lisp which has the same "problem"... except it comes with a super-simple macro to do exactly what you want, apparently:

(multiple-value-bind (quotient remainder) (floor x y) ;; some code referring to quotient and remainder )

which (excepting perhaps edge-cases I'm not considering, and definitely excepting some error-checking) is just

(defmacro mvb (vars form . body) `(multiple-value-call (lambda ,vars ,body) ,form)

The same thing should work in Racket, modulo syntax and names.

Asking a lisp programmer to do everything with special forms/primitive language elements is like asking a Haskell programmer to do everything in the IO monad. Sure, it's possible, it will work just fine; but... it's just wrong.

By the way, the existence of the #'values function by no means implies there's some data structure being created; indeed, that's the whole point of the #'values construct. Anything you could do with #'values you could do in a list which you then destructured; #'values is to be used when the common-case is to throw away the "structure" and just use each value individually or not at all, like with the return values of #'floor. So in fact #'values is exactly what you want; I'm not sure why it's a "hack" when lisp programmers write it under one name and "the solution" when you write it under a different name.

Ah, it occurs to me that maybe racket doesn't work like this, but in common lisp at least, the transiency of values can be seen in that when you say, e.g., (+ (floor a b) c), the remainder of a/b is thrown away; just the first value is used. That's another huge benefit over structures-to-be-destructured, but obviously doesn't work if the extra values are always important.

The point of my discussion with Maybe is that /even if/ it's just a nullable pointer, conceptually it's essentially a [restricted] tuple. (pointer-is-null,data). There's still two pieces of data there, even if the representation of one of them is cleverly folded into generic object representation or what-have-you. By definition it can't be done with a single piece of data: (Maybe a) is not the same type as (a), for all a. Even if (Maybe Word16), e.g., were represented in a single value at a single place in memory, that value would have to hold more than 16 bits. Then it's viewable as a... tuple, again; one element in 16 bits and the other in the remaining bits.

Re: A Haskell Programmer Tries to Learn Racket

#158
post #139

Earlier quoted context omitted.

I guess that I don't feel these so painfully because I don't think Node is necessarily successful at it's goal, though I believe its goal is admirable. CPS might not be the most elegant way to schedule threads, but it is fairly simple which is one kind of boon. I'm also pretty sure that high concurrency means a variety of things allowing a distinction between Node High Concurrency capability and Twitter High Concurre…

I mostly agree with everything you say. I think it's sad that so many in our industry use such poor tools. Racket, for example, is an excellent tool for beginners. The PLT group that produces it has long had a focus on introductory programming and has produced resources such as HtDP ( http://htdp.org/ ) and Bootstrap ( http://www.bootstrapworld.org/ ) yet Racket is far more capable than Node, Ruby, and the like.

Complete agreement... A world where Racket was in browsers instead of Javascript would be wonderful.

Re: A Haskell Programmer Tries to Learn Racket

#159
post #66

Earlier quoted context omitted.

I mean, it's neat that you can build everything out of cons, in the sense that it's neat that Turing machines and the lambda calculus can perform any computation, but that doesn't mean it's a good idea to so in your code, any more than encoding numbers with Church numerals. Why use alists when you can use hash tables, why use... weird SICP-style struct list things when you could just use structs/vectors, etc. >Hash T…

> I wonder what Clojure programmers do here. About the same. (defn message [text & {:keys [style color]}] ...) (message "Text" :style :bold :color :red) Because typing those extra two brackets is apparently too much trouble.

I would just accept the hash, I think a lot of us prefer it to the pseudo keyword args.

    (defn message [text {:keys [style color]}] ...)
    (message "Text" {:style :bold :color :red})
To the person asking, that {:keys [style color]} is destructuring, it's not required, but it's nice, it's equivalent to doing:

    (defn message [text opts]
       (let [style (:style opts)
             color (:color opts)]
          ...))

Re: A Haskell Programmer Tries to Learn Racket

#160

Earlier quoted context omitted.

The one good thing about the packaging system is that each dependency is its own version, so you can easily load different versions of the same package.

I'd have to check again, but I looked for specific versions of a JS file and found it repeated multiple times throughout the forest of node_modules. If side-by-side is desired, then just suffix the folder with a version name. foo.js-1.1 and foo.js-1.0 can be in the root and reused by every package that needs either. Maybe it does that and I didn't understand what I was looking at.

It's quite naive about it, so it will copy them over and over again. Supposedly there are tools that make everything in node_modules symlinks to the same files.

It's not exactly an advanced and polished system, but it still has a feature that is hard to get with others.

Post reply on HN