Fork me on GitHub
#off-topic
<
2023-11-30
>
James Amberger02:11:44

suppose you have a very long string, several MB say, and a list of short strings (10-100 chars say), maybe just a couple but maybe several hundred or a thousand, and you want to get back the long string with all instances of all the short strings elided. What are some viable approaches?

hiredman02:11:56

You compile the short strings into an automata, a regex really that is an or of all of them, and walk the regex (starting a new matcher on each character) over the long string, discarding matchers that can't match. As you feed characters into the matchers, also copy the characters into a stringbuilder, deleting from the stringbuilder on a match

hiredman02:11:57

There are third party alternative java regex libraries that might be nicer to work with for this than java's built in Pattern, but I am not sure

hiredman02:11:59

You might also be able to get rid of running multiple matchers

hiredman03:11:31

Oh right, I forgot you can't feed a character at a time to java's in built regex

p-himik08:11:33

Isn't what you describe exactly what String.replaceAll already does? Assuming you feed it stuff like (str1|str2|str3|...).

👍 2
James Amberger17:11:57

Okay, makes sense. Is there a way to compile a regex, an x such that (x coll-of-strings) gives you the str1|str2|… you need?I mean besides some editor trick + eval

p-himik17:11:01

Just (str/join "|" coll) (assuming none of the strings have characters that are special to RegEx) and then call re-pattern on it.

mauricio.szabo04:11:20

So.... I just did something crazy. I was quite mad about the lack of Solid and other frameworks' support for ClojureScript... so I decided to try and make a macro that invokes Babel to generate some code from JSX. After a lot of attempts... I think I have a prototype!

🆒 5
🚀 6
Martynas Maciulevičius14:11:59

What does it mean? Does it mean that now you can take CLJS and convert it into JSX so that later it would be converted into what Solid framework understands? Or does it mean something else?

mauricio.szabo15:11:00

It means that we can take a hiccup form, and it'll generate JSX and send to Babel in a single step, generating a valid JS on the other side. It basically is a macro that makes what Babel does, so it happens before ClojureScript's compilation. The great thing about this (if it works on most cases) is that every super-power that Clojure have still works - in this prototype, I still have REPL support, hot-reload, etc

5
mauricio.szabo20:11:22

I'll try to fix some edge-cases and make a talk about it

🎉 1
Thomas Cothran16:11:43

I'm interested in some feedback on the idea of using cognitive development models for understanding how software engineers think about design. Why do different developers have spontaneously different reactions to, say, the distinction between "simple and easy", or to the significance of reducing coupling and increasing cohesion? Psychologists like Jean Piaget use cognitive development models to show how different sorts of understanding rely on prior cognitive skills. These cognitive skills are arranged into levels, such that, if one is on a lower level, the conditions for understanding higher level concepts aren't there. I think the same sort of explanation is useful for explaining the divergences in the opinions and practices of software developers. I've put together a sketch of what I think the levels are https://gist.github.com/thomascothran/c7152559da0dfbe862236e495b5d1467. Does this ring true? Are there better models out there?

mmer16:11:48

One of things that I find intriguing is that often developers are programming in one model while holding a completely different model in their heads. I find this is particularly true with clojure as you pass a data structure through different functions you have to hold the model in your head. (yes I know you could use spec to describe it - but ...) I also think this is true of meta programming where you have to hold two models in your head while writing the macro or meta program.

seancorfield18:11:46

Interesting that you should arrive at three levels/categories. Back when I was on the C++ Standards Committee, we joked that there were three levels of programmer: public, protected, and private that somewhat corresponded to your three levels. A public programmers assembles solutions from the building blocks they have without necessarily understanding how they work or the tradeoffs involved in the different ways of assembling them. At the other end, a private programmer has much more understanding of both how software "works" at a fundamental level but also how to design and build robust software that can withstand change and/or be more reusable/more adaptable. With the protected programmer inbetween: understanding more of the tradeoffs than the public programmer but not yet able to reach the next level of adaptable software.

seancorfield18:11:07

(that was the best part of 30 years ago)

isak20:11:44

Level 3 rings true (and with great example), but not level 1 or 2. I disagreed with your last article (about 2 kinds of readability) too, because I think your second example made it more flexible, not more declaratively readable. The flexibility is something that may or may not pay off, and I would agree with your level-1s that it makes it more complex. Whether it is worth it is another question. Anyway I think you should reconsider level 1 and 2 and see if you can leave room for the possibility that some cases of adding indirection or abstraction end up being a net negative. I don't think there is any room for that with the words you have now.

Thomas Cothran21:11:42

