Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-22-2009, 06:28 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Associative Arrays

Will we ever get them?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 01-22-2009, 06:44 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Oooh, yeah. Good idea.
Reply With Quote
  #3  
Old 01-22-2009, 07:21 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
We already have hashes, associative arrays would just be the same thing with different syntax.
Reply With Quote
  #4  
Old 01-22-2009, 08:10 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by WhiteDragon View Post
We already have hashes, associative arrays would just be the same thing with different syntax.
There's a difference between manually scripting things and to have them implemented straight in the engine, though.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 01-22-2009, 08:35 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by xXziroXx View Post
There's a difference between manually scripting things and to have them implemented straight in the engine, though.
I don't really get what you mean.

Hashes are the most common way associative arrays are implemented, so we have associative arrays, just without the conventional syntax one would see in for example in PHP.
Reply With Quote
  #6  
Old 01-22-2009, 08:48 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
At some point you would think people would just want to plob javascript into the engine.
Reply With Quote
  #7  
Old 01-22-2009, 09:02 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Loriel View Post
At some point you would think people would just want to plob javascript into the engine.
Lua please.
Reply With Quote
  #8  
Old 01-22-2009, 09:10 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Crow View Post
Lua please.
Basically a toss-up between one-based arrays and the icky closure semantics, but, yeah, okay, lua.
Reply With Quote
  #9  
Old 01-22-2009, 09:40 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Loriel View Post
Basically a toss-up between one-based arrays and the icky closure semantics, but, yeah, okay, lua.
Well, now that we're at it... Haskell?
Reply With Quote
  #10  
Old 01-22-2009, 09:46 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by WhiteDragon View Post
Well, now that we're at it... Haskell?
I have never felt a stronger urge to throw my chair at some guy through the internet than I am experiencing right now.

I would not even know where to begin to write an associate array in haskell that has any better than O(n) lookups.
Reply With Quote
  #11  
Old 01-22-2009, 11:00 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Loriel View Post
I have never felt a stronger urge to throw my chair at some guy through the internet than I am experiencing right now.

I would not even know where to begin to write an associate array in haskell that has any better than O(n) lookups.
Haskell provides the lookup function which works differently on different data structures.

If you do it on a list like [("a", "1"), ("b", "2"), ("c", "3")] it'll return in O(n).

However, if you do it on a Data.Map which are represented as immutable balanced binary trees, it'll give you a O(log(n)).

Those would be the preferred methods since they both provide a purely functional interface, but you can use hash tables as well with an imperative interface in the IO Monad (with a data HashTable) giving you the O(1).
Reply With Quote
  #12  
Old 01-29-2009, 06:38 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Keep your inferior languages to yourself, obviously Python would be the better choice, its popularity speaks for itself. Utilizing Boost::Python makes it much easier to wrap C++.

Python implements hash tables (associative array) as the 'dict' object. You can specify dict literals using angle brackets.

e = {'key1': 'value1', 'key2': 'value2'}
print(e['key2'])

Python allows you to define many functions called by the interpreter, in this case, e['key2'] = 3 maps to e.__setitem__('key2', 3). You can quite easily take control of item or attribute lookup or other things.

One of the major points in favor of Python is readability, which is obviously important in Graal considering the programming experience and amount of people that would be looking at one script.

Thanks for thread URL Ziro.
__________________

Last edited by Inverness; 01-29-2009 at 06:58 PM..
Reply With Quote
  #13  
Old 01-29-2009, 09:13 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Inverness View Post
Keep your inferior languages to yourself, obviously Python would be the better choice, its popularity speaks for itself. Utilizing Boost::Python makes it much easier to wrap C++.
If we are going down that road, keep your python to yourself and give me C++.

Lua is designed for embedding to begin with and there are plenty of ways to wrap C++ into lua. What makes boost.python superior to third-party lua binding libraries?

Quote:
Python implements hash tables (associative array) as the 'dict' object. You can specify dict literals using angle brackets.

e = {'key1': 'value1', 'key2': 'value2'}
print(e['key2'])

Python allows you to define many functions called by the interpreter, in this case, e['key2'] = 3 maps to e.__setitem__('key2', 3). You can quite easily take control of item or attribute lookup or other things.
lua, and I am pretty sure javascript as well, does these too, for what it is worth, and the associative-array data type is way more integrated into the core languages of lua and javascript as far as I can tell.

