|
Jose Valasquez posted:wtf is a ring buffer imagine 4 balls on the edge of an array
|
# ? Jan 23, 2022 18:55 |
|
|
# ? Apr 23, 2024 20:28 |
|
Jose Valasquez posted:wtf is a ring buffer
|
# ? Jan 23, 2022 18:55 |
|
when source engine games freeze and you hear the last half second of audio over and over and over again, that's a ring buffer
|
# ? Jan 23, 2022 19:02 |
|
carry on then posted:when source engine games freeze and you hear the last half second of audio over and over and over again, that's a ring buffer
|
# ? Jan 23, 2022 19:08 |
|
p. sure ring buffer is gen z slang for your sphincter.
|
# ? Jan 23, 2022 19:11 |
|
Jose Valasquez posted:wtf is a ring buffer
|
# ? Jan 23, 2022 19:13 |
|
tracecomplete posted:Go huffers have spent the last decade telling me I am a fool and a poltroon for wanting a baseline modern language because Rob Pike Said It Wasn't Important (he didn't really but Go huffers also can't read), this guy is fine. and now they're all pretending that they never said that generics are bad and would actively make the language worse
|
# ? Jan 23, 2022 19:18 |
|
kitten emergency posted:imagine 4 balls on the edge of an array I’m amazed at how well this describes it
|
# ? Jan 23, 2022 19:20 |
|
jesus WEP posted:drat goons really can’t fit the meter can't fit a lot of things
|
# ? Jan 23, 2022 19:43 |
|
Jose Valasquez posted:wtf is a ring buffer So a normal queue or a buffer can be implemented as either an array or linked lists. To maintain First In First Out (FIFO) semantics, you want to be able to add data at one end of the data structure (append to be consumed last) and to consume it from the other (remove at the start). In a linked list this is easy to do because you can keep a pointer to the end of the list and add elements there, while you remove from the head of the list. However, this requires a bunch of dynamic memory allocation is rather indirect. With an array implemented naively, you'd need to move data around (if you always remove from the 0 index, then you would need to move all other entries around which would be very inefficient). A ring buffer uses a fixed-size array and has one pointer for the insertion location, and one pointer for the consumption location. When either reaches the end of the array, it wraps back to the start. As long as you properly make sure that the writer never takes over the reader (the queue is full) then you're able to use a single pre-allocated array to contain all your bufferable data in a single area and just move pointers around (you can overwrite the data already read before having to de-allocate or garbage collect it), which gives you very good performance. In the context of generics, this is useful because the array size is usually a function of the type of data you want to store in there. So if you want to make a generic ring buffer, you'll need to be able to keep the same interface (and implementation) regardless of the data type you want to use. Generics let you do that. Go not supporting generics means that each implementation has to either be unique (copy-pasted with a search and replace for each data type), or needs to store interface{} references, which is garbage. MononcQc fucked around with this message at 21:22 on Jan 23, 2022 |
# ? Jan 23, 2022 21:06 |
|
yeah. people often make the argument that generics systems lead to over-abstraction and some kinda silly code patterns (which is fair, they absolutely can do that), and so they try to justify not having generics by saying that having a few well-chosen generic currency types (lists, dictionaries) and algorithms (sort, find) is really 90% of what you need (probably also true) and that the last 10% isn’t worth the complexity and the risk of having a bunch of annoying generics weenies running around for the next five years defining numeric taxonomies. ring buffers make a good counter-argument because they’re relatively well-known and pretty unambiguously useful for certain use cases. if you think about things with similar recognition, a lot of them are stuff like alternative list/dictionary implementations (linked lists, sorted trees) with several decades of arguments against using them outside of really specialized code
|
# ? Jan 23, 2022 22:02 |
|
its particularly egregious in go where the people afraid of generics are the same ones splashing interface{} (aka void pointer) casts everywhere and acting like that's better i guess its the next generation of C weenie mindset now that i think about it
|
# ? Jan 23, 2022 22:09 |
|
I never got the whole argument that generics are confusing because imo they’re more intuitive than other Go language features that people don’t seem to have beef with. channels and pointer vs value receivers come to mind. like yeah it gets hairy once u need to start dealing with covariant vs contravariant types but most common uses don’t need to care about that
|
# ? Jan 24, 2022 00:54 |
|
yeah a lot of the generic issues come with the subtyping when you allow class hierarchies where the -variant types get in. The rest of it is pretty straightforwards in general.
|
# ? Jan 24, 2022 00:55 |
|
I haven’t looked at Go generics but shouldn’t it be easier for them than most languages anyway? all they have are structs, typedefs and interfaces. and structs/interfaces cannot extend or inherit from each other. all the language provides is embedding which afaik is just syntactic sugar
|
# ? Jan 24, 2022 01:03 |
|
dads friend steve posted:I haven’t looked at Go generics but shouldn’t it be easier for them than most languages anyway? all they have are structs, typedefs and interfaces. and structs/interfaces cannot extend or inherit from each other. all the language provides is embedding which afaik is just syntactic sugar i haven’t looked at them since the original proposal but my recollection is, much like go modules, they’re too clever by half and more awkward to work with than you’d hope
|
# ? Jan 24, 2022 01:10 |
|
Go generic iirc have one specific problem in that nil is both a standalone type and also a variation of an interface (an interface can be a typed nil), which sadly means that golang may have to deal with covariance and contravariance but only for god drat nils.
|
# ? Jan 24, 2022 01:57 |
|
MononcQc posted:Go generic iirc have one specific problem in that nil is both a standalone type and also a variation of an interface (an interface can be a typed nil), which sadly means that golang may have to deal with covariance and contravariance but only for god drat nils. hilarious
|
# ? Jan 24, 2022 02:02 |
|
lmao
|
# ? Jan 24, 2022 02:33 |
|
jsiaajdsdaa 10 minutes ago | parent | context | favorite | on: Ask HN: Where are you going to find long-form cont... I think I'm fundamentally opposed to long form content. I can learn a lot more from one line of code than 10 pages of theory.
|
# ? Jan 24, 2022 03:29 |
|
hersko 30 minutes ago | parent | context | favorite | on: Ask HN: Where are you going to find long-form cont... The Joe Rogan podcast. Listening to long-form, multi-hour conversation is so refreshing compared to what traditional news shows have become. e: ok last one since this thread is like cheating randycupertino 1 hour ago | parent | context | favorite | on: Ask HN: Where are you going to find long-form cont... /r/TrueReddit and /r/FoodforThought subreddits are both pretty interesting and tend to have insightful long-form articles.
|
# ? Jan 24, 2022 03:31 |
|
It's very on brand that the first comment in that thread links to a astral codex ten
|
# ? Jan 24, 2022 03:45 |
|
dads friend steve posted:I never got the whole argument that generics are confusing because imo they’re more intuitive than other Go language features that people don’t seem to have beef with. channels and pointer vs value receivers come to mind. like yeah it gets hairy once u need to start dealing with covariant vs contravariant types but most common uses don’t need to care about that I don't have anything useful to respond to this post with but I saw your avatar and I'm really thinking about replacing it with a still from Erlang: The Movie right now
|
# ? Jan 24, 2022 20:55 |
|
Meanwhile this entire beaucoup loving bonkers thread https://news.ycombinator.com/item?id=30061040 "I was deceived about Covid safety" Naturally it's a substack and naturally the first wet plop of "evidence" is a chart taken out of context and cropped to fit an argument the chart's authors expressly do not hold to be true, so equally naturally the hackernewses slurp it up with a spoon quote:csense 37 minutes ago | prev | next [–]
|
# ? Jan 24, 2022 20:57 |
|
MononcQc posted:yeah a lot of the generic issues come with the subtyping when you allow class hierarchies where the -variant types get in. The rest of it is pretty straightforwards in general. java generics are a pretty good argument against rejecting generics due to complexity. cause theyre super complex and like ten people understand java generics fully and its fine. i still dont know what a lub is and yet i can make generic types just fine. some of them even had type parameters with multiple bounds, which i mostly used to find a bug in the jdk and demonstrate to the coder after me how dangerous it is to let a mid go unsupervised
|
# ? Jan 25, 2022 05:39 |
|
I've done some very dodgy stuff with Java generics. Like writing a Wrapper<T extends SomeClass & SomeInterface> so that I could then pass around Wrapper<?> instances and write code that was polymorphic over my interface, but that I could also pass to something that expected an instance of SomeClass. Why I didn't just add a getAsSomeClass() method to the interface that just returns this I still don't know.
|
# ? Jan 25, 2022 05:49 |
|
every static type system has limitations. we just had someone on the swift forums suggest permitting typealias Fn = (Input) -> Fn because it'd be useful when writing non-terminating state machines, and i had to politely yet firmly inform them that it was never going to happen. eventually you get the hang of what a language can and can't do, and how you get things done, but before you reach that point it can feel pretty frustrating. and some people really develop mental blocks and refuse to get through that, the same way that some people refuse to learn algebra
|
# ? Jan 25, 2022 07:20 |
|
Jabor posted:I've done some very dodgy stuff with Java generics. i had abstract generic controller classes that would have like AbstractAdminController<T extends CRUDEntity & Image> and use reflection in the constructor to find out the actual parameter for T and generate an admin UI for the entity. iirc the jdk bug was that passing a T into a lambda that expected an Image would fail at runtime
|
# ? Jan 25, 2022 22:22 |
|
TameAntelope 1 hour ago | root | parent | next [–] I'd actually flip that, and say if you can't give daily feedback you're a "bad" developer (I'd probably use "inexperienced" or "new" rather than "bad", because it's a hard mindset shift and it takes time). In fact, not only should you be able to give daily updates, you should be able to ship functionality on the daily. From first line of code into production and in front of customers should only ever take about 2 to 16 hours of work. If you can't work at that cadence, you're probably not being as effective as you could be, as a developer. A "good" manager enables you to work like this. reply
|
# ? Jan 25, 2022 23:11 |
|
tell me you’ve only worked on fun size apps without telling me you’ve only worked on fun size apps
|
# ? Jan 25, 2022 23:36 |
|
tell me you've never worked on software with legal or ethical consequences for bugs without telling me you've never worked on software with legal or ethical consequences for bugs
|
# ? Jan 25, 2022 23:55 |
|
my lived experience is universally applicable, and is an effective benchmark to measure your own competency against
|
# ? Jan 26, 2022 02:05 |
|
olorum posted:TameAntelope 1 hour ago | root | parent | next [–] seems like a big leap from talking about what you did yesterday (if you did something you can also say that you did it) to pushing code daily. which requires a lot of infrastructure and process maturity to do properly
|
# ? Jan 26, 2022 03:50 |
|
Nomnom Cookie posted:seems like a big leap from talking about what you did yesterday (if you did something you can also say that you did it) to pushing code daily. which requires a lot of infrastructure and process maturity to do properly the old boss just edited files live on the server over ftp. why make it more complicated than it has to be
|
# ? Jan 26, 2022 04:12 |
|
maybe i'm telling on myself a bit here but i've always wondered how people like that manage the evolution of their database schema
|
# ? Jan 26, 2022 04:15 |
|
Sapozhnik posted:maybe i'm telling on myself a bit here but i've always wondered how people like that manage the evolution of their database schema Thoughts and prayers.
|
# ? Jan 26, 2022 04:17 |
|
Sapozhnik posted:maybe i'm telling on myself a bit here but i've always wondered how people like that manage the evolution of their database schema the ol' import/export db.sql razzmatazz!
|
# ? Jan 26, 2022 04:25 |
|
Zamujasa posted:the old boss just edited files live on the server over ftp. why make it more complicated than it has to be i guess if you have no process whatsoever then pushing code daily is also easy. huh i think there is a valley between "we're idiots and just push everything to prod immediately" and "we've put so much engineering into our CI/CD infrastructure that we just push everything to prod immediately" which is where you find people who think git flow is a good idea. they have to avoid breaking production but can't afford to automate it
|
# ? Jan 26, 2022 04:25 |
|
Sapozhnik posted:maybe i'm telling on myself a bit here but i've always wondered how people like that manage the evolution of their database schema what is there to manage? just add new columns and tables as needed
|
# ? Jan 26, 2022 04:31 |
|
|
# ? Apr 23, 2024 20:28 |
|
Maximo Roboto posted:bad opinion from hn poster not agreeing, but on the same general subject, something that I do miss is voices with singing power -- it seems to have gone out of fashion? Like, the 1980s, most woman singers I can think of in pop had kinda slightly deep, powerful voices, and a careful use of vibrato And I am kind of just sad that we do not have more of that in the mainstream in general
|
# ? Jan 26, 2022 04:47 |