Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

For me, it's like writing 10824 "ten thousand eight hundred and twenty four".

I'd rather read a real regex using the verbose flag to comment groups:

- it shows the real regex for quick scanning and for those familiar with the syntax

- it explains things to the people that are not familiar with it or if the regex is complicated

- it forces the writer to divide the regex into logical groups

- such a system would have comment anyway, to indicate what you are matching such as "product code, date, color" for each part of the matching code.

- if you can't write or read regex and your job is programming, spending an afternoon learning them should be your next step. They are everywhere, no matter the tech stack: unix tools, IDE, 3rd party libs...

- there are plenty of regex tester UI, which let me copy the regex and test various case to see what it does, and tweak it

But I can see the value of such a lib for learning regexes.


I'll disagree here. While I have quibbles about the specific API used in this project, I like the idea of an imperative regex builder, especially if it can be type checked.

Every time I turn to regex, I waste time debugging which characters I forgot to escape or accidentally escaped when all the brackets and slashes blur together. I debug why some group isn't matching right because regex's semantic density makes it hard to tell where the group starts and ends. I turn to regex debuggers because they're necessary, but they're not great experiences, and at first glance I'd think a type checked regex builder could make debuggers unnecessary a lot of the time.

There's also a discoverability problem. I know non-capturing groups and negative lookbehind are a thing, but I always have to look them up because it's hard to remember the arcane syntax if I don't use them often. And my peers don't even know some of those things exist, so they struggle to solve easy problems. A library that my editor would offer autocomplete suggestions for would really help this.

I also think a regex builder would promote better organization - break the regex into parts, assign the parts to variables, and reuse portions of a regex. That's all possible with traditional regex, but I don't see folks doing it because it seems few folks know about verbose regex, building logic with string concatenation is discouraged in many situations, and if your language has a native regex data type, declining that in favor of string building feels weird. If all a regex builder did was reframe what developers feel is natural to do, that's beneficial.


Here is what I see.

You want an automated tool to build a regular expression for people who don't understand regular expressions. There is no shortage of ways that this is going to lead to disasters. Starting with the fact that far too many developers do not understand the difference between pattern matching and parsing, and will reach for the wrong tool with no idea what it is doing and why they can't get it to do what they want.

See https://stackoverflow.com/questions/1732348/regex-match-open... for more.


I'd like to clarify that my position isn't about "not understanding regular expressions". Sure, it could help people who don't. But even for people like me: I read the O'Reilly regex pocket book and other materials, I studied formal regular languages during college, built a basic lexer/parser for a senior project, I've written no shortage of simple and complicated regexes in application code in the workplace, and once in a conference lecture I was the first audience member to recognize and shout out when the speaker quizzed which commonplace file format the given gnarly full-page regex matched.

I'll never be up there with Brian Kernighan[0], but I know my way around regex at least as well as what I feel is reasonable to expect and accommodate from the average developer.

My position is that even with a background in regexes that's a lot deeper than just Googling and putzing on Regex101.com, traditional regex syntax is still a frustrating time sink that's hard to get correct without more trial-and-error than feels intrinsically necessary. The syntax provides zero opportunity to discover there's a more effective way to perform a task. I have trouble identifying a compelling value proposition for traditional syntax besides familiarity and natural serializability, and the fact that it gets the job done at all.

I don't believe traditional regex syntax is the optimal way to accomplish text pattern matching tasks in the workplace, and I'm open to other tooling that makes it success simpler and more reliable. People misuse regexes all the time (examples like the one you linked are almost tropes at this point), but I don't think that's compelling justification on its own for preserving the status quo.

[0] https://www.cs.princeton.edu/courses/archive/spr09/cos333/be...


My only complaint about the regex syntax is that it does not allow you to separate things out with whitespace, or add comments about what the chunked units. The x modifier fixes both.

What you traditionally see with a complex RE for a complex pattern is the same as what you traditionally see with someone writing complex SQL statements on a single line. Stop trying to treat it like a black box, and treat it as a programming language in its own right. Use whitespace, indentation, and comments (when necessary) to communicate intent as well as just to make it do its job.

Other than that, regular expressions say what they mean and mean what they say very concisely directly. Particularly the PCRE variants of the language. I consider that conciseness and directness a virtue.


