[-] FizzyOrange@programming.dev 1 points 3 weeks ago

Nice work. Aren't wasm proc macros already prototyped in Watt though?

[-] FizzyOrange@programming.dev 2 points 1 month ago

Screenshots. Print screen. Wayland famously doesn't have a way to do this very basic task (all of the desktop environments had to add custom extensions).

Seems like they finally did it though really recently. And it only took 12 years!

[-] FizzyOrange@programming.dev 2 points 2 months ago

No but I think this is probably a great use case for AI. Haven't tried it though.

[-] FizzyOrange@programming.dev 2 points 2 months ago

One nice thing about XML is that there's an official way to link to the schema from within the document. If you do that you can easily automatically validate it, and even better you get fantastic IDE support via Red Hat's LSP server. Live validation, hover for keys, etc.

It's a really nice experience and JSON schema can't really match it.

That said, XML just has the wrong data model for 99% of use cases.

[-] FizzyOrange@programming.dev 2 points 4 months ago

It has them, but you can't use them from a single-file script. You have to set up a pyptoject.toml, create a venv and then pip install . in it. Quite a lot of faff. It also makes some things like linting in CI way harder than they should be because the linters have to do all that too.

With Deno a single .ts file can import third party dependencies (you can use any URL) and Deno itself will take care of downloading them and making them available to the script.

Some other languages have this feature to certain degrees. E.g. I think F# can do it, and people are working on it for Rust, but Deno is at the forefront.

[-] FizzyOrange@programming.dev 1 points 4 months ago

Yeah exactly. You made it faster through algorithmic improvement. Like for like Python is far far slower than C++ and it's impossible to write Python that is as fast as C++.

[-] FizzyOrange@programming.dev 1 points 4 months ago

The only interpreted language that can compete with compiled for execution speed is Java

"Interpreted" isn't especially well defined but it would take a pretty wildly out-there definition to call Java interpreted! Java is JIT compiled or even AoT compiled recently.

it can be blazingly fast

It definitely can't.

It would still be blown out of the water by similarly optimized compiled code

Well, yes. So not blazingly fast then.

I mean it can be blazingly fast compared to computers from the 90s, or like humans... But "blazingly fast" generally means in the context of what is possible.

Port component to compiled language

My extensive experience is that this step rarely happens because by the time it makes sense to do this you have 100k lines of Python and performance is juuuust about tolerable and we can't wait 3 months for you to rewrite it we need those new features now now now!

My experience has also shown that writing Python is rarely a faster way to develop even prototypes, especially when you consider all the time you'll waste on pip and setuptools and venv...

[-] FizzyOrange@programming.dev 1 points 4 months ago

Unless the C++ code was doing something wrong there's literally no way you can write pure Python that's 10x faster than it. Something else is going on there. Maybe the c++ code was accidentally O(N^2) or something.

In general Python will be 10-200 times slower than C++. 50x slower is typical.

[-] FizzyOrange@programming.dev 2 points 4 months ago

threading bugs are sometimes hard to catch

Putting it mildly! Threading bugs are probably the worst class of bugs to debug

Definitely debatable if this is worth the risk of impossible bugs. Python is very slow, and multi threading isn't going to change that. 4x extremely slow is still extremely slow. If you care remotely about performance you need to use a different language anyway.

[-] FizzyOrange@programming.dev 1 points 5 months ago

formatting does depend on the type of variables. Go look at ktfmt’s codebase and come back after you’ve done so…

I skimmed it. It appears to visit the AST of the code and format that, as any formatter does. ASTs have not been type checked.

Can you give an example?

it gives you an option, just like if it was an interface. Did you actually try this out before commenting?

Precisely! It doesn't know the answer so it has to guess, or make you guess.

And how often are you naming functions the exact same thing across two different classes without using an interface?

You mean how often does the same field name come up more than once? All the time obviously! Think about common names like id, size, begin, children, etc. etc.

I’m sorry, but you clearly haven’t thought this out, or you’re really quite ignorant as to how intellisense works in all languages (including Ruby, and including statically typed languages).

I'm sorry but you clearly haven't thought this through, or you're just happy to ignore the limitations of Ruby. I suspect the latter. Please don't pretend they aren't limitations though. It's ok to say "yes this isn't very good but I like Ruby anyway".

[-] FizzyOrange@programming.dev 2 points 5 months ago

I can give you some basic Python set-up advice (which is hard-won because nobody tells you this stuff):

  1. Use pyproject.toml, not requirements.txt. It's better and it's the recommended way.
  2. Always use type annotations. I saw you used it a bit - well done! But just use it everywhere. Add declarations & type annotations for your class member variables. You'll thank me later! Also prefer Pyright to Mypy; it is far far better (and the default for VSCode).
  3. I would recommend using Black to autoformat your code. It's easily the best Python formatter. You can automate it using pre-commit.
  4. ALWAYS PUT MAIN IN A FUNCTION. You should not run any code at a global scope. Do it like this:
def main():
  ...

if __name__ == "__main__":
    main()

There are two reasons:

  1. Generally it's good to keep variables to the smallest scope possible. Putting everything in a global scope will just mean people start using it in their functions, and then you have a mess.
  2. Any code you put in a global scope gets run when you import a module. Importing a module should not have any side effects.

Other minor things:

  1. Path has a crazy/neat override of the / operator so you can do Path("foo") / "bar" / "baz.txt".
  2. Don't use assert for stuff that the user might reasonably do (like not choosing a background image). assert is meant to be for things that you know are true. You are asserting them. Like "hey Python, this is definitely the case".
  3. TK is an ancient shitty GUI toolkit. I would recommend QT instead (though it will probably be more pain to set up).
[-] FizzyOrange@programming.dev 2 points 1 year ago

Never to be seen again...

Seriously though this feels a lot like those books that start with "How to read this book" sections.

view more: ‹ prev next ›

FizzyOrange

joined 1 year ago