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

I shoved £500 down in Sept 2017 knowing full well it was a gamble, and still have a roughtly £500 balance now -- having skimmed enough off the top over the years to buy a couple of iPhones and whatever else. I 100% consider this profit to be literal dumb luck.

Unironic congratulations on being self-aware enough to take your profits without it affecting your reasoning. Anecdotally, not many seem to come out of crypto net positive with that mindset.

> [TIMTOWTDI] literally means 'there is more than one way to do it in Perl' - and you can perhaps infer from that that there's little to no reason to do it using anything else

Not my experience at all, FWIW. For me, and the vast majority of Perl devs I’ve worked with over the past 30 years, TIMTOWTDI absolutely means some of the “ways to do it” don’t involve Perl, and that’s not only OK but expected. Of course Perl isn’t the be all/end all. It’s a lot of fun though!

(I’m a majority Perl coder to this day, it’s my favourite language by far. Hell, I even find it readable and easy/fun to debug)


How popular was/is monkeypatching in Perl?

It is possible to do so, but it stands out in a way such that most people aren't doing it using direct language features unless necessary. If you have `strict` and `warnings` enabled, which is recommended, then the interpreter can give runtime warnings or compile-time errors if you try to manipulate the symbol table or redefine a function. If you still want to use those on a case-by-case basis, you have to turn off those pragmas within a scope. So there are built-in ways the language discourages using them arbitrarily.

In tests, you can use monkeypatching as a quick way to mock, but typically, you use modules that wrap up the functionality and make it cleaner. The mocks get cleaned up on scope exit.

There are also more principled ways of having composable behavior, such as <https://metacpan.org/pod/Class::Method::Modifiers> (advice/method combination).

There is another approach that takes advantage of the variety of scoping approaches Perl has. If one uses `local`, it indicates the use of dynamic scope rather than the standard `my` lexical scope. This can be used for things like setting an environment variable temporarily and automatically reverting it when leaving the scope. But this is not common.


Very. I use `Test::MockModule` (not just in tests) or `Sub::Override` or `Class::Method::Modifiers` a lot, according to convention/style or as I see appropriate — but there are, of course, tons more ways to do it.

Wait, what? Englishman in my 50s here and I use phrases like that all the time — “I’ll be missing standup cos I’ve a GP appointment”, “leaving at lunchtime as I’ve a train to catch”, “gotta dash, I’ve chores to do”. No one’s ever said I sound German!

I think it's more fair to call it a distinguisher of American English vs. British English.

Even just reading "I've a train to catch" gives a British accent in my mind.


A particular part of Britain as well. I have never used “I’ve” in that way ( I speak more RP than with an accent)

Which is exactly why to cut it out. If you put salt in my cup of tea, I’m gonna notice and it’s gonna ruin the drink.


Microsoft poured salt into your cup years ago, you just did not notice.


If you put more salt into this rather thinly-stretched metaphorical cup when telling me what Microsoft did you are not going to endear yourself to me. Why muddy your message?


> I spent a lot of time working is South East Asia. Jakarta is the worst city, yes it is big but very filthy like New Delhi or India in general. Second filthiest is Malaysia.

Malaysia's a pretty decent size country, not a city. Can't say as I'd have referred to KL as filthy on any of my visits (admittedly only 3 times over the past 12 years). Kuching wasn't filthy either.


Quoting the “what to submit” guidelines: If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity.


I find it very hard to judge whether I'm fulfilling that part of the guidelines. I only have a few submissions, and I think I'm good there, but I'm more conflicted when it comes to upvoting or engaging in other people's submissions. For example, earlier today I saw a thread on German laws on date rape drugs. I upvoted the thread. Do I think it's important for people to talk about date rape drugs? Certainly. I'm not sure if it falls under satisfying my "intellectual curiosity", though. Is HN "the right place" for this conversation? I'm not sure, though I think the reality on the ground would say "yes". Most likely, all of this is an organic adaptation that HN has experienced.


Can’t comment on the others but I copy screenshots to the clipboard multiple times a day in macOS and have done for years. Very frequently I send them via Screen Sharing to another Mac and paste there, something I value hugely.


In the main, the sigil refers to the type of the eventual value, regardless of what contains it. The tl;dr is that you mostly use `$` unless you're wanting more than one value, or to dereference (when you use the sigil for the type of reference). Some examples:

    @array = ("a", "b", "c", "d"); # @array contains scalars
    $array[0];                     # use `$` for a single element
    @array[0..2];                  # use `@` for an array slice
    @array = ( [1..5], [6..10] );  # @array now contains array references
    $array[0];                     # use `$` still because references are scalars
    $array[0][1];                  # still use `$` even when going multidimensional
    @{ $array[0] };                # use `@` to dereference an array ref to array
    %hash = ( a => "b", c => "d"); # % for hash of key/value pairs
    $hash{a};                      # `$` because you're getting a single scalar
    @hash{"a","c"};                # `@` because you're getting an array of values
Where things become a bit less regular is the difference between reference and non-reference for hashes and arrays when they are top level. At the top level, you need a `->` but that becomes optional at levels below (because at levels below, they have to be references).

    $arrayref = [1,1,2,3,5];       # `$` because we're creating an array reference
    $arrayref->[0];                # `->` because top level
    $arrayref = [ [ 1 ], [ 2 ] ];  # arrayref of arrayrefs
    $arrayref->[0][0];             # no second `->`
    $arrayref->[0]->[0];           # ... but you can use it if you want!
And then there's stuff like getting a slice out of an arrayref

    $arrayref = [1,1,2,3,5];
    $arrayref->@[0..3]; # oh dear. get a real array with an `@` but not at the start!
So... yeah.


> Where things become a bit less regular is the difference between reference and non-reference for hashes and arrays when they are top level. At the top level, you need a `->` but that becomes optional at levels below

Yes, that's probably what I was remembering. Thanks for the exposition.


Yahoo! had a shitload of Perl.


> Of those only people are at all common, and not on large roads. I have never even seen roadkill large enough to be unsafe to drive over.

I moved from London out to the sticks ~4.5 years ago and since then have seen deer, pigs, and cows multiple times each year on the larger roads around where I now live. Animals roam. People leave gates open or damage fences. It happens. Plus the named storms frequently bring trees down onto or even across roads.


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

Search: