• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:26
CEST 14:26
KST 21:26
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy18ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
$5,000 WardiTV TLMC tournament - Presented by Monster Energy2GSL CK: More events planned pending crowdfunding3Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage4Weekly Cups (March 23-29): herO takes triple6
StarCraft 2
General
Quebec Clan still alive ? BGE Stara Zagora 2026 cancelled Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win Rongyi Cup S3 - Preview & Info
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding $5,000 WardiTV TLMC tournament - Presented by Monster Energy RSL Season 4 announced for March-April
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power Mutation # 518 Radiation Zone
Brood War
General
BW General Discussion ASL21 General Discussion so ive been playing broodwar for a week straight. Gypsy to Korea Pros React To: JaeDong vs Queen
Tourneys
Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro24 Group F [BSL22] RO32 Group B - Sunday 21:00 CEST
Strategy
Fighting Spirit mining rates Muta micro map competition What's the deal with APM & what's its true value Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game Nintendo Switch Thread Darkest Dungeon
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread The China Politics Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How Streamers Inspire Gamers…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
StarCraft improvement
iopq
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2029 users

The Big Programming Thread - Page 365

Forum Index > General Forum
Post a Reply
Prev 1 363 364 365 366 367 1032 Next
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.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
October 03 2013 06:31 GMT
#7281
On October 03 2013 11:36 sluggaslamoo wrote:
Show nested quote +
On October 03 2013 10:54 3FFA wrote:
On October 03 2013 09:21 misirlou wrote:
On October 03 2013 08:50 sluggaslamoo wrote:
On October 02 2013 17:08 Tobberoth wrote:
On October 02 2013 10:05 Kambing wrote:
On October 02 2013 09:52 sluggaslamoo wrote:
On October 01 2013 15:21 Tobberoth wrote:
On October 01 2013 15:03 Abominous wrote:
On October 01 2013 07:46 Kambing wrote:
[quote]

Those two sentences contradict each other. If kids are writing code that they don't understand, then programming is far from trivial. What can be said is that, we're still learning how to effectively teach it when the ground underneath us changes rapidly.

They understand the code, not the work behind it. And in todays world, 90% of programmers do not need to understand what's going on behind and why.

Just like programmers in the old days didn't have to know exactly how a CPU is wired electronically.

It's just another level of abstraction. It gives more power to programmers at lesser cost, but the actual problem-solving is the same. One the one hand, you can be pissed that someone can, for example, make a flash game more advanced that NES games with less than half the knowledge of the people making the actual NES games... on the other hand, you can appreciate that the programmers of those days could not make modern games with the tools at hand.

Yeah, simple shit is easier to make today, but the difference between a bad and good programmer isn't shown in simple things. The level you have to perform at to be considered a really good programmer today has simply been raised, it's not enough to be able to do some sweet optimization on a sorting algorithm, you have to be able to juggle big code bases and far more calculations per second.


Then why start with Java. Why not use Haskell?

1. Its a "higher level of abstraction" to Java.
2. You can write things with less code.
3. You can problem solve better with Haskell
4. You don't have to worry about memory management as much as Java

...


Some people would argue that Haskell meets those goals better than Java. For example, I would be in that camp. The problem is that Haskell is not as accepted in industry as Java (and other alternatives) which is a detriment for most people.

This. Learning using haskell would make perfect sense if it was actually widely used in the industry. However, there are several more issues why Haskell would be worse than Java as a learning language.

1. Functional programming is far more different from classic procedural programming than OOP. If you learn Java first, you can learn C quite easily. If you learn haskell first, you'll probably be confused when you go to either C or Java.
2. Haskell might be shorter codewise than Java, but it's certainly not less complex. It's a complete copout to use the PutStr example since understanding of IO actions in Haskell takes longer learning than classes, static and hell, add in a huge part of the standard library as well. OOP is, countrary to popular belief it seems, actually not a difficult concept to grasp for beginners. Employees has a name and can say hello. I have two employees, one is named James, one is named Earl. When they say hello, they do it the same way but show different names. Cool, now you understand classes, objects, fields and methods.

What the goal of an introduction to programming is to have students who don't know how to program and get them to the point where they can experiment and learn on their own. Java is far better than C and haskell in this situation, because once you learn the basics of OOP, you can make full-on programs, with GUI, IO, networking etc. I'd say Python is a great contender as well, though Java is still stronger in the industry.


Its popular belief because it is a difficult concept to grasp.

