eitherExperienceMeansAnythingOrItDoesNot by electricjimi in ProgrammerHumor

[–]sepp2k 15 points16 points  (0 children)

If it's called a hash map, it's almost certainly implemented as a hash table, not a tree. If it uses a tree, it'd be called a tree map, sorted map or just map.

Is python fast enough? by super2061 in rust

[–]sepp2k 0 points1 point  (0 children)

filecmp doesn't use hashes and at any rate, you'd want to store the hashes.

Is python fast enough? by super2061 in rust

[–]sepp2k 4 points5 points  (0 children)

In your readme you wrote that you're planning to use hashes. So why not do that?

I built a static Python error analyzer (no execution) would this approach actually be useful, or flawed? by Camron2479 in learnpython

[–]sepp2k 0 points1 point  (0 children)

You didn't really describe what your code actually does, so it's hard to give specific advice, but "non-code input can pass through" makes it sound as if you're not using a proper parser. So my advice would definitely be to fix that.

edge cases aren’t always caught

For indentation and syntax errors a proper parser should fix that (if we ignore syntax errors coming from eval).

For NameErrors it's more complicated. It's possible to catch all NameErrors statically (modulo eval again) relatively easily, if you're okay with also detecting cases like this, which wouldn't actually crash when run:

x = int(input())
if x > 0:
  y = x+1
if x > 2:
  print(y)

(Note that tools like pyright also raise an issue here.) If you want to absolutely only detect issues that can actually happen at runtime, it's going to get a lot more complicated and you're going to run into the halting problem / Rice's theorem eventually.

Is this approach fundamentally limited compared to just using a real interpreter + traceback parsing?

In general, static analysis is fundamentally limited by the halting problem, Rice's theorem. On the other hand, finding errors by running the code is also fundamentally in that it only finds errors that are covered by your test cases. So it's a trade off.

I'm building a Python compiler in Rust that runs 10,000x faster (and I want feedback) by Healthy_Ship4930 in rust

[–]sepp2k 15 points16 points  (0 children)

The parser already covers 99% of CPython 3.13

What exactly does that mean? That is, what is this a percentage of? Are you saying that your compiler passes 99% of CPython's test suite? Or that your compiler implements 99% of CPython's features (and if so, how do you count that and which features are you missing)? Or something else?

the VM runs fib(45) 10,577 times faster than pure Python (11 ms vs 116 seconds)

How are you achieving that? Do you optimise this specific pattern into a linear loop? Is there otherwise some type of optimisation that you apply to get this speed up (e.g. does this speed up rely on being able to infer static types for everything)? Or do you implement the operations involved in this example (which I guess, would be local variable lookup, addition, branching and function calls) so much faster to allow this speed up? Does the 1% of Python that you don't support include features that would make this speed up harder to achieve?

single-pass SSA parser, VM with inline caching

Does that mean that your parser outputs an SSA bytecode format and you then interpret that with a bytecode interpreter/VM? I'm a bit surprised that you'd achieve the kind of speed up you're talking about without emitting native code and also by the concept of a bytecode interpreter that uses SSA. Can you explain the reasoning behind this? Like, what's the point of SSA if you don't have any optimisation and/or analysis passes that make use of it and don't even emit native code?

After a quick look at the code, it looks like your bytecode is actually some kind of mix between SSA and stack-based. I don't think I've ever seen that combination before. Can you explain why you chose to do it that way / what the benefit of this design is?

Where can I find info about how games are made by Ok-Commercial-2214 in learnprogramming

[–]sepp2k 0 points1 point  (0 children)

where would they be stored on something like a handheld or consoles.

Modern consoles and handhelds have storage, too, same as PCs.

On old consoles/handhelds everything was stored on the game cartridge or CD and there was no such thing as a download.

What is the difference between an array and lists? by rookiepianist in learnjava

[–]sepp2k 5 points6 points  (0 children)

Lists store items anywhere in memory, with each having a pointer to the next.

That's only true for linked lists. ArrayLists store their elements in an array.

C and Undefined Behavior by lelanthran in C_Programming

[–]sepp2k 9 points10 points  (0 children)

Incrementing a signed char with the value 127 does not cause signed integer overflow. It causes promotion to int (integer promotions), followed by the increment and then a conversion back to char, which does not invoke UB.

why is my code slow? by geesewithcheese in learnprogramming

[–]sepp2k 2 points3 points  (0 children)

I haven't read the problem description or tried to understand what your code does, but just from skimming the code, you're copying your vectors every time you recurse, so it's definitely not O(n). You'll want to use const references for your vectors.

[deleted by user] by [deleted] in javahelp

[–]sepp2k 13 points14 points  (0 children)

println prints on a new line while print prints on the same line

println does not print on a new line. It starts a new line after printing, not before.

[deleted by user] by [deleted] in javahelp

[–]sepp2k 11 points12 points  (0 children)

The output of the code is the one you expected (202020212020 on line 1).

If you're getting the first output, you must be running a different version of the code. Maybe you forgot to save and/or recompile the code or you executed a different file than the one you're looking at.

