I've been trying to learn Flash/AS3 and it has some pretty strange quirks. This is the latest one, no abstract classes. That might not bother some people but it's more or less my programming style to use them. It does allow function overrides so I guess I'll figure something out, but wow. I thought all OO languages had that. It might sound weird but Flash is one of the hardest things I've had to learn. It's just so odd.

Wernaeh
—
2009-12-28T00:41:04Z —
#2

Reminds me of my first experiments with Perl - their object-oriented paradigm is really hard to grasp if one is used to the way of proper programming languages such as C++ or Java. Perl doesn't have the concept of actual objects with member variables, but instead, any object is just a hash map that contains the members and a special tag that says the object belongs to some class.

fireside
—
2009-12-28T02:05:15Z —
#3

Yeah, I don't think I'll ever attempt Perl. Knock on wood.

starstutter
—
2009-12-28T07:41:34Z —
#4

I'll tell you a strange concept: no way to declare variable types (not just some, all variables)

lua has a lot of strange elements:

passing in as many parameters as you want to a function

returning as many elements as you want

not declaring the types of variables or... even declaring variables at all

using functions as objects

"object oriented" programming by using arrays

counting from 1

ect ect

to be honest a lot of these elements are really nice, but the whole "not declaring variables" thing is a real problem. Example; declaring variables, and then wanting to change them later on:

The good news is that, while lua can develop a lot of bugs if your not careful, those bugs can generally be fixed quickly because of how rapidly you can change and test code. You don't have to recompile, restart or nothin

fireside
—
2009-12-28T14:57:52Z —
#5

Yeah, I think no type casting is going a step too far. I think some of them have a type casting option. The scripting languages are a little strange, but mostly they are just used for a glue, so it doesn't matter that much even if they aren't really OO. Once in a while it drives me a little nuts, though. The only one that is really OO that I know about is Python. I've never actually used Lua. I've used Javascript, which is a trimmed down, more or less useless Java. It's all right because the language structure is the same as what I'm used to anyway. If you have to do anything a little heavier with them, they start to look pretty messy. A lot of engines use Lua because it's lightweight and pretty fast as far as scripting languages go. I'm sure I'll come across it eventually. My trouble is that I'm so used to OO that when I have to do it a different way I sort of scratch my head. I don't really know how to organize code in a different way. AS3 is basically OO, but it's just set on this movie paradigm. So you go to frame so and so, the timer isn't even really a loop, you use a stage, and all kinds of other strangeness, and linking the graphics to the AS3 code is weird, too. It almost makes sense, but then you hit this case that doesn't work and you go searching through a ton of help files, or I do.

TheNut
—
2009-12-28T15:59:31Z —
#6

To make ActionScript even more fun, it doesn't support polymorphism or operator overloading. Are you also using the Flex framework? More joy awaits you @fireside

Yeah, I don't think I'll ever attempt Perl. Knock on wood.

I come to see Perl as one of those esoteric programming languages that successfully progressed into a production level language.

starstutter
—
2009-12-28T16:03:12Z —
#7

Yeah I'm finding it hard to imagine how a lot of people script entire games in lua or any non-object oriented script. Lua has "OOP" but it's very strange and a bit too much effort to maintain if you're trying to control objects held in C++.

I'm trying a wierd little experiment that I hope works out well. It works off the principle that a "game" can be basicly described as a series of interactions between various objects. Actors are assigned their own "behavior scripts" that are kept in lua. If you work with shaders a lot, it is actually a very similar concept... just with AI and actions instead of graphics.

There's also "interaction scripts" which are the same thing, but take 2 actors types as parameters and there you can define how those 2 types of actors deal with eachother. During the game update, it goes something like:

for every object x for every object y RunInteractionScriptOf(Xtype)And(Ytype)(x, y);

Of course there is other code to keep scripts from repeating twice, stop unrelated actors from calling interactions, methods for instant indexing (for speed purposes).

And of course, lua is fast, but only as fast as scripting languages go. I also set up a system where I can create a carbon copy of every script written in lua and put it in C++. To switch out the scripts, all I have to do is specify that the object will be running a script in CPP instead of in lua. It's about a 20 second process all in all.

I'm still anxious to see how all this works in the end.

TheNut
—
2009-12-28T17:25:49Z —
#8

LUA, Python and others are in my opinion the first iterations to dynamic scripting and have their pros and cons. One of the things I love about .NET is that it can compile code at runtime into native code, which by far the best way to go about things. You get all the benefits and power of a complete, strongly typed OO language and the performance of compiled code. A win-win.

I was excited about LUA until I realized how much of a pain in the butt it can be with multithreaded applications. Debugging them can also be a nightmere at times.