http://www.netgore.com/sites/default/files/ObjectOrientedProgramming.pdf

Structured programming took me about 6 months to master. Once you learn the concepts of functional decomposition, expression and abstraction you are 90% of the way there. OOP about 3 years to get to the point where I actually wrote clean code (of course when I started I thought I was writing clean code, then I look back on it years later and realise it was terrible). That journal was written after 6 months of learning OOP, if I were to write it again it would be completely different.

ah memories. when I look back on my high school days and every var was called i1,i2,i3,str1,str2,str3,x1,x2,y1,y2 and I managed to not get turned around, so it was good standard.
Yeah I have to agree with you, I use OOP for 5 years (1 high school + 4 college) and everytime I turn in a project I find something new that I was not doing/doing wrong in OOP, feeling I am still a long way from mastering it. But I also agree it's very easy to understand the principle.

The truth is every language has it's purpose and if your purpose is readability you go for a higher language and if you want performance you go for a lower.


Could you demonstrate an example of a common OOP mistake you made in HS and how you would write it differently now, just for my HS eyes?


Not sure if you're asking both of us but just in case you wanted my input...

For me when I initially started delving into OOP books and Responsibility Driven Design, it was over-engineering the design of objects and object decomposition and thinking way too hard. I would spend hours figuring out the best layout of my new project. Now I don't even bother to design the overall layout of my program and somehow end up with a much simpler and easier to maintain program.

That's not to say that the core principles of OOP (Abstraction, Encapsulation, Polymorphism, Inheritance) and RDD aren't important, its that these principles work much better when you use them on the fly.

Its not that learning these concepts help you design better, its that you often fall into common patterns which these concepts help you to fix much more quickly. For example if you have a lot of like objects, you will immediately think of using a base class that these objects can inherit from to reduce the size of your code base. Without learning about inheritance, you will not only waste time reinventing the wheel, but you will also have an inferior solution.

Its like the old saying 'When you are given a hammer, everything turns into a nail'. When you learn new concepts in OOP, you always feel like you HAVE to use them. The advantages of certain features of OO should only be used when you really need them, they are much more specific than you think.

For example don't use inheritance to plan for the future, use inheritance ONLY if you can see the benefits of it RIGHT NOW, if its not immediately making your code base smaller, don't use it, you can always do it later. Refactoring > Designing.

Sometimes I see people design big vertical inheritance hierarchies and end up with really fragile programs, when they could have just used one robust concrete base class with half the code, a quarter of the time, and half the headaches to maintain.

If you think too far ahead you end up writing way too much boiler plate and getting locked into a framework which you realise later doesn't fit well with what you wanted. So the idea should be that you should spend a lot of time learning the principles and how to design, but when it comes to coding, be in the present.

http://en.wikipedia.org/wiki/You_aren't_gonna_need_it

I agree with all of those issues and definitely recognize them as issues I've had myself with OOP. However, you are talking about mastering it and using it in a way which is most productive to you. Indeed, structured programming is far simpler to master (since it's a far simpler process) but we are talking about first time students, their goal isn't to master it, it's to start getting somewhere, giving them as much power as possible in the least amount of time and effort. Problems such as over-using OOP concepts, you learn by experience, it's not really something you have to be taught.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
October 03 2013 06:58 GMT
#7282
Problems such as over-using OOP concepts, you learn by experience, it's not really something you have to be taught.


Well just by looking at this thread I'd say 90% of people who seriously studied OO have fallen victim to it and haven't learned.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
bigglesbiggles
Profile Joined August 2013
New Zealand30 Posts
Last Edited: 2013-10-03 11:09:03
October 03 2013 11:08 GMT
#7283
on haskell and java and 'industry':

haskell is used in cool jobs you can't get,
java is used in shit jobs you can get but don't want to do.
assuming you actually find programming interesting / successfully learned how to do it at some point.
probs the best jobs where you program are the ones where your job title isn't 'developer'.
after the initial excitement of "hey i can do computer!" wears off, that is.
im not cosigning z.a. shaw in general but i feel like this a lot http://programming-motherfucker.com/.
dijkstra was right about basically everything and every time a program breaks despite extensive testing or your course teaches you useless corporate information, he warned us. it's not like knuth's programs are often broken, and his methodology is close to what dijkstra prescribes.
also, learning oop and 'design patterns' is a horrible substitute for actually learning about data structures.

Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
October 03 2013 13:25 GMT
#7284
On October 03 2013 15:58 sluggaslamoo wrote:
Show nested quote +
Problems such as over-using OOP concepts, you learn by experience, it's not really something you have to be taught.


Well just by looking at this thread I'd say 90% of people who seriously studied OO have fallen victim to it and haven't learned.


Could you specify why?
misirlou
Profile Joined June 2010
Portugal3291 Posts
October 03 2013 16:05 GMT
#7285
On October 03 2013 11:36 sluggaslamoo wrote:
Show nested quote +
On October 03 2013 10:54 3FFA wrote:
On October 03 2013 09:21 misirlou wrote:
On October 03 2013 08:50 sluggaslamoo wrote:
On October 02 2013 17:08 Tobberoth wrote:
On October 02 2013 10:05 Kambing wrote:
On October 02 2013 09:52 sluggaslamoo wrote:
On October 01 2013 15:21 Tobberoth wrote:
On October 01 2013 15:03 Abominous wrote:
On October 01 2013 07:46 Kambing wrote:
[quote]

Those two sentences contradict each other. If kids are writing code that they don't understand, then programming is far from trivial. What can be said is that, we're still learning how to effectively teach it when the ground underneath us changes rapidly.

They understand the code, not the work behind it. And in todays world, 90% of programmers do not need to understand what's going on behind and why.

Just like programmers in the old days didn't have to know exactly how a CPU is wired electronically.

It's just another level of abstraction. It gives more power to programmers at lesser cost, but the actual problem-solving is the same. One the one hand, you can be pissed that someone can, for example, make a flash game more advanced that NES games with less than half the knowledge of the people making the actual NES games... on the other hand, you can appreciate that the programmers of those days could not make modern games with the tools at hand.

Yeah, simple shit is easier to make today, but the difference between a bad and good programmer isn't shown in simple things. The level you have to perform at to be considered a really good programmer today has simply been raised, it's not enough to be able to do some sweet optimization on a sorting algorithm, you have to be able to juggle big code bases and far more calculations per second.


Then why start with Java. Why not use Haskell?

1. Its a "higher level of abstraction" to Java.
2. You can write things with less code.
3. You can problem solve better with Haskell
4. You don't have to worry about memory management as much as Java

...


Some people would argue that Haskell meets those goals better than Java. For example, I would be in that camp. The problem is that Haskell is not as accepted in industry as Java (and other alternatives) which is a detriment for most people.

This. Learning using haskell would make perfect sense if it was actually widely used in the industry. However, there are several more issues why Haskell would be worse than Java as a learning language.

1. Functional programming is far more different from classic procedural programming than OOP. If you learn Java first, you can learn C quite easily. If you learn haskell first, you'll probably be confused when you go to either C or Java.
2. Haskell might be shorter codewise than Java, but it's certainly not less complex. It's a complete copout to use the PutStr example since understanding of IO actions in Haskell takes longer learning than classes, static and hell, add in a huge part of the standard library as well. OOP is, countrary to popular belief it seems, actually not a difficult concept to grasp for beginners. Employees has a name and can say hello. I have two employees, one is named James, one is named Earl. When they say hello, they do it the same way but show different names. Cool, now you understand classes, objects, fields and methods.

What the goal of an introduction to programming is to have students who don't know how to program and get them to the point where they can experiment and learn on their own. Java is far better than C and haskell in this situation, because once you learn the basics of OOP, you can make full-on programs, with GUI, IO, networking etc. I'd say Python is a great contender as well, though Java is still stronger in the industry.


Its popular belief because it is a difficult concept to grasp.

http://www.netgore.com/sites/default/files/ObjectOrientedProgramming.pdf

Structured programming took me about 6 months to master. Once you learn the concepts of functional decomposition, expression and abstraction you are 90% of the way there. OOP about 3 years to get to the point where I actually wrote clean code (of course when I started I thought I was writing clean code, then I look back on it years later and realise it was terrible). That journal was written after 6 months of learning OOP, if I were to write it again it would be completely different.

ah memories. when I look back on my high school days and every var was called i1,i2,i3,str1,str2,str3,x1,x2,y1,y2 and I managed to not get turned around, so it was good standard.
Yeah I have to agree with you, I use OOP for 5 years (1 high school + 4 college) and everytime I turn in a project I find something new that I was not doing/doing wrong in OOP, feeling I am still a long way from mastering it. But I also agree it's very easy to understand the principle.

