Pages: 1 2 3 4 5 »
  Print  
Author Topic: Pride  (Read 7892 times)
Offline (Male) Josh @ Dreamland
Posted on: March 02, 2010, 11:21:36 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
I'm so proud of this little community for not hanging on security considerations when looking to the efficiency ones. :3

Good news. Here's the result of parsing this code:

Code: [Select]
#include <map>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <iostream>

#include <windows.h>

Quote
No error.
Parse time: 1509 milliseconds
++++++++++++++++++++++++++++++++++++++++++++++++

Macros (12684) [+ ]
Variables [+ ]
>>d
Define: CreateWindow
  #define CreateWindow CreateWindowA
>>d
Define: CreateWindowA
  #define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k) CreateWindowExA(0,a,b,c,d,e,f,g,h,i,j,k)
>>d
Define: CreateWindowExA
  CreateWindowExA:  Function with 12 parameters, returning HWND__  Dereference path: (params = 786444)*</group>
>>

Since Windows includes everything, and I do mean everything, that anyone could ever need to make a game, there's really no point in assuming the parser needs further work. The parser no longer requires lists of functions and types.

Oh, and, if you noticed the odd parameter count when I asked it to define CWExA, don't worry, it stores that count in a jumbled short. It used to dissect the short and display the actual parameter bounds, but the code that does so got lost in one SVN commit or another.


Since you've all proven to be concerned with efficiency, here are some related tidbits of considerations:

1) The most pressing efficiency loss when treating EDL more like GML than C relates to the switch () statement. Those of you who are particularly well-informed with either GM or ENIGMA know that both engines treat a switch like a less-ugly chain of if()s. The complexity is the same; an == check for each label. A consideration, however, is to make a small, close-to-perfect hash function. Basically, this will allow for var case labels using some template magic. GM People: Stop reading after this next sentence.

I believe this can be done in O(1), maybe with two or three checks a number. Basically, a hash function will be used on the input to each case label, assuming these are constant. (Thanks to the C parser, checking can be done on this when they are not literals [such as 3.14 or "some string"]. How great is that?) Basically, the hash will take the sum of first and last byte of any strings along with its length, do some round() tricks on floats, and leave ints alone (C++ doesn't allow switching anything but int, and doesn't allow case labels of anything but constant int). Now, the thought of course is, what if two strings produce the same hash? That's why one check is done at the case label. You'll see the same idea being employed in hash maps. I owe it to Luda that I was enlightened to it. If anyone has a better idea, of course, by all means...