For me, a regex usually has to be wrapped into a function, which I can then throw copious amounts of unit tests at. Regex is, IMHO, a easy-to-write hard-to-read language, so I find it more fruitful to use tests to specify what is the task being accomplished, so that - if it's easier - I can just rewrite the appropriate regex from scratch rather than trying to decipher how the old one is broken.

If the task is complex enough, regex might not even be the right tool for the job, and the function boundary provides a sensible encapsulation boundary.


> if you can't write or read regex and your job is programming, spending an afternoon learning them should be your next step

I’m one of those super stubbornly bullheaded people who believes I can learn or do anything if I’m simply willing to devote the time/energy to it so I don’t say this lightly:

I am absolutely incapable of “reading” RegEx.

I use RegEx. I (conceptually) understand RegEx. I can write Regex quickly and effectively without much thought. But I can’t read it to save my life. In fact it’s so difficult for me that I struggle to believe there are people who actually can “read” it.

I can decipher it but it’ll take me a bit - more like solving a little puzzle in my head than reading and understanding a piece of code.

And judging by the way a lot of people talk about RegEx (including seasoned programmers) I can’t imagine I’m alone.


Does any representation deserve to be singled out as the "real regex"? I'd have picked the abstract syntax tree. A bunch of constructor calls are closer to that.

(Yes, the Perl regex syntax has some advantages, and I'm only objecting to what you're calling it. Though it's also true that a tree structure has advantages over a string: for instance, you don't have to parse it to manipulate it.)


I think you are one hundred percent correct :)

But I can see it being useful if the idea is translated to NLP -> regex

a GPT3 to regex would be awesome


I could see it being awesome from a "This is cool" perspective, but I wouldn't trust it to actually work.

Just imagine it getting a negative swapped or something.


I think it would be useful to generate a regex - which would then get written down in the code to ensure it doesn't change? You could test it, ensure it works, then just use the output of the neural net...


Good point, that does actually sound quite useful.



So basically node_modules?


I keep using a lot of text messages: I have many people with different type of chat apps, or no chat apps at all (old gen), so the only way to reach everybody is doing that instead of juggling with different services.

I don't use whatsapp, and don't have an iPhone, so no imessage. Most people don't use Telegram or Signal which I do. Not to mention a lot of geeks have their favorite way of being contacted (slack, wire, etc).

And of course all that will have change in a few years. Before you had to have facebook. When in Asia, it was lime or something else.

As soon as you have a lot diversity in your life, text messages are the only thing that works all the time, plus they are free in my country.

In fact, iMessage is basically sending text messages without the user knowing they do if the other hand is not an Apple device.

In the end, I suspect text messages will still be here in 10 years, and all people around me asking to subscribe to yet another chat service will have change 3 times (and lose their contact list in the process).


Intent.

When your parent put sugar in a cake, they you to enjoy the cake for you own enjoyment. They will dose the cake, and make you experience the cake in this context.

Kinder wants you to enjoy it so you buy it again. The goal is not the enjoyment but the reaction after it. Dosing the sugar, the other ingredient, the context you will consume it and the so on are going to be completely different.

When you hear "Ride of the Valkyries" being played in apocalypse now, you don't hear the voice of the director suggesting "now you should feel this particular way, because I said so". You just enjoy the craft.

Some movies and series now, it feels like the way they put music, cuts, etc. are just cheap plots designed by engineers to get something out of you.

You can't feel the desire of creating and sharing something, rather you are given a product designed to specs.


> When you hear "Ride of the Valkyries" being played in apocalypse now, you don't hear the voice of the director suggesting "now you should feel this particular way, because I said so". You just enjoy the craft.

This is a great counter-argument to your theory, since that song (like all choices in that movie) was explicitly chosen to manipulate — to make you feel specific ways about the U.S. military and the Vietnamese villagers, to induce tension, etc.

The intent hasn't changed, you have. You'll discover this when re-experiencing old favorites and discovering that they've lost the magic because you've developed the tools to see behind the curtain.


Exactly, saying intent is what makes the difference is all nice in theory. But faced with reviewing and watching actual shows/movies, true intent is never uncovered (unless the director admits to it). You can get cases where a person enjoys a film and another dislikes how they were 'manipulated'.