@U08JKUHA9 I don't mean to rule out "thinking in implementations", or choosing easy vs simple. Sometimes the easy choice is the better choice. Squarespace is fine for some websites; A shared excel sheet is fine for some business use cases. Or, in a code base, the costs of drawing an architectural seams may sometimes exceed the benefits. The problem is when one thinks one is weighing the costs and benefits, but doing so in a way that is systematically produces highly coupled systems. Many (most?) developers seem to grant that simplicity is better, but nevertheless think that all their particular situations are the exception. My claim is that there are levels of development that explain why -- in practice -- some software developers tend to produce decoupled, cohesive systems, and others highly coupled systems where the business rules could be squirreled away almost anywhere

👍 1
Thomas Cothran21:11:40

@U04V70XH6 - that's an interesting way to divide the layers as well. It makes me think my divisions are tailored more to business-oriented applications (where the challenge is usually to think at a higher level). Versus other cases where the challenge may be performance (where the challenge is to understand the lower level mechanics).

seancorfield21:11:38

Hey, it was the C++ crowd after all... 🙂

seancorfield21:11:17

I think the other thing to bear in mind is that developers don't inherently move through these layers over time. Some stay at level 1 all their careers, some reach level 3 very quickly. I know plenty of level 1 programmers who've had 20 years of experience... but they've only worked in environments that accepted and supported "level 1" work: they haven't been pushed to improve/advance. And there often are no "level 3" folks where they work, because the environment isn't challenging/interesting enough for them to stay...

💯 1
Bob B21:11:04

Another model that might feed into thinking about this topic is Dreyfus' model of skill acquisition. I also think that "cognitive development" is maybe a bit grandiose when scoped specifically to software dev.

1
Sam13:12:40

The image is so oversimplified and under-detailed that it means nothing. 2-6 year olds have ethics, they understand the concept of yours/mine, they understand that it's wrong to hit other people. Similarly, 2-6 year olds have some degree of rationality and logical thinking. At the same time, the logical thinking of a 7-11 year old is minor. To do something like this you have to be very precise. For example, you can to say "we made this logical puzzle that involves stacking cubes in a particular way. We find that, on average, kids under 4 can not solve it". That's fine, but trying to generalize that to "kids to under 4 can not think logically" is naive and dishonest. Another example from the pic is that 7-11 year olds supposedly understand numbers. I don't think I even understand numbers. At the same time, my 3 year old can count with some success. What understanding numbers "in general" is completely subjective, which kind of invalidates the research from the start. I think this type of thinking leads nowhere but to misunderstanding.

Thomas Cothran15:12:37

@UM7566XGS - you do realize this is a diagram? Surely you wouldn't think the standard model of physics can be conveyed in a diagram. I'm puzzled why you would think it's any different with developmental psychology. In any case, it's just a way of framing the argument I'm making. It's not something I am relying on.

Kimo16:12:25

Hey, really neat article. Still going over it. I noticed one sentence - > Facility in mathematics is really about being able to execute a series of steps correctly. Did you mean to include not here? The paragraph seems like it would flow properly that way. I'd say formulating problems is really not an obvious series of steps.

thanks2 1
Luke Zeitlin20:12:53

Also skeptical about the existence of such scales / phases but I do find it interesting to reflect on. Cook-Greuter scale and also spiral dynamics are interesting to compare to Piaget's scale. I suspect there is no "correct" model out there

Emanuel Rylke07:12:38

Robert Kegan extended Piaget's model, also covering adulthood, and if I squint a little your levels 1-3 map to Kegan stages 3-5. https://vividness.live/developing-ethical-social-and-cognitive-competence here is a blog post introducing them if you want to explore that

👀 1
Hans (www.flowmanifesto.io)21:11:29

Please if you are interested in #flow join that channel to discuss ways of moving enteprises forward. As a teaser read one of my columns written long time ago when I started this movement 🎈 https://www.linkedin.com/pulse/stop-modern-form-slavery-hans-van-bommel?utm_source=share&amp;utm_medium=member_ios&amp;utm_campaign=share_via

Nathan Smith03:12:59

This feels icky to me. Like when right-wing Americans have signs in their yard saying “Taxation is slavery” Call it “wage theft” or something else but slavery is slavery and this is a structural policy misalignment and a big problem but sure as heck isn’t slavery.

Drew Verlee23:11:24

Whats the name of the algorithm which will return the path from a node to a different node in a tree. DFS can do this with the right accumulator. But is there a name for this algorithm? I want to make sure i have the "ideal" implementation of this and i'm not missing something.

phronmophobic23:11:34

I think the general name for this is https://en.wikipedia.org/wiki/Pathfinding. Depending on the graph, good places to start are Dijkstra's algorithm and A*.

Drew Verlee04:12:20

yeah, thats what i assumed to. Basically what i have is a modified Dijkstra's algorithm.

Bobbi Towers23:11:23

This made me think of Alex's "A-Maze-ing Clojure" talk https://www.youtube.com/watch?v=ZMQbHMgK2rw

🏎️ 4