Better HN
topnewbestaskshowjobs
Log inSign up

kortex

8,487 karma · joined Feb 1, 2017 (9y ago) · 2,549 submissions

Submissions

comment 4y ago · link · parent

You are absolutely right that there are domains that are just inherently more stateful and not easily leant to a functional style. What I've found so far on my functional journey is that it can be handy to lean into this aspect of "punishing" certain problems. It kind of forces you to think more explicitly about mutation and when you actually want to invoke it. Thus you end up writing a lot in terms of transactions and hypotheticals - "if I get a POST /users request, what SQL queries do I emit?"

You have execution engines (a web framework and sql engine) that encap a block of pure function. There's no side effects (save maybe logging) whatsover inside your mini-program.

FP patterns like monads let you compose blocks of execution so you can have bigger mini-programs that are more ergonomic to write.

SQL query builders are (I think) a kind of Monad. You can compose selections, filters, groups, etc without ever executing, building up a big "what if" into a transaction. No side effects until you execute, it's pure data in data out. Which means for example you can write true unit tests without mutating a "real" db by composing transactions together.

FP falls apart when you have to reason about "nuts and bolts" of actual computation models, IO, network, time, RNGs, DMA, gpus, large data arrays. FP acolytes say "just let the computer/compiler do it" eg write in FP and compile to optimized imperative machine code, but someone still has to write drivers at the end of the day.

comment 4y ago · link · parent

Nope, unless you do some serious contortions and basically say that the universe is a lambda calculus that operates on each moment in time to produce a new view of reality.

Computers that do anything useful have all manner of I/O. Highly oversimplified in modern architecture, but you can think of I/O as a bunch of memory cells that are DMA'd by external forces. Literally the exact opposite of functional, IO registers are the epitome of global mutable state. Then you have interrupts and the CPU operates in response to these events.

The viewpoint of "computers are mutable state" is inherently better because of parsimony - it requires less degrees of indirection to explain what is happening. Just because you could shoehorn reality into a physical model, does not make it equally valid. You basically need to break it down to the Schrodinger equation level to have a purely functional model when even idealized gates are involved because propagation delay impacts things like how fast you can DMA.

comment 4y ago · link · parent

Not a beek, but I'm close friends with some, and might actually take the plunge this year.

This looks like a classic case of "automating the wrong way" and thinking in terms of agents instead of tools (force multipliers).

What beekeepers really benefit from are tools that let them do more work with less effort. Hive lifters are a perfect example [1]. The most popular design has a couple of mechanical flaws that can lead to buckling, and the hand winch is kind of a pain to use with really heavy supers. That's the real kind of innovation the field would benefit from.

Another is logistics. Schlepping around hive boxes, sugar water, tools, supplies, through loose farm mud, is a real hassle. Tractors are expensive and not really maneuverable. A "farm tug" would be crazy useful - something like an electric wheelbarrow (which exists) but a more generic/modular form factor.

1 - https://beehivelifters.com/product/beehive-lifter-manual-2-w...

comment 4y ago · link · parent

I run all python through `black` and `isort`; this is still a huge step up in my book in terms of readability and ergonomics compared to the standard `git diff` or gnu `diff`.

comment 4y ago · link · parent

The reporter clearly does not do this habitually, as it took them several (frustrating, from the sound of it) days to figure out what they did. Sounds like it was in large part a learning experience for them.

comment 4y ago · link · parent

> Things are never done 100% correctly

Risk is rarely phrased in terms of "100% correct" because risk-management in engineering is well aware of the "swiss cheese model" of failure. More accurately, disaster occurs not when things go less than 100% perfect, but when things start approaching 100% wrong. All of the redundant layers of safety have to fail such that catastrophic failure is the outcome.

The real question is how many layers of safety is enough? Chernobyl, clearly insufficient. Fukushima, still flawed, and folks knew so at the time. The high water mark is such that none of the mistakes of Chernobyl or Fukushima would ever be made again, and we have not one, but two generations and 50 years of improved designs since Fukushima.