Take a example of a clueless director putting rise of the valkeryies on a chopper scene in his movie without knowing about the scene in 'apocalyse now'. He knows the song as certain qualities to it and his intent is to bring these emotions across. Yet, is the watcher being manipulated despite this genuine intent?

What's more useful than making a useless distinction between what's genuinely fake and what's manipulative is looking at execution. Is the director being clumsily formulaic (common with many netflix shows now) or does it fit coherently as a work.


Same here. When watching the Elton John movie, I could see all the artificial image enhancements made to the picture to make it look better, but burning the sincerity out of it in the process. Same for sound, which made characters mouth completely out of sync with the music (the first scene, the voices are singing intensely, but you can see the faces not breaking a sweat, uncanny valley ensued).

This week, I started (and gave up) to watch "the witches", which has clearly been designed by committee. All the ingredients are nice, but there is this feeling that they are put in there because people though they should be, not because they felt it should. It was not story telling, it was product manufacturing. We were being sold concepts: this is a lovable character, here is a tragedy to bound, here is the bad guy, she is scary, oh, look at the grandma you wish you had, and so on.

The problem is, they do that because it works. Star wars remakes made banks. Disney live actions as well.

If I discuss this with my friends, they don't seem to mind, they enjoy it.

Now I ate at Mc Donalds for year, enjoying it, so I get that you can very well enjoy scientifically crafted quick and satisfying experiences.

But at least for movies, it's becoming hard for me. Maybe I have rose glasses about movies in the past, but I watched Groundhog Day last week, and it felt nothing like this. Pure creative and fun experience.

I guess it' a blessing: it will save me time and money.

On the other hand, it leaves a bad taste in my mouth. Don't know why I'm bitter about this, cause it's not like it's an important thing, but I react strongly to it.


I wish there were a way to save comments on HN, because this is exactly how I feel about the movie / TV show industry down to a T.


click on the timestamp, click "favorite" (note the lists of favorited submissions and comments are public in your profile)


Thanks a bunch! It's always fun learning about the hidden features of HN.


That's a hilarious description of my meditation practice.


I was surprised how much I liked zulip. The threading model and the policy of few notifications by default speaks to me.

The UI is not the most modern but the software is productive and friendly for a chat application, particularly when you look for an old information burried in the history.



Oh, but I'm OK with paying.

I paid for netflix, lastpass and zoom. I still pay for dynalist, audible or for having my own email address.

However, I'm not OK with having a logged in google account that accumulates everything I do into their DB and AI while I use their services.

Even when you pay, they still milk your private life.

And they have proved time after time they cannot be trusted with it.


Netflix also accumulates all of your watching habits and feeds it into AI while using their services.


Netflix doesn't have an ubiquitous search engine, analytic scripts on half the web sites in the world, Android, gmail, maps, youtube, and so on.

Netflix business is not to accumulate data on you and resell it, or to display ads.

Netflix was not part of the PRISM program.

Netflix is not Google.


Is that a bad thing if it helps you to find great new content?


Except most of what you "discover" is actually more of the same. That why we have so much divisiveness in our society, people are unknowingly in echo chambers so deep they don't know anything else exists.


It's just not a great argument against YouTube since "accumulates everything I do into their DB and AI" is something both services do in the name of better recommendations.


You can disable the the tracking on your account if you want with or without Youtube premium.

https://support.google.com/accounts/answer/6139018?co=GENIE....


I'm not going to trust google with that after a decade of terrible track record.

I don't believe one second there is a way to opt out of Google tracking you. At best, you can lower the settings on how much it displays the informations it has on you.


I personally don't think that Google spend money to store your data if they aren't actively using it, though I can understand the sentiment. That said, you might as well switch it off if privacy is something you care about.


Do we know how long does the vaccine holds?

Is that like polio and lasts for years, or like the flu and you need a new dose each year?


There isn't really a way to know for certain (as not much time has passed), but there are hints that it might last for years[0].

[0]: https://www.nytimes.com/2020/11/17/health/coronavirus-immuni... (with links to the studies inside)


Unless I missed it, there hasn't been any data released. I'm only seeing PR accouncements.


