@samth racket -l tests/racket/test
now works in docker! (the problem was some tests didn’t work when run as root
, and docker runs the container entrypoint process as root and PID 0 by default)
Does anyone know why compose
takes arguments in reverse order?
@slack1 my guess is it’s because it’s standard mathematical composition order. Given functions f
g
and h
composed as g(h(f(x)))
in standard mathematical notation. It is always evaluated inside out so using Racket’s compose
you’d write it as (compose g h f)
I don’t think of it as “reverse order,” but as “let’s move some parentheses around:”
> (displayln (add1 0))
1
> ((compose displayln add1) 0)
1
Note how displayln
and add1
are in the same order in both.
Maybe this intuition helps you too.
I see now
though intuitively, I still feel like it’s natural to think from inner to outer
as A -> B -> C
there might be a library for that (“diagram order”), but I can’t find it right now
@slack1 It’s not exactly compose
, but you might be interested in threading macros: https://docs.racket-lang.org/threading/index.html
mmm very interesting
maybe you can try writing a new function compose*
that takes arguments in a more “intuitive” order, it’ll be fairly easy to write.
Now I think I understand some of the funny arrows I’ve seen in Clojure
@ben, @slack1: @notjack’s point-free
package provides a flipped version of compose
Ah I think the threading library has funny interactions with lambdas -_-a
@slack1 if you want a real function, use point-free
, not threading
threading
is a macro.
what lexi said
if you want a real function but also want the pretty underscore chaining syntax, use the thrush
function from point-free
combined with the fancy-app
package for pretty lambdas
actually whoops
thrush+
is for that
if you want to thread into a lambda with threading
, wrap it in extra parens, e.g. (~> 3 ((lambda (x) (+ x 2))))
thrush
is the reversed version of compose
ohhh I see
(thrush f g h) == (compose h g f)
(thrush+ x f g h) == ((thrush f g h) x)
But am I wrong in saying that threading is like an official library of Racket, and thrush is someone’s personal library on Github?
no, threading is my library; it isn’t official.
that would be correct; also thrush is part of point-free
which is my library
fwiw both lexi and I also work on standard racket libs so we’re not entirely inexperienced :)
speak for yourself :)
ohh whoaa I see
im pretty sure I’ve seem at least some commits from you to stuff in the main dist
then again, my memory is not so good
yes, I’m just teasing re: “not entirely inexperienced”
why is it called thrush
?
birds
birds
??????
Birds
Ah a songbird
there’s a book called To Mock a Mockingbird that’s about the combinator calculus
and it assigns bird names to a bunch of combinators
lol
I’m only on the barbers chapter
looking back, calling it thrush
in the point-free
package is more “cute” than “useful”…
I thought it was a technical term I never heard of hehe
Something from the deep lore of category theory
in your defense, the bird combinators are pretty related to category theory
err, *unrelated?
I don’t think the bird combinators are very related to category theory
They’re compositional patterns for morphisms. At least, I think I remember reading something forever ago claiming the two were related and that thinking about their relationship is useful. I don’t exactly do much category theory…
oh, maybe… but then again, everything is related to category theory if you try hard enough. they definitely don’t come from category theory.
oh definitely
@edwardsayer has joined the channel
@nickr500 has joined the channel
@lexi.lambda I respect your opinions because you have so much experience programming. But I’ll tell you what. I’ve been trying to learn Haskell as my first real programming language, and it’s been extremely tough. Would you say as someone who’s learned Racket, Haskell, and probably many other languages, that I’m making a reasonable decision? I’ve talked to a ton of people in the Lisp and FP world—everyone has their opinions. That alone is perhaps more fascinating than actual programming. Perhaps there’s no true one road or way to learn, but I’m open to opinions. Some people tell me learning Haskell is easy with the right tools. I’ve yet to see anyone learn it easily—or probably any language for that matter.
I love Racket as a language, but I feel like if I want to make money doing this, it may not be the right decision. Then I think—if I invest so much of myself into one language, will I have the same bias? At that point, I suppose I’d have to think my way out familiarity. I realize Racket is an educational/academic language—well—sort of like Haskell (don’t say that to Haskellers!), but I suppose it’s interesting some of the most advanced languages originated as academic languages or remain so.
I would not personally recommend learning Haskell as your first language
@dustin do you want to pick up an “industry” language that’s slightly functional-ish and easy to get jobs with or a language that’s much more functional and you have an alright chance at getting a job with if you’re in the right area?
for the latter, I think clojure’s got a shallower learning curve than haskell while still seeing much more industry use than racket
Here’s a better question. What path would you take knowing what you know now? I’m going to guess you’d say Racket; I could be wrong. But one of the nicer things about Racket, I think, is the documentation, and how you can create a language of your own. I’ve also thought about learning JavaScript well enough and then moving onto PureScript. But then, I get a bunch of other varying opinions. Some feel learning PureScript is doable—others think you need some other FP experience. I feel like Haskell is so minimal and foreign, it’s hard to grasp because of that. PureScript is probably similar in that regard. Elm makes it easier, but then I get the feeling of using something dumbed-down.
For a first language, it’s a good idea to use a simple language. You’re trying to learn how to program, not how to use this particular brand of hammer.
(This is why the HTDP course doesn’t use Racket as its language but, instead, languages designed specifically for teaching.)
@notjack that’s a really great question. I’ve thought about Clojure, but when you say shallower, what sort of resources are available? I’ve only somewhat researched Clojure. Most of my efforts are shattered after talking to a few Haskellers.
if you’re learning to program, I second @jaz and recommend How to Design Programs and its teaching languages.
Alright, thanks. I realize a lot of this stuff is subjective, but I do like how friendly and less opinionated the Racket community is.
@dustin I’m not super experienced with clojure so I don’t know. My limited experience did find the docs for most of clojure very lacking, especially when compared to racket’s docs
but @jaz is right, racket is probably the best way to go if you’re looking to first learn programming, especially structured programming on projects that are more than just toys
You’ll find, eventually, that learning a particular language is easy. The important stuff that you learn while working with one language will (mostly) transfer over to another. There are some things, though, that you’ll only learn from exposure to multiple languages. You know this already, of course, but, for example, if you only work with untyped languages, you may find type systems hard to grasp.
A great deal of the complexity that you find in languages has little to do with good programming.
Is there a where to go from here section in HTDP?
There is [http://www.ccis.northeastern.edu/home/matthias/HtDP2e/part_epilogue.html#%28part._moving-on-devs%29], though I’m not sure if it’s quite what you’re looking for.
This is a really great point.
This is a seriously good quote from that section:
>Some of you wanted to see what computing and programming are all about. You now know that computing is merely a generalization of calculating, and you may sense how useful program design is to you. Even if you never develop programs again, you know what distinguishes a garage programmer from a serious software developer. When you interact with developers as a professional, you know that systematic design matters because it affects your quality of life and the bottom line of your business.
Think I’ve been talking to too many of those.
I wanted to like the Scala language, but every time I’d mention it around a Haskeller, they immediately say something like: Scala is dishonest about what it can do, it’s a horrible language—no one should ever use it— on and on, etc.
I think one of the things I look for in languages/libraries/tools (at least in my experience with frontend), is the support system, documentation, all of that. I think the Racket community understands this. Alexis made a post about documentation and I thought she summed that up nicely:
It’s probably one of my single most regarded ways in making decisions: quality of life—that’s a great way to put it.