this post was submitted on 01 Jan 2024
35 points (81.8% liked)

Programming

17417 readers
37 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
top 9 comments
sorted by: hot top controversial new old
[–] philwills@programming.dev 33 points 10 months ago (1 children)

Man... I thought this was going to be a proper rant about using maps where you should be using other things... No, it's a make sure you type your function inputs rant...

[–] hackeryarn@lemmy.world 11 points 10 months ago* (last edited 10 months ago) (1 children)

I wasn't trying to go into typing as much as using structs or objects when working with known data attributes. Sorry that it was a bit misleading.

The original actually went into using trees, sets, heaps, tries, etc., but it felt way too... ranty. After writing all that out, I realized that most of those other cases come up really infrequently, and that my biggest gripe was about not using structs or other pre-defined key container types. I thought it would be better to keep things short and focused.

Maybe I should re-write and publish a data structures edition.

[–] philwills@programming.dev 3 points 10 months ago

I would like that! Very much!

[–] wesker@lemmy.sdf.org 13 points 10 months ago (1 children)
[–] hackeryarn@lemmy.world 9 points 10 months ago (1 children)

I love the addition of dataclass. Makes refactoring such a breeze. If you need to extract some function, boom, you already have a class that you’re using everywhere.

[–] wesker@lemmy.sdf.org 5 points 10 months ago

Me too. I like to really take my time up front when modelling, because it makes a project so much easier and enjoyable down the road.

[–] xmunk@sh.itjust.works 3 points 10 months ago* (last edited 10 months ago) (1 children)

As a PHP programmer... I strongly object.

Everything is a map!

[–] Solemarc@lemmy.world 2 points 10 months ago

My most loved and hated feature in PHP is associated arrays. I've seen an associated array that uses 16gb of memory before, it was as beautiful as it was horrifying.

[–] Reptorian@programming.dev 1 points 10 months ago

Chances are there's probably something similar to dictionary in Python in your languages or at least it's a import/#include away. Although I don't use general programming languages at all, in my used language (G'MIC), I do something like dict$var=input where $var is a defined variable, and this way I can access input by doing ${dict$var} and that's similar to Python dictionary. In C++, there's hash table implementation out there via github. That being said, there are sometimes when you don't need a hashtable dependent on the hashmap, and sometimes, it's just as simple as basic mathematics to access data.