The truth is every language has it's purpose and if your purpose is readability you go for a higher language and if you want performance you go for a lower.


Could you demonstrate an example of a common OOP mistake you made in HS and how you would write it differently now, just for my HS eyes?


Not sure if you're asking both of us but just in case you wanted my input...

snip


My input.

Ill give you this example. This is from a map of mars where "mars object" represents one cell.
https://www.dropbox.com/s/l9p2t9h1ycwpv8t/MarsObject.java
it represents empty cells, valuable cells, obstacle cells. Maybe I should have refactored it to different classes each but I used a base class for everything, overall it was more basic and easy approach but its not the right one. Seperating it would make it easier to add new object types or modify existing ones. I also use some object propertys that are global so they should have been static instead.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
October 03 2013 16:22 GMT
#7286
On October 03 2013 20:08 bigglesbiggles wrote:
on haskell and java and 'industry':

haskell is used in cool jobs you can't get,
java is used in shit jobs you can get but don't want to do.
assuming you actually find programming interesting / successfully learned how to do it at some point.
probs the best jobs where you program are the ones where your job title isn't 'developer'.
after the initial excitement of "hey i can do computer!" wears off, that is.
im not cosigning z.a. shaw in general but i feel like this a lot http://programming-motherfucker.com/.
dijkstra was right about basically everything and every time a program breaks despite extensive testing or your course teaches you useless corporate information, he warned us. it's not like knuth's programs are often broken, and his methodology is close to what dijkstra prescribes.
also, learning oop and 'design patterns' is a horrible substitute for actually learning about data structures.


How is learning OOP and design patterns a substitute for learning about data structures? How will your knowledge of how a hashtable works help when you need the observer pattern? How will your knowledge of a linked list help you when you need the factory pattern?

Those things are not comparable at all. OOP and design patterns are on a completely different level than data structures.
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2013-10-03 16:26:00
October 03 2013 16:24 GMT
#7287
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.
http://www.fimfiction.net/user/Treasure_Chest
misirlou
Profile Joined June 2010
Portugal3291 Posts
October 03 2013 16:33 GMT
#7288
for what it's worth, it wasn't a game. Its a collection of AI Agents exploring Mars using REPAST for the simulation framework
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
October 03 2013 18:28 GMT
#7289
On October 04 2013 01:24 Frigo wrote:
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.

OOP is quite essential in a lot of ways in game programming. "Entity Component Systems" are mostly a giant load of hype, and hardly anyone really understands what is important and what is not important when it comes to game engines.

Just try to realize that any advice you give is likely ill-informed and probably going to just do more harm than good. It's silly of you to assume OOP = inheritance.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
October 03 2013 18:39 GMT
#7290
On October 04 2013 01:24 Frigo wrote:
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.

It is not unsuited for it, it's just not as clear cut. In a business applications, it's usually quite easy to model using OOP, it becomes harder in a game. That said, it can still be very beneficial. Separating game logic from the rendering is a tough job with huge benefits. Good knowledge of OOP, MVC in particular, can help a ton.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-10-03 19:07:04
October 03 2013 19:06 GMT
#7291
With all these OOP sceptics, I was wondering when you really shouldn't use OOP? Are those cases only when:
  • performance is important, e.g. embedded systems, possibly drivers, etc
  • you have low memory
  • when you want a simple function, e.g.

    int calc(int a, int b) {
    return a + b;
    }



I know OOP isn't a silver bullet.
Kambing
Profile Joined May 2010
United States1176 Posts
Last Edited: 2013-10-03 19:59:14
October 03 2013 19:56 GMT
#7292
On October 04 2013 04:06 darkness wrote:
With all these OOP sceptics, I was wondering when you really shouldn't use OOP? Are those cases only when:
  • performance is important, e.g. embedded systems, possibly drivers, etc
  • you have low memory
  • when you want a simple function, e.g.

    int calc(int a, int b) {
    return a + b;
    }



I know OOP isn't a silver bullet.


It turns out that OOP is quite compatible with performance-demanding, memory constrained contexts, e.g., C++. It is, foremost, a code organization principle that does not place particular demands on implementation. On the other hand, the main tenant of functional programming, that of referential transparency, place constraints on how a program executes which in turn affects performance and memory footprint. However, even functional programs can be made performant given appropriate optimizations, e.g., OCaml, MLton. In this sense, choice of programming paradigm is independent of your first two cases; it is the implementation of a particular programming system that dictates performance and memory usage.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
October 03 2013 19:58 GMT
#7293
On October 04 2013 04:06 darkness wrote:
With all these OOP sceptics, I was wondering when you really shouldn't use OOP? Are those cases only when:
  • performance is important, e.g. embedded systems, possibly drivers, etc
  • you have low memory
  • when you want a simple function, e.g.

    int calc(int a, int b) {
    return a + b;
    }