comment 4y ago · link · parent

> Just because the growth rate isn't constant, does not make it not exponential.

That's literally what makes it not exponential (I.e. when it falls low enough that it is no longer proportional to the derivative). Sigmoid functions, catenary functions (hyperbolic trig), even the complex exponential (regular trig), and the like all have exponential terms. We don't use the term "exponential growth" in any of these cases unless there is growth without bounds - aka the real coefficients are positive.

comment 4y ago · link · parent

I agree eval is pretty gross and folks should not be encouraging its use since it can lead to bad habits.

Quit/exit are pretty innocuous though. I actually just thought exit was an alias for sys.exit. I've never had a problem using plain exit() in programs.

comment 4y ago · link · parent

I myself kind of went full circle. I started mostly python, then started to really embrace bash, mainly because I joined a company where everyone else used it a ton, got pretty decent at it. Even wrote basically a primitive container orchestrator in Bash because my PM didn't want to use anything "newfangled". Then I joined a startup at basically the ground floor, and it's almost entirely pure python, with some Makefiles to automate common operations. All that to say, I have a lot of experience with both paradigms.

And frankly...bash kinda sucks as a programming language and environment. It's a footgun factory. Even when I was most fluent, I constantly had to deal with nested quotes, escaping, stringly types, empty variables, implicit behavior.

Python's biggest weak point is definitely its packaging and dependency ecosystem... but it at least has one. Bash doesn't even have modules. And it's gotten MUCH better over the years, with pyproject.toml, poetry, actual version resolvers, pipx makes managing venvs for cli tools way easier.

"but bash is everywhere" says many folks. yeah, and? There was a point in time where it wasn't. Python is seeing way more market penetration.

Xonsh (python based shell) and plumbum (python library which makes pipe-operating and subprocessing easier) are both great.

comment 4y ago · link · parent

What exactly do you mean by "defining the physical representation of the data"? Like, "here is a type called uint32, it is a 32 bit little endian unsigned number. Here is struct Foo, it has two uint32 fields". Like, that level of granularity?

Basically Katai struct but can also be used to serialize, not just deserialize?

comment 4y ago · link · parent

