Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Bloody
Mar 3, 2013

itt i suddenly realize i dont know poo poo about data structures

i feel like a lotta non-array poo poo is good because you can resize it easy but if you stuff it in an array now u cant so???

Adbot
ADBOT LOVES YOU

hobbesmaster
Jan 28, 2008

just use a dynamic array

hobbesmaster
Jan 28, 2008

or more realistically, use your language's library that internally uses a dynamic array

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
also depending on your workload you may not need to resize often or at all so just copying into a larger array when needed is fine.

Bloody
Mar 3, 2013

i started doing things with garbage-nn again

i compeltely broke it. oops

JewKiller 3000
Nov 28, 2006

by Lowtax
it shouldn't be too surprising that you can implement basically any data structure with arrays, since your data structure is in memory, and memory is just a big array

Bloody
Mar 3, 2013



this is not accurate

Notorious b.s.d.
Jan 25, 2003

by Reene

GameCube posted:

re: languages, high schoolers are being taught javascript now. have fun with THAT poo poo

with any luck this means that ten years from now, everyone under the age of 30 will flat refuse to use js under any circumstances, because they have bad memories from school

(as with java, today)

Bloody
Mar 3, 2013

ah great async reads were loving everything up (???)

Luigi Thirty
Apr 30, 2006

Emergency confection port.

day 49601 of trying to figure out how to make pixel go from UV coordinates of texture to screen coordinates of triangle

ErIog
Jul 11, 2001

:nsacloud:

Luigi Thirty posted:

day 49601 of trying to figure out how to make pixel go from UV coordinates of texture to screen coordinates of triangle

Do you have barycentric coords for your pixel? Plug the UV's of the triangle's vertices(from the model file) into your Barycentric->Cartesian formula along with your barycentric coords and voila you have your texel***

***if you want do perspective correction on that it's a bit more work because you need barycentric clip coordinates instead
https://github.com/ssloy/tinyrenderer/wiki/Technical-difficulties:-linear-interpolation-with-perspective-deformations

Oh, and generally the UV coords are going to be between 0 and 1 so you'll have to multiply by the width/height of your texture image to get the specific location within the specific texture.

ErIog fucked around with this message at 04:37 on Aug 4, 2016

triple sulk
Sep 17, 2014



Notorious b.s.d. posted:

with any luck this means that ten years from now, everyone under the age of 30 will flat refuse to use js under any circumstances, because they have bad memories from school

(as with java, today)

i'm glad that c# will escape this punishment because it's good

Notorious b.s.d.
Jan 25, 2003

by Reene

triple sulk posted:

i'm glad that c# will escape this punishment because it's good

it will escape this punishment only because it will be forgotten

Luigi Thirty
Apr 30, 2006

Emergency confection port.

ErIog posted:

Do you have barycentric coords for your pixel? Plug the UV's of the triangle's vertices(from the model file) into your Barycentric->Cartesian formula along with your barycentric coords and voila you have your texel***

***if you want do perspective correction on that it's a bit more work because you need barycentric clip coordinates instead
https://github.com/ssloy/tinyrenderer/wiki/Technical-difficulties:-linear-interpolation-with-perspective-deformations

Oh, and generally the UV coords are going to be between 0 and 1 so you'll have to multiply by the width/height of your texture image to get the specific location within the specific texture.

I ripped out the slow barycentric calculations in favor of Chris Hecker's triangle splitting rasterization method but I can get the coordinates again. I don't care about perspective deformation yet, that can come after I can at least project a 256x256 checkerboard onto a flat triangle properly

Luigi Thirty fucked around with this message at 05:21 on Aug 4, 2016

LordSaturn
Aug 12, 2007

sadly unfunny

Luigi Thirty posted:

project a 256x256 checkerboard onto a flat triangle properly

pick a top-left corner and blit?

triple sulk
Sep 17, 2014



Notorious b.s.d. posted:

it will escape this punishment only because it will be forgotten

~better 2 be forgotten than 2 fade away~

Toady
Jan 12, 2009

LeftistMuslimObama posted:

*hugz*

can i just say, im super impressed that yospos seems to be the most progressive forum w/r/t queer people and minorities? its hilarious to see d&d-ers constantly express awful opinions only to come to yospos and see people yelling at subjunctive because facebook hosed up a trans thing again (also shoutout to subjunctive for helping me resolve a bug related to name changes when i had to do that for my facebook, lol)