I know OOP isn't a silver bullet.


There isn't really ever a definitive reason not to use OOP unless you are programming a microchip with 1kb of memory or something similar. Sometimes it's not the best tool for the job, but there isn't really a situation where you could say "Never use OOP in this case". In some situations like throwaway scripts it's overkill and procedual solutions are simpler, in others functional programming is better suited for the job, but OOP is never really "bad". It all depends on the situation.

OOP is a very broadly defined thing, it's not just about using classes and inheritance, it also encompasses some really useful design principles that you can use even without using a single object. There are also some parts in OOP that are completely overused, e.g. inheritance, and that should be used as little as possible even when writing fully object oriented code.
billy5000
Profile Blog Joined December 2010
United States865 Posts
October 03 2013 21:25 GMT
#7294
Speaking of pros and cons of OOP, what do you guys think about Go's opinion about it? I don't have any experience with a large project, let alone a heavy use of OOP, so I can't really agree or disagree on much of anything. But I'd like to see if anyone here can relate to their decisions.
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 03 2013 21:42 GMT
#7295
On October 04 2013 06:25 billy5000 wrote:
Speaking of pros and cons of OOP, what do you guys think about Go's opinion about it? I don't have any experience with a large project, let alone a heavy use of OOP, so I can't really agree or disagree on much of anything. But I'd like to see if anyone here can relate to their decisions.

I don't really see an opinion about OOP in there.
It uses a different approach to classes/interfaces than C++/Java/C#, which is for the most part just that: different.
If you have a good reason to disagree with the above, please tell me. Thank you.
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2013-10-03 22:12:19
October 03 2013 22:03 GMT
#7296
On October 04 2013 03:28 CecilSunkure wrote:
Show nested quote +
On October 04 2013 01:24 Frigo wrote:
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.

OOP is quite essential in a lot of ways in game programming. "Entity Component Systems" are mostly a giant load of hype, and hardly anyone really understands what is important and what is not important when it comes to game engines.

Just try to realize that any advice you give is likely ill-informed and probably going to just do more harm than good. It's silly of you to assume OOP = inheritance.


Please do a bit of research before you write such a sorry excuse of a post that essentially boils down to "it is a hype, therefore it is crap, also you are stupid".

Contrary to your claim, there are many people who are aware of the various aspects and details of game engine design, as well as software development considerations. The fact that it seems cloudy and unsure to you, is a product of your ignorance and lack of experience on the subject matter, rather than some inherently mysterious property of game development and game engine design.

Among people with proper knowledge of game engines and component based entities (i.e. not you), there is virtually no disagreement about the superiority of ECS. It is a very powerful software development pattern, and has overwhelming advantages over OOP or even mixins for game objects:
- Easier, faster game design and prototyping without having to modify the codebase. Game designers have to bother programmers less.
- No poorly built, fixed inheritance trees you have to hack your way around. No structural constraints encouraging poor quality code full of hacks.
- Dynamic component addition, removal and change. Inheritance and mixins are static, they can not handle this change common in games.
- Clear separation between component data and logic. Unified handling of the same components. All logic is in "systems". No more spaghetti logic all over the place.
- Cleaner, better refactored, more reusable components. Existing components are much more flexible and can fit a much wider range of cases than OOP hacks. They are called components for a reason.
- Component processor systems naturally fit in the game loop. Their order and result is more deterministic than unpredictable multi threaded OOP hacks with logic all over the threads.
- Component based entities can be better serialized, deserialized and edited either via text files or appropriate tools.
- Component based entities and game worlds can be better synchronized between servers and clients.
- Entities and their components naturally fit relational databases, completely bypassing the object-relational impedance mismatch. This is especially important for MMORPGs and other persistent world games.
- Depending on component storage, bulk processing can be faster by exploiting cache locality, branch prediction and other modern processor features.

On October 04 2013 03:39 Tobberoth wrote:
Show nested quote +
On October 04 2013 01:24 Frigo wrote:
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.

