Sign in to follow this  

Noobtastic languages question

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the difference between scripting languages and (for lack of a better term) regular languages? Why would you go through the hassle of interfacing C++ with Lua, for example, rather than just writing your code in C++? I realize this is a noobish question, but if you could answer it, I'd appreciate it.

Share this post


Link to post
Share on other sites
It's not as simple a question as you might think. (Is Python a scripting language or a programming language? The answer is...it depends.)

Part of the answer is that scripting languages don't have to be compiled. You can run it, make a change, run it again, and have the change instantly take effect. With C++ or Fortran or Java, you need to recompile before running it again.

The question you really want to ask is: what are the pros and cons of any language? With C++ you gain speed, the power of OO and generic programming, and compatibility with a wide range of libraries, but have to struggle with manual memory allocation, obtuse syntax, and slow compiles. Lua is easy to code with and lets you rapidly make changes to your program, but doesn't have the same kind of power as C++.

These days, only masochists would write an entire game using nothing but C++ :)
I'm a fan of Python myself, but Lua is okay too. It depends on your design.

Share this post


Link to post
Share on other sites
Quote:
Original post by drakostar
With C++ you ... have to struggle with manual memory allocation, obtuse syntax, and slow compiles.

These days, only masochists would write an entire game using nothing but C++ :)


That's an interesting response. I've never found manual memory allocation to be much of a hassle, and I like C++'s syntax. Also, I've never really had a very high compile time (although I see how that would change if my project gets much bigger).


In that case, what are the differences between some of the well-known scripting languages? And what are scripting languages typically used for? I've only got experience with C++ and C#, and not much with C#.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmrldDrgn
I've never found manual memory allocation to be much of a hassle

No, it's not a big deal after you've used it for a while. The last memory leak I encountered and spent days trying to track down...was a compiler bug.

Quote:
and I like C++'s syntax

Seriously? Do you use templates? Do you have interdependent classes that require forward declarations?

Quote:
Also, I've never really had a very high compile time (although I see how that would change if my project gets much bigger).

Even when you're talking about just a small project with a 1-minute compile. Compare that to 0 seconds. You don't have to sit around twiddling your thumbs while trying to fix a bug.

Quote:
In that case, what are the differences between some of the well-known scripting languages?

I'll give you the names of some popular ones, and let you do the research:
Perl
Python
Ruby
Lua
Tcl
Bash

Quote:
And what are scripting languages typically used for?

Same thing any language is used for: writing programs. The nifty thing about languages like Python, Lua, or Tcl is that they can be easily used to build hybrid systems with C or C++.

There are two distinct ways to build a hybrid system: extension and embedding.
With extension, you write your C++ code as a module/library that gets loaded and used from the script. With embedding, you put an interpreter in your C++ program and call the scripts as needed.

Python and Tcl are typically used with C++ extensions, and I believe Lua can only(?) be embedded.

Share this post


Link to post
Share on other sites
Quote:
Original post by drakostar
Quote:
and I like C++'s syntax

Seriously? Do you use templates? Do you have interdependent classes that require forward declarations?

Templates aren't much harder than C# generics, in my opinion. Interdependent classes isn't exactly syntax, but yeah, that can be a pain.

Quote:
And what are scripting languages typically used for?

Quote:
Same thing any language is used for: writing programs.


Well, duh :-). I only asked because I've seen several times on this forum things like "If the primary purpose of your program is to run other programs, you should be using a scripting language anyway", which led me to think there was something more fundamentally different about scripting languages. Thanks for the input and the list - I'm off to google some of them.

Share this post


Link to post
Share on other sites

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this