sorawee
2020-9-23 07:51:22

The recommended way now is to use React Hooks, which doesn’t use class.


sorawee
2020-9-23 07:52:06

Oh duh, just saw that @soegaard2 also mentioned Hooks below.


sorawee
2020-9-23 07:53:04

(Btw, I meant, recommended way from React people)


blerner
2020-9-23 10:57:16

When scribble renders images, it appears that it surrounds them with a 3px blank border. Is there any way to get it to not do that? (E.g., rendering (circle 40 "outline" "red") generates an 86x86 pixel image, instead of the 80-pixel image I’d specified.)


blerner
2020-9-23 11:00:02

I think I’ve tracked it down to add-padding in html-render.rkt, but it’s private and doesn’t seem to be parameterized….


blerner
2020-9-23 11:18:46

I’ve tried tracking it down further and found convert-bounds-padding which seems to imply the 3px border, but when I tried using it in scribble, i.e. (paramterize ([convert-bounds-padding '(0 0 0 0)]) (circle 40 "outline" "red")) , I get the same result as before.


blerner
2020-9-23 11:31:40

I’ve hacked around it for now by using pict’s inset to shave off those pixels, but that seems like a hack…


spdegabrielle
2020-9-23 13:28:41

is there a racket package like PyInquirer? I’ve found charterm, but my search-fu has failed me for finding a package that does the textual UI stuff. dialogs, defaults, Y/n, etc.


smatuszeksa
2020-9-23 17:17:55

@smatuszeksa has joined the channel


soegaard2
2020-9-23 17:32:36

@leif Here is a simple example of using React Hooks with Urlang. There are three examples in one. Change App between App1, App2 and App3 to see the three versions. The example is written to use one file only (just to make the example self contained).

https://gist.github.com/soegaard/0622c798426f2aef168b6d4dc6568ca5


leif
2020-9-23 17:49:07

@blerner Is it possible that its due to scribble’s css file?


leif
2020-9-23 17:49:30

And if you extend the file you can remove the border?


leif
2020-9-23 17:49:42

@soegaard2 OOOH, thanks. :slightly_smiling_face:


blerner
2020-9-23 17:49:52

no — it’s literally due to how convert handles picts


leif
2020-9-23 17:52:18

@blerner Ah, okay, I see. The problem is probably that your parameterizing convert-bounds-padding around the instantiation of the pict, rather then during the rendering (or rather, where the convert is happening.


leif
2020-9-23 17:56:52

@blerner I presume you’re rendering from the command line?


leif
2020-9-23 17:57:10

(If you’re using the render API directly you can just paramterize around the call to render.


blerner
2020-9-23 17:57:30

yes, scribble 2500f20.scrbl from the command line, basically


leif
2020-9-23 17:57:42

If you are running it from the command line, I think we’ll need to convert it the pict to an image directly so the renderer doesn’t touch it.


leif
2020-9-23 17:58:08

@blerner Okay then, one last question:


leif
2020-9-23 17:58:12

How did you notice this?


leif
2020-9-23 17:58:32

I think I can get this to work for you, but I honestly wouldn’t have noticed a 6 pixel difference.


blerner
2020-9-23 17:58:49

leif
2020-9-23 17:58:55

Which makes it hard to test if I’m write (short of setting up a proper pict testing harness.)


blerner
2020-9-23 17:59:10

asked students to copy and paste images into their file (since we didn’t need to give an entire starter file), and it also specified some pixel dimensions


blerner
2020-9-23 17:59:13

so students got confused


leif
2020-9-23 17:59:13

I don’t have the username/password for that page


leif
2020-9-23 17:59:20

Ah, okay.



leif
2020-9-23 18:06:50

@blerner Actually, how did you get scribble to keep the pict’s relative size?


leif
2020-9-23 18:07:18

Like, when I use scribble to render (circle 40), the image ends up being twice the size (92 pixels rather than 46)


blerner
2020-9-23 18:08:26

we’re not doing anything fancy — literally just inserting a 2htdp/image into the scribble and letting it render. that 2x is coming from the pict@2x render mechanism, I think


leif
2020-9-23 18:08:35

Anyway, if you just put pict->bitmap in front of your pict, it should not add extra padding.


blerner
2020-9-23 18:08:56

if you’re on an hidpi computer when you render, it’ll do the 2x resolution thingy


leif
2020-9-23 18:08:57

Ah, ya, that makes sense.


leif
2020-9-23 18:09:55

Although if you’re using 2htdp/image that would make it harder to use pict->bitmap….one more moment.


blerner
2020-9-23 18:10:24

not urgent right now; I’ve already worked around it for today, and need to focus on other parts of fundies for the next hour or twelve…


leif
2020-9-23 18:12:26

@blerner Oh wow, it looks like pict->bitmap actually does work on 2htdp/image images.


leif
2020-9-23 18:12:30

So ya


leif
2020-9-23 18:12:44

Anyway, g’luck on the rest of fundies.


caente
2020-9-23 18:16:18

how frequently you guys create new langs to solve problems? DSL are discourage in many production environments, arguably because most langs I’ve seen it discouraged do suck at DSLs (Scala and Java), but I also heard that it is frown upon generally. The common arguments are, I think, that to make a “new” lang that is expressive enough to help newcomers to the codebase is actually harder than write whatever libs in the base lang, since it is easier to just figure out what a random method/function is supposed to do (even more if we keep them short and to the point) I’m new to Racket, and the idea of custom made langs intrigues me, but at the same time, I cannot imagine what features of the platform could “erase” the problems that I’ve seen associated to DSLs


greg
2020-9-23 18:27:21

I really don’t do this much. So you should listen more to other people, who have, than to me. Having said that:

I’ve seen domain-specific libraries that are obscure and difficult, particularly for newcomers who are new to the domain.

So I wonder if the newcomer-problem is really orthogonal to it being a domain specific “language”?


greg
2020-9-23 18:28:48

In fact, I might say, it’s kind of the opposite. In the beginning is some domain-specific library. It is refined over time, hopefully. But still, it’s challenging for newcomers.

And so maybe someday you try to turn it into a domain specific language. Try to make it easier. Formalize it. Document it.


greg
2020-9-23 18:30:36

Keeping in mind that Racket has macros, and so some domain specific languages might start off as a collection of functions and of macros to “sugar” and ease the usage.


greg
2020-9-23 18:30:58

And so a kind of natural next step is to make it into a language.


caente
2020-9-23 18:31:39

yeah, I think the main hindrance of DSLs is that, when you inevitably find a scenario for which the DSLs is insufficient, people end up falling back to the base lang, and at that point, the whole code base gets weird, but you make a good point, perhaps a DSLs should be the result of the refinements to a lib


greg
2020-9-23 18:31:41

But if you’re solo, maybe there’s no point to a lang. Maybe the value is with teams, and production environments, where you have newcomers and your software has a culture that needs to be learned.


greg
2020-9-23 18:32:35

A couple interesting links:



caente
2020-9-23 18:32:47

yup I am currently doing BR :slightly_smiling_face:



greg
2020-9-23 18:33:19

The latter has thoughts from people who know what they’re talking about, unlike me armchair theorizing. :smile:


caente
2020-9-23 18:34:37

I am essentially “sold” on learning Racket because making new langs, I have been thinking for a while that indeed, when we make libs, what we want to do is a new lang for the current domain, my hopes are that Racket does solve whatever problems other langs have with DSLs, but I am an impatient person, and wanted to ask around for real life examples…


caente
2020-9-23 18:34:49

(I also clicked the second link)


soegaard2
2020-9-23 18:42:26

@caente The line between a “language” and a “library with macros” is blurry. In other languages you can’t introduce new binding constructs, new definition forms nor new control forms. Adding these would result in a “new” language. In Racket is normal to introduce such forms as macros in a library. At times some take the plunge and invest in new, custom syntax - but usually it’s sugar on-top of a standard Racket library.


caente
2020-9-23 18:47:00

interesting, but there is a serious push for the language oriented programming thing right? it is what brought me to Racket


soegaard2
2020-9-23 18:55:43

Yes, the infra structure in Racket is just right for that purpose.


caente
2020-9-23 19:14:22

interestingly, after just a couple of weeks, I have not only got used to the parenthesis, they do in fact seem a more sensible syntax, hopefully this won’t be just a short honeymoon…