frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

The /o in Ruby regex stands for "oh the humanity "

https://jpcamara.com/2025/08/02/the-o-in-ruby-regex.html
42•todsacerdoti•2h ago

Comments

rco8786•1h ago
Love these sorts of deep dives, thanks!
cbsmith•1h ago
As an old Perl programmer, I knew immediately what the /o would do. ;-)
Amorymeltzer•6m ago
I've always loved the recent[1] summary from `perlre`:

>o - pretend to optimize your code, but actually introduce bugs

1: I still think of it as a relatively new change, but it's from 2013: <https://github.com/Perl/perl5/commit/7cf040c1f649790a4040aec...>

riffraff•1h ago
Unsurprisingly, `END {}` is also inherited from perl, tho I think it originally comes from awk.
mdaniel•14m ago
Similarly unsurprisingly, with its BEGIN friend https://docs.ruby-lang.org/en/3.3/syntax/miscellaneous_rdoc....

In the spirit of "what's old is new again," PowerShell also has the same idea, and is done per Function with "begin", "process", "end", and "clean" stanzas that allow setup, teardown, for-each-item, and "finally" behavior: https://learn.microsoft.com/en-us/powershell/module/microsof...

phoronixrly•52m ago
It's kind of a cool feature. I like it.
lupire•42m ago
This is the same problem people have with closures, where it's unclear to the user whether the argument is captured by name or by value.
layer8•16m ago
This isn't the same problem, because this is about whether the regex is instantiated each time the code around the regex is executed, or only the first time and cached for subsequent executions. The same could in theory happen with closures, but I haven't ever seen programming-language semantics where, for example, a function containing the definition of a closure that depends on an argument of that outer function, would use the argument value of the first invocation of the function for all subsequent invocations of the function.

For example, when you have

    fn f x = (y -> x + y)
then a sequence of invocations of f

    f 1 3
    f 2 6
will yield 4 and 8 respectively, but never will the second invocation yield 7 due to reusing the value of x from the first invocation. However, that is precisely what happens in the article's regex example, because the equivalent is for the closure value (y -> x + y) to be cached between invocations, so that the x retains the value of the first invocation of f — regardless of whether x is a reference by name or by value.
zer00eyz•37m ago
Im sorry but the classics never go out of style:

"Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems."

stavros•4m ago
Yeah but it's kind of tired when it's being used every time someone makes a mistake with regex. I've used them extensively in my career and never once regretted it.
fanf2•20m ago
This is one of the features that Ruby cribbed directly from Perl. The Ruby documentation seems really bad, in particular “interpolation mode” is grievously misleading.

Perl’s documentation is far more clear about the consequences:

