Walnut356

joined 1 year ago
[–] [email protected] 2 points 1 year ago

Seems you missed the last line

compiles to fast code

[–] [email protected] 7 points 1 year ago* (last edited 1 year ago)

Iirc godot uses beta branches and semver, so the only updates you get are the ones that dont break anything.

[–] [email protected] 1 points 1 year ago

Obligatory shoutout to Qownnotes for being excellent, fully open source, and with owncloud integration.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

15532 on-type format (, by adding closing ) automatically

Thank fucking god lmao. The PR specifically mentions the Some( case too, which is exactly where i encounter this the most.

Overall very nice changes

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago)

Nah, i dont think that's true at all. Priority number 1 is learn the language that deals in what you're most interested in. Priority 2 is learning the language whose ecosystem you can tolerate.

Why? Because you learn most when you enjoy what you're doing.

I'm interested in performance and systems programming so i tried to start with c++. C++'s ecosystem and tooling are complete garbage and i spent more time fighting it than learning to program. I learned python for a specific project, but eventually started learning rust because i was frustrated with python's lack of low level functionality (and speed).

Rust has a lot of modern features that c++ doesnt (and that arent buried behind 20 years of "do this, no wait that's bad, actually do this instead"). The tooling is excellent for beginners, and there's lots of core and standard library features that simplify some of the stupid things about low level programming. And you dont have to start with all the low level fiddly bits, you can start with variables, conditionals, and functions just like you would in python or whatever.

As for book recommendations:

NOT the official rust book. Imo it assumes you already know at least one other programming language. It doesnt always go into enough detail about advanced concepts, but other times goes into WAY too much detail for true programming beginners.

The two that i liked the most were:

Programming Rust by Blandy, Orendorff, and Tindall

Rust in Action by Tim McNamara

I've also heard good things about Command-Line Rust by Ken Youens-Clark, but i havent read it myself.

Also, dont be afraid to read language-agnostic books that cover general computer science concepts like Dive Into Algorithms, Understanding The Machine or Data Structures The Fun Way after you've gotten your feet wet.

[–] [email protected] 5 points 1 year ago

You could say that about anything. Of course you have to learn something the first time and it's "unintuitive" then. Intuition is literally an expectation based on prior experience.

Intuitive patterns exist in programming languages. For example, most conditionals are denoted with "if", "else", and "while". You would find it intuitive if a new programming language adhered to that. You'd find it unintuitive if the conditionals were denoted with "dnwwkcoeo", "wowpekg cneo", and "coebemal".

[–] [email protected] 9 points 1 year ago

“Unintuitive” often suggests that there’s something wrong with the language in a global sense

I mean only if you consider "Intuition" to be some monolithic, static thing that's also identical for everyone. Everyone has their own intuition, and their intuition changes over time. Intuition is akin to an opinion - it's built up based on your own past experiences.

just because it doesn’t look like the last one you used — as if the choice to use (or not use) curly braces is natural and anything else is willfully perverse on the part of the language designer.

I don't think it's that deep. All people mean when they say it is that "[thing] defied my expectation/prior experience". It's like saying "sea food tastes bad". There's an implicit "to me" at the end, it's obvious i'm not saying "sea food factually tastes bad, and anyone who says they like it is wrong or lying".

[–] [email protected] 3 points 1 year ago

Here's the script. It's nothing fancy, and iirc it only works for top level functions/classes. That means you still have to take care of attributes and methods which is a little annoying, but for simple stuff it should save a bit of time.

[–] [email protected] 10 points 1 year ago

For downsides, i'd like to add that the lack of function overloading and default parameters can be really obnoxious and lead to [stupid ugly garbage].

A funny one i found in the standard library is in time::Duration. Duration::as_nanos() returns a u128, Duration::from_nanos() only accepts a u64. That means you need to explicitly downcast and possibly lose data to make a Duration after any transformations you did.

They cant change from_nanos() to accept u128 instead because that's breaking since type casting upwards has to be explicit too (for some reason). The only solution then is to make a from_nanos_u128() which is both ugly, and leaves the 64 bit variant hanging there like a vestigial limb.

[–] [email protected] 36 points 1 year ago (8 children)

Please don't say the new language you're being asked to learn is "unintuitive". That's just a rude word for "not yet familiar to me"...The idea that some features are "unintuitive" rather than merely temporarily unfamiliar is just getting in your way.

Well i mean... that's kinda what "unintuitive" means. Intuitive, i.e. natural/obvious/without effort. Having to gain familiarity sorta literally means it's not that, thus unintuitive.

I dont disagree with your sentiment, but these people are using the correct term. For example, python len(object) instead of obj.len() trips me up to this day because 99% of the time i think [thing] -> [action], and most language constructs encourage that. If I still regularly type an object name, and then have to scroll the cursor back over and type "len(", i cant possibly be using my intuition. It's not the language's "fault" - because it's not really "wrong" - but it is unintuitive.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (2 children)

Pyo3 doesnt generate type hints at all iirc. There's some more info here

The gist, as i recall, is that you're supposed to maintain a .pyi file in the rust project folder that gets automatically added in by maturin when building. I'm no regex wizard, but i was able to whip together a small script that generates simple function and class stubs that also have the rust docstring. Iirc they're planning on adding some official support for generating type hints, but i have no idea how far along it is or where it is on the priority list

[–] [email protected] 2 points 1 year ago

It's most useful when you're using some data you already have as the dictionary key. A usecase i had for this was a binary file parser with 10 types of event markers. It was originally coded with if/elif, but performance was a pretty big consideration. Using the event markers as keys to a dictionary dispatch improved performance by about 15% and made the code significantly more readable.

view more: ‹ prev next ›