AIUI, the thing that makes a vaccine's effectiveness very short term, like flu vaccines, is the natural evolution of the virus, not its effect on the immune system. It's not that people who got a 2015 flu aren't still immune to the 2015 flu, it's that wild flu virii look different in specific ways that cause them to slip by. As such, I think these drug companies don't really have much to release for each vaccine.

(That isn't to say the immune system can't forget immunity - TDAP boosters are for evolution, but for refreshing the immune system - but that super short term immunity like flu, AIUI, is about the virus not the vaccine.)


> As such, I think these drug companies don't really have much to release for each vaccine.

They should still release the data. PR releases don't always match reality.


> Unless I missed it, there hasn't been any data released. I'm only seeing PR accouncements.

Because there is no long term data on covid19 mutation speed.

You need a cohort to take the vaccine and then some time before doing a retroactive study.


There's still data, and it hasn't been released. I would like to know the details of 95% effective.


I was listening to an interview with Paul Offit[1] a vaccinologist and member of the FDA Vaccines and Related Biological Products Advisory Committee (which advises on COVID-19 vaccines).

His message was "You honestly don't know ahead of time", but his caveatted guess was actually that it would be long-lasting (giving the example of measles), not like the flu.

[1] https://open.spotify.com/episode/6Z7m56ACJ1VZ0ZKuw4iiGb


I'm in a rush, so hopefully someone can dig up some actual links to scientific papers, but current immunity from naturally infected people has stayed strong and shows no sign of weakening. The immune response from the vaccination has at least as strong, so in all likelihood we're looking at very long response.


Doesn't immunity only last several months though?


No, that's just been a popular conspiracy theory.


No, it stays strong and shows no sign of weakening.


According to several studies, that's not true.

"Two new studies demonstrate how severity of disease is predictive of longer-lasting antibody production and detail how immunity wanes over time but may exist for up to 7 months."

https://www.cidrap.umn.edu/news-perspective/2020/10/studies-...

https://www.cdc.gov/coronavirus/2019-ncov/hcp/duration-isola...

There's also evidence of re-infection

https://www.thelancet.com/journals/laninf/article/PIIS1473-3...


You (or rather the writer of that news piece) apparently confused antibodies and immunity. Not only are antibodies not the only mechanism of the adaptive immune system, T cells are harder to test for but equally important. Also it's normal that the body doesn't keep them around indefinitely after an exception. It creates memory cells and quickly recreates antibodies and T cells when needed.

There is evidence that reinfection does occasionally happen, but none that it happens frequently enough to worry about. The paper you've linked mentions four cases.


You're right, but are there any peer reviewed papers that back up your argument?

> The paper you've linked mentions four cases.

Those are confirmed cases. That doesn't mean there's only 4 total.


I don't know if there are any papers for Covid in particular but it's how the immune system works in general. AFAIK there is no reason to assume it Covid differs in that respect.

> Those are confirmed cases. That doesn't mean there's only 4 total.

I'm sure there are more, but how many? There have been hundreds of millions of infections (according to the WHO). If there are a few dozen or even a thousand reinfections among them, it's not a phenomenon we need to worry about.

We could assume that reinfections are common even without any evidence for or against, but then we are playing something akin to Pascal's wager. Also, I think if reinfections were common, by now we would very likely have evidence for that by now.


Your first link only focuses on (the easier to test) antibodies, and doesn't mention T cell memory, which is the much more important factor in long-term immunity.

And of course there are going to be individual cases of reinfections with 55+ million cases.


Your logic checks out, but are there peer reviewed papers that back up your argument? This isn't my field, so I'm not aware of any.


There is one right in the list on the CDC page you linked[0]. There is also a recent Nature paper[1] that shows that T cells levels are stable for at least the first 100 days they observed. I don't know of a specific link to send you for that, but that usually indicates T cell immunity on the timescale of multiple years (otherwise some drop in levels would have already been visible in the observed time period).

[0]: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7427556

[1]: https://www.nature.com/articles/s41591-020-01143-2


> The immune response from the vaccination has at least as strong

Is that true? I always thought it was at most as strong (eg, David Katz says so here: https://youtu.be/YLLENema1Co?t=462), but I'm seeing this assertion float around also. Which is it?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: