top | item 40103954

(no title)

joesb | 1 year ago

I'm lost on how should I integrate all these "languages" of Racket into a single application. Like, I can see there are `typed/racket`, `racket/gui` and `scribble/base` languages. But how do I write a GUI application that create PDF while also having all the code be typed? I tried following Racket tutorial multiple times but I'm still lost on how to tied each unrelated "languages" together.

IMO, each chapter of the tutorial just talk about unrelated "language" and then never once show how they all work together. One chapter will talk about web server but not class system, then another chapter will talk about another "language" that support class but then never write web server in it.

discuss

order

cess11|1 year ago

You can think of the #lang line as a kind of compiler instruction with that file as scope. There's much more to it but that's a good starting point. If you have an application and want to add types doing it one file at a time is a good strategy.

Besides the #lang line you can also use 'require to bring in libraries, so a single file could contain GUI as well as web server code. #lang isn't constrained to one language at a time either, if they don't conflict you can just add more to that line.

jbclements|1 year ago

I think this is a fair question. In my opinion, if you're developing a larger application then nearly all of your code will either be in the "racket" language. If you're keen on types, substantial fractions of this may be in the "typed/racket" language. It is true that all of the languages share a common substrate, and they can more or less all interoperate, but it's definitely not the case that a programmer would be likely to break their program into five equal pieces and use a different language for each one. You'll probably write your docs with scribble. Using different languages allows you to have a fundamentally different programming model, and while having that as a backdrop made things like the development of Typed Racket feasible, it isn't something that should prevent you from starting.

TL/DR: Just use Racket. If you find that you really wish that you had some other feature or style of programming, you can investigate whether there's a language that already provides that.

All of this is my opinion, of course.

zelphirkalt|1 year ago

You are supposed to be able to choose for each module the language of the module, I think.