HNHacker News
TopNewBestAskShowJobs

marhee

167 karma · joined August 24, 2021

submissionscomments
marhee··on Zig's comptime is bonkers good
Interesting points.

> Implementing generics in this way breaks parametricity. Simply put, parametricity means being able to reason about functions just from their type signature. You can't do this when the function can do arbitrary computation based on the concrete type a generic type is instantiated with.

Do you mean reasoning about a function in the sense of just understanding what a functions does (or can do), i.e. in the view of the practical programmer, or reasoning about the function in a typed theoretical system (e.g. typed lambda calculus or maybe even more exotic)? Or maybe a bit of both? There is certainly a concern from the theoretical viewpoint but how important is that for a practical programming language?

For example, I believe C++ template programming also breaks "parametricity" by supporting template specialisation. While there are many mundane issues with C++ templates, breaking parametricity is not a very big deal in practice. In contrast, it enables optimisations that are not otherwise possible (for templates). Consider for example std::vector<bool>: implementations can be made that actually store a single bit per vector element (instead of how a bool normally is represented using an int or char). Maybe this is even required by the standard, I don't recall. My point is that in makes sense for C++ to allow this, I think.

marhee··on I am rich and have no idea what to do
I read it in Dutch.
marhee··on I am rich and have no idea what to do
I believe one of the founders of Booking.com has had some similar experience (source: "De Machine", the book about Booking.com) and after 4 years of travelings & yoga etc. he sneaked back in into the company. Most of his coworkers do not know he's a founder. He's been fixing Perl bugs, writing scripts and coding some features at least for some years (maybe he's moved on already, don't know, the book is a couple of years old).
marhee··on Algorithms We Develop Software By
Side note: “write everything twice” (WET) is originally meant as a reaction to DRY (“don’t repeat yourself”). I think the author uses the credo here for something else (which is still good advice).
marhee··on Embedded Rust in Production?
Did you not offer to rewrite it in Python? I was a techical director at a company where we worked a lot with frontend contractors. Some loved typescript others were fans of vanilla js. When the balanced tipped there were rewrites from one to the other (ts to js to ts again), the first one two months full time, the second was interspersed with feature development. Of course the developers were very happy they could do it; it improved the solutions and afterward they both had 1) extreme product ownership 2) excellent company problem domain knowledge. So, a win-win for everyone. So I think, especially as it is a smaller part, than translating back in to Python would be warranted (provided you like it and would stay a while), not a big deal and a quite natural option.
marhee··on LaTeX Style Guide for EE 364B [pdf] (2014)
Why does “I contend” feel awkward to you? It is more specific than “I differ” because that could also mean that the author physically differs, which is awkward, while “contend” is specifically used for disagreement on some topic? Does “I contend” maybe has a ring to it of being scholastic/pretentious? (Also non-native English, just curious)
marhee··on A Brief Intro to Clean Architecture, Clean DDD, and CQRS
I believe “database independence” is an anti-pattern in 99% of the cases. Abybody with me?

I’ve had great success by not using a database abstraction layer:

- you can invest the time you spend on being a generalist on many databases to be a real expert on one

- no more fighting the abstraction layer; use any persistence feature directly

- better perfomance is easier to achieve

- simpler data modelling and execution

- simpler backups

The list goes on tbh.

Drawbacks? Well yes: you have to make a really good decision on your dbms (hint: psql). But that’s actually an advantage deguised as a drawback: wanting to be able to easily change the dbms is just fearing making decisions. It’s like requestibg a car where you can swap out any type of engine.

(Also, use a single dbms. Really. There’s nothing any nosql can do that psql/mysql can’t do (mayve vice verca) unless maybe in really specific cases).

marhee··on Show HN: Coros – A Modern C++ Library for Task Parallelism
Coroutines are just multiple call stacks. If coroutine A calls coroutine B then B excutes on its on stack and can ‘yield’ a value back to A. Yielding is just a return across stacks without destroying the current stack. So A continued with the yielded valie on its own stack and when ready calls B again which continues on its own stack with the next statement after the previous yield. Etc.

Notice that this does not necessarily involve parallelism, although it can. For example, Lua has non parallel (cooperative) co-routines. Go had parallel coroutins, called goroutines, but theoretically only if they they use channels to exchange values. Otherwise, if they’re not exchanging information they would not becoroutins in the sense that they work together in solving something.