It is not unsuited for it, it's just not as clear cut. In a business applications, it's usually quite easy to model using OOP, it becomes harder in a game. That said, it can still be very beneficial. Separating game logic from the rendering is a tough job with huge benefits. Good knowledge of OOP, MVC in particular, can help a ton.


There is at least one business module at my workplace that would benefit from component based entities. Unfortunately they use an inheritance tree and as a result the code smells all over the place. I will tell more about these code smells and how to recognize whether your particular use case requires components rather than inheritance or mixins.

Game logic and rendering is naturally separated with component based entities. Though actually you can reuse the movement system for interpolated rendering.

And remember, if you try to enforce OOP in cases that require components, you are digging your own grave.
http://www.fimfiction.net/user/Treasure_Chest
Cyx.
Profile Joined November 2010
Canada806 Posts
October 03 2013 22:30 GMT
#7297
On October 04 2013 07:03 Frigo wrote:
Among people with proper knowledge of game engines and component based entities (i.e. not you), there is virtually no disagreement about the superiority of ECS. It is a very powerful software development pattern, and has overwhelming advantages over OOP or even mixins for game objects:


So I'm by no means an expert on this, but the idea I had of 'component-based' entities wasn't that it replaced OOP at all - rather, I thought the idea was to break up the fragile, painful inheritance heirarchy part of it, and make your code more modular and easier to use. Now admittedly inheritance is one of the things that people kind of seem pretty gung-ho on when they're really excited about OOP - but that being said, there is a LOT more to OOP than using inheritance, and component-based design seemed to me to be ONLY about removing that specific, painful part of OOP and keeping all the other nice parts of it.

So correct me if I'm wrong, but are 'component-based entities' and 'object-oriented entities' actually mutually exclusive? Because it seems to me like the better comparison would be 'component-based' vs. 'inheritance-based' which is a whole different discussion, and definitely not the one we're having right now ^^
Kambing
Profile Joined May 2010
United States1176 Posts
Last Edited: 2013-10-03 23:41:52
October 03 2013 23:05 GMT
#7298
On October 04 2013 07:30 Cyx. wrote:
Show nested quote +
On October 04 2013 07:03 Frigo wrote:
Among people with proper knowledge of game engines and component based entities (i.e. not you), there is virtually no disagreement about the superiority of ECS. It is a very powerful software development pattern, and has overwhelming advantages over OOP or even mixins for game objects:


So I'm by no means an expert on this, but the idea I had of 'component-based' entities wasn't that it replaced OOP at all - rather, I thought the idea was to break up the fragile, painful inheritance heirarchy part of it, and make your code more modular and easier to use. Now admittedly inheritance is one of the things that people kind of seem pretty gung-ho on when they're really excited about OOP - but that being said, there is a LOT more to OOP than using inheritance, and component-based design seemed to me to be ONLY about removing that specific, painful part of OOP and keeping all the other nice parts of it.

So correct me if I'm wrong, but are 'component-based entities' and 'object-oriented entities' actually mutually exclusive? Because it seems to me like the better comparison would be 'component-based' vs. 'inheritance-based' which is a whole different discussion, and definitely not the one we're having right now ^^


No. Component-based entities and object-based entities are not mutually exclusive. The distinction is between composition vs. inheritance. Over the last decade, people have come to realize that the former is much more useful than the latter in practice.

Relating this to the discussion about Go, many Java and C# programmers nowadays prefer to use interfaces and shallow class hierarchies over inheritance and deep class hierarchies. This is the style of "object-oriented programming" that Go promotes. As mentioned before, it's "just different", but it is more inline with current OO practices.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2013-10-03 23:55:27
October 03 2013 23:50 GMT
#7299
On October 04 2013 07:03 Frigo wrote:
Show nested quote +
On October 04 2013 03:28 CecilSunkure wrote:
On October 04 2013 01:24 Frigo wrote:
OOP is particularly unsuited for game objects, because

1) Components like position, exploration status, color, visibility, resource content, et cetera, can not be grouped in any semantical sense, all inheritance based attempts will be incorrect and lead to long, fragile class hierarchies. This antipattern smells rather rancid, just consider a class called ExploredCellWithColorAndResource.

2) Class hierarchies are strictly static, you can not modify entities on-the-fly, for example in the case of resource depletion of a cell, only by replacing the object, which destroys the identity of the entity, which gives rise to numerous bugs. Case in point: Starcraft unit transformations.