(https://perldoc.perl.org/perlop#Regexp-Quote-Like-Operators)

   o   Compile pattern only once.

  […]

  PATTERN may contain variables, which will be
  interpolated every time the pattern search is
  evaluated, except for when the delimiter is a
  single quote. […] Perl will not recompile the
  pattern unless an interpolated variable that
  it contains changes. You can force Perl to skip
  the test and never recompile by adding a /o
  (which stands for "once") after the trailing
  delimiter. Once upon a time, Perl would recompile
  regular expressions unnecessarily, and this
  modifier was useful to tell it not to do so,
  in the interests of speed. But now, the only
  reasons to use /o are one of:

  [reasons]

  The bottom line is that using /o is almost
  never a good idea.
In the days before Perl automatically memoized the compilation of regexes with interpolation, even back in the 1990s, it said,

  However, mentioning /o constitutes a promise
  that you won't change the variables in the
  pattern. If you change them, Perl won't even
  notice.
Perl 4’s documentation is briefer. It says,

(https://github.com/Perl/perl5/blob/perl-4.0.00/perl.man#L272...)

  PATTERN may contain references to scalar
  variables, which will be interpolated
  (and the pattern recompiled) every time the
  pattern search is evaluated. […] If you want
  such a pattern to be compiled only once, add
  an “o” after the trailing delimiter. This
  avoids expensive run-time recompilations, and
  is useful when the value you are interpolating
  won't change over the life of the script.

How Promise Works in JavaScript

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
1•aanthonymax•1m ago•0 comments

Coccinelle: The secret weapon of the Linux kernel devs

https://coccinelle.gitlabpages.inria.fr/website/sp.html
1•agvxov•1m ago•0 comments

Ultrasound movie review and film summary (2022)

https://www.rogerebert.com/reviews/ultrasound-movie-review-2022
1•walterbell•5m ago•0 comments

Why Are Games Scary?

https://blog.lauramichet.com/why-are-games-scary/
1•speckx•5m ago•0 comments

Candyfloss: Python Sugar for Gstreamer

https://git.hella.cheap/bob/candyfloss
1•mpweiher•8m ago•0 comments

Natural Gas Inventories Rise but Heat Wave Could Fuel Strong Demand

https://oilprice.com/Latest-Energy-News/World-News/Natural-Gas-Inventories-Rise-but-Heat-Wave-Could-Fuel-Strong-Demand.html
2•PaulHoule•8m ago•0 comments

Context Engineering for AI Agents: Lessons from Building Manus

https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
1•Anon84•10m ago•0 comments

Modular Mentorship

https://quietmoats.substack.com/p/modular-mentorship
1•blue-green-bear•12m ago•0 comments

What am I falling in love with? Human-AI relationships no longer just sci-fi

https://www.cnbc.com/2025/08/01/human-ai-relationships-love-nomi.html
1•sowbug•13m ago•0 comments

Show HN: Wordle-style game for Fermi questions

https://www.fermiquestions.org/
1•danielfetz•15m ago•0 comments

'AI' just means LLMs now

https://blog.jxmo.io/p/ai-just-means-llms-now-superintelligence
2•jxmorris12•16m ago•1 comments

Ask HN: Does "vide coding" for Hardware exists?

1•byebyetech•17m ago•1 comments

Ex-CIA Whistleblower: "The NSA Audited the 2024 Election, Kamala Harris Won"

https://thiswillhold.substack.com/p/ex-cia-whistleblower-the-nsa-audited
2•akudha•18m ago•0 comments

Show HN: Conway's Game of Life in JavaScript with efficient implementation

https://github.com/gkoos/conway
1•gkoos•18m ago•0 comments

The Poe API(OpenAI compatible)

https://creator.poe.com/docs/external-applications/openai-compatible-api
1•ifree•20m ago•0 comments

Hamas hostage Evyatar David forced to dig what he fears will be his own grave

https://www.timesofisrael.com/a-living-skeleton-buried-alive-hostage-evyatar-davids-family-publishes-clip-of-hamas-video/
1•mhb•20m ago•0 comments

A Day at Two San Francisco Malls, One That Died and One That Thrived

https://www.nytimes.com/2025/08/02/us/san-francisco-malls-downtown.html
2•mitchbob•22m ago•1 comments

Xkcd: Unsatisfied

https://xkcd.com/584/
3•tarpit_idea•22m ago•0 comments

Physicists should revel in the diversity of ways to understand quantum mechanics

https://www.nature.com/articles/d41586-025-02346-8
1•sampo•23m ago•0 comments

Show HN: Cortex – OS-wide AI with instant context input

https://cortexdesktop.com/
2•andrewfhou•25m ago•1 comments

VibeCamp – Don't learn to code. Learn to create with AI

https://www.vibecamp.ai/
2•kelseyfrog•29m ago•1 comments

The unreasonable likelihood of being: origin of life, terraforming, and AI

https://arxiv.org/abs/2507.18545
2•bookofjoe•31m ago•0 comments

Show HN: Accelerate AI agent development by grounding AI assistant in local docs

https://github.com/botingw/langgraph-dev-navigator
1•botingw_job•32m ago•1 comments

Linear Types for Programmers

https://twey.io/for-programmers/linear-types/
2•marvinborner•34m ago•0 comments

Invisible Symbols

https://symbol.so/invisible-characters
1•liquid99•42m ago•0 comments

US Army tests robot coyotes to prevent catastrophic bird strikes

https://cyberguy.com/robot-tech/army-tests-robot-coyotes-prevent-catastrophic-bird-strikes/
1•speckx•44m ago•1 comments

Telo MT1

https://www.telotrucks.com/
14•turtleyacht•46m ago•1 comments

The Creative Tension Between Developer and Language

https://krishna.github.io/posts/creative-tension-between-developer-and-language/
1•kenshi•49m ago•1 comments

Show HN: I've had success in SaaS and now I'm building tools for indie hackers

https://reallysimplesupport.com
1•gigamick•50m ago•0 comments

German police expands use of Palantir surveillance software

https://www.dw.com/en/german-police-expands-use-of-palantir-surveillance-software/a-73497117
7•LeftHandPath•50m ago•1 comments