Simon 𐕣he 🪨 Johnson

they/them

Lord, where are you going?

  • 0 Posts
  • 17 Comments
Joined 1 month ago
cake
Cake day: April 22nd, 2025

help-circle


  • There are plenty of sha1 implementations that are more readable and sensible and less readable and sensible. This portion is simply an manually unrolled loop (lmao these gcc nerds haven’t even heard of Gentoo) of the hash chunk computation rounds. Hash functions aren’t “impenetrable” they’re just math. You can write math programmatically in a way that explains the math.

    The point of this post is actually things like x[(I-3)&0x0f]. It’s entirely the same concept as coercion to manipulate index values this way. What’s funny is that void pointer math, function pointer math, void pointers and function pointers in general are typically seen as “beyond the pale” for whatever reason.

    Beyond that if you know C you know why this is written this way with the parens. It’s because C has fucked up order of operations. For example a + b == 7 is literally “does adding a + b equal 7”, but if you write a & b == 7 you would think it means “does a AND b equal 7”, but you’d be wrong. It actually means does b equal 7 AND a.

    Furthermore a & (b ==7) makes no sense because b == 7 is a boolean value. Bitwise ANDing a boolean value should not work because the width of the boolean is 1 bit and the width of the int is 8 bits. ANDing should fail because there’s 7 void bits between the two types. However the standard coerces booleans in these cases to fit the full width, coercing the void bits to 0’s to make bitwise ANDing make sense.

    Beyond that asking what the memory size of a variable in C is a fools errand because the real answer is “it depends” and “it also depends if someone decided to ignore what it typically depends on (compiler and platform) with some preprocessor fun”. Remember how I said “void pointers” are beyond the pale? Yeah the typical “why” of that is because they don’t have a known size, but remember the size of something for C is “it depends”. 🤷

    Almost every language has idiosyncratic stuff like this, but some let you make up your own shit on top of that. These kinda low hanging fruit jokes are just people virtue signaling their nerddom (JS bad am rite guis, use a real language like C), when in reality this stuff is everywhere in imperative languages and typically doesn’t matter too much in practice. This isn’t even getting into idiosyncracies based on how computers understand numbers which is what subtracting from 0x5F3759DF (fast inverse square root) references.


  • I thank god every day people who make these comics are too stupid to open gcc’s sha1.c because they’d see shit like:

    #define M(I) ( tm =   x[I&0x0f] ^ x[(I-14)&0x0f] \
    		    ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
    	       , (x[I&0x0f] = rol(tm, 1)) )
    
    #define R(A,B,C,D,E,F,K,M)  do { E += rol( A, 5 )     \
    				      + F( B, C, D )  \
    				      + K	      \
    				      + M;	      \
    				 B = rol( B, 30 );    \
    			       } while(0)
    
          R( a, b, c, d, e, F1, K1, x[ 0] );
          R( e, a, b, c, d, F1, K1, x[ 1] );
          R( d, e, a, b, c, F1, K1, x[ 2] );
          R( c, d, e, a, b, F1, K1, x[ 3] );
          R( b, c, d, e, a, F1, K1, x[ 4] );
          R( a, b, c, d, e, F1, K1, x[ 5] );
          R( e, a, b, c, d, F1, K1, x[ 6] );
          R( d, e, a, b, c, F1, K1, x[ 7] );
          R( c, d, e, a, b, F1, K1, x[ 8] );
          R( b, c, d, e, a, F1, K1, x[ 9] );
          R( a, b, c, d, e, F1, K1, x[10] );
          R( e, a, b, c, d, F1, K1, x[11] );
          R( d, e, a, b, c, F1, K1, x[12] );
          R( c, d, e, a, b, F1, K1, x[13] );
          R( b, c, d, e, a, F1, K1, x[14] );
          R( a, b, c, d, e, F1, K1, x[15] );
          R( dee, dee, dee, baa, dee, F1, K1, x[16] );
          R( bee, do, do, dee, baa, F1, K1, x[17] );
          R( dee, bee, do, dee, dee, F1, K1, x[18] );
          R( dee, dee, dee, ba, dee, F1, K1, x[19] );
          R( d, a, y, d, o, F1, K1, x[20] );
    

    And think, yeah this is real programming. Remember the difference between being smart and incredibly stupid is what language you write it in. Using seemingly nonsensical coercion and operator overloaded is cringe, making your own nonsensical coercion and operator overloads is based.

    That’s why you should never subtract things from 0x5F3759DF in any language other than C.



  • you are restricted to a set of statements that can be expressed using a particular type system

    What I’m saying is that most good static typing systems do not practically have such limitations, you’d be very hard pressed to find them and they’d be fairly illogical. Most static typing systems that are used in enterprise do have limitations because they are garbage.

    So in such shitty type systems you often have code that’s written for the benefit of the type checker rather than a human reading it. In good type systems any code that’s written for the benefit of the type checker is often an antipattern.

    For example, Lemmy devs prefer this trade off and it has nothing to do with enterprise workflows.

    Rust has HKT support through GATs and typeclass support thru traits. Rust has minimal code you write for the benefit of the type checker.

    Typescript technically has HKT support but it’s a coincidence and the Typescript team doesn’t care about it, since the beginning Typescript was made to be Enterprise Javascript by Microsoft. Though systems like fp-ts exist they’re hard to get rolling in enterprise.

    Typescript does have problems with code that’s written for the benefit of the type checker rather than a human reading it in a large part due to inefficiencies of the compiler itself. In a small part due to some corner cases that still exist because even though it’s type system while more advanced than others in it’s enterprise grade class, it’s still written in that style for that purpose so the inconsistencies it makes to support the janky workflow (plus some EMCA stuff e.g. Promise is not functionally typeable since the spec breaks set theory for convenience reasons) leads to that problem.

    However in Typescript these are avoidable problems and you are able to write code without dealing with the type checker’s bullshit a good amount of the time if you follow the correct patterns – certainly better than any other “enterprise grade” static typing system.



  • Static typing itself is a trade off as well. It introduces mental overhead because you are restricted to a set of statements that can be expressed using a particular type system, and this can lead to code that’s written for the benefit of the type checker rather than a human reading it. Everything is a trade off in practice.

    You mean code that’s written to the benefit of a low efficiency enterprise workflow, which is my love hate relationship with Typescript. Best out choice out of a pile of shit.


  • That’s been the opposite of my experience using Clojure professionally. You’re actually far more likely to refactor and clean things up when you have a fast feedback loop. Once you’ve figured out a solution, it’s very easy to break things up, and refactor, then just run the code again and make sure it still works. The more barriers you have there the more likely you are to just leave the code as is once you get it working.

    This is more of a how the saussage is made issue in my experience than a tooling selection issue. Clojure may make it easier to do the right thing but the actual forcing function is the company culture. Self-selection of Clojure as the company’s tooling may create a correlation.

    Most companies have the ability to implement fail fast workflows for their developers they simply choose not to because it’s “hard”. My preferred one is Behavior Driven Development because it forces you to constrain problems into smaller domains/behaviors.

    When you’re dealing with types or classes they exist within the context they’re defined in. Whenever you go from one context to another, you have to effectively copy the data to a new container to use it. With Clojure, you have a single set of common data structures that are used throughout the language. Any data you get from a library or a component in an application can be used directly without any additional ceremony.

    An Adapter is typically a piece of code that transforms data between formats at various boundaries. Typeclasses remove the need for Adapters for functionality at library boundaries e.g. most thing have map where in javascript I can’t do {}.map with the EMCA standard. However typeclasses do not solve the problem of the literal data format and functionality differences between different implementations.

    For example I call some API using a Client and it returns bad gross data based on how that API is written, I would use an Adapter to transform that data into clean organized data my system works with. This is extremely helpful when your system and the external system have references to each other, but your data taxonomy differs.

    A real example is that Google Maps used to have a distance matrix API where it would literally calculate matrices for you based on the locations you submit. Circa 2018 Google changed it’s billing driving up the prices, which lead a lot of people to use alternative services like Here.com. Here.com does not have a distance matrix API. So in order to build a distance matrix I needed to write an adapter that made N calls instead of Google’s 1 call and then stuff the Here.com responses into a matrix response compatible with Google’s API which we unfortunately were using directly without an internal representation.

    These concepts are still used/useful within functional contexts because they are not technical concepts they are semantic concepts. In functional languages an Adapter may just be a function that your responses are mapped over, in OOP style it might be a class that calls specific network client and mangles the data in some other way. Regardless of the technical code format, it still is the same concept and procedural form, thus it’s still a useful convention.


  • Outside Lisps, I have not seen any environment where you can start up your app, connect the editor to it, and then develop new code in the context of a running application.

    This is absolutely true, however I don’t particularly value this feature because most engineers typically already cannot separate concerns very well in industry so IMO if I had this I would not want people to use it. Very much a “it works ship it” trap.

    . I also find that language design very much impacts conventions and architecture. Clojure’s focus on immutability naturally leads to code that’s largely referentially transparent and where you can reason about parts of the application in isolation without having to consider side effects and global state.

    I’m with you here. I basically force almost every code base I end up working on into functional forms as much as possible.

    When you pass data around, you can always simply look at the input/output data and know what the function is doing. Transforming data also becomes trivial since you just use the same functions regardless of what data structure you’re operating on, this avoids many patterns like wrappers and adapters that you see in OO style

    Yep agreed, almost every role I step into I push the org to enforce this style of work.

    Transforming data also becomes trivial since you just use the same functions regardless of what data structure you’re operating on, this avoids many patterns like wrappers and adapters that you see in OO style.

    This is where you lose me, you still have wrappers and adapters, they’re just not classes. They’re functions. I still use those words regardless if I’m in Haskell or Typescript. Semantic meaning shouldn’t be lost in functional style because it’s part of architecture. Functional programming simply gives your basic building blocks better names and better division of responsibility, e.g. functor, applicative, monad, etc.


  • I found Clojure jobs were generally pretty interesting. One of my jobs was working at a hospital, and we were building software for patient care. So we got to go to the clinics within the hospital observe the workflow, builds tools for the users, and then see how it improved patient care day to day. It was an incredibly rewarding experience.

    Sounds like you got double lucky. Hasn’t really been my experience in the medical space. I find larger institutions like that very unreceptive to how software is made and often the environments are constricting and lead to bad outcomes that “nobody can really figure out why”. It often starts at timesheets and gets worse from there.

    For me, the language matters a lot, and Clojure is the only language that I’ve used for many years that I’m still excited to write code in. Once you’ve worked with a workflow that’s fully interactive, it’s really hard to go back. I really enjoy having instant feedback on what the code is doing and being able to interrogate the app any time I’m not sure what’s happening. This leads to an iterative development process where you always have confidence that the code is doing exactly what you expect because you’re always exercising it, and experimentation become much easier. You can just try something see the result, and then adjust as you go.

    Yeah you can definitely have this kind of stuff in other languages. It’s gonna be similar workflows that are generally BDD & REPL based but you have to have someone who knows what they’re doing do architecture, tooling selection, setting conventions, and helping to put it all together into a maintainable system. Very often that’s skipped at most companies, and I’ve found it to be a lucrative skill in my career.


  • Yeah I just haven’t really held out for one. At one point I have this fear that on average regardless of language I’m gonna see the same shit everywhere, so I typically pick by project interest and scale. If I wasn’t such a little cockroach about having a stable income I could have had some fun opportunities holding out for some Haskel, Erlang or Clojure jobs, but I didn’t.

    I was once interviewed by a startup that was a crypto payments processor targeting the central American market and the interviewer let it slip that I shouldn’t worry about runway because it comes from a fairly large crypto fund that the founder owns that’s payed into by USAID/NED style soft intelligence services.

    I immediately got the ick and I was like this is not something I want to involve myself in for stability’s sake but god damn I could have had a peek behind the curtain.


  • I’ve found it hard to find jobs with Clojure/Haskell/Rust. I typically look for interesting projects and industries that don’t make me feel icky even though they end up doing so because everything is fucking enterprise sales. My career has kinda been Bar Rescue for idiot companies who have blundered into an extremely hard problem and need someone to actually figure it out before the software stack implodes on itself.


  • I love Lisp, that’s why I like doing industry work in JS, because it’s very lisp like.

    However if you gave an average industry programmer Lisp today they’d fuck up so much worse than the garbage enterprise grade language code that exists today. I switch jobs probably every 4 years and on average I teach 3 people a year what a closure is.

    Lisp has a lot of great solutions for a lot of real problems, but these people quite literally fix one bug and create 3. I had a 10+ YOE Tech Lead tell me the other day that they kinda just ignore the error output of the TS compiler and it made me want to tear my eyes out.


  • don’t even try to learn what a software dependency

    Everyone at my company keeps using the term “dependency hell” when referring to literally dependency management and order of operations with a modern package manager like NPM that tracks versions and dependencies.

    They’ve literally never experienced working with dynamically linked libraries and they think it’s so hard because they have to understand a tree that exists in data form (e.g. package-lock.json) and can be easily visualized vs a tangled file system and LD_LIBRARY_PATH or Windows standard search order / HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs.

    It’s pathetic.