3) Uniform data collections are much better suited for batch processing than classes.

The correct solution is to use Component-Based Entities, also called Entity Component Systems.

Use the proper tools.

OOP is quite essential in a lot of ways in game programming. "Entity Component Systems" are mostly a giant load of hype, and hardly anyone really understands what is important and what is not important when it comes to game engines.

Just try to realize that any advice you give is likely ill-informed and probably going to just do more harm than good. It's silly of you to assume OOP = inheritance.


Please do a bit of research before you write such a sorry excuse of a post that essentially boils down to "it is a hype, therefore it is crap, also you are stupid".

Lots of angry, angry words.



So, umm? You are able to use these fancy Component Based Entities without classes and objects? Sounds pretty hard... that's a lot of functions... How do you even pass around that much data?

While his response was quite baiting, it is completely true that OOP != inheritence. Just because you use an OOP language doesn't mean you have to be an idiot and only use inheritance. Favoring composition ( has a ) over inheritance (is a) generally works for the better anyways.
Frigo
Profile Joined August 2009
Hungary1023 Posts
October 04 2013 00:10 GMT
#7300
On October 04 2013 08:50 berated- wrote:
So, umm? You are able to use these fancy Component Based Entities without classes and objects? Sounds pretty hard... that's a lot of functions... How do you even pass around that much data?


It is pretty easy, you just have to eat your veggies and then you can do it too.

While his response was quite baiting, it is completely true that OOP != inheritence. Just because you use an OOP language doesn't mean you have to be an idiot and only use inheritance. Favoring composition ( has a ) over inheritance (is a) generally works for the better anyways.


Mixins, aka composition based reuse without inheritance, still does not solve the problem of dynamic component addition and removal, neither the runtime change of the "class" of an entity. Close but no cigar.
http://www.fimfiction.net/user/Treasure_Chest
Prev 1 363 364 365 366 367 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Team League
11:00
Playoffs Day 2
WardiTV753
ComeBackTV 609
Rex91
3DClanTV 58
Liquipedia
CranKy Ducklings
10:00
Sea Duckling Open #144
CranKy Ducklings80
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko363
Rex 84
StarCraft: Brood War
Britney 50886
Sea 1977
Jaedong 1455
EffOrt 401
Hyuk 392
Mini 350
Shuttle 321
firebathero 298
Light 257
Last 205
[ Show more ]
ggaemo 154
Zeus 153
hero 138
PianO 94
Pusan 73
Shinee 65
Shine 57
[sc1f]eonzerg 56
HiyA 40
Free 35
Hm[arnc] 34
Barracks 32
scan(afreeca) 31
yabsab 19
Movie 18
Sacsri 17
GoRush 12
Noble 12
Sexy 10
ajuk12(nOOB) 9
Rock 6
Dota 2
Gorgc6697
XaKoH 829
XcaliburYe241
Counter-Strike
zeus398
Heroes of the Storm
Khaldor19
Other Games
singsing1777
B2W.Neo980
Hui .124
ArmadaUGS69
QueenE51
Organizations
Counter-Strike
PGL14223
Other Games
BasetradeTV978
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
CasterMuse 0
sctven
[ Show 13 non-featured ]
StarCraft 2
• CranKy Ducklings SOOP48
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1938
• TFBlade1305
Upcoming Events
uThermal 2v2 Circuit
2h 34m
IPSL
3h 34m
Hawk vs TBD
StRyKeR vs TBD
BSL
6h 34m
n0maD vs perroflaco
TerrOr vs ZZZero
MadiNho vs WolFix
DragOn vs LancerX
Sparkling Tuna Cup
21h 34m
WardiTV Team League
22h 34m
OSC
1d
BSL
1d 6h
Sterling vs Azhi_Dahaki
Napoleon vs Mazur
Jimin vs Nesh
spx vs Strudel
IPSL
1d 6h
Artosis vs TBD
Napoleon vs TBD
Replay Cast
1d 20h
Wardi Open
1d 21h
[ Show More ]
Afreeca Starleague
1d 21h
Soma vs YSC
Sharp vs sSak
Monday Night Weeklies
2 days
Afreeca Starleague
2 days
Snow vs PianO
hero vs Rain
GSL
2 days
Replay Cast
3 days
Kung Fu Cup
3 days
The PondCast
4 days
Escore
5 days
Korean StarCraft League
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Escore Tournament S2: W2
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
WardiTV TLMC #16
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.