4 ms·
Seems totally reasonable. The rise of Ruby shows that modern languages should optimize for programmer efficiency first and speed second. Modern scripting langu
by joe_the_user 18y ago
Seems totally reasonable. The rise of Ruby shows that modern languages should optimize for programmer efficiency first and speed second.
Modern scripting languages have several data structures: mostly arrays, hashes and strings. But it is a hassle move data between them.
The next language should only have one, the ordered dictionary.
x = [],
x << "hi" # 1=>"hi",
x["seven"]=6 # 1=>"hi", "seven"=>6,
Etc
- ggchappell 18y agoVery thought-provoking idea. So, here I am designing the Next Big Language. And I'll take your suggestion. Now, first issue: if I say x = "dog", then the value of x is really 1 => 'd', 2 => 'o', 3 => 'g' Right? And despite the fact that this is an O.D., it should print in a string-like way: dog. Now suppose I do x['z'] = (1 => 2, 2 => 3) Now x is 1 => 'd', 2 => 'o', 3 => 'g', 'z' => (1 => 2, 2 => 3) How should it print now? Next issue: If I do y[1] = 'a' and y[3] = 'b', and then y << 'c', what is the value of y? Final issue: Do the above questions really matter? One could argue in the first case that if I want something to print nicely, then I will probably keep it in a "reasonable" form, and not mix data types in odd ways. So it really doesn't matter much how the O.D. I came up with prints. Similarly, in the second case, if I want a collection to work well as a stack or queue, then I am probably not going to use the bracket operator to do strange things with it. So it doesn't matter which of the multiple reasonable options for the behavior of << is chosen. Or maybe it does matter?
- joe_the_user 18y agoHey, Someone took it seriously! I would assume that strings and "ordinary" O.D. would differ in their object type: each would inherit from an abstract O.D. and each would have a different print/display function (you could have a "hidden" variable specifying this function if you wished to keep in all concrete). If I do y[1] = 'a' and y[3] = 'b', and then y << 'c', what is the value of y? probably y = { 1=>'a', 3=>'b', 4=>'c'}, though like any good OO/metaprogramming language, "<<" would be an overidable function. "Do the above questions really matter?" I am arguing for the next language and by that token, I haven't answered all the questions this raises. I think old languages like lisp and new languages like Ruby prove that new languages can unleash new possibilities, even more than fifty years after the original computer languages were created. Thanks for your detailed reply, seriously...
- lacker 18y agoJust to pose the counter argument, is it that hard to move data between hashes and lists? In reasonable languages it is at most a single function call. Javascript has eliminated many differences between arrays and hashes (objects) but this leads to many bugs. For example, you have a third-party library that adds a .toString function on every object. But you also have code that iterates over the keys in an array, and now that iteration code hits a "toString" key instead of just the array indices you expect. Admittedly you could blame this on the object-hash identification rather than the array-hash identification....
- joe_the_user 18y ago1) As others have pointed out, creating an ordered hash out of an array and unordered hashed takes doing. Conversion between (ordered) arrays and unordered hashes doesn't solve this problem. 2) By my previous reasoning, I think identifying objects and hashes is also the-way-to-go, once you can figure out for to do it correctly. Javascript clearly has some problems. One possible solution is having different functions to iterate different types of keys, so objects/members could be added without being seen by data iterators. Of course, I don't claim to have put all this is into the codified form it needs in order to form the basis of a language. I'll do that if and when I ever create a new language.