we're recovering slashdotters

Toady
Jan 12, 2009

i used to get compliments for my low slashdot user id. pretty cool stuff

Toady
Jan 12, 2009

Luigi Thirty posted:

they taught databases in high school for some reason so I learned SQL in 11th grade

Junior college babby cs was Python
regular college babby cs was C++
the data structures class was Java
and then I had to take another Python class for some reason

i feel like i lucked out, my small town high school taught c++ in 10th grade and gave us a linux server to host web pages on. i doubt that lasted long after i left

the school library's IT guy found out i was into genetic algorithms and 3d rendering, and he got excited and would print out documentation he wrote and give it to me. he was like Lazlo in Real Genius

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

LeftistMuslimObama posted:

*hugz*

can i just say, im super impressed that yospos seems to be the most progressive forum w/r/t queer people and minorities? its hilarious to see d&d-ers constantly express awful opinions only to come to yospos and see people yelling at subjunctive because facebook hosed up a trans thing again (also shoutout to subjunctive for helping me resolve a bug related to name changes when i had to do that for my facebook, lol)

oh, i am an idiot.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

so loving future posted:

honestly tho.... who didn't learn qbasic first?

i learned, well, used the basic in all the different home computers my friends had: c64, spectrum, amstrad, msx

my first utility programs/scripts i made for myself were probably made in arexx on an amiga

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

my friends and i used to make crappy text adventure games in qbasic on the computers in the school library. i also remember making animations by manually drawing out pixel maps for the whole screen and getting a couple of frames in there before i'd get bored

comedyblissoption
Mar 15, 2006

Mr Dog posted:

uh

...?

that makes about as much sense as implementing a linked list as an array
implementing a linked list as an array would probably be faster the vast, vast majority of the time

linked lists that are implemented as dynamically allocated non-contiguous memory should be considered incredibly niche

optimizing for the computer's cache is one of the most important things in a data structure and linked lists poo poo all over that

comedyblissoption
Mar 15, 2006

LeftistMuslimObama posted:

ya, using c++ for teaching cs would be a bit like using chuck tingle books as the basis of a creative writing degree
our intro to cs class in high school was c++ taught by someone who didnt know c++

it's as terrible as you think it might be

comedyblissoption
Mar 15, 2006

Illusive gently caress Man posted:

not sure who's the terrible programmer in this situation, me, or every python dev. I don't really 'get' mixin classes or why every python dev uses them for everything and they continually frustrate me when I'm trying to figure out what code actually does.
dynamic typing is absolutely terrible because for any complicated abstraction, you have to expend a ton of mental energy to reverse engineer what the hell is going on

in a deece static typed system, usually abstractions can be easily embedded into the type system to be immediately apparent

Valeyard
Mar 30, 2012


Grimey Drawer

comedyblissoption posted:

dynamic typing is absolutely terrible because for any complicated abstraction, you have to expend a ton of mental energy to reverse engineer what the hell is going on

in a deece static typed system, usually abstractions can be easily embedded into the type system to be immediately apparent

I am going to keep banging this drum but dynamically typed languages do not work very well for big bad production systems, unless you wrote it and want some job security

abraham linksys
Sep 6, 2010

:darksouls:
the last 3 places i've worked at were all python shops and i walked away from those 3 years with the hot take that python at scale is basically "imagine if java was easier to get up and running with and then worse in every possible way"

i only have the most passing surface-level familiarity with java though, so ymmv. it frustrates me cuz i really like python as a fun lil thing i can use to make side projects and scripts and it's super powerful for creating tiny one-off services quickly (web scrapers, etc) but holy poo poo if you try to "architect" anything with it it really ends up being as verbose and complex as java except without any of the actual good aspects of it

i may be using go at my next gig which seems like it kind of sucks for web services, but at least i think it'll be easier to maintain than the python codebases i've worked on

Bloody
Mar 3, 2013

dynamic sucks because it kills off language discovery as part of the development process. if I had to look poo poo up in separate api docs instead of wander through namespaces and signatures with an auto completer I would literally never get anywhere

GameCube
Nov 21, 2006

just use pycharm

Valeyard
Mar 30, 2012


Grimey Drawer

GameCube posted:

just use pycharm

It's good, but not good enough

