greg
2018-5-12 13:22:56

@ghoetker I’m about to head out the door and not sure I understand the full context of what you want to do. But a couple ideas, one of which may help, idk: - You can use process or process* to start another program. You get its input/output as Racket ports, so you can write/read to/from it. Not sure this fits your echo command. But e.g. I use this in Frog to pipe stuff to a Python Pygments program; it’s faster than system-ing pygmentize many times. - Are you using Apple’s plutil because you couldn’t get Racket’s xml/plist working — figure out how to extract the data you want from the s-expression? If so, someone here (or me, later) could hep you try again with that approach. I imagine that would be fastest of all.


cmscalzo
2018-5-12 14:24:02

@cmscalzo has joined the channel


cmscalzo
2018-5-12 14:25:26

hello, I’m interested in what people are doing to learn Racket - is anyone here available to answer a few of my (quick) questions?


ghoetker
2018-5-12 14:41:25

@greg Thank you very much. I’ll experiment with process. This is actually a preliminary step to convert from Apple’s binary plist format to its text-based plist format. The latter is what I posted about a few days earlier and would, time permitting, love some help navigating that process also. To date, I’ve successfully converted it to an x-expression—although I’m not sure in the best way :smile: From there, however, I got stuck and ended up experimenting to determine that I needed to extract the 3rd item of the 9th item of the 11th item of the 3 item of the x-expression (treating it as just a bunch of nested lists. Somewhere, a Racket developer flinched when I did so, I’m sure.


ghoetker
2018-5-12 14:46:08

@cmscalzo Welcome! I am a fellow beginner, although I’m stunned in the practical tasks I’m already able to accomplish, and would be happy to answer any “So, as a beginner…” questions. For more technical questions, you are also in the right place. Members of this channel have been tremendously helpful in getting me over some “I’m just not getting something…” bumps. I’ll be on and off Slack given some travel, but will respond to any questions as I can. Welcome again.


cmscalzo
2018-5-12 14:54:07

thanks @ghoetker!


cmscalzo
2018-5-12 15:15:01

ok, so here’s what I’d like to ask:


cmscalzo
2018-5-12 15:15:14
  1. why did you decide to learn Racket?

cmscalzo
2018-5-12 15:15:48
  1. are you interested in learning other functional programming languages?

cmscalzo
2018-5-12 15:16:49
  1. why did you pick Racket instead of other Lisp “flavours” like Scheme, Common Lisp, or Clojure?

ghoetker
2018-5-12 16:27:28

@cmscalzo As background, I’m a older vintage academic (33 years experience at being 18), so my first languages were BASIC and Turbo Pascal. Fairly limited programming after that until I started my PhD in Business, at which point I started working with the commercial statisical package, Stata, and its associated DSL. Quite good at that now. I’ve done a reasonable amount in NetLogo, a DSL for Agent Based Modelling (ABM). I have a collaborator on some ABM work who uses Python, which I’ve become decent at reading, but find oddly frustrating to write. Being a long-time Apple fan, I have also done some work with Swift, but nothing too deep.

  1. why did you decide to learn Racket?

(a) Had some practical problems to address programmatically, e.g., managing an overly large BibLaTex file with all my accumulated research material. (b) Being an academic programming for my own purposes, I’m free to use whatever appeals. So, Racket not being mainstream (YET) isn’t a problem. (c) Perhaps because my experience with NetLogo, which has its distant roots in Lisp, something just felt more natural about Racket than Python. (d) Ninety percent of the time, I’ve found it very easy to reason about. (e) I also fiddle with programming just for pleasure. It engages my brain in different ways that my normal work. So, the nice “feel” I get from Racket is important to me.

  1. are you interested in learning other functional programming languages?

Not at this point, although I’ll continue to work with NetLogo (and hopefully get better at it!)

  1. why did you pick Racket instead of other Lisp “flavours” like Scheme, Common Lisp, or Clojure?

(a) Partially it’s just what I encounted first by chance, but I did then look at the other Lisp flavours. (b) Absolutely awesome community! Beyond the help more experienced hands have generously given me, reading the mailing list and Discord is a positive daily experience. Lots of very smart people working together to advance long-term goals, yet still very welcoming to newcomers. Don’t take this as a negative statement about the other communities, about which I don’t have enough experience to judge. (c) Dr. Racket is an wonderful IDE. (d) The Racket website, particularly the documentation, is amazing. Other than NetLogo, which is a more narrowly focused language, I’ve not seen anything close to this useful for any other language. (e) Lots and lots and lots of functionality. I only use about, oh, 30% of what Racket can do and am sometimes overwhelmed by the presence of the other 70%. But, as I’ve gained experience, I’ve come to appreciate the range of what’s available. I was recently geeking out to my son about the options for string-join, for example.


dedbox
2018-5-12 16:36:52

Hi, @cmscalzo! Welcome to the channel. I’ll take a swing.


dedbox
2018-5-12 16:37:09
  1. I learned about Racket in college, as a homework assignment. Racket “fits” my internal problem-solving processes better than other languages and toolchains. It is also customizable in ways other languages are not.

  2. Absolutely. Every language is useful in its own way. Learning Haskell has definitely changed the way I use Racket.

  3. I prefer Racket over Lisp because Racket is a Scheme. My favorite features are its hygienic macros, proper tail recursion, and its lightweight threading/synchronization model. I prefer Racket over other Schemes, mainly because of the community and the effort it makes to be inclusive and relevant.

The docs are excellent and easy to read offline. The tools work as advertised. Things have names that make sense. These things make Racket easy to learn and reliable in practice. Clojure is my least favorite “scheme” because it does these things poorly. Other Schemes tend to focus on being smaller, faster, or highly specialized for uncommon use cases.


cmscalzo
2018-5-12 16:49:22

hi @dedbox - thank you very much, that’s really useful (and I agree, I see Clojure more as a “common lisp” than a “scheme”)


cmscalzo
2018-5-12 16:50:38

can I ask you if there are other FP languages (other than Haskell) that you’d like to learn? (e.g., Erlang, etc.)


hastebrot
2018-5-12 18:24:34

@hastebrot has joined the channel


cmscalzo
2018-5-12 18:31:02

thanks @ghoetker! what did you use to learn Racket? books, videos, …?


dedbox
2018-5-12 18:40:01

@cmscalzo programming languages are a life-long obsession of mine. On the functional side, I’ve learned Erlang, ocaml, SML/NJ, and many “multi paradigm” languages like Scala, Go, and Rust.


dedbox
2018-5-12 18:40:28

Racket is the only one I don’t forget after extended periods of working in other languages.


cmscalzo
2018-5-12 18:45:56

thanks @dedbox! how do you usually learn new languages?


dedbox
2018-5-12 19:00:34

By using it.


dedbox
2018-5-12 19:01:52

Racket’s docs are excellent, but that won’t matter much if you don’t have a way to put the information into a context that you understand and care about.


dedbox
2018-5-12 19:06:24

I started with hobby projects. DrRacket is a pretty good tool for exploring the language. I like to pick a programming task I think I can handle and then just go figure it out. Homework can be a powerful motivator, and I imagine coding competitions would do as well.


dedbox
2018-5-12 19:08:10

Programming languages are usually designed to hit a “sweet spot” that makes solving certain kinds of problems fun or safe. Matching languages to problems is another skill that takes some practice.


philip.mcgrath
2018-5-12 19:09:59

@philip.mcgrath has joined the channel


dedbox
2018-5-12 19:10:28

For example, sometimes I use Haskell to test hairy ideas in a purely functional environment, where the tooling can keep track of many details I don’t care about.


dedbox
2018-5-12 19:13:31

Ocaml is a decent alternative that leverages traditional functional techniques like algebraic data structures and functional pattern matching.


dedbox
2018-5-12 19:15:07

I learned Ocaml in the same class I learned Racket. Totally worth it, but I haven’t written much Ocaml since.


dedbox
2018-5-12 19:17:21

Practically speaking, learning to appreciate these other languages made me wish Racket had some of their features. Racket is designed to be modded, so I keep coming back to it to try to add my favorite features. Usually, the effort fails but my Racket-fu improves.


cmscalzo
2018-5-12 19:42:19

thanks @dedbox!


greg
2018-5-12 22:40:57

@ghoetker Looping back to this: https://racket.slack.com/archives/C09L257PY/p1526009003000240 That’s really weird XML. The info you care about seems like it’s not stored in a very structured way. It’s the <string> elements at index 4 (numbering from 0) that <array> element. Is it documented/guaranteed to be at index 4? If so, you could do this: ;; assuming `plist-xml` is a string with the XML text you pasted above (match (call-with-input-string plist-xml-text read-plist) [(list* 'dict assoc-pairs) (for/or ([assoc-pair (in-list assoc-pairs)]) (match assoc-pair [(list 'assoc-pair "$objects" objects-value) (match objects-value [(list* 'array _0 _1 _2 _3 payload _) payload])] [_ #f]))])


greg
2018-5-12 22:42:51

I don’t love that code. If I needed to work with plists frequently, I might want to make a wrapper around read-plist that produces something using Racket data structures like lists and hashtables. More like the jsexprs that the json module produces from read-json.


greg
2018-5-12 22:43:31

But if you’re looking for get-it-done-dammit, that is one such example.


ghoetker
2018-5-13 03:46:38

@greg Thank you very much. Since I hope this is a one and done project, I’ll probably keep it simple. Seeing the code one would use is a huge boost to learning!


ghoetker
2018-5-13 03:48:07

@cmscalzo I learned Racket through a combination of the intro material on the website, stumbling through documentation while trying to solve specific problems and asking for help on slack or the mailing list when I got stuck.