Readit News logoReadit News
joejev commented on Strings Just Got Faster   inside.java/2025/05/01/st... · Posted by u/Tomte
delusional · 10 months ago
The example is entirely unconvincing. Why would you store those calls in a map and not just a variable?

Even if the map is crucial for some reason, why not have the map take a simple value (like a unint64) and require the caller to convert their string into a slot before looking up the function pointer. That way the cost to exchange the string becomes obvious to the reader of the code.

I struggle to find a use case where this would optimize good code. I can think of plenty of bad code usecases, but are we really optimizing for bad code?

joejev · 10 months ago
Isn't the entire point of an optimizer to convert "bad code" into "good code"?

Your proposed solution is to have the user manually implement a hash table, but if you have a good optimizer, users can focus on writing clear code without bugs or logic errors and let the machine turn that into efficient code.

joejev commented on Fat pointers in C using libcello   libcello.org/learn/a-fat-... · Posted by u/dgellow
joejev · 6 years ago
Interesting idea, but this implementation has UB:

    typedef void* var;

    struct Header {
      var type;
    };

    // ...

    #define alloc_stack(T) header_init( \
      (char[sizeof(struct Header) + sizeof(struct T)]){0}, T)

    var header_init(var head, var type) {
      struct Header* self = head;
      self->type = type;
      return ((char*)self) + sizeof(struct Header);
    }
The section "struct Header* self = head" is UB. The alignement requirement of the local char array is 1 but the alignment requirement of struct Header is that of void* which is probably 8.

joejev commented on Configs suck? Try a real programming language   beepb00p.xyz/configs-suck... · Posted by u/gyre007
comex · 6 years ago
Makefiles are executable, with their own crappy ad-hoc Turing-complete language. For example, here’s the full list of functions supported by GNU make:

https://www.gnu.org/software/make/manual/html_node/Functions...

Naturally, trying to do anything even slightly complex with it quickly leads to an unreadable cacophony of dollar signs, backslashes, and soft and hard tabs (you need both!). Just like the modern YAML-based systems, Make’s language wasn’t originally intended to be a full scripting language, but had scripting bolted on because people needed it. If only it had chosen to embed a real programming language instead, you could have the functionality without sacrificing readability.

joejev · 6 years ago
It's not an ad-hoc turing complete language, it is just a programming language. Makefiles are just programs. There are some strange implicits, but that isn't unique to the Make programming language.
joejev commented on Retro: A Modern, Pragmatic Forth   forthworks.com/retro/book... · Posted by u/UkiahSmith
RodgerTheGreat · 7 years ago
I think this is a bit of a misconception. A critical element of Forth is that there are two stacks: a data stack for operands, and a return stack for keeping track of what word to return to after each call completes (and other fun stuff). These stacks grow and shrink independently. Unused operands on the data stack quietly flow along to the next word that takes a peek with no overhead. There's no difference between how the stacks are used within an "expression" and between "function calls"- these concepts don't exist at all like they do in curly-brace languages!

In a typical non-Forth "stack VM", there is a single stack which behaves like the C stack: allocate an activation record with locals on a function call, pop the whole thing off at the end. Intermediate calculations go on top of all this, avoiding the need to explicitly register allocate in bytecode, but operands don't naturally flow between function definitions; they're copied around explicitly as the stack grows and shrinks.

joejev · 7 years ago
I think they meant that the bytecode itself reads like a forth. The data stack works just like it does in forth within a single Python function.
joejev commented on Near-duplicate features of C++ (2017)   nayuki.io/page/near-dupli... · Posted by u/nayuki
hermitdev · 7 years ago
I've gotten into arguments about this in the past.

As you've shown, references can be null, but theyre not supposed to be and are assumed nearly universally to not be.

The argument comes down to when the undefined behavior occurs: is it at the deference to create the reference, or is it on the first memory access using the reference? The language pedants will say the former, but in practice, it's the latter.

In practice, you'll likely be able to invoke a member function on a null pointer or reference, as long as that member doesn't directly or indirectly access data members, or virtual functions of the type. Obligatory, I dont recommend doing this or relying upon this behavior, it's just behavior I've seen in my 2 decades of debugging C++.

joejev · 7 years ago
> The argument comes down to when the undefined behavior occurs: is it at the deference to create the reference, or is it on the first memory access using the reference? The language pedants will say the former, but in practice, it's the latter.

The undefined behavior is always when the null reference is created. The issue will _usually_ manifest when you try to dereference the pointer, but the undefined behavior was creating the null reference in the first place.

joejev commented on Kickstarter’s staff is unionizing   theverge.com/2019/3/19/18... · Posted by u/tmm
Retra · 7 years ago
None of that is relevant to the employer-employee relationship. My employer's competition is not my competition. Even if there were no hiring competitors, they would still not be my competition. I would still want equitable bargaining power with my employer.

And regardless of that, if my employer is willing to pay our CEO over 20x what they pay their average employee, they are not in a position to niggle over the kinds of systemic inefficiencies they would suffer under a union.

joejev · 7 years ago
> And regardless of that, if my employer is willing to pay our CEO over 20x what they pay their average employee, they are not in a position to niggle over the kinds of systemic inefficiencies they would suffer under a union.

Do you not believe that a CEO could have at least 20 times the impact on the value of a company than the average employee, and if so, should they not be compensated accordingly?

joejev commented on The CPython Bytecode Compiler Is Dumb   nullprogram.com/blog/2019... · Posted by u/ingve
andrewf · 7 years ago
This [1] is a bytecode optimizer for Python - it takes the bytecode from CPython's compiler, and outputs bytecode with a few select optimizations.

Anyone know of someone taking this idea further?

[1] http://code.activestate.com/recipes/277940-decorator-for-bin... - it's old, for Python2.4

joejev · 7 years ago
I work on a library for doing Python bytecode transformations like this, but with a more abstract API. Here is a similar transformation with this library, which works with Python 3: https://github.com/llllllllll/codetransformer/blob/master/co...
joejev commented on Why has Plan 9 chosen statically linked binaries instead of dynamic ones? (2004)   9p.io/wiki/plan9/why_stat... · Posted by u/stargrave
taeric · 7 years ago
I think the dream is you could have one SSL process that others communicated with. Message passing at large.
joejev · 7 years ago
So, like some sort of shared library that my programs dynamically communicate with? How is this functionally different from a shared object?
joejev commented on Japan’s special take on a packed lunch   bbc.com/travel/story/2018... · Posted by u/MiriamWeiner
coldtea · 7 years ago
>How far are you going to have to go in Tokyo if you're craving Mexican? And is there even a decent Mexican restaurant in Tokyo? (I'm guessing the answer might be yes but not many.)

You'd be surprised.

https://www.tripadvisor.com/Restaurants-g298184-c29-Tokyo_To...

joejev · 7 years ago
I've been to chiles, not surprised to see that on the top of the list.

u/joejev

KarmaCake day262October 1, 2014View Original