Gets too confused with lots of similarly named methods

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

as a terrible programmer i am thankful for ide auto-completion. i have discovered many useful parts of the java standard library by just scrolling through that little popup box. i end up reading the javadoc anyway of course. but there are a lot of situations where it has given me a more intuitive feel of how different classes and data structures work

MononcQc
May 29, 2007

The organisational structure and social constructs around a code base are more significant indicators of quality than most known technical metrics. [pdf]

if you want maintainable code and scalable systems, that's where you gain the most to optimize

Shaggar
Apr 26, 2006

abraham linksys posted:

the last 3 places i've worked at were all python shops and i walked away from those 3 years with the hot take that python at scale is basically "imagine if java was easier to get up and running with and then worse in every possible way"

i only have the most passing surface-level familiarity with java though, so ymmv. it frustrates me cuz i really like python as a fun lil thing i can use to make side projects and scripts and it's super powerful for creating tiny one-off services quickly (web scrapers, etc) but holy poo poo if you try to "architect" anything with it it really ends up being as verbose and complex as java except without any of the actual good aspects of it

i may be using go at my next gig which seems like it kind of sucks for web services, but at least i think it'll be easier to maintain than the python codebases i've worked on

java is easier to use than python in every single way

Shaggar
Apr 26, 2006
also lol @ using go

stramit
Dec 9, 2004
Ask me about making games instead of gains.
Do I have a wrong opinion? I just had a fun discussion with a colleague about documentation. I like putting most of it in tooltips and making things pretty discoverable on the user side (good UX, workflow hints). This means the docs live with the code so when the code changes it's quick and easy to update. He wants it all in manual pages that are managed separate from the code and basically say the same things as the tooltips would. This would mean a code change needs tooltip updates + manual update (including updated screenshots). To me this just means that in ~1 week the docs will be out of date. Am I wrong?

Shaggar
Apr 26, 2006
generate the manuals from the documentation in the code.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Shaggar posted:

generate the manuals from the documentation in the code.

I wish, but that is not possible for this system.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Strumpy posted:

Do I have a wrong opinion? I just had a fun discussion with a colleague about documentation. I like putting most of it in tooltips and making things pretty discoverable on the user side (good UX, workflow hints). This means the docs live with the code so when the code changes it's quick and easy to update. He wants it all in manual pages that are managed separate from the code and basically say the same things as the tooltips would. This would mean a code change needs tooltip updates + manual update (including updated screenshots). To me this just means that in ~1 week the docs will be out of date. Am I wrong?

as a rule of thumb, tooltips are bad.

but if it's just hints that might help the user and don't actually contain any essential information, they have some value.

tef
May 30, 2004

-> some l-system crap ->

HoboMan posted:

trees being implemented as arrays is basically the most mindblowing thing i ever learned

python has heapq :shrug: heapsort exists :shrug:

here's http://arxiv.org/pdf/1509.05053.pdf

ARRAY LAYOUTS FOR COMPARISON-BASED SEARCHING

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Mr Dog posted:

*puts on fishmech hat*

yeah a heap (data structure) is definitely best implemented as an array, because it will always be dense. a sparser tree like a rb tree is generally implemented as heap dynamically allocated nodes though.

i'm having trouble thinking of a situation where you'd want to put an rb tree into an array. like, ok if your keys and your values are fixed-length, and you really want to mmap() the poo poo so that it's stored in a backing file, but then because it's red-black that means you're going to be mutating it (otherwise you'd just make it into an array that's sorted ahead of time because at that point an array that you binary search is exactly equivalent to a linearized dense binary search tree) but then that means you have to be transactionally consistent with your updates and that's um really loving hard so you're going to have a write-ahead log as well and anyway at that point what you have is basically a database table so really you want a b+ tree and that's just a whole different animal altogether and...

if it's not being persisted to disk (and therefore doesn't need to store links as offsets within the arena as opposed to just using pointers like a normal person) then cramming a bunch of tree nodes into a gigantic contiguously-allocated dynamic array is a pessimization in every sense that matters.





.... did i pass the algorithms and data structures phase of the interview yet lol

like you've got an immutable tree and you put it to disk and you want to have quick operations

you could just store it in a sorted output (sstables), but if you store it in BFS search order, things go much faster.

as uh the alternative left/right keys are always next to each other in the array

  • Locked thread