marhee··on What Does It Mean to Learn?
“Knowledge is not free; you have to pay attention”(Feynman)
marhee··on GPU-Friendly Stroke Expansion
I believe metafont, created by Knuth for Tex, is an exception here in that it does use strokes.
marhee··on Ask HN: Why do message queue-based architectures seem less popular now?
Worst case scenario you service is not available for a couple of hours. In 99% of business, customers are totally okay with that (if it's just not every week). IRL shops are also occasionally closed due to incidents; heck even ATMs and banks don't work 100% of the time. And that's the worst case: because your setup is so simple, restoring a backup or even doing a full setup of a new machine is quite easy. Just make sure you test you backup restore system regularly. Simple system also tend to fail much less: I've run a service (with customers paying top euro) that was offline for ~two hours due to an error maybe once or twice in 5 years. Both occurrences were due to a non-technical cause (a bill that wasn't payed - yes this happened, the other one I don't recall). We were offline for a couple of minutes daily for updates or the occasional server crash (a go monolith, crash mostly due to an unrecovered panic), however the reverse proxy was configured to show a nice static image with the text along the lines "The system is being upgraded, great new features are on the way - this will take a couple of minute". I installed this the first week when we started the company with the idea that we would do a live-upgrade system when customers started complaining. Nobody ever complained - in fact customers loved to see we did an upgrade once in a while (although most customers never mentioned having seen the image).
marhee··on Windows 10 wallpaper was physically built and photographed (2015)
Interesting but I am not sure I understand this:

>> contact-and-removal operation takes constant time, the worst-case time complexity of the algorithm is O(n).

How is the contact-and-removal operation constant time? How can that assumption ever be true? If you use a parallel processor like human vision or human feel (ie. which pressure nerve activates on the hand) it may appear constant, but if you use a computer it would be n right (as you would need to check n slots). Wouldn't either defy O(n)?

marhee··on C Style: My favorite C programming practices (2014)
> developers have a hope of being able to determine which #includes can be removed and which can't

Can’t a modern compiler do that already? Didn’t google but seems an obvious compiler feature at the very least behind a warning flag.

marhee··on YC: Requests for Startups
The Stugna anti-tank-guided-missile seems to indeed have this feature:

"...that is connected to the firing unit by a cable, allowing it be used at distances up to 50 metres (160 ft) away"

Source: https://en.wikipedia.org/wiki/Skif_(anti-tank_guided_missile...

marhee··on Show HN: Error return traces for Go, inspired by Zig
I suspect it is based on https://pkg.go.dev/runtime#Caller
marhee··on Don't waste money on a math coprocessor they said
I remember "Dune 2" (1992) could use a co-processor? Not sure, we never had a machine with a co-processor but a friend had and he said that at start-up the game said something like "Co-processor found - let's use it!" and then game could run faster I believe (not sure).

Edit- Dune 2, not Dune 2000

marhee··on Forty years of programming
Ha! Experiences forearm and shoulder pain. Proceeds to mention casually he's into rock climbing. DisplayS photos of games where (jerky) mouse mileage is, to put is mildly, excessive.

Talking about elephants in the room here... I don't think it's the keyboard or mouse, dude! ;)

I've done rock climbing myself. Obviously, it's a huge burden on the ligaments of the upper body. It's also very fun (not in the least because it's a bit scary), but you will feel those wrists a shoulders a bit the next day. Small price to pay, until it because really painful.