I was excited about LUA until I realized how much of a pain in the butt it can be with multithreaded applications.

Is it a nightmare if you're running lua on a single thread (while other things like physics) are running on a seperate thread? Or how about if lua scripting was one of the last things you did in the program and the first half (intensive engine updates) was carried out with multithreading and the second half (lua) was a single thread?

Btw, I'm making it a point to write it like "Lua" and not "LUA". The creators apparently really hate it when people write it like that. It's not an acronym

fireside
—
2009-12-28T17:33:17Z —
#10

To make ActionScript even more fun, it doesn't support polymorphism or operator overloading. Are you also using the Flex framework? More joy awaits you

What's kind of sad or funny, depending how you look at it, is you go to these sites and someone shows the most convoluted scheme imaginable to support something that the language doesn't. See you can do it! Sure, bud. I'll just try that out right now.

Really, though, I'm not into that heavy about OO or anything. I just want to put all similar code in a base class, differential code in an extended, put them in a container and call the same function like update or something, but it does it's own thing depending on the extended class. Apparently I can do that with the override keyword. The containers aren't fussy about type so the abstract class isn't as important, you just leave an empty function in the base class. Had me worried for a while there. I was just "What do I do now?"

I haven't used Flex. I bought Flash because I plan on using video like things in this game I want to do. I hate it in some ways but the whole online game thing is pretty cool, especially with Flash or Flex because of all the portals.

I'm still anxious to see how all this works in the end.

Let us know how it works out. Sounds like a good experience, anyway. I would think that the other party will start asking for all kinds of things you didn't anticipate. I don't envy anyone that writes an engine that other people use.

onyxthedog
—
2009-12-28T19:10:11Z —
#11

HaXe is a pretty neat language, that can be compiled to a SWF file (action script?), C++, and a couple other things. It's OOP. Just thought I would throw that in.

I'll tell you a strange concept: no way to declare variable types (not just some, all variables)

It's not that there isn't any typing, it's that Lua uses dynamic typing.

The con is you give up early, compile-time error checking for errors related to inappropriate values based on type. Some people believe that all bugs can be thought of as poorly-defined, type-related issues. Static typing can help compilers produce faster code too. And, it helps in development efficiencies because things like Intellisense being able to tell you a method wants a boolean comes from typing.

The pro is that things like Javascript's eval() function and other run-time dynamic behaviors becomes possible, or certainly easier.

There's lots on the net on static vs. dynamic typing. It's one of those pointlessly-but-hotly debated nerdy topics in software development.

It's not that there isn't any typing, it's that Lua uses dynamic typing.

I know, and it's not that I really mind the issue of no type specification. That *is* the only way to do quazi-"function overloading" in lua. What really gets me is not specifying that you're declaring a variable at all. That is a real debugging problem. Also (unless I missed some sort of warning about it) it doesn't tell you when you've accidently written 2 functions with the same name! It just picks a random one and assigns it!!

I still am very much liking Lua overall though The prototype capabilities are unbelivable.

There's lots on the net on static vs. dynamic typing. It's one of those pointlessly-but-hotly debated nerdy topics in software development.

Dear lord, I remember looking on a small personal forum group who started an engine project together. They had pages upon pages of ranting and passionate debate about whether or not to throw in an extra months worth of work for about a %1.8 speed increase.

What really gets me is not specifying that you're declaring a variable at all. That is a real debugging problem.

The usual dynamicist's answer is that unit tests should take care of isolating any errors.

fireside
—
2009-12-30T22:44:53Z —
#17

you could use interface as abstract class in actionscript.

Good point. I'll see if I can play around with that. Thanks for the example. I think AS3 will be fine, it's a matter of getting used to it. Same way with Flash. It has a lot of nice features.

Alex_11
—
2010-01-29T05:21:28Z —
#18

If you are unfamiliar with the concept of an abstract class, let me explain. Think of an abstract class as a super-powered interface. It defines a series of functions that must be implemented, and it cannot be instantiated directly. It goes a step beyond an interface because it also defines some functions that are already fully implemented. To use an analogy, all electronic devices generally have the same connector to plug into the wall. However, not all electronics have the same purpose. A coffee maker and a DVD player do very different things. The problem, of course, is that the coffee maker and DVD player have different controls for turning power on and off. The coffee maker might have a switch, while the DVD player has a button. We can't implement the toggle Power function in Abstract Electronic Device because many electronics will have different controls, so we need some way to force all subclasses of Abstract Electronic Device to implement this function themselves.

Reedbeta
—
2010-01-29T06:21:41Z —
#19

Alex, what makes you think anyone in this thread needs an explanation of what an abstract class is?