Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How can I force variables check?

Author
Message
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 01:04
Hello,

I wish to force variables checking, so the compiler will check every variable.
I search something like strict used to oblige the compiler to accept variables only if they have been declared.

Thank you!

--Alessandro
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 01:12
Are you working in Tier1 or Tier2?

Cheers,
Ancient Lady
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 01:13
Sorry, I forgot to mention. Tier-1 (basic).

--Alessandro
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 01:37
Then, nope, there is no way to enforce variables being declared before using them.

Sorry, even the original basic (way back when) was meant to be simple and easy to use and not force the poor students to worry about such basic concepts.

Cheers,
Ancient Lady
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jun 2012 01:37
Let me guess - fat finger syndrome?

The other day I spent hours looking for a bug only to find it was the use of a mis-spelt constant name - I think in my case it was Landcape


On the subject of compiler options, I'd like conditional compilation so I can miss out all my debug code.

Yeah, I know Tier 2 does it, but I can see no reason why Tier 1 can't, it's technically no different from #constant or #include.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 01:42
@ale870 - I agree that strict typing would be a good idea. Quite a lot of errors I see reported are a result of not declaring variable types in advance.

Suggest moving to C/C++ or Pascal.

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 01:47
I think it could be an option to be activated via code (like Blitzmax and other languages already do) or via IDE.

I tried to use AppGameKit via Lazarus pascal, but I noticed that the final game is a little bit faster using Basic and slower using Pascal.

C++ ? No thanks. I love C but I hate C++.

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 02:15
Did you do a release or debug build? I'd expect the Pascal release version to be faster.

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 11:25
I tried both obviously.
The bottle neck seems in AppGameKit self. In fact it seems that there is a "delay" during some AppGameKit functions call.
But consider I didn't make deep tests. I tried a couple of demos (and a couple of programs made by me) and I got those results.

Generally speaking, consider that Lazarus Pascal is not so FAAST. In fact in Delphi, in order to make the code so fast (almost fast as native C code) they worked directly in assembler (this is the reason why delphi cannot be successfully converted for linux or Mac).

Only the most recent delphi versions start to work in mac also.

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 11:32
Delphi is just as fast as C - it shares the same back-end as the C++ compiler. It may be the DLL calls which slow things down. We need a static library!

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 11:38
Delphi is not fast as C, is fast as C++ (which is slower than C).

Yes, probably you are right, we need a static library in order to get the things faster!

One question: I'm not an expert in Free PAscal: so do you know if I can an application using FP and AppGameKit for android?

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 14:14
Quote: "Delphi is not fast as C, is fast as C++ (which is slower than C)."


Totally disagree! You can't generalise like that. A vast amount depends on the kind of project.

