The Big Programming Thread - Page 367
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
phar
United States1080 Posts
| ||
|
drafael
3 Posts
![]() @sluggaslamoo - on a closing note, the thing about redis is that it is high speed enough to actually have this normally local and lose-able data on a shared, replicated server. This means that it's easier to do things like load balancing between your server instances and dealing with stuff like server crashes gracefully, which is something I assumed would be a requirement for MMOs! | ||
|
sluggaslamoo
Australia4494 Posts
On October 04 2013 14:46 phar wrote: Before you select a database tech, you have to have fairly good ideas about what you need in terms of #1 most important: what is actually being stored? then: read latency (random) read latency (for lots of shit) write latency (random) write latency (for lots of shit) read throughput write throughput consistency level of the above operations (do you want to offer really fast not-terribly-consistent reads, or really slow consistent reads? or both?) how conflicts between machines/replicas/clients/whatever are handled for writes what happens when one of your db machines takes a shit and dies what happens when an individual machine doing a read or write query decides that it's cool to suddenly take forever to do disk i/o etc etc Before you actually settle on what your actual requirements are, discussing individual db choice is a pointless endeavor. For example: for an mmo, maybe it's ok to store most things in a very fast inmemory cache. Things like, "where is this dude standing?, where is that dude standing? what is dude1 doing? what is dude2 doing?" Maybe then things that are more static (what is each person carrying?) can be stored off the individual server, on some shared db. That db might have much less stringent requirements for latency & throughput. Maybe you only write to this every so often, instead of every action. But then we're still leaving unanswered what happens if an individual server that has your inmemory cache of stuff-that's-going-on dies, starts being slow like a bitch, or w/e. Who knows? Do we just drop it and say "oops sorry, machine error, all that shit you just did disappeared"? I've played games that do that. It kinda sucks. There's just too many open questions to have a serious discussion about "what db to use for an mmo." It's just silly to talk about it in this format. Except that most games do things more or less the same way. Everything that happens inside the world instance is stored in memory, always. Some games will lazily and asynchronously store important information to secondary storage so when the server dies, you don't lose everything. You also won't notice this happening as data manipulation in memory is instant and the replication is done in a separate thread. Server clusters may also use checksums to test synchronisation between servers, if you have clusters that replicate player information in memory. | ||
|
Tobberoth
Sweden6375 Posts
On October 04 2013 09:48 bigglesbiggles wrote: heh, I think you kind of sidestepped what i was saying there. my frustration is that people use OOP and Design Patterns as a substitute for understanding data structures. data structures and algorithms are much more fundamental tools, and are practically always used in programming. OOP is more situational, and it's debatable whether learning & thinking in canonical design patterns is even helpful at all. in plenty of situations, it is completely nonessential to know either of these things. like anything else in programming, knowing them will enrich your ability as a computer programmer because they will give you a better understanding of programming culture & the available programming techniques. but they are far from the essential tools they're made out to be by the software engineering gurus. what i am saying is that focusing on them at the expense of learning to design data structures and algorithms is a mistake. unless you want to write only enterprise java, in which case disregard everything i have said. I disagree. As a professional software developer, you will have more daily use of design patterns than knowledge of data structures and algorithms in the majority of positions. How often do you implement a sorting algorithm yourself? How often do you have to sit and ponder which collection type to use? Deciding how to refactor code, how to design a new aspect of the software, how to make up smart solutions for bigger problems, that's what you spend most of your time doing. Optimization is important, in some cases very important, but you do that afterwards with the facts in front of you. Disregarding anything where you need a good grasp of OOP and design patterns as "enterprise java" just indicates you're a computer scientist who think you'll be working on an OS kernel or device drivers or something similar... when the vast majority of programmers actually do work on larger systems. Your personal preference on what programming you like has no real impact on what's most important to learn in an education aimed at software development. | ||
|
bigglesbiggles
New Zealand30 Posts
here's a thing Dijkstra prepared especially for you and has fired from his grave through me to meet your eyes at this precise moment http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1209.html truly he is prescient. there are many more fantastic letters that he has written for you to read in his archive. | ||
|
Tobberoth
Sweden6375 Posts
On October 04 2013 21:17 bigglesbiggles wrote: apparently i want a job clipping software components together and writing boilerplate. sounds like all my least favourite parts of my job, where do i sign up? i'm glad to have learned that the business community's assessment of software quality is fact, and is not subject to disputation. design patterns are jobgetter therefore they are also good and work well. argument over. i lose. here's a thing Dijkstra prepared especially for you and has fired from his grave through me to meet your eyes at this precise moment http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1209.html truly he is prescient. there are many more fantastic letters that he has written for you to read in his archive. No one is disputing the fact that a great grasp of math, algorithms, data structures and all the other low level stuff is important to computer science. What is being disputed is the worth in training droves of programmers to program device drivers/doing research into new programming languages etc when the vast majority of them does not need that knowledge. If you want to research computer science, obviously you should focus on concepts like algorithms. If you're new to the field or if your goal is to work in IT departments of big companies, screw it, you won't need it to a degree where it's worth wasting years on. You're being extremely condescending towards enterprise programming. Which is fine, you obviously don't care for it. But there's still tons of programmers needed to do that job. | ||
|
Abominous
Croatia1625 Posts
On October 04 2013 21:17 bigglesbiggles wrote: apparently i want a job clipping software components together and writing boilerplate. sounds like all my least favourite parts of my job, where do i sign up? i'm glad to have learned that the business community's assessment of software quality is fact, and is not subject to disputation. design patterns are jobgetter therefore they are also good and work well. argument over. i lose. here's a thing Dijkstra prepared especially for you and has fired from his grave through me to meet your eyes at this precise moment http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1209.html truly he is prescient. there are many more fantastic letters that he has written for you to read in his archive. Spot on, mr. Dijkstra! | ||
|
sluggaslamoo
Australia4494 Posts
On October 04 2013 21:17 bigglesbiggles wrote: apparently i want a job clipping software components together and writing boilerplate. sounds like all my least favourite parts of my job, where do i sign up? i'm glad to have learned that the business community's assessment of software quality is fact, and is not subject to disputation. design patterns are jobgetter therefore they are also good and work well. argument over. i lose. here's a thing Dijkstra prepared especially for you and has fired from his grave through me to meet your eyes at this precise moment http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1209.html truly he is prescient. there are many more fantastic letters that he has written for you to read in his archive. Yeah boilerplate sucks! Time to code my next website in... ALGOL!
| ||
|
Kambing
United States1176 Posts
I can only describe as improving one's mathematical skills, where I use mathematics in the sense of "the art and science of effective reasoning". As a matter of fact, the challenges of designing high-quality programs and of designing high-quality proofs are very similar, so similar that I am no longer able to distinguish between the two: I see no meaningful difference between programming methodology and mathematical methodology in general. Is perfect for it. ^_^ | ||
|
enigmaticcam
United States280 Posts
![]() I'm working on a project and would like to use this kind of functionality, two buttons on opposite ends that can scroll through a list of content. I'm assuming it would have to be done with javascript? | ||
|
adwodon
United Kingdom592 Posts
On October 05 2013 00:45 enigmaticcam wrote: Web design question: How would I go about creating something like this (from imgur)? ![]() I'm working on a project and would like to use this kind of functionality, two buttons on opposite ends that can scroll through a list of content. I'm assuming it would have to be done with javascript? A bit of googling could help you on this one: http://www.1stwebdesigner.com/css/fresh-jquery-image-gallery-display-solutions/ Just google jQuery image gallery or something to that effect. There's a tonne of straight forward solutions. | ||
|
Shield
Bulgaria4824 Posts
I think I know theory, e.g. Aggregation: Laptop 0..1 ♢-------- 0..* USB mouse Composition: Laptop 1 ♦------- 0..1 Touchpad In the 1st case, there shouldn't be strict ownership. So if you destroy the laptop, the USB mouse can still exist. In the 2nd case, there is strict ownership. If you destroy the laptop, then its parts (Touchpad in this case) cease to exist. However, how does one put this in practice? Is it supposed to be only design methodology? If you can provide some simple C/Java code, it would be nice.. Other languages like C++ may also be ok as long as they're readable. | ||
|
enigmaticcam
United States280 Posts
On October 05 2013 01:04 adwodon wrote:A bit of googling could help you on this one: http://www.1stwebdesigner.com/css/fresh-jquery-image-gallery-display-solutions/ Just google jQuery image gallery or something to that effect. There's a tonne of straight forward solutions. Thanks! Website design is still very foreign to me, so I never know quite where to start. | ||
|
Frigo
Hungary1023 Posts
On October 04 2013 12:16 sluggaslamoo wrote: I don't know what paradigms have to do with database performance. A lot actually. ECS translates rather directly to either relational tables or key-value stores, it completely circumvents the object-relational mismatch and the expensive operations to translate between objects and database entries. The way I implemented my component storage is essentially a Map<Class<? extends Component>, Map<int, Component>>, in other words for every component type I have associations between entity ids and component instances of the particular component type. The choice of the inner map implementation is important, since there is a tradeoff involved between space and performance. I have two implementations for it, one is a simple ArrayList<T extends Component> with optimal lookup performance, the other is a Trove TIntObjectHashMap which stores sparse maps in a space efficient manner while still providing excellent performance. In my case entity ids are pooled int values, meaning they are reused and are always between [0..n), but Trove maps would work with non-pooled long values too, and is probably preferred when replication and synchronization is taken into account. It is not hard to see the parallels with databases: the first choice corresponds to storing components in a huge table where columns are component types and rows are entity ids, cells are either null or component instances, the second choice corresponds to a key-value database with component type and entity id as key(s). It is simple and flexible enough to conform to the addressing method of a particular key-value store or document database. It is also easy to see that it would not take much work to actually store all these components in an in-memory, or cached on-disk database, with all the nifty features modern databases offer. In my case I would just create a new ComponentStorage implementation. However at the moment database backed components are not the direction I am going. However you should look at CouchDB which is a document oriented database (as opposed to a relational database) which scales much better than RDBMS through replication and the fact that it doesn't use tables. Especially for games, relational databases are an inferior solution even just performance wise, not to mention how much easier it is to maintain code-wise. For the record you normally use an ODM with CouchDB which is object oriented. A few months ago I was trying to sort through the chaos that is open source nosql databases and found LevelDB and LMDB among a few others to be interesting enough to consider (for other purposes as well). Basically what would be nicest is a fast key-value store or document database that is either a cached on-disk db or a memory mapped on-disk db. Replication and such features are nice but they introduce another tradeoff and additional problems so I don't want to deal with that for quite a long while. | ||
|
Deleted User 101379
4849 Posts
On October 05 2013 01:14 darkness wrote: How are composition and aggregation put in practice? I think I know theory, e.g. Aggregation: Laptop 0..1 ♢-------- 0..* USB mouse Composition: Laptop 1 ♦------- 0..1 Touchpad In the 1st case, there shouldn't be strict ownership. So if you destroy the laptop, the USB can still exist. In the 2nd case, there is strict ownership. If you destroy the laptop, then its parts (Touchpad in this case) cease to exist. However, how does one put this in practice? Is it supposed to be only design methodology? If you can provide some simple C/Java would be nice. Other languages like C++ may also be ok as long as they're readable. All pseudocode: // Base class for creature behavior defining things all creatures do This is a simplified but real-world applicable example of composition. You have a class that uses another class to specify it's behavior, meaning you can reuse the same behavior for different entities without having to subclass it. You can even change the behavior of the entities on-the-fly, e.g. when a quest makes an entity hostile. // Base class for gaming consoles It looks very similar, but the Controllers don't define the (classwise) behavior of the Console, they are just part of it, they don't change the Console and they exist and have a meaning without it. | ||
|
berated-
United States1134 Posts
On October 05 2013 01:36 Frigo wrote: A lot actually. ECS translates rather directly to either relational tables or key-value stores, it completely circumvents the object-relational mismatch and the expensive operations to translate between objects and database entries. The way I implemented my component storage is essentially a Map<Class<? extends Component>, Map<int, Component>>, in other words for every component type I have associations between entity ids and component instances of the particular component type. The choice of the inner map implementation is important, since there is a tradeoff involved between space and performance. I have two implementations for it, one is a simple ArrayList<T extends Component> with optimal lookup performance, the other is a Trove TIntObjectHashMap which stores sparse maps in a space efficient manner while still providing excellent performance. In my case entity ids are pooled int values, meaning they are reused and are always between [0..n), but Trove maps would work with non-pooled long values too, and is probably preferred when replication and synchronization is taken into account. It is not hard to see the parallels with databases: the first choice corresponds to storing components in a huge table where columns are component types and rows are entity ids, cells are either null or component instances, the second choice corresponds to a key-value database with component type and entity id as key(s). It is simple and flexible enough to conform to the addressing method of a particular key-value store or document database. It is also easy to see that it would not take much work to actually store all these components in an in-memory, or cached on-disk database, with all the nifty features modern databases offer. In my case I would just create a new ComponentStorage implementation. However at the moment database backed components are not the direction I am going. A few months ago I was trying to sort through the chaos that is open source nosql databases and found LevelDB and LMDB among a few others to be interesting enough to consider (for other purposes as well). Basically what would be nicest is a fast key-value store or document database that is either a cached on-disk db or a memory mapped on-disk db. Replication and such features are nice but they introduce another tradeoff and additional problems so I don't want to deal with that for quite a long while. Can you please explain "expensive operations to translate between objects and database entries"? Are you speaking to trying to persist large object graphs in a normalized manner? Or? Also, how is Map<Class<? extends Component>,Map<int, Component>> not object oriented? If you need a fast key value store though, redis or memcached might prove helpful. | ||
|
Sub40APM
6336 Posts
| ||
|
phar
United States1080 Posts
But anyways, it's possible that you could be directed to a site, have it do something bad, and then have it redirect automatically to another site. That's not going to very typical, and if your internet isn't super fast you likely would be able to see it happening. It's possible Amazon has some kind of referral program that would net someone a certain % of a purchase if you bought after using a link they clicked on. I don't know what Amazon's setup is like, so that may not be possible. Do you have the link in the email? One way is to copy the link (actually rightclick on the link and select copy url or w/e, sometimes the link you see and the link go to after clicking on are not the same), paste it somewhere, and see what the leftmost domain name is. E.g. if you see foo.bar.cz/hi?somestuff=amazon.com/b/ref=asdfasd Then it's not linking to amazon. It's going to bar.cz | ||
|
Sub40APM
6336 Posts
| ||
|
phar
United States1080 Posts
| ||
| ||

![[image loading]](http://i.imgur.com/9wDoPZH.png)