Re:Creating Languages in Racket (2011)
by bmitc on Wednesday February 03, 2021 @07:48AM
(#26013151)
I really wish the Racket team would write a book on Racket’s language making capabilities, or create a MOOC. I attended Racket School 2019, and it was awesome. The material was well put together and walked us through macros to #langs. But the only published material to walk a person through macros and building languages are Fear of Macros and Beautiful Racket.
I have many ideas for little DSLs in Racket, but I am too slow and am slogging my way through learning how to create them.
Re:Creating Languages in Racket (2011)
by disconcision on Wednesday February 03, 2021 @08:43AM
(#26013490)
Agreed that a book would be great, but worth mentioning that the course page for racketschool 2019 itself now provides the current best intro to syntax/parse and DSL making in racket: https://school.racket-lang.org/2019/plan/
Re:Creating Languages in Racket (2011)
by bmitc on Wednesday February 03, 2021 @01:24PM
(#26017131)
That’s a good resource for sure, so thanks for pointing people there. Basically, it would be great to take that year’s Racket School and turn it into an expanded and more streamlined work.
You seem to say, I wish there was a book on X, but there is only this book on X. What more do you want? I don't mean that rhetorically, what additional things would you like to see covered?
Re:Creating Languages in Racket (2011)
by Decabytes on Wednesday February 03, 2021 @01:43PM
(#26017393)
I've worked through Beautiful Racket before, though it's been awhile. I think my main issues are
1. You need to install the Beautiful Racket package, which makes the starting point for creating the languages easier, but is not representative of how it's used in the Racket Docs (not that I'm saying the Racket docs have a better intro)
2. Uses Brain Fuck. It feels like there has to be a language that fits in between unintelligible but easy to parse, and extremely verbose and complex. (It's probably scheme but that's taken in this context)
And sometimes I just need to see the same problem from a few different angles before it will stick. That's why Greg's Fear of Macros wasn't able to take me all the way to a comfortable place with macros.
I think BR is a great book, and I definitely learned a lot from it, I'll probably go back to it at some point to see if I can get it to click. I've been on a Racket kick recently so I've got a decent amount of hours into the language.
Also I'm always struck with a feeling when I'm coding in Racket where I go "Would a dsl be good here?" I know Racket makes it easy but I don't even know about what makes a good dsl, or how certain dsls might be harder than other based on the way Racket does L.O.P. Again this might just be from inexperience.
Lastly I would also like to see some examples of typed languages being created using typed Racket. I know there is the Turnstile library, but from my understanding it makes it easier to created typed languages, but that the possibility was there before. I'd rather learn the hard unabstracted way first before moving to using a library.
Re:Creating Languages in Racket (2011)
by bmitc on Friday February 05, 2021 @03:26PM
(#26040757)
There’s not a book on x in this case, which is why I said what I said.
A language is more than just a reader and expander for toy languages. It also includes domain specific editor functionality and domain specific errors, among other things (like understanding macros and phases at a deeper level).
Re:Creating Languages in Racket (2011)
by ssivark on Wednesday February 03, 2021 @01:15PM
(#26016998)
If you feel like sharing the ideas, I’m sure many people would be interested in seeing potential example applications where this (abstract and somewhat uncommon, in other languages) capability can be put to good use.
Re:Creating Languages in Racket (2011)
by srcreigh on Wednesday February 03, 2021 @02:02PM
(#26017654)
You can go as complex as your own type system. One type system was added to Racket called Typed Racket. No new features were needed in the language or tooling, they just used Racket macros to build a Racket with static compiler errors which integrates with the IDE.
Two similar cases. One is Typescript. That's a new language with different syntax, a new compiler which targets JS. It also provides its own tooling for IDEs. Another is Python. Over time there were PEPs to add syntax for type hints, and now type systems are being added to the language.
When Racket did this, they were able to do it in Racket without adding more features to the compiler or IDE. There's built in support for static analysis, compiler errors, editor integration. Not to mention a way to organize all the information you need to do type checking in the compile steps, and make that information accessible in the right places. The new type safe Racket was built using plain ol Racket.
1. Play around with static analysis checks. I want to rebuild Typescript style structural inference to Racket. I like how TS is unsound (has no runtime performance penalty for mixing untyped code), and is easily disabled via any if it's in the way. I love the focus on great error messages. Maybe one day I will contribute to Typed Racket :)
2. New syntax for creating structs. Racket had structs that are initialized like (point 1 2). What if you want keyword syntax ie (point #:x 1 #:y 2)? What if you want that to work with match too? Do you want a JS-style syntax such as (point #:x #:y 2) which pulls in x as an identifier? You can do all this! The rebellion library is pretty awesome in this regard [1], with some sample usage of it in a script here [2].
Re:Creating Languages in Racket (2011)
by srcreigh on Wednesday February 03, 2021 @03:59PM
(#26019029)
Excellent. Can't wait to try it out.
It's exciting to think of "Deep" checking as a complement to optional checking. Use a mix of both in one code base to play their strengths. For example it'd be great to define a deep type checked module for parsing data. You get static errors and runtime validation too. But, also, use that module from an optionally type checked module, which doesn't add any extra runtime costs if some of your other code / dependencies are untyped.
Re:Creating Languages in Racket (2011)
by iainctduncan on Wednesday February 03, 2021 @12:30PM
(#26016259)
It is certainly true that Racket has a ridiculously low number of books on it that aren't textbooks. It's a real pity. I like Racket a lot, but there is so little focus on use outside of academia that I don't hold my breath on it becoming a production appropriate tool for typical business software.
Re:Creating Languages in Racket (2011)
by spdegabrielle on Wednesday February 03, 2021 @02:46PM
(#26018231)
It’s growing;
Racket Programming the Fun Way
An introduction to the Racket functional programming language and DrRacket development environment to explore topics in mathematics (mostly recreational) and computer science.
Re:Creating Languages in Racket (2011)
by dang on Thursday February 04, 2021 @11:35PM
(#26033156)
I'm sorry you had some bad experiences, but please stop posting repeatedly about this to HN. It's not helping, and the repetition lowers the signal/noise ratio.
Re:Creating Languages in Racket (2011)
by tgbugs on Wednesday February 03, 2021 @12:33PM
(#26016304)
I was sitting at that table during that conversation. I'm sorry to hear that Leondro's experience was not a good one, but he does not speak for everyone that was there, he may have felt uncomfortable but he cannot speak for the others.
To paint a whole community based on those interactions is completely unwarranted. There are political issues within the Racket community as there are within any community, but they are not the ones described here.
In point of fact, because of attitudes like the one expressed by the parent certain extremely valuable, active, and long standing members of the community have ceased to participate publicly because of abuse they have received by, shall we say, new incoming "waux" participants.
Re:Creating Languages in Racket (2011)
by cnasc on Wednesday February 03, 2021 @09:03AM
(#26013649)
I find Emacs with racket-mode much better for editing, but DrRacket has some really nifty IDE features that racket-mode doesn’t have. I probably split 80/20 between them
Re:Creating Languages in Racket (2011)
by JasonFruit on Wednesday February 03, 2021 @08:43AM
(#26013491)
Racket's IDE is pretty good, but it doesn't match the pure editing facilities of Emacs, and racket-mode supplies similar functionality. I use exclusively Emacs for Racket, and other Scheme-like languages.
Re:Creating Languages in Racket (2011)
by spdegabrielle on Wednesday February 03, 2021 @03:04PM
(#26018434)
As the other commenters have mentioned, Racket Mode is excellent, especially racket-xp-mode: “An optional minor mode that enhances racket-mode to explain and explore code.” https://www.racket-mode.com/#racket_002dxp_002dmode
The other thing worth mentioning is Racketeers often use their favourite editor, only switching to DrRacket or Racket Mode when they need specific functionality.
Re:Creating Languages in Racket (2011)
by swatson741 on Wednesday February 03, 2021 @01:56PM
(#26017576)
DrRacket is a pretty good IDE but, it doesn't have the flexibility and consistency of Emacs. A lot learning material for Racket features the DrRacket IDE.
A common pattern for Vim users is to happily code in Vim and occasionally switch DrRacket for specific tasks. And use the command line tools - https://docs.racket-lang.org/raco/index.html
Re:Creating Languages in Racket (2011)
by tenaciousDaniel on Wednesday February 03, 2021 @09:48AM
(#26014008)
I'm currently trying to create a language but have never done it before. I'm a web developer, so I'm writing some reduced test cases in Node, but I seriously doubt that I'd use it for actual parsing.
Racket seems like a good choice; have never heard of it before. Anyone know the pros/cons/alternatives?
Re:Creating Languages in Racket (2011)
by tenaciousDaniel on Wednesday February 03, 2021 @10:26AM
(#26014430)
I'm trying to build a language for UI designers. The goal is to give them a very easy language that allows them to describe visual behavior using grammar and concepts that are familiar to them.
Entirely declarative, low-tech, almost like pseudo-code.
Re:Creating Languages in Racket (2011)
by Decabytes on Wednesday February 03, 2021 @02:50PM
(#26018287)
One potentially untapped potential of Racket that I think about is sort of as a universal language platform. Seeing more already existing languages reimplemented in Racket would be cool. I know the underlying implementations of other languages don't always line up to Racket, and that you wouldn't be able to use the libraries of the language in question, but it could potentially reduce the friction of extending software you love.
You want to extend this piece of software to suit your needs, but aren't a fan of Racket, extend it in a language with Javascript like, Python like, Java like syntax etc (that ultimately compiles to Racket). An example would be a Game Engine in Racket, that has bindings to other languages a la the Godot Engine, or some other piece of standalone software.
Re:Creating Languages in Racket (2011)
by velcrovan on Wednesday February 03, 2021 @01:48PM
(#26017466)
After attending Racket School in 2019, I was able to do a Racket implementation of Tabloid in a couple of days: https://github.com/otherjoel/tabloid ...fun stuff!
I have many ideas for little DSLs in Racket, but I am too slow and am slogging my way through learning how to create them.
You seem to say, I wish there was a book on X, but there is only this book on X. What more do you want? I don't mean that rhetorically, what additional things would you like to see covered?
1. You need to install the Beautiful Racket package, which makes the starting point for creating the languages easier, but is not representative of how it's used in the Racket Docs (not that I'm saying the Racket docs have a better intro)
2. Uses Brain Fuck. It feels like there has to be a language that fits in between unintelligible but easy to parse, and extremely verbose and complex. (It's probably scheme but that's taken in this context)
And sometimes I just need to see the same problem from a few different angles before it will stick. That's why Greg's Fear of Macros wasn't able to take me all the way to a comfortable place with macros.
I think BR is a great book, and I definitely learned a lot from it, I'll probably go back to it at some point to see if I can get it to click. I've been on a Racket kick recently so I've got a decent amount of hours into the language.
Also I'm always struck with a feeling when I'm coding in Racket where I go "Would a dsl be good here?" I know Racket makes it easy but I don't even know about what makes a good dsl, or how certain dsls might be harder than other based on the way Racket does L.O.P. Again this might just be from inexperience.
Lastly I would also like to see some examples of typed languages being created using typed Racket. I know there is the Turnstile library, but from my understanding it makes it easier to created typed languages, but that the possibility was there before. I'd rather learn the hard unabstracted way first before moving to using a library.
I wish there was a long tutorial on DSLs + static analysis, preferably abstract interpretation.
Develop a DSL that is a bit beyond a toy example, and show how to carry out static analysis. All in one place.
I think this would help a lot towards making the goal of Racket, language-oriented design, more popular.
A language is more than just a reader and expander for toy languages. It also includes domain specific editor functionality and domain specific errors, among other things (like understanding macros and phases at a deeper level).
Two similar cases. One is Typescript. That's a new language with different syntax, a new compiler which targets JS. It also provides its own tooling for IDEs. Another is Python. Over time there were PEPs to add syntax for type hints, and now type systems are being added to the language.
When Racket did this, they were able to do it in Racket without adding more features to the compiler or IDE. There's built in support for static analysis, compiler errors, editor integration. Not to mention a way to organize all the information you need to do type checking in the compile steps, and make that information accessible in the right places. The new type safe Racket was built using plain ol Racket.
There's a reasonably accessible paper about this here: https://www2.ccs.neu.edu/racket/pubs/scheme2007-ctf.pdf
So here are some of my ideas:
1. Play around with static analysis checks. I want to rebuild Typescript style structural inference to Racket. I like how TS is unsound (has no runtime performance penalty for mixing untyped code), and is easily disabled via any if it's in the way. I love the focus on great error messages. Maybe one day I will contribute to Typed Racket :)
Making your own compiler error appear in Racket is just 5 lines of code. https://gist.github.com/srcreigh/a0a087adc26e15af0160e8866d4...
2. New syntax for creating structs. Racket had structs that are initialized like (point 1 2). What if you want keyword syntax ie (point #:x 1 #:y 2)? What if you want that to work with match too? Do you want a JS-style syntax such as (point #:x #:y 2) which pulls in x as an identifier? You can do all this! The rebellion library is pretty awesome in this regard [1], with some sample usage of it in a script here [2].
[1]: https://docs.racket-lang.org/rebellion/Data_Types.html [2]: https://github.com/srcreigh/shift-remapper/blob/main/generat...
This is already done. See https://github.com/racket/typed-racket/pull/952 for RFC and https://github.com/racket/typed-racket/pull/948 for the implementation.
It's exciting to think of "Deep" checking as a complement to optional checking. Use a mix of both in one code base to play their strengths. For example it'd be great to define a deep type checked module for parsing data. You get static errors and runtime validation too. But, also, use that module from an optionally type checked module, which doesn't add any extra runtime costs if some of your other code / dependencies are untyped.
Pretty basic, but it helped me a bit.
Racket Programming the Fun Way An introduction to the Racket functional programming language and DrRacket development environment to explore topics in mathematics (mostly recreational) and computer science.
https://nostarch.com/racket-programming-fun-way
What type of material would you like to see?
What parts of the API are you finding difficult?
To paint a whole community based on those interactions is completely unwarranted. There are political issues within the Racket community as there are within any community, but they are not the ones described here.
In point of fact, because of attitudes like the one expressed by the parent certain extremely valuable, active, and long standing members of the community have ceased to participate publicly because of abuse they have received by, shall we say, new incoming "waux" participants.
You must have had a really, really bad experience.
https://news.ycombinator.com/item?id=25941867
Edit: Also Programming Languages: Application and Interpretation, which I haven't been through yet, so can't endorse fully: https://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-0...
[1] https://www.racket-mode.com/
The other thing worth mentioning is Racketeers often use their favourite editor, only switching to DrRacket or Racket Mode when they need specific functionality.
Everything seems to be emacs/DrRacket focussed from what I see.
A common pattern for Vim users is to happily code in Vim and occasionally switch DrRacket for specific tasks. And use the command line tools - https://docs.racket-lang.org/raco/index.html
Works with Clojure, Racket, Fennel and Janet.
Racket seems like a good choice; have never heard of it before. Anyone know the pros/cons/alternatives?
What's yours about?
Entirely declarative, low-tech, almost like pseudo-code.
You want to extend this piece of software to suit your needs, but aren't a fan of Racket, extend it in a language with Javascript like, Python like, Java like syntax etc (that ultimately compiles to Racket). An example would be a Game Engine in Racket, that has bindings to other languages a la the Godot Engine, or some other piece of standalone software.