Quote:
One of the major points in favor of Python is readability, which is obviously important in Graal considering the programming experience and
amount of people that would be looking at one script.
This is way subjective. Show me how Python is more readable than lua. Lua's syntax is really hard to beat as far as elegance and straightfowardness go.
Reply With Quote
  #14  
Old 01-29-2009, 10:12 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Loriel View Post
If we are going down that road, keep your python to yourself and give me C++.
Why have one when you can have both? It's quite easy to write C/C++ extensions for Python.
Quote:
Originally Posted by Loriel View Post
Lua is designed for embedding to begin with and there are plenty of ways to wrap C++ into lua. What makes boost.python superior to third-party lua binding libraries?
Python is designed for both embedding and extending. Boost::Python is merely the connection between C++ and Python's C API, and is designed to wrap your C++ code without changing it. There's also the fact that it is part of Boost, I'd think the name carries some weight.
Quote:
Originally Posted by Loriel View Post
lua, and I am pretty sure javascript as well, does these too, for what it is worth, and the associative-array data type is way more integrated into the core languages of lua and javascript as far as I can tell.
Python uses the dict (dictionary/associative-array) data type for storing all local, module (global), and object variables. It is a vital part of the language, so naturally it is extremely optimized same with Lua and Javascript.
Quote:
Originally Posted by Loriel View Post
This is way subjective. Show me how Python is more readable than lua. Lua's syntax is really hard to beat as far as elegance and straightfowardness go.
I'd like a specific situation to apply it to.
__________________

Last edited by Inverness; 01-29-2009 at 10:31 PM..
Reply With Quote
  #15  
Old 01-30-2009, 01:47 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Hey, let's find a thread where Inverness DOESN'T start arguing that Python is better than all other languages when he actually hasn't used most of the other ones people are talking about!
Reply With Quote
  #16  
Old 01-30-2009, 02:32 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by WhiteDragon View Post
Hey, let's find a thread where Inverness DOESN'T start arguing that Python is better than all other languages when he actually hasn't used most of the other ones people are talking about!
If you get the impression that I'm saying Python is "better than all other languages" then you have the wrong one.

I'm saying Python is better for Graal's needs, which are: clear and readable syntax, extensive documentation, and rich object-oriented capabilities, among other things.
__________________
Reply With Quote
  #17  
Old 01-30-2009, 03:28 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Inverness View Post
Keep your inferior languages to yourself, obviously Python would be the better choice
Quote:
Originally Posted by Inverness
If you get the impression that I'm saying Python is "better than all other languages" then you have the wrong one.
Either that or I'm illiterate.
Reply With Quote
  #18  
Old 01-30-2009, 03:55 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by WhiteDragon View Post
Either that or I'm illiterate.
I think its the latter.

And I await your response to the second half of my previous post.
__________________
Reply With Quote
  #19  
Old 01-30-2009, 04:05 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Inverness View Post
I'm saying Python is better for Graal's needs, which are: clear and readable syntax, extensive documentation, and rich object-oriented capabilities, among other things.
1. Lua has clear and readable syntax.
2. Lua has extensive documentation.
3. Lua is richly MULTI-paradigm! Check it out, you can be imperative, functional, prototypal, and object-oriented! Amazing!


1. Haskell has concise syntax.
2. Haskell has extensive documentation.
3. Haskell is a functional programming language! Sweet! Check it out, everything is a function!
Reply With Quote
  #20  
Old 01-30-2009, 04:21 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by WhiteDragon View Post
<post>
I see what you did there.

Of course, the better means of comparison would be to solve Graal problems in the language. And I think I'm bored enough to do that.
__________________
Reply With Quote
  #21  
Old 01-30-2009, 08:19 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Inverness View Post
Of course, the better means of comparison would be to solve Graal problems in the language. And I think I'm bored enough to do that.
Ah, let us just hack together a quick Graal clone and cram any scripting language we can get out hand on into it!
Reply With Quote
  #22  
Old 01-30-2009, 09:05 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Loriel View Post
Ah, let us just hack together a quick Graal clone and cram any scripting language we can get out hand on into it!
Already working on it.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.