2) The next most annoying thing is compatibility garbage related to simple functions, like draw_primitive_begin(). From my reckonings, GM uses DirectX's idea of a Vertex Buffer Object. That's not always an option for GL... R3 and lower use glBegin(). This raises a compatibility issue when drawing two at once (this is allowed in GML, but not in GL). The reason I assume GM uses VBO is that it can in fact keep two separate primitives going at once. Long, long ago I decided to deal with the problem by allowing a statically allocated array to be used to hold the points for quick iteration... I made it static because I didn't want the overhead each function call to make sure we hadn't overflown anything and needed more space. However, this meant either an annoying amount of memory overhead, or an equally or more annoying setting to allow the maximum number of points to be set. (I thought 360 would be reasonable for most applications, but...) Anyway, in retrospect, it was an awful idea (good thing it was #if'd out by default). I think the plan should be to try for VBO, but if it doesn't exist, just offer glBegin(), no buffering. (This would break some compatibility for people with Intel cards barely meeting stone-age GL specifications). The good news is, no one who had any decent coding practice would notice the break.

I figured I'd get your opinions on those little things as well. If/when there is a DirectX port, that won't really be a concern (the nice thing is that with DirectX, we can make the same decisions as Yoyo did, good or bad, and no one can complain. Too bad I'm still using GL).


I'd throw in a third thing, but that's probably enough to swallow for one post. Those who would like to put their two cents in on security issues can do so in the previous thread. I guess we'll just keep doing this until I have a public opinion on the decisions that haunted me in early development stages (I want to get it all right this time. Or at least most of it).


While you people decide that, I'll be replacing lists of types and functions in the GML formatter with the new lookup calls. (Also, I think I need to make sure "using namespace" works in the global scope. )
« Last Edit: March 02, 2010, 11:26:36 PM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: March 02, 2010, 11:36:56 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Yeah, using namespace std works. I asked it to print the using scope... it took five seconds or so...
Asking it to print everything it had just parsed took 36 seconds. Heh...
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Grundoko
Reply #2 Posted on: March 03, 2010, 11:13:24 AM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
I hate to be a nag, and I know release dates are hard to give, especially for a programmer, but in what general time period do you expect R4 to be released?
Logged
Post made March 03, 2010, 12:43:37 PM was deleted at the author's request.
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: March 03, 2010, 01:49:58 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
I do love my parentheses (and messing with you). Really, they're mostly for thoughts that might confuse the rest of the sentence; I separated them because they are confusing or because they are pieces of info that those who read them should probably know.

Grundoko:

Since if I even hint it's toward the end of the month, you'll guess what day it is, I may as well tell you I want it out on April Fool's day. I might release some things for testing around the 15th or 20th.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Grundoko
Reply #5 Posted on: March 03, 2010, 04:55:03 PM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
April 11th sounds like a good release date :p
Would be a good birthday present.
Logged
Offline (Male) Josh @ Dreamland
Reply #6 Posted on: March 03, 2010, 06:20:22 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
*shrug*

Oh, and Fede: Many people use primitives for circle-related effects. Think ripples or rings. Especially awesome with surfaces.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) freezway
Reply #7 Posted on: March 03, 2010, 08:11:56 PM

Member
Joined: Dec 2009
Posts: 220

View Profile
I'll defiantly test!
Logged
if you drop a cat with buttered toast strapped to its back, which side lands down?
joshdreamland: our languages are based on the idea that it's going to end up FUBAR
/kick retep998
Offline (Unknown gender) Micah
Reply #8 Posted on: March 03, 2010, 08:59:01 PM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
What will you be defiant about?
Logged
Offline (Male) retep998
Reply #9 Posted on: March 03, 2010, 09:30:01 PM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Hell yeah I'll be testing this piece of pure awesomeness.
As soon as Enigma is working with everything I need, I am ditching game maker and the gmc.
Today I realized that the gmc really is just full of flaming nitpicking idiot noobs.
Even the staff were joining in on the flaming.
It was 5 pages of pure crap.
People shouting their opinions and then attacking anyone who said the slightest thing different from them.
I really hope to have a better community here.
« Last Edit: March 03, 2010, 09:34:21 PM by retep998 » Logged
Offline (Unknown gender) Micah
Reply #10 Posted on: March 04, 2010, 12:48:13 AM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
The signal-to-noise ratio on a forum so large is bound to be much smaller. As Enigma gets more popular, these forums will devolve beyond what they already are to become just as bad.

In fact, in some ways, the GMC is preferable to these forums.
« Last Edit: March 04, 2010, 12:52:28 AM by miky » Logged
Offline (Unknown gender) The 11th plague of Egypt
Reply #11 Posted on: March 04, 2010, 10:44:15 AM
Member
Joined: Dec 2009
Posts: 284

View Profile
There are many people in the GMC who helped me solving my coding problems. Kudos to them.

Back to us, will we be able to make games with R4, or just testing?

And what about the frontend? Is it usable?
Logged
Offline (Male) Rusky
Reply #12 Posted on: March 04, 2010, 11:11:42 AM

Resident Troll
Joined: Feb 2008
Posts: 960
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
You could make games with R3, sort of.
The frontend is LGM. It's been usable far longer than Enigma.
Logged
Offline (Male) RetroX
Reply #13 Posted on: March 04, 2010, 06:09:54 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
With that hash, wouldn't "hello" and "herro" be considered two identical strings?  What does it check besides the length and first and last characters?
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #14 Posted on: March 04, 2010, 06:23:53 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Retro and other concerned individuals:

In the case that strings are involved, it'd be a hijacked switch. What I was hinting at is basically this (assume that the hash of "hello" and "herro" is 143):

Code: [Select]
case 143:
  if (enigma::sval == "hello") { ... }
  if (enigma::sval == "herro") { ... }

Note, however, a couple things:
1) Ideally, the hash function would be played with a little bit to try to achieve the fewest collisions possible
2) An actual hijacked switched statement would look more like this:
 
Code: [Select]
switch hash()
    case hash: if (...) goto ...
    case hash: if (...) goto ...
    break;
3) The most ideal option, but perhaps a more difficult one, is to do the hash map myself, storing pointers to goto labels in my own array (this is legal in C)
This would look like this:
goto enigma::hashmap_switch_1[sval];
Where operator[] computes the hash, starts raiding pre-defined buckets for the correct label, then returns it for jump. This is how switch() actually works, and how I hope to do it.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: 1 2 3 4 5 »
  Print