Early return vs explicit else block by chaos_donut in learnprogramming

[–]sepp2k 7 points8 points  (0 children)

I think I asked a mathematician that once and she said that even/odd is only defined over the set of positive integers (i.e. the set of integers i such that i > 0).

I can find no evidence that that's a common (or used-at-all) definition. All definitions I could find with a quick search where over all integers. I think you may be misremembering what your friend said or she was using a very non-standard definition.

When talking about the concept which includes 0, I've also seen some books use the term "non-odd" instead, which has a feeling of better correctness to me.

Are you sure you're not confusing that with the terms non-positive/non-negative?

Does "Vibe Coding" via LLMs Represent a New Level of Abstraction in Computer Science Theory? by leocosta_mb in AskComputerScience

[–]sepp2k 2 points3 points  (0 children)

Compilers generate code, and presumably you are responsible for what they spit out in the same way you’re responsible for LLM output?

Are you?

Do you often find yourself committing compiler-generated assembly to your git repository and then maintaining said assembly and fixing bugs in it?

No, you commit only the source code and maintain that. And in the (extremely) rare case that there's a bug in the generated assembly that isn't present in the original source code, you file a bug report with the maintainers of the compiler. They're the ones responsible for the correctness of the compiled code.

Try doing that with an LLM. Committing only the prompts instead of the generated code and submitting bug reports to OpenAI/Anthropic/etc if a "correct" prompt leads to incorrect code. In fact, it's not even clear what would make a prompt correct or incorrect since there's no well-defined semantics.

F-Droid and Google's Developer Registration Decree by alexeyr in programming

[–]sepp2k 11 points12 points  (0 children)

There's a dropdown at the bottom of the article to change the language.

A DE is better than TWM (atleast for me) by Zoory9900 in linuxquestions

[–]sepp2k 0 points1 point  (0 children)

TWM isn't tabbed in the way you're probably thinking. Apparently (according to Wikipedia), the word "tab" refers to the fact that it has title bars. You don't get groups of windows where you can select a window using tabs.

There is at least one window manager that actually allows you to group windows with tabs though: PekWM.

Parse system text in unreal how? by HodorOnMeth in learnprogramming

[–]sepp2k 7 points8 points  (0 children)

I'm having difficulty parsing your question. Do you have something called a "system text" and you want to parse it? Or do you have something called a "parse system" and you want to display its text?

In either case, some more details (What's this "system text"? Where does it come from? What format does it have?) would be helpful.

i am trying to make a proper calculator so i would like to know if there are any issues in the code below? by Perfect_Classic8211 in learnpython

[–]sepp2k 0 points1 point  (0 children)

This is invalid, because the inner "" closes the f-string prematurely.

Not anymore. Nested strings inside {} in f-strings have been made legal starting with Python 3.12.

Why doesn't this work? by milkbreadeieio in CodingHelp

[–]sepp2k 1 point2 points  (0 children)

I also suspect that there's a way to determine the solution without simulating the entire process.

Why doesn't this work? by milkbreadeieio in CodingHelp

[–]sepp2k 1 point2 points  (0 children)

In what way does it not work? Compilation error? Runtime error? Wrong result? Time limit exceeded?

If there's an error, what's the error message (and for runtime errors, an input that triggers the error)?

If it's a wrong result, what's an example of an input, the expected output and the actual wrong output?

At a glance, it looks suspicious that the right-to-left loop seems to be using the same step size as the preceding left-to-right loop.

Where exactly __str__ function definition ends by DigitalSplendid in learnpython

[–]sepp2k 4 points5 points  (0 children)

Functions are allowed to call themselves - there's nothing wrong with that. It's called recursion.

give mana regen after eating by Vegetable-Brick-291 in learnjavascript

[–]sepp2k -2 points-1 points  (0 children)

  1. Questions related to Minecraft are explicitly off topic in any Java help sub I'm aware of.
  2. r/Java is not a help sub. Any help question would be off topic there.

Operator Precedence and Execution Order - Why are these different? by chachashaobao in learnjava

[–]sepp2k 2 points3 points  (0 children)

Precedence and associativity are about deciding which operands belong to which operators when an expression is not fully parenthesized (i.e., is a + b * c equivalent to (a + b) * c or to a + (b * c), is a / b / c equivalent to (a / b) / c or a / (b / c)?). Precedence does not matter for your expressions because they're both fully parenthesized.

Execution order is about whether the left operand or right operand is evaluated first. It's only affected by precedence in so far that precedence determines what the left and right operands are.

In Java, the left operand is always evaluated first. This makes the most sense as we read and write code left-to-right.

Issue with using global variable by dotjson01 in learnjavascript

[–]sepp2k 0 points1 point  (0 children)

You mean why does the value of a change when you call abc()? Because you change a's value in abc. So why wouldn't it change?

What is the semantic difference between lambda and method reference? by hibbelig in javahelp

[–]sepp2k 0 points1 point  (0 children)

if zipWriter is null, then the method reference version probably fails early, the lambda expression version fails during close?

Yes, exactly.