Author Topic: New language  (Read 41887 times)

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: New language
« Reply #30 on: June 06, 2013, 03:52:54 AM »
Just FYI- Python really is a utility language. Good for hobby projects, but it has pretty low performance compared to something like lua, which is also elegant in very similar ways. Lua is also industry standard for games, so... I'd recommend checking it out.

Good for hobby projects like YouTube and EVE Online  :P (sorry, couldn't resist)
Everyone you will ever meet knows something you don't.
 - Bill Nye

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #31 on: June 06, 2013, 04:53:10 AM »
Just FYI- Python really is a utility language. Good for hobby projects, but it has pretty low performance compared to something like lua, which is also elegant in very similar ways. Lua is also industry standard for games, so... I'd recommend checking it out.

Good for hobby projects like YouTube and EVE Online  :P (sorry, couldn't resist)

It's a good point. Both of their code-bases were built before Lua became the informal standard.

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: New language
« Reply #32 on: June 06, 2013, 05:11:18 AM »
I will second Python.  It's very easy to learn, quick to code, and has some interesting differences from other languages.  I like that it requires precision but without a lot of extraneous typing (for example, the indentation of loops and other code blocks must be consistent, but you don't need lots of "{}" symbols that you'll lose track of).

If compilation errors due to mismatched braces are your biggest problem, then of course, languages that don't have braces are an obvious choice.
Fame (Untitled) - my game. Everything is a roguelike.

Quendus

  • Rogueliker
  • ***
  • Posts: 447
  • Karma: +0/-0
  • $@ \in \{1,W\} \times \{1,H\}$
    • View Profile
    • Klein Roguelikes
Re: New language
« Reply #33 on: June 06, 2013, 11:13:30 AM »
As is a text editor that matches braces.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #34 on: June 08, 2013, 02:41:23 PM »
Just FYI- Python really is a utility language. Good for hobby projects, but it has pretty low performance compared to something like lua, which is also elegant in very similar ways. Lua is also industry standard for games, so... I'd recommend checking it out.
I find lua syntax ugly and way too verbose for a scripting language. And the language itself doesn't have some kind of standard 'ease of use' library. Each lua-based project invents it's own 'classes' and other infrastructure.
As for lua speed... Yes, in pure number crunching lua is good. But if you want to make some heavy computations, scripting language is hardly your choice. Other than calculations, when we use classes and other complex things, it's speed is more or less on par with python. lua's c/c++ interface is far from being convenient and far from being fast.
IMO lua is more suitable as some kind of macro/automation/plugin kind of language then something primary.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #35 on: June 09, 2013, 03:41:53 AM »
Hm. What exactly you don't like in C++11?

It's too not-C++.

And I don't know what lambda is.
Actually they are more closures then lambdas. And as far as I know, C++ is the only language
where you can control closed variables mode - by copy vs by reference.

And still. What features of new standard are making C++ into not-C++?
In any case, no one forces you to use features that you don't like for one reason or another.

miki151

  • Rogueliker
  • ***
  • Posts: 264
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #36 on: June 09, 2013, 06:23:55 AM »
No, they are lambdas. Closures (from named functions) have always been possible in C++ without extending the language.
KeeperRL, Dungeon Keeper in roguelike style:
http://keeperrl.com

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: New language
« Reply #37 on: June 09, 2013, 06:33:40 AM »
Python can be it. I've been reading source code of Blender's python scripts and it doesn't look hopeless. It's quite easy to understand it without knowing a lot about the language.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #38 on: June 10, 2013, 04:03:52 AM »
No, they are lambdas. Closures (from named functions) have always been possible in C++ without extending the language.
Nope, they are closures, as they can close local variables:
Code: [Select]
int x=0;
std::vector<int> v;
fill(v);
std::for_each(v.begin(),v.end(),[&](int v){x+=v;});
Of course if they don't close any variables, they work as lambdas :)
Closures weren't possible in C++ prior to C++11 in any form.

Krice: python is a nice language to learn, yes. And it has vast number of libraries for most of your needs.
You can also peek at falcon (www.falconpl.org)

miki151

  • Rogueliker
  • ***
  • Posts: 264
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #39 on: June 10, 2013, 06:00:28 AM »
Below is a closure that's not a lambda, and this code worked before C++11. (I'll spare you the implementation of class Closure :)).

void fun1(int x, int y) { cout << x + y; }

void fun2(Closure<int> c) {
  c(5);
}

int main() {
  int x;
  cin >> x;
  fun2(new Closure(fun1, x));
}
KeeperRL, Dungeon Keeper in roguelike style:
http://keeperrl.com

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #40 on: June 10, 2013, 02:54:56 PM »
Below is a closure that's not a lambda, and this code worked before C++11. (I'll spare you the implementation of class Closure :)).

