HNHacker News
TopNewBestAskShowJobs

dharmaturtle

454 karma · joined October 7, 2013

[ my public key: https://keybase.io/dharmaturtle; my proof: https://keybase.io/dharmaturtle/sigs/xb251-ShxEpBNZae8VvDaqxiONfTyI-GZD4nZSKYG_A ]

Or you can reach me at my HN handle at gmail

submissionscomments
dharmaturtle··on Coconut: Simple, elegant, Pythonic functional programming
Kinda the other way around honestly. FP predates OO by decades. If you think of "traditional OOP" as C-style syntax, then you could conceivably think of C-style syntax as an attempt to make FP more readable.

Personally, I prefer FP-style (ML in particular) syntax. I think the fact that OOP languages are copying ML features like pattern matching, preference for immutability/call-by-value, and "do-notation" as a testament to FP's power.

Side note about syntax, honestly it's just glue. `<$>`, `|>`, `<*>`, and all the other symbols are just boring operations that are used so often that it's preferable to use symbols so programmers can focus on the meat. In other words:

    functionA <$> functionB |> functionC <*> functionD
is easier to read than

    functionA(map(functionB(pipe(functionC(bind(functionD))))))
dharmaturtle··on AMD Laptops finally reach the 4k screen barrier
Also a programmer here. 4k 39" TV with zero scaling is my main setup. It's lovely - I highly recommend it. With a tiling window manager, I can see lots of code, run my tests, keep an eye on the command line, have API docs open, all kinds of stuff. It's even more dramatic than going from 1 screen to 2, IMO. In a way it's going from 2 to 4 :D
dharmaturtle··on Speed Matters
I can't touch type symbols. (!@#$%^&*)

I can feel my brain stutter every time I need to type an esoteric operator.

...okay I know what I'm doing this weekend.

dharmaturtle··on What I wish I knew when learning F#
Linking your demo of VS Code Notebooks cause it was great: https://youtu.be/_QnbV6CAWXc?t=1298
dharmaturtle··on America’s unemployed are sending a message: Safety and compensation matter
Fair. I was mildly triggered when scanning this thread, so thought I'd make the metric clear to anyone else.

Back on topic, if you sort by Leasure/Travel or Economy/Labor, it is pretty clear that red states have the lead.

dharmaturtle··on America’s unemployed are sending a message: Safety and compensation matter
To be clear: this site defines "recovery" by combining COVID and economic factors - equally weighted.

If we look solely at COVID transmission rate, that's a somewhat different picture: https://covid.cdc.gov/covid-data-tracker/#cases_casesper100k...

dharmaturtle··on Why I'm donating $150/month (10% of my income) to the musl Libc project (2019)
If you use chrome, this exists: https://chrome.google.com/webstore/detail/amazon-smile-redir...
dharmaturtle··on Offline First
> one of the missing pieces is situations where some parts of the object graph should not be visible or editable by certain users. That sort of thing comes up the whole time and can be pretty complex yet is often just handwaved away.

I discovered this problem in my domain about two months ago. My solution was to split my Aggregate Root into smaller pieces, to use DDD terminology. In my domain, each user/client owns their own data. However they may choose to publish that data and have it be publicly visible so others may view/comment/copy/pull-request it. It's basically Github for flashcards. So, I have an Aggregate Root for publicly visible flashcards, and another Aggregate Root for a user's personal flashcards. It helps that there are distinct behaviors for each Aggregate Root - there's no real point to leaving a comment on a personal flashcard, and there's no real point to "studying" a public flashcard (because that implies logging your study history to the public card). It does mean, however, that there needs to be a translation layer - it should be possible to convert a private flashcard to a publicly visible one, and it should also be possible to copy a public flashcard to your own personal collection.

Obviously this is very domain specific.

dharmaturtle··on Offline First
Seems like you're describing event sourcing. I'm building an offline-first app and doing pretty much what you're describing.

> I always end up duplicating almost all of the backend logic into the clients as well

Yep, this is a pain I feel acutely. I'm using dotnet (C#/F#) because it allows me to ship & run DLLs on the browser with Blazor, leading to significantly less duplicate code. F# can transpile to Javascript with Fable (F# + Babel), so that's also an option. I haven't fully vetted Blazor yet, but it seems good. Clojure can also run on the server and on the browser with ClojureScript.

The only other option I see is going fullstack Javascript, and I hate Javascript.

dharmaturtle··on Using RSS to replace social media
What RSS service you're using? I'm in the market.
dharmaturtle··on Git Commands Explained with Cats (2017)
re: navigation:

VS Code can render PNGs, so you can hit the period key on GitHub and just navigate the repo's PNG folders.

dharmaturtle··on Why Are So Many Young Men Giving Up on College?
I recently read The Case Against Education. It's very interesting, even if you don't buy the conclusion. From the book:

> The Good Student, by definition, fits the profile of a typical B.A. who did not continue on to graduate or professional school. Now let’s define three more ability archetypes: the Excellent Student, the Fair Student, and the Poor Student. The Excellent Student fits the profile of the typical master’s degree holder. The Fair Student fits the profile of the typical high school graduate who does not try college. The Poor Student fits the profile of the typical high school dropout. Ideally, to repeat, “fits the profile” is all-inclusive, covering cognitive ability, character, background, and every other trait. In terms of measured cognitive ability, Excellent Students are around the 82nd percentile, Good Students the 73rd, Fair Students the 41st, and Poor Students the 24th.

> Results closely match common sense. High school is lucrative for all four archetypes. Even Poor Students can reasonably expect the resources they invest in high school to out-perform high-yield bonds. College, in contrast, is a solid deal only for Excellent and Good Students. Largely owing to their high failure rate, Fair Students who start college should foresee a low 2.3% return on their investment. For Poor Students, it’s a paltry 1%.

https://en.wikipedia.org/wiki/The_Case_Against_Education

dharmaturtle··on Sauna use as a lifestyle practice to extend healthspan
> So you pull that tube over yourself and then cover the top with the sleeping bag?

Yep. Ghetto AF. That's why the chair is there to elevate the sleeping bag - otherwise I wouldn't be able to reach the sleeping bag from inside the tube.

> No worries about air circulation or passing out?

Circulation is fine. It's far from airtight - air creeps in from the bottom through the cracks, and I can always just open a small hole in the "ceiling" if needed. Never done it though cause it doesn't get stuffy. Haven't passed out, though that would be seriously dangerous since the heating element is exposed and I'd likely be burned.

> Is it pitch black in there?

Yes, so that's why there's a nightlight on an extension cable in the pic. Also a flashlight on my phone.

dharmaturtle··on Sauna use as a lifestyle practice to extend healthspan
I built a super cheap "traditional" dry sauna. It's basically an electric burner, a pot to increase surface area and humidity, a 25 foot roll of thermal foil, and a sleeping bag as the ceiling. I disassembled the burner, removed all the plastic pieces, and short circuited the safety cutoff. It's jank AF, but in the end less than 100$. AFAIK there aren't any dry saunas under $1000 - the heater alone is ~$200. Mine is also portable, so it's in the garage in summer and in the laundry room in winter. There are portable infrared saunas for ~$100, but most studies are on the "dry" type. I rubber band a block of ice to my phone and do my reading/social media in there, so the time cost is reduced.

https://i.imgur.com/Lml7Vms.jpg

About 1 year in and I haven't burned down the house... yet.

dharmaturtle··on Hell Is Other REPLs
I've been using VS Code Notebooks with F# - it's fantastic. Basically Jupyter Notebooks for VS Code.

Demo: https://youtu.be/_QnbV6CAWXc?t=1298

dharmaturtle··on Weird Languages
Scala experimented with type providers, but it looks abandoned: https://docs.scala-lang.org/overviews/macros/typeproviders.h...

Idris has them (but it's Idris) https://docs.idris-lang.org/en/latest/guides/type-providers-...

This SO answer states that Java has something similar called "Type Manifold" https://stackoverflow.com/a/53037742

I only have F# experience so I can't comment about the ergonomics of the above. I love, love, love the JSON/Regex type providers. I'm trying to move away from SQL (to event sourcing) so haven't used that type provider yet.

dharmaturtle··on Performance Improvements in .NET 6
To add to the other comment, how about Fabulous?

https://github.com/fsprojects/Fabulous

dharmaturtle··on Performance Improvements in .NET 6
Depends on what OP is familiar with. If they know/like functional programming, I'd recommend F# highly. If not... Yeah go with C#.

Then later learn F# because it's absolutely kick ass :)

dharmaturtle··on Software Engineering's Greatest Hits [video]
> The fundamental problem, IMHO, with error-handling is the call/return nature of most of our programming languages

I actually consider this a benefit, not a problem. The alternative, as I see it, is to side effect... which 99% of the time is a bad idea if there's an alternative.

> particularly with intermediate functions that don't really know what happened below them and don't really have enough of the context from their callers to handle the error

If you write a `map` function, you can use it in your pipeline to map over the Ok case and your intermediate functions don't need to know they're taking an Ok|Error type. This is exactly the same as what occurs in the `map`/`select` higher ordered function that's on the `list` type. The function passed to map/select doesn't know that it's being used on a list. In the same way, the function being passed to `Ok.map` doesn't know that it's being used on a discriminated union.

> You can then have the filter have an out-of-band mechanism for actually dealing with the error, analogous to Unix stderr.

To me this is a side effect and should be avoided. Basically your filter is partitioning your list into two lists, one of OKs and one of Errors, logging the errors, and then not reporting anything back to the consumer. LMK if I'm misunderstanding.

dharmaturtle··on Software Engineering's Greatest Hits [video]
I'm a big fan of "Railway Oriented Programming" [1]. Basically your code has two paths - the "Ok" route and the "Error" route. Your code won't compile unless you handle the Error case.

However, it requires language level support to use easily - you need mutually exclusive types like discriminated unions. It's harder to do in most OO languages like C#/Java/Javascript, but you can do it with some effort. Which is why most don't.

[1]: https://fsharpforfunandprofit.com/rop/

dharmaturtle··on Event Sourcing (2005)
Interesting... just to be clear, an _individual stream of user events_ is an aggregate. E.g. a user Bob Smith's events are independent of another user like Jane Doe. It isn't the case that the entire "User Table" is a single aggregate - each row in it is an aggregate.

If you're trying to do multimaster db storage, like a phone app syncing with some cloud server, where an aggregate resides in two separate locations, this is where event sourcing shines. It's just like git, right, and so you can do all the stuff that git can do - merge event streams, rebase events... it's actually the reason why my pet project switched from an RDBMS to event sourcing. Related video: https://skillsmatter.com/skillscasts/1980-cqrs-not-just-for-...

dharmaturtle··on The EU Wants a Universal Mobile Charger, but Apple Doesn’t
I guess gaslighting is what they do now.

> We, who consider ourselves absolutely leading on privacy, see what we are doing here as an advancement of the state of the art in privacy, as enabling a more private world.

https://arstechnica.com/tech-policy/2021/08/apple-defends-ip...

dharmaturtle··on Event Sourcing (2005)
> it means that there is only one instance that processes commands

Not necessarily. Depends on how you shard the aggregate/streams. Since aggregates _by definition_ maintain their invariants, you can have literally a shard for every aggregate. Overkill, but it illustrates the point. Since there's no state shared between aggregates, you can process each aggregate/stream on its own instance.

> this instance checks all command ids if they appeared before (so keeps track of all ids in an efficient way)

Yep. If you trust the client and don't mind losing old commands, this isn't too hard - use a monotonically increasing number (e.g. ms since the epoch) as part of the commandId. Any command with an id less than the commandId in the aggregate will be rejected as "out of date". Note that this serves as an optimistic concurrency check.

If you don't trust the client (or you don't want to lose old commands issued on a possibly out of date view) and just use GUIDs as commandIds, then yes you'll need to keep track of some ids - but not necessarily all. Do you really need commandIds past 1000? (Depends on your domain.) You'll need to "roll up" the events into some summary view anyway to check/maintain business invariants, so keeping, say, the last 100 commandIds as part of that summary view is simple.

dharmaturtle··on Event Sourcing (2005)
If a command is successfully converted/persisted into an event, that event should contain the command's ID. When the command is replayed, the domain aggregate/event stream will contain that command ID, and will therefore reject/ignore the replayed command.
dharmaturtle··on Event Sourcing (2005)
They have a channel in this slack that's pretty good for getting answers to questions:

https://github.com/ddd-cqrs-es/slack-community

dharmaturtle··on Event Sourcing (2005)
What's wrong with EventStore? https://www.eventstore.com/
dharmaturtle··on Event Sourcing (2005)
Event sourcing is really good for building occasionally connected applications (e.g. phone app). Makes conflict resolution so much easier than, say two relational databases.

Basically it follows the git model - distributed systems are each their own sources of truth, and allows for (relatively) simple syncing of state. When two distributed systems conflict, well... you need to write some kind of merge algorithm that may or may not ask for user input. But at least the accidental complexity is significantly reduced.

dharmaturtle··on Event Sourcing (2005)
I would argue that there is no such thing as "the business model". There may be a projected rolled up summary state... but that's only one possible view out of infinitely many. For example, one possible "business model" could be "customers who have changed their emails in the past month". You shouldn't favor any particular view as being the favored "business model"... unless you're doing snapshots, in which case everything goes out the window.

Basically, I vote for `SetCustomerEmail`.

dharmaturtle··on SpaceX launching satellite to display billboard ads in space
> Once in orbit, a selfie-stick attached to the side of the CubeSat will film the display screen. This footage will be livestreamed on YouTube or Twitch so anyone can tune in to watch the satellite's screen, Reid said.

https://www.businessinsider.com./spacex-start-up-launch-sate...

You won't be able to see it with the naked eye. Hell, it's not easy to spot the ISS even with a telescope/app.

dharmaturtle··on NASA solved a $100M vibration problem cheaply by strobing the display
> vibration amplitude classified into low (< 0.3 g) or high (>0.5 g) (i.e., into 2 levels) were performed to assess the significance of these findings

https://ntrs.nasa.gov/api/citations/20150000242/downloads/20...

I was hoping to find something like "5cm", but it looks like "g" is all they offer.

← PreviousPage 4 of 6Next →