4 ms·
It seems most people here have never used (and not tried) racket. I decided to use racket for my little sides projects, as replacement for scala and clojure.
by bad_login 12y ago
It seems most people here have never used (and not tried) racket.
I decided to use racket for my little sides projects, as
replacement for scala and clojure.
I choose it because it was clear for me i can't stand limitations
other language impose to me in way of style and boilerplate, the
racket macro (aka syntax transformer) system is the most advanced
i know to reduce the boilerplate to a minimum and so just write
what i want to express. In facts i rarely write macro because
writing a good macro demand you take care of errors syntax, i am
lazy in the bad meaning of the term.
I choose it because it's dynamic typed and i get more convinced
that type go on your way most of the time (expect complex
algorithms)(i write little projects, so refactoring argument is
out). It enable me to write code and eval it on the fly with
geiser (using enter! on the back), after eval the new function i
test it in the repl, hack until the function meet the requirement
copy paste from repl and boom i get a unit test. Because it as
eval and it will become handy one time in your programmer life
for sure.
I choose it because of it's sexpr syntax, as a heavy user of
emacs i know that other syntax is a pity.
Also because it has (and i use):
1. llar parser (implemented through a macro).
2. A pattern matching nothing to envy scala or clojure deconstructs.
3. An optional type system.
4. A contract system.
What i find hard as a new comer (to racket, not as a programmer
already now scala, clojure, half of c++ :), php) is
1. The broadness of the features the language offer, which
feature to use e.g.: class or generics.
2. The documentation is rich but lack of examples for the common
cases, so you need to read the doc of the function (sometime it's
huge).
3. Understanding how racket module works is quite hard and you
have the documentation, if you don't plan to play with the macro
expander (the stuff that run your macro) and some dynamic
features you don't really need to.
4. You need to 'register' the errortrace library if you want a
stacktrace, quite a surprising behaviours for me.
My opinionated conclusion:
Racket is the best language design i ever see, it's hard to learn
but make you feel learning an other language will just become to
learn a new sub-optimal syntax. Sadly the ecosystem is lacking
libraries and peoples and i am not helping in this way.
- samth 12y agoI'm glad you like Racket, and you're right about some of the weaknesses, especially in providing guidance and examples for how to do things. I have questions about points 3 and 4. For 3, do you mean it's hard to figure out how the implementation of something works, especially when that something is a complex macro? If so, I can't disagree. For 4, if you just run Racket programs at the command line, you should get stack traces (although less nice than the ones errortrace provides). Do you not get those?
- bad_login 12y agoFor 4 if i run from the command line (racket 5.93) i just get the contract violation message, which don't provide positional informations, it's not usefull when you have a list contract error with dozen of uses in a file. For 3 i mean the words like 'visiting', 'instantiated', the phases, the syntax transformer there are many things to grasp. For instance i used to believe that phase 1 bindings where the functions executed by the expander instead of the one defined by define-syntax. For complex macro i just expand it that's fine. Other point the continuation is hard to grasp, i really understand when i see http://www.infoq.com/presentations/continuations-web-os http://www.infoq.com/presentations/continuations-web-os, the key point that help me is the fact he mentions continuation capture also the exit. Another flaws i didn't mention is messages of typed/racket could be hard to understand especially one involving parametric function, this problem occur time to time in the mailing list. I know you take this kind of problems seriously. A point why i like racket is because it's lexical scoped but also let me precise the portion i want more dynamism in with parameters or with eval + namespace. Racket also miss some tooling the one come in mind is coding standard checker and formater, it could be done with free-identifier=? and have some rules. New macro could write their associated rule as metadata in a submodule. Is it doable, i mean technically not the fact to expect macro writer will write such rules?
- samth 12y agoThanks for the feedback. Certainly there are lots of complicated concepts to learn in the macro system. On 4, if I run this program: https://gist.github.com/8fbc12877e2639c5f94c https://gist.github.com/8fbc12877e2639c5f94c I get a backtrace like this: [samth@huor:~] r ~/tmp/x.rkt /: contract violation expected: number? given: '(1 2 3 400 500 600) argument position: 2nd other arguments...: 6 context...: /home/samth/tmp/x.rkt: [running body] There's no other stack frames because `average` is inlined, but if you have more complicated functions you should get more stack frames.
- MrBuddyCasino 12y agoAh, someone with Clojure experience. I wanted Clojure to be my next language to learn, so now I'm curious why you ditched it in favor of Racket? Especially: - Whats the concurrency story for Racket? - If I wanted to code my REST endpoints in Racket, are there competitive libraries available?
- logicchains 12y agoRegarding the Racket concurrency story, it has places; http://docs.racket-lang.org/reference/places.html http://docs.racket-lang.org/reference/places.html. "A place is a parallel task that is effectively a separate instance of the Racket virtual machine. Places communicate through place channels, which are endpoints for a two-way buffered communication." So places are somewhat like Erlang processes. Distributed Places are also interesting: http://docs.racket-lang.org/distributed-places/index.html http://docs.racket-lang.org/distributed-places/index.html
- seabee 12y agoPlaces are about parallelism. For concurrency specifically, the most interesting features are threads, channels, and futures and can all be found here: http://docs.racket-lang.org/reference/concurrency.html http://docs.racket-lang.org/reference/concurrency.html Distributed places is pretty cool, however!
- MrBuddyCasino 12y agoThanks. So basically we get most of what Java has to offer plus thread mailboxes, which is nice. Not sure what to make of Places though - zeroMQ exists and has Racket bindings, is there something Places is better at?
- bad_login 12y agoI ditch clojure because i wanted something with a more meta-language capabilities (syntax object + racket macro), it also as a llar parser and a lexer lib which i needed when i made the choice. For the libraries you can checked out yourself at http://pkgs.racket-lang.org http://pkgs.racket-lang.org, for what i do i don't need one of the library. For concurrency keep in mind that racket use green thread where clojure use jvm thread so OS thread in openjdk. I don't what you want to do with clojure, but i think it is a best choice than racket. Clojure as a very opiniated way of how you should write a program and this view reflects in propably every clojure library. The documentation in clojure is lacking but it provide the implementation (on the web page) so the learning is imho faster especialy if you are new commer to functional programming. The other advantage is the leverage it get from the jvm in term of performance use of the java lib.