void fun1(int x, int y) { cout << x + y; }

void fun2(Closure<int> c) {
  c(5);
}

int main() {
  int x;
  cin >> x;
  fun2(new Closure(fun1, x));
}
first of all, this code is incorrect :)
and second - closure is syntactic sugar that saves you a lot of typing.
manual implementation of syntactic sugar feature equivalent to this feature doesn't make it into this feature :)

miki151

  • Rogueliker
  • ***
  • Posts: 264
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #41 on: June 10, 2013, 07:02:37 PM »
Whatever, just making clear what is a closure and what is a lambda.
KeeperRL, Dungeon Keeper in roguelike style:
http://keeperrl.com

eclectocrat

  • Rogueliker
  • ***
  • Posts: 81
  • Karma: +0/-0
  • Most of your personality is unconscious.
    • View Profile
    • Mysterious Castle
    • Email
Re: New language
« Reply #42 on: June 10, 2013, 08:23:13 PM »
Just FYI- Python really is a utility language. Good for hobby projects, but it has pretty low performance compared to something like lua, which is also elegant in very similar ways. Lua is also industry standard for games, so... I'd recommend checking it out.
I find lua syntax ugly and way too verbose for a scripting language. And the language itself doesn't have some kind of standard 'ease of use' library. Each lua-based project invents it's own 'classes' and other infrastructure.
As for lua speed... Yes, in pure number crunching lua is good. But if you want to make some heavy computations, scripting language is hardly your choice. Other than calculations, when we use classes and other complex things, it's speed is more or less on par with python. lua's c/c++ interface is far from being convenient and far from being fast.
IMO lua is more suitable as some kind of macro/automation/plugin kind of language then something primary.

Syntax is a stylistic choice, and Python has second to none library support (the main reason it is used), but the rest of what you say is pretty bunk.

Lua really is a lot faster than Python, I know because I measured, and had to ditch Python after it became long in the tooth on certain computations running on an iPod touch. Another, less noted performance criteria, Lua fits with all of it's libraries in about 250kb, Python is comparatively enormous. This makes a difference on mobile devices.

Lua's C interface is also very fast (where did you get the impression it is slow? There is an overhead, but every scripting language that imports native functions has to incur a context switch cost), but if it's not fast enough for you then LuaJIT's FFI makes it insanely fast and as easy as writing C code in your Lua file. The C API is also simple enough to make a convenient wrapper in a single header file, thus removing error prone and aften buggy tools from the equation.

I don't really care what language anyone uses, but I needed to post this in case someone read your post and got the wrong idea.

PS> Have you tried to use Python's native bindings? If you think that Lua's C interface is inconvenient, then what adjective is reserved for Python?

PPS> I love Python, nothing against it, but lets call a spade a spade.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #43 on: June 11, 2013, 03:22:57 AM »
Lua really is a lot faster than Python, I know because I measured, and had to ditch Python after it became long in the tooth on certain computations running on an iPod touch. Another, less noted performance criteria, Lua fits with all of it's libraries in about 250kb, Python is comparatively enormous. This makes a difference on mobile devices.
Keyword is 'computations'. As I said - lua is good at numbercrunching. Definitely better then python.
But lua have it's own weak points, performancewise. For example iteration over table.
It is slower then the one in python. Call of closures is also slower, because of the way closures done in lua.
IMO table is overall weakest point in lua. 1 based array index? wtf?
Assign nil to erase item? wtf?

Lua's C interface is also very fast (where did you get the impression it is slow?
There is one thing in C interface that makes things a little ugly.
If you inject your object along with some methods into lua, in each
method wrapper you have to check type of 'self' to match your object's type.
Because there is no such thing as method, there are only functions,
and they can be called with any table as 'self' value.

Quote
PS> Have you tried to use Python's native bindings? If you think that Lua's C interface is inconvenient, then what adjective is reserved for Python?
I haven't used python for embedding, only as standalone language.
I find making C modules for python easy.

IMO if you care SO MUCH about performance of scripting language, you probably using it for wrong thing.
I know about performance of lua and python because I work on my own scripting programming language,
and I have to compare performance of various basic things, to make sure I'm doing everything right.

P.S. performance is important, but it's not the most important thing for scripting language. The most important, IMO, is ease of use. This is where python is far better then lua. There are  several IDE's for python, but I haven't seen at least one complete for lua.
« Last Edit: June 11, 2013, 03:44:24 AM by Xecutor »

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: New language
« Reply #44 on: June 11, 2013, 07:17:09 AM »
You can literally write blocks of and get C code performance if you need it via FFI. This includes arrays. It's even easier to use than Python's C interface.