4 ms·
I think the thing I'd miss most from python if I was using this is multiple-inheritance. Not even necessarily true multiple inheritance, but at least some kind
by traverseda 3y ago
I think the thing I'd miss most from python if I was using this is multiple-inheritance. Not even necessarily true multiple inheritance, but at least some kind of mixin.
- rollcat 3y agoClass-based inheritance is IMHO overrated. Most of the time you're interested in specific behavior (what is the area under this shape?), rather than some abstract taxonomy (is square a specialized rect or is rect a generalized square?). Composition and interfaces tend to produce less convoluted designs, and the most obnoxious problem with multiple inheritance ("diamonds") has to be explicitly addressed at the call site, rather than by meditating on the globally-determined method resolution order.
- runlaszlorun 3y agoHow do feel about prototypical inheritance and/or mixins as an alternative? I sorta feel like the component in the Entity/Component/System model that’s been getting popular in gaming drifts into the same territory as well though I’ve never written games.
- reactordev 3y agoECS is different. Systems coordinate entities, entities have components, some of them can be behaviors, some of them are not (vertex data). You would need to provide something that a component can inherit to derive that it’s a behavior. Unity does this by calling it a MonoBehavior (not Mono as in singular, mono as in Mono runtime, the name stuck). Having an ECBS system: one could model all the permutations as described while keeping code concise, shareable, and non-repeatable. Unity is really an ECBS. Inheritance vs non is as old as OOP vs functional. Each has their place, each has their pros and cons. Having functional components and behavior traits attached to object inheritance based entity nodes is probably the best of all composition. Entities can get more and more complex with inheritance chains (further classifying what components can be attached), components can include behaviors, data, events/triggers, sub-components. Behaviors (triggering events or waiting for) is where your game logic would mostly reside.
- runlaszlorun 3y agoAha, thx for the insight. Very helpful. A couple questions: 1) If I wanted to learn more about ECS/ECBS, would Unity be a decent place to learn? I know sometimes the terms get coopted (for example, MVC as a term gets fairly abused at times in web development) so I wasn’t sure if their implementation was a good one to learn from. And while I’m a fan of open source, Unity certainly does seem to be a leader in adoption and available assets, etc and not a bad place to start. I’m not really looking to develop a commercial game, but in addition to my poking around game engines to see if and what might be applicable ideas for a more classic business/personal type apps, I am interested in building something that broadly speaking sorta acts like an FPS or Arma type game but just for the sake of playing around and simulating different drones and drone swarms, etc in a 3D environment and playing with that. Pretty crude is fine, and AAA level graphics aren’t really a huge concern. I think I honestly could prob get pretty far with just a non-graphical, non-gamelike OO design with JS/Python/whatever as a crude simulation. But I’ve heard that standing up something like an FPS in Unity is not too difficult. And I don’t plan on pushing boundaries from a graphics or asset perspective. 2) > Systems coordinate entities Could you elaborate a bit? Systems are the one aspect that for me are hardest to get my head around coming from more standard web/business development. So physics engines would be a system right? But I’m not sure what are other examples. Thx for the info. And feel free to just refer to links if you know amy decent ones. I’ve been poking around ECS from a far for a couple years now but haven’t really found articles that fill in the gaps for things like systems in ECS. Though I’m sure the fact that I have little context in game development sure doesn’t help… lol.
- reactordev 3y agoUnity is just the loudest, they certainly aren’t the first and they definitely didn’t invent the paradigm. ECS/ECBS is a pretty common construct. This wiki is the Bible for ECS/ECBS systems: http://entity-systems.wikidot.com/ http://entity-systems.wikidot.com/
- skitter 3y agoThat page seems to be more about the entity-component architecture (entities are composed of components, which define data and behavior for one aspect of the game) then about entity-component-systems architecture (entities are composed of components, which are pure data; systems can query this database). Traditional Unity, as that site points out, is EC; Unity DOTS is ECS. Not sure why the site would be the bible on the topic either as it only some surface-level information and links (and hasn't been kept up to date much).
- rollcat 3y agoI think any object/type system is good, as long as it doesn't encourage atrocities. I personally am guilty of implementing a fully-blown class-based inheritance system on top of Lua's metatables, and thank $DEITIES it didn't make it into any production project! Nowadays if I write Lua, I mostly see metatables as a memory usage optimization. If you have thousands of small objects with many methods, and all of them share the same set of methods, it makes a lot of sense to have a single vtable, to save some memory. Otherwise I wouldn't bother, it's not like Lua lets you control struct member padding to ensure they fit in a single cache line.
- canadianfella 3y ago[dead]
- Pxtl 3y agoImho it's just that method signatures are enough work to write and maintain that inheritance is needed for simple code reuse sometimes. A language with good constructs for convenient call-signature reuse and redirection at the function level could probably skip implementation inheritance.
- MarkMarine 3y agoThis language is targeted toward embedded machines with very low resources, are you using python with multiple inheritance on embedded?
- traverseda 3y agoSure, I use micropython on the rare occasion when I'm playing with microcontroller stuff. Mostly that's hobbyist stuff, but still it's a feature I'd miss.
- MarkMarine 3y agoI’ve been using C for work on embedded for so long the idea of that is foreign to me, do you have any code in GitHub that is a good example? I’d like to read it.
- traverseda 3y agoNot really, I was working on a little web interface for the some hardware called "eduponics" but my day job has been keeping me pretty busy. Obviously micropython has a lot of downsides as compared to writing stuff in C, much higher energy requirements for one thing, but there are some nice things as well. A REPL can be really nice when you're a hobbyist using hardware that you aren't familiar with, makes it really easy to try stuff out. Performance wise you can do hard real time stuff in interrupts, as long as you don't treat it like python at all, no creating objects, if you need to do real stuff try to pass it back to a soft real-time event loop (python asyncio does a reasonable approximation of a co-operative real-time multitasking OS). You can also inline assembly directly into your functions, or some other python-like DSLs that have much better performance. I don't think anyone is using it seriously in any commercial products yet honestly, but for quickly hacking together something with some SPI peripherals it's a pretty nice environment.
- matt_trentini 3y agoThe company I work for uses MicroPython commercially, for medical devices. It's used in a growing number of commercial segments.