FPC is getting close to reasonable Android performance, but not quite there yet. I've been experimenting with RemObjects' Oxygene for Java compiler, which works to some extent, but is fiddly and requires a lot of changes to the Pascal code-base, which is not what we really want. I'll keep checking on the FPC front!

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 14:16
ok, thank you!
(I will submit my wishlist to AppGameKit admins

--Alessandro
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jun 2012 14:37
Quote: "You can't generalise like that. A vast amount depends on the kind of project."

I agree.

It also depends a lot on the efficiency of the compiler and how well the source translates to the working requirements of the target - data types used, number formats etc.

The more work a compiler does to get the source to the native code of the target, the less work the resulting code will have to do when it runs.

Plus a lot of languages were designed for a specific type of task, Forth for radio telescopes, Fortran for maths, C for Operating system design etc. So it makes sense that the compiler would be better with code dealing with those subjects.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 15:10
Absolutely. Modern compilers produce highly efficient code for their target processor, in most cases far better than could do by hand-coded assembler, because they can handle pipe-lining, branch prediction etc in a highly-optimised way.

With systems like AppGameKit, a lot depends upon the efficiency of the OpenGL core, and that's pretty-much out of our control.

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 15:35
I don't want to arise a flame but, even if you said right matters, you have to consider that c++ takes some "decisions" at runtime. This is the reason why c++ is a little bit slower than c. (same for delphi).

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 15:48
For example?

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 16:11
BENCHMARK:

http://unthought.net/c++/c_vs_c++.html

http://synflood.at/blog/index.php?/archives/732-Performance-of-C-vs.-C++.html


RUNTIME:

http://en.wikipedia.org/wiki/C%2B%2B

See: Dynamic polymorphism

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr315.htm


http://en.allexperts.com/q/C-1040/Difference-Overriding-Overloading.htm

http://www.codeproject.com/Questions/141657/run-time-polymorphism-VS-compile-time-polymorphism

<< Now, a short answer on "What is 'that' resolved at runtime ? (overriding)".

After some thinking: overriding itself is done during compile time as well: a virtual function in two different classes (relative throw inheritance) is called indirectly, through Virtual Method Table (VMT).
A caller may work with a variable which is known during compile time as a variable of some parent class, but during run time the actual class instance is one of derived class (which is fine due to inheritance). If not VMT (not virtual function), the called method would be the one of the compile-time class, but due to VMT a virtual method called during run-time will be the one of actual run-time reference.

So, while all the methods (virtual or not) are known during compile time, which exactly is called are known only run-time -- late binding. For a final note: planning object-oriented classes needs understanding and planning. Formally making methods virtual per se may introduce no late binding or polymorphism. Again, I recommend reading; see the references below. >>

==============================

Generally speaking, higher level languages (and C++ is "higher" than C), take a language near to our "natural" / human understanding. But if a language is "better" (easier or more "expressive") for humans, it takes "more time" to be resolved in a "machine way".

You must think that only machine code is the fastest language. So every language higher than machine code (not Assembler, but pure machine code) involve more "code" to be "resolved". Sometimes this process can be related to code-size. A program in machine code is smaller than the same C code, and C code is smaller than C++, which is smaller than Pascal, etc...

Obviously, this is a GENERAL discussion since, as you said, we need to consider compiler efficiency, intermediate code optimizations, programmer skills (you can write good code to work with a language), etc...

This discussion is a never-ending discussions (you can find a ton of these over the web).
As I said, I don't want to arise a flame, and I don't want to say a language is BETTER than another one (some people manage programming languages like a religion!).

--Alessandro
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 16:40
Hmmmm, object oriented assembler would be something very strange (not possible, but strange).

Many years back, I did a lot of graphics programming at the assembly language level because that was the only way to get the speed needed on the platforms (PDP-11/03 w/RTS-11 OS, IBM PC and IBM AT w/DOS).

Yup, the closer you get to really 'being' the machine, the faster it runs.

Fortunately, we now have access to much more powerful and faster machines (go Pentiums! oops, sorry, yeah quad cores!), so we have the luxury of using higher level languages.

Cheers,
Ancient Lady
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 16:46
Quote: "Hmmmm, object oriented assembler would be something very strange (not possible, but strange)."


OOP in assembler? LOL sounds crazy!!!

Quote: " Many years back, I did a lot of graphics programming at the assembly language level because that was the only way to get the speed needed on the platforms (PDP-11/03 w/RTS-11 OS, IBM PC and IBM AT w/DOS).

Yup, the closer you get to really 'being' the machine, the faster it runs.

"


Better for MACHINE -> BAD for Humans
GOOD for HUMANS -> BAD for Machines !!!!!!

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 16:50
This doesn't compare two things that are the same.

Visual Studio uses exactly the same compiler to output code from C as it does from C++.

Why is C/C++ code smaller than Pascal? Where does that idea come from? It just isn't true!

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 17:08
Quote: "This doesn't compare two things that are the same."


Sorry, which things?

Quote: "
Visual Studio uses exactly the same compiler to output code from C as it does from C++.

Why is C/C++ code smaller than Pascal? Where does that idea come from? It just isn't true!"


C and C++ compilers cannot be the same, think to this! C and C++ are DIFFERENT (even if they have similar names!).
Even Pascal and Delphi are DIFFERENT (even if some people call Delphi as "object pascal").

Generally speaking, C code is smaller than other languages due to the "low-level" approach. Low level programming means FUNCTIONS, algorithms, etc... more near to the machine code. It means there is lesses "unnecessary" code.

When a language is more "human-friendly" it means it contains some "infrastructures" not required to the computer. It means those "infrastructures" must be managed, and take space and time (computation time).

Consider that, for example, a computer does not work with objects (machine code is not OOP). It means when you use OOP you insert a "layer" (infrastructure) between you and your computer. That code takes space and computation time.
In fact the fastest compiled languages are, generally speaking, procedural languages, since OOP is not so COMPUTER-FRIENDLY.

Machine code is an interpreted procedural code. Don't forget this fact.
Computer likes only that code.

If I speak italian and you speak german (for example) we need to use english to communicate. English is a layer, and takes more time to be used than if you could use your native language (same for me).

A parser, a compiler, need to insert "funky" code to convert "your language" (e.g. C language) in computer language (machine code).

As I said, this is a generic discussion. I know you can find some exceptions, but try to take the abstract nature of this discussion.

For example, even if, in general, BASIC is higher than Pascal, I use PureBasic which is incredibly fast (maybe faster than some Pascal or C++ or even C compilers).

--Alessandro
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 17:21
C++ is an extension of C. All of the syntax and commands that you use in C are usable in C++.

ale870, I love your analogy of human languages for comparing complexity levels. It is so correct.

This forum gets sooooo excited when someone compares or disparages one language over another.

Cheers,
Ancient Lady
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 17:25
Quote: "This forum gets sooooo excited when someone compares or disparages one language over another."


We need to walk carefully, since the flames are around the corner!

I'm not a fan of this language or of that one. I'm happy that so many languages exist, since there is a good language for any good job I need to do!!

--Alessandro
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 17:26 Edited at: 1st Jun 2012 17:27
Quote: "C++ is an extension of C. All of the syntax and commands that you use in C are usable in C++."


It means C++ is compatible with C, not it is an extension.

Many BASIC languages are so similar, but they are different! Thay are, sometimes, compatible.

--Alessandro
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jun 2012 17:41
Quote: "Even Pascal and Delphi are DIFFERENT (even if some people call Delphi as "object pascal")."

Some of those people being the ones who created Delphi

Quote: "Because Delphi is trademarked, compatible compilers continued using the name Object Pascal."

http://en.wikipedia.org/wiki/Object_Pascal#Versions
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 18:13
C++ is an extension of C. That's why it's called C++. Read the history of the language.

Only recently has Object Pascal been renamed to Delphi. It's still, by language definition, Object Pascal. Delphi was the IDE (the best ever, and still) but Embarcadero chose to change the language name. It's still Pascal!

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 1st Jun 2012 18:28
Quote: "Only recently has Object Pascal been renamed to Delphi. It's still, by language definition, Object Pascal. Delphi was the IDE (the best ever, and still) but Embarcadero chose to change the language name. It's still Pascal!"


Maybe you are too young, but Delphi was born with Borland. I used it since version 1.0, and in the company where I work for we still use XE2.

Delphi 1.0 (about 1995) was the first real competitor of Visual Basic (not .NET, but VB6!!).

Delphi is the complete environment. Delphi is different from Object Pascal, since Delphi compiles directly in true assembler (this is the reason it was so difficult to be ported in other platforms or other CPU).
They tried to make Kylix, but failed (they stopped to Kylix 3).

About Delphi, see Wikipedia: http://en.wikipedia.org/wiki/Borland_Delphi

<< Delphi (later known as Delphi 1) was released in 1995 for the 16-bit Windows 3.1, and was an early example of what came to be known as Rapid Application Development (RAD) tools. Delphi evolved from Borland's "Turbo Pascal for Windows", itself an evolution with Windows support from Borland's Turbo Pascal and Borland Pascal, very fast 16-bit native-code MS-DOS compilers with their own sophisticated integrated development environment (IDE) and textual user interface toolkit for DOS (Turbo Vision). >>

Quote: "C++ is an extension of C. That's why it's called C++. Read the history of the language."


No, you are wrong. C++ was born as an improvement of C. They have some semantic points in common, but the real nature of C++ is REALLY different.

From wikipedia: http://en.wikipedia.org/wiki/C%2B%2B

<< The language began as enhancements to C, first adding classes, then virtual functions, operator overloading, multiple inheritance, templates, and exception handling among other features. After years of development, the C++ programming language standard was ratified in 1998 as ISO/IEC 14882:1998. The standard was amended by the 2003 technical corrigendum, ISO/IEC 14882:2003. The current standard extending C++ with new features was ratified and published by ISO in September 2011 as ISO/IEC 14882:2011 (informally known as C++11).[9] >>

As you can read there, it is not an extension, but an enhancement. Then it gained an independent "life".

An "extension" is something that you can use in a system to adding features to the original system. Maybe an extension is a DLL, or you can call "extensions" the proprietary libraries (from ANSI C) that Microsoft introduced in C compiler to let it manage Ms Windows operating system (files system, kernel, forms, etc...).

--Alessandro
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 19:55
(very small voice)wow! such an amazing bunch of posts from such a simple statement - "Delphi is just as fast as C".

I loved working with Borland Turbo Pascal. It was the first computer language I ever bought for my own computer back in the mid 80's.

My first language was Fortran, followed by MIX assembler, than Pascal (all while in college). Pascal was everything I was looking for that was missing in Fortran. And since then, many more languages have followed.

Quote: "Maybe you are too young"


I'm not one hundred percent positive, but I think JimHawkins and I are a couple of the oldest programmers on (in?) this forum.

Cheers,
Ancient Lady
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jun 2012 20:23 Edited at: 1st Jun 2012 20:23
Look out, you're gonna' start age war next

Zimmers at the ready!


P.S I don't know how international Zimmers are, so...

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2012 20:41
No, No. Make Love Not War! (oops, really dating myself.)

I may be ** years old chronologically, but my friends and family will always say that I act like about 20 (sometimes 16). I don't know if I'm being complimented or insulted. But, I try to enjoy life.

Cheers,
Ancient Lady
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 21:38 Edited at: 1st Jun 2012 21:43
I love the idea that I'm too young. Bless.

Just for the record - I will be 70 on September 26th, so get the cards ready!

I've used Delphi, and a shed-load of other things, since Delphi 1. My main 13-year project is in Delphi 7. For new stuff I use XE2.

Delphi does NOT compile into assembler. Assembler is a human readable language. Delphi, along with just about every other compiler, compiles into very fast native machine code.

The reason Kylix was dropped was nothing to do with compilers or code generation - it was because nobody, including me, could give a stuff about Linux unless they were writing server-side software.

I won't argue about whether C++ is an extension or not, and certainly not about whether it's an improvement! If I'm going to stare at code all day I prefer it to be as clean and elegant as possible. I find statements like:



rather nasty to look at!

When I wrote Music Machine for the Pearson group I had to mix up to 24 waveforms in real time with pitch-shifting and bending on what was then pretty poor PC hardware. The fastest (ie fastest output code) compiler I could find was the Oberon-2 compiler from a Russian company called XDS. The programmers had all worked on Soyus, and when I met them in London I discovered that they really knew how to party, as well as how to get the maximum out of a processor!

So I learned Oberon-2, and Music Machine was almost entirely written in it. It still runs perfectly on a 64-bit W7 machine.

So you can put any errors of mine down to Altzheimers rather than youth. Those of us who have been hacking out this stuff for many decades do just occasionally have a few rather worn tee-shirts to pass on!

Love to all.

-- Jim
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jun 2012 21:48
Incidentally, love the Zimmer Frame.

I'm just opening mine. It has a screw-top and the word "Merlot" on the label.

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 2nd Jun 2012 00:04
... ok ok, but my age is better than yours

Quote: "Delphi does NOT compile into assembler. Assembler is a human readable language"


Yes, sorry my mistake, I wanted to say machine language.

Kylix was an example, the real problem in delphi machine code was porting delphi to other cpu and more operating systems.



A question for you (ok another flame is arriving!!!):
do you know Game Maker Studio (from yoyo): did you try it? Is it good?
Pro and cons? It could be a serious competitor for AGK.

Have you tried it (it means... did you spend 99 bucks to buy and test it)?

--Alessandro
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd Jun 2012 12:43 Edited at: 2nd Jun 2012 12:52
Just about all compilers output machine code. Otherwise, what's the point?

Embarcadero has Arm processor back-end support on the road-map - meanwhile there's Oxygene for Java, which compiles Delphi source into Java.

I looked at Game Maker Studio this morning. It is rather expensive. For your $99 you get the IDE and Mac OS X and Windows output. For HTML5 it's another $99 and for Android and iOS it's $199 each!

So for full cross platform it's nearly $600.

The GML language is a kind of C variant without strong typing:
http://en.wikipedia.org/wiki/Game_Maker_Language

It appears to have all the worst aspects of C (for example, = can be both a boolean test and an assigment - a language flaw that has eaten all C programmers over the years)

It only has two data types - float and string!!!

Bizarrely, anything > 0.5 evaluates to TRUE and less than 0.5 evaluates to FALSE. Bonkers!!

On the plus side it claims to be able to do 3D, and has a drag&drop visual designer, which AppGameKit could seriously do with!

As far as I can see, the only reasonably-priced contender with AppGameKit is Monkey, which I mostly like quite a lot. The language is a cross between a simplified Java and Blitz Basic. Like Dark Basic, it has its origins on the Amiga, which I like for sentimental reasons.

In general I'd say that best strategy is to design your game or application in a design document before you start coding, perhaps even write the outline in pseudo-code, keep your assets well-separated from the actual code, and don't make last-minute arbitrary decisions. If you use pseudo-code or diagrams (which I use a lot) you can then choose the best tool to put the flesh on the bones.

Another technique which could be stressed more for new programmers is the use of "stub" functions, and playing "paper computer." Stub functions start off by merely reporting they've been called to check the logic - then their actually muscle is added. Paper computer means, get a bit of paper, walk through the logic (maybe with calculator in hand) and write down what you expect.

After all these years I think programming is a bit like decorating a room: the better the preparations, the better the better the paint-job!

-- Jim
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 2nd Jun 2012 12:55
I'm no mod, but I'd say start a new topic. This one has drifted far enough from the OP.
polomint
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location: Lancashire, United Kingdom
Posted: 2nd Jun 2012 13:46
I agree with AgentSam, I'd like to hear more from Jim, it's fascinating listening to someone who has been there, done that, with years of experience..

Blackberry App Development & ZX Spectrum Game Development.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd Jun 2012 14:43
Sorry, guys. I was only answering some points and questions raised!

-- Jim
ale870
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location:
Posted: 2nd Jun 2012 19:22
This is a never ending discussion (you can find tons of discussions like this one in the web).

I bought GameMaker Studio basic version 99$ in order to check it.
If you are interested I can post some personal comments on it (if admins agree with this: talking about the competitors).

--Alessandro

Login to post a reply

Server time is: 2024-05-02 16:53:12
Your offset time is: 2024-05-02 16:53:12