I would recommend to the author to try and mix in in some other fun sports like kite-surfing or mountain biking etc. Or dancing (salsa I can recommend if you're open to the latin music). And limit mouse-mileage-heavy gaming a bit maybe? There's a lot of other options (try Return of the Obra Dinn).

Finally, I don't know if other have experienced this, but reflecting a bit on how you do programming can also help. Thinking more, resisting that urge to start typing away did a lot for me personally wrt my wrists and shoulders starting to loving me again. But that may be just me, of course.

marhee··on Vale's first prototype for immutable region borrowing
Yes, there is a generation number in the reference. It is checked against the generation number of the allocation that is stored in the allocation:

  void __check(GenerationalReference genRef) {
    uint64_t currentGeneration = *(uint64_t*)((char*)genRef.alloc - 8);
    assert(genRef.rememberedGeneration == currentGeneration);
  }
So indeed you it allows you to check for a match, as long as the alloc pointer is valid. The alloc pointer is invalid after a free, because it maybe be in a region no longer accessible to the program (it was returned to the os by free's implementation) or it was given out as part of an other allocation, in which case it can hold arbitrary data.
marhee··on Vale's first prototype for immutable region borrowing
Yes, I am wondering too.

How would it even stop use-after-free and double-free?

The "check" function accesses the allocation because it needs the generation number of the allocation. So basically, the reference needs to access the allocation to check if it can access the allocation. Right.

(That doesn't work of course, because if the allocation was freed, access to the allocation and so its generation number is undefined).

This seems obvious so maybe I am missing something big here?

Or something entirely different is meant or targeted here with "memory safety".

marhee··on Ask HN: How do you not take criticism of your work personally?
It may be the case that you’re ambushed by critical reactions. Prime yourself before reading comments, get your guards up a little. This puts some distance between you and the comment(er). Your skin may still be hit, but not your soul.

Secondly, if somebody says something that you dont agree with but is not really important or interesting, or even snarky, don’t respond. Just ignore it. Respond to another comment (if present) thay you do find constructive and interesting. This is very powerful because you actually respond to the snarky comments without responding. This can sometimes be the loudest and best response. Don’t waste energy where there is no gain.

It helps. Remember also that finding flaws is a lot easier than creating things, especially if new ideas are involved. Also remember that love makes blind; it’s easy to fall in love with one’s own ideas/solutions and so ignoring its shortcomings. The easiest to fool is yourself. But that’s fine if you allow yourself to adjust.

Finally, allow yourself to be convinced. If somebody has a good argument against your case, give them a little credit. Try to have a conversation and not a debate.

marhee··on Ask HN: Has anyone here left the big city in pursue of a simpler life?
> The problem is that doing that will very quickly tell you that modern society fucking sucks. Almost nothing works, everyone hates each other, things that are important get ignored because of greed, and most importantly, there's almost nothing you can do about it.

You might be heavily biased due to the news & social media you take in. What remains of this if you remove all ideas about "society" that came to you in digital form? Do the people around you really all "hate each other"? Does "nothing works", really? Do important things get ignored in your physical vicinity? And if not, why could you not do anything about it?

I am saying this because a lot of (younger) people don't realise most salient news is negative news (climate distaster, war, crime etc). Well maybe they do realise this but still latently let it dictate their whole world view even though it is in complete disregard to their local world which have none or little of those problems (war, direct climate issues, hard visible racism, etc etc) .

If you just look around yourself, both in the physical world and in time (ie. in your life up to now), how much is completely, really, "fucked-up", anyway? Sure some distasters happen (relatives, friend or pets that die etc), but other than that, life around me is pretty much amazing considering how your life would've looked like 100 years ago.

Still, nature is really nice of course. We originate from nature, so it soothes us naturally (well most of us). So why not do both? Stay a couple of month per year outside of bigger cities / detach from digital media. After a while you'll miss the city probably as much as you miss nature now. So mix it up a little. Variety is the spice of life.

marhee··on Poor sleep drove me insane, and my long path to recovery
> And I started taking antihistamines daily.

Antihistamines can make you drowsy, ie. "brain foggy": (Quoting the web)

Side effects of antihistamines * sleepiness (drowsiness) and reduced co-ordination, reaction speed and judgement – do not drive or use machinery after taking these antihistamines. * dry mouth. * blurred vision. * difficulty peeing.

I take them sometime myself (for the same symptoms as the article) and I really notice the drowsiness - even though it differs from time to time. So I really limit usage.

> Even my lifestyle in my early 20s was a confounding issue. Did I party too hard? Did that era of my life alter my brain chemistry in a way that made me irreparably damaged?

Long-term effects of recreational drugs use (this includes alcohol I would say) have be studied quite a bit I believe not much last-long effects have been found. So don't worry about it, it does not alter your brain permanently.

Finally I like to say that what helped the author a lot is just a shift in focus to personal well-being. Any shift in focus helps in most cases. Taking up dancing, playing guiter, camping, whatever, can also make you feel like you can breath again. Hyperfocus, on any kind of activity, can be damaging in the long run for most people. Variety is the spice (& fresh air) of life. But note that hyperfocus includes hyperfocus on personal health, well-being and mental health issues, etc. This can also be damaging and anxiety inducing, as you try to start "fixing" everything and trying to "understand" all your root cause in a infinite loop, start comparing with others, etc. So limit the time spend there as well, I would say.

marhee··on Elixir for Humans Who Know Python
You could reuse df (as the method presumably change df), in addition:

- you have more room to comment what the intention of the code/call is

- you have room to handle / check for errors

For example, the "sort_values" and "groupby" in you example are obvious most readers. But "transform("cumsum") is probably obvious to you but I don't know the intention of the code.

By reassigning to df it makes it clear that the returned value from each of the functions is a `df` (some kind of query builder I think). Actually rewriting you r code I discovered your groupby did a groupby and then selected a result column I think.

So we would get:

   // sort result on dependency date 
   df = df.sort_values('dep_date')

   // ... check if sort_values worked (i.e `dep_date` is valid column)

   // group result by name and select duration column 
   durations = df.groupby('name')['duration']

   // compute columns cumulative sum of durations
   sum = durations.transform('cumsum')
I agree its much more verbose, so this won't work if you (just) want conciseness.
marhee··on Elixir for Humans Who Know Python
> The pipe operator, |>, passes the output of a function to the first argument of the next function. So, instead of writing something like:

foo(bar(baz(new_function(other_function(my_input)))))

You have the option to write:

my_input |> other_function() |> new_function() |> baz() |> bar() |> foo()

The readability benefit is clear - you don't have to read the code "backwards" to understand what it really does.

—- (end of snippet)

This is a nice example of fixing a problem that does not need be there at all.

Just use intermediate variables instead of doing clever stuff. Benefits:

- 1 way of doing stuff

- variable names will help readers understand the intention of the function calls

- you can do explicit error handling for each call

Note: in contrast, in shell prompts the pipe operator is useful because:

- less typing counts here

- prompts are use-once mostly, maybe repeated (history & scripts), but readability is not a mayor concern

- commands deal with large amount of data often, hence storing in intermediate variables can be expensive or even impossible.

None of these points are valid for a programming language. (Unless of course you just fancy the syntax)

Btw I find the joke about “bearded wizards” not very inclusive towards women. It feels assuming that only men (can) be that wizardry.

marhee··on My mindfulness practice led me to meltdown (2021)
> ...and began self-medicating with drugs and alcohol. Looking back, it was also during this time period that I had my first dissociative experiences, in which elements of my sense of self became separated in a way that impaired my ability to function.

This was a couple of years before the "meltdown". While meditation surely may have induced mental health issues, the drugs and alcohol probably didn't help.

What stands out is that he had mental health issues and some point that grew worse, sadly. It temporally correlated with meditation but that doesn't mean it was predominantly caused by it.

The meditation may have triggered things, sure, but my guess is he likely would have had a meltdown also if he went all-in on some other activity for 10 years.

After all, with multiple years (4, 6?) between the first dissociative symptoms and the break down, you could also argue that the mediation may even slowed or alleviated the effects of the mental disorder until some threshold was hit.

marhee··on Why big tech companies need so many people
Because of Price’s law: the square root of number of employees do about 50% of the work (that creates value). So 10.000 emmployees means 100 persons do 50% and 9900 the other 50%.

This mean that a team of 4 is the most efficient size. However if you want to scale you must loose efficiency. Because of Price’s law: the square root of number of employees do 50% of the work (that creates value). So 10.000 employees means 100 persons do 50% and 9900 the other 50%.

This mean that a team of 4 is the most efficient size. However if you want to scale you must loose efficiency.

marhee··on Ask HN: Burnt out from big tech. What's next?
Better a small boss than a big servant, right? (Chinese proverb I believe)

No need to hesitate - you've worked 10 years in FAANG, you'll get 10 jobs offers per month if needed. So, just do it.

But remember, freedom is responsibility.

So, have fun while doing 3 or 4 projects of your list. Switch between them to keep it light and fun. If you get depressed or if you start to just consuming full-time (gaming, Netflix, sleeping, party/drugs etc) for a prolonged period (>month) you don't have the "rigor" and you should get back to a job where people tell you what to do.

In essence, be your own best parent/teacher.

Good luck.

Related

marhee··on Ramanujan Factorial Approximation (2012)
What's the advantage of this approximation in python/code? I can see it being useful analytically, but what's the advantage in code? The formula has an ^n in it, so doesn't it have the same complexity as n! ?
marhee··on A Regular Expression Matcher (2007)
"Lines" is short for "lines of code" I would say so comments and whitespace would not count. But holistically speaking you are right of course.
marhee··on NASA: Tonga blast was 10 megatons, more powerful than a nuclear bomb
I wonder how much greenhouse gas (CO2, etc) is emitted by such an eruption. Would it contribute significantly to global warming?
← PreviousPage 2 of 3Next →