So a project with primarily Japanese support with what looks like a Japanese lead dev (https://za.kuro.red/) should use easy English words? K.

comment 4y ago · link · parent

> Why can't the pirates simply copy every single bit of the newer game media as they did before?

Ah! So actually, they implemented a really (technically) cool DRM that is totally sideband to the bits of data on the media. It relied on tracking servo feedback that most (all?) cd burners ignored.

Though, this pertains to ps1, I'm sure they did something similar and perhaps harder to spoof for ps2.

https://hackaday.com/2018/11/05/how-the-sony-playstation-was...

comment 4y ago · link · parent

I think dark matter (and dark energy, for the same reason) invite lots of armchair discussion by curious non-experts precisely because they are basically fudge factors. There's no ontological baggage and the theories are fairly "decoupled" from other aspects of physics. It's basically data, a fitted curve, and some X factor (or Lambda for dark energy) added on to make the data fit the curve. That X does not interact with any other models outside of cosmology in any currently observable way, and not for lack of searching.

That makes it really tempting to think "well maybe it's the model/equation that's wrong", which has been exactly the case throughout scientific history: planet Vulkan vs Relativity, phlogiston vs oxygen, luminiferous ether vs QED.

comment 4y ago · link · parent

Yeah, absolutely. Personally, when I zoom out, and look at the trends of engineering in general: simpler modular systems that compose well together vs bespoke solutions, RISC-V precisely follows the trend. Reduce global state. Make it easier (for humans and algos) to reason about control flow. Have a simple core with optional extensions. This all makes building multi-core solutions way simpler. We are fast running out of transistor density improvements. But we are getting way better at building coprocessors. There's clear value in "doing more simple things in parallel".

comment 4y ago · link · parent

> the pollution and climate impact is just dislocated in space and time to the power plant when the truck is charging.

Isn't that the major point (aside from get the heck out of the way) of these anti-idling laws? Reduce the localized noise and air pollution.

Also NYS gets a ton of electricity from carbon-free sources.

comment 4y ago · link · parent

Not at the macro level. Natural selection isn't just about fitness of an individual. For example, altruism can be selected for, despite resulting in the sacrifice of the individual. It increases the fitness of their kin by globally reducing risk. If you extend "kinship" to "all of humanity", then having a pool on non-reproducing scientists still increases the species' fitness.

https://m.youtube.com/watch?v=iLX_r_WPrIw

comment 4y ago · link · parent

This is a great suggestion. My manager hates the term "tech debt", because it's too vague and everyone has their own idea of what constitutes tech debt. But what we can enumerate are things like heavily intertwined logic and IO, difficult to follow business logic, poor documentation, long functions, etc.

comment 4y ago · link · parent

How do you do quadrature modulation of light? There's no phase information? Or do you just mean 8-bits-per-symbol encoding?

Or does the amplitude of the led vary continuously? I was assuming PCM.

comment 4y ago · link · parent

How much is a heap of sand? It's a Sorites problem. There exists a continuum between "changing your profile picture to be tinted like flag X" and "everyone is saying and doing the same thing and it's an entrenched social norm".

It's certainly less impactful than doing something substantive but it also costs nothing to signal boost. Same like boycotts, it only works en masse.

comment 4y ago · link · parent

Has anyone already learned Dvorak and made the switch to some other "more efficient" layout, such as Colemak, Workman, Neo, this new one, etc? Has it actually been more ergonomic, efficient, and/or faster than Dvorak?

I have a Moonlander and have it totally tricked out so I have no problem with qwerty hotkey locations. It's basically just the time delta to grind a new layout. When I learned Dvorak around 2009, it took me about a month to reach parity. It might be even faster this time around since I'm constantly messing with my layout with small tweaks and having to relearn muscle memory.

Also if you aren't using some kind of layer scheme to map things like ~./()= up/down/left/right to home keys, you are really missing out :p

comment 4y ago · link · parent

That's really impressive. I'm a bit skeptical at first but then I recall I've done similar feats (nowhere near as crazy) from time to time, I call it "jedi mode" when I seemingly just have a huge jump in motor cortex symmetry e.g. when juggling or spinning poi. I also taught myself to write left handed over about a few hours of bored free periods in high school. Quality is noticeably worse though.

Still, switching hands is super impressive. Were you already ambidextrous?

comment 4y ago · link · parent

I ran into this and I run some flavor of Dvorak on everything. Once I got my Zsa keyboards (first an Ergodox then a Moonlander, I love both but slightly prefer the moonlander) I added a level shift which makes it issue Command+<qwerty letter>. You can do the same with a regular keyboard in linux (haven't tried but I know it's possible with xkb) or mac (karabiner I think?).

I have 16 layers of possible keys activated by thumb chords (though in practice my brain runs out of awareness of different combos far before my ~1000 unique keys). So I just dedicate a layer to this pseudo-qwerty.

Need to get around to writing that emoji layer...

comment 4y ago · link · parent

General purpose languages like being turning complete, not as a main goal per se, but it's hard to be expressive and not be TC. TC means you can't statically determine execution behavior (halting problem). There's not a lot of things in this category. Some that come to mind are Cue and Dhall.

Hashicorp HCL2 might also be, but I don't know if they are turning-complete off the top of my head. Some blog suggests it actually is TC, but I cannot corroborate.

Starlark/bazel is TC.

You can add Berkeley Packet Filters and BLooP to the list of TI languages: https://www.quora.com/What-is-an-example-of-a-Turing-incompl...

https://news.ycombinator.com/item?id=28915655

https://dhall-lang.org/#

https://njoseph.me/mediawiki/DevOps/Terraform

comment 4y ago · link · parent

It's yellow lights across the board, literally nothing is green. That's usually indicative of some sort of software infrastructure level failure or cascade failure, not an application-level failure, which usually manifests as one or two specific services going down (depending on how you define "infrastructure" and "application" - with IAC, arguably the software defined infrastructure _is_ an application). I doubt its a physical hardware issue. It's rarely hardware (except when your DS catches on fire).

No red lights, so it's probably not something catastrophic like that facebook DNS SNAFU, but it definitely smells infrastructure- or deployment-scoped. Like either small DNS issue, or some load balancers are sending traffic to servers which cannot handle it programmatically (schema change?) so they are barfing.

comment 4y ago · link · parent

You don't want general purpose languages for IDLs, full-stop. You need straightforward parsing, that is easy to standardize and implement, with some guarantees about bounded execution. That means no recursion, usually means no or limited loops, ideally single pass parsing, actual context-free grammar, etc.

comment 4y ago · link · parent

Right. Lets say you live in a cookie cutter apartment complex. You go to door 22 instead of 23, and because the landlord uses cheap locks, you are able to get in with your key and a bit of jiggling. You make it as far as the kitchen table with a very surprised family before you realize it's not your apartment. Not BnE.

The CFAA uses "intent" and "defraud" quite a few times. That's not gonna stop some DA from trying to throw it at you, and your life is gonna suck, but state of mind is going to be the most important factor. The disclosure shows you weren't in it to defraud. Obligatory IANAL.

comment 4y ago · link · parent

Not GP but one time we did a cyanation reaction (attaches a -CN group) in the pilot plant involving trimethylsilyl cyanide (TMS-CN). We had what looked honest to god like an 8lb propane tank of the stuff ("cyanide and cyanide accessories" lol), with an air-free delivery siphon, typical for air-free, pyrophoric, and toxic reagents.

Normally we'd do this in the high potency suite but the reaction scale was too big so we did it in the conventional GMP pilot plant. Bunny suits and cyanide meters for all three chemists.

I calculated that dose-wise, it was enough to kill tens of thousands, were it directly delivered, however if it were merely vaporized, it would only kill those in the immediate area, and would hydrolyze quickly. There's a great article linked elsewhere in thread about the ineffectiveness of chemical weapons, I've added it for convenience because it's a great read. Air is big, the distance-cubed law really dilutes any toxic agent beyond dangerous limits quite fast (comparing pound for pound lethality of conventional explosives).

https://acoup.blog/2020/03/20/collections-why-dont-we-use-ch...

comment 4y ago · link · parent

That doesn't sound like they were using SSL for authorization. SSL (in the usual use case) just ensures the client to server connection. You can e.g. use special installed certs for accessing VPNs, but I don't think that's the situation here. It just seems like the client was expecting some domain name to serve some endpoints, and he just MITM them to proxy it to his own servers. That's not hacking because here SSL isn't being used for authorization.

The bottom line is the resource permissions weren't scoped right, like at all, and no amount of SSL is gonna fix it - that's what logins and tokens and oauth and that whole dance are for.

Sorry, endpoints aren't doors of a house, where "waltzing in just because it's unlocked is breaking and entering." They are protocols. Merely "talking" to open protocols is/should not be a crime.

comment 4y ago · link · parent

Eh, I agree it was kind of a dumb move, but there's no reason he shouldn't be able to have a snoop around. This wasn't "hacking" in the exploit sense. Web scraping, poking and prodding at APIs (yes even "private" ones), indexing a user ID, looking at source code, injecting your own code (e.g. modifying client js), redirecting some requests, none of these are hacking or exploitation, they are literally how the technologies of TCP/IP, HTTP, the web, and web browsers are meant to work.

I'm not sure where the line of "trying to break security" it, but none of the above count. Even accidentally blasting some endpoint with automated garbage. Intent matters.

comment 4y ago · link · parent

Great point. Although, that sounds like a typical example of "let's write it the ergonomic but less performant way first, then profile and refactor as needed". That seems very tractable for that sort of refactor, especially with type safety.

Also I would not be surprised to see JIT-like behavior from go tooling, first party or otherwise, if that sort of approach takes off.

1
343536
85