Advertisement

Good scripting language?

Started by February 24, 2003 05:47 PM
26 comments, last by BradDaBug 21 years, 10 months ago
What''s a good scripting language for Linux? I''ve decided I just might learn one, and now I gotta decide which one. My main motive is sometimes I notice that when I want to try something, I try it in C++, but it would be so much simpler and easier to just write a quick script and do it that ways. So what are some good scripting languages and what kind of features does each one have?
I like the DARK layout!
Bash:
It''s probably the shell you''re already using. It''s rather difficult to do huge programs on, but for things that are, say, three lines long, it works well. Extremely cross platform; any platform that has bash and the programs you''ll likely use (grep, sed, awk, cut, sort, etc.) will run it. Which basically means any unix like system will run it. You''ll probably end up learning at least a little bit of it anyway. You might as well learn it a bit more formally. Its biggest feature is that it scales down very, very well. (it''s virtually impossible for a scripting language to do that much similarly because bash is just the shell you''re using)

Perl:
I don''t use perl, and so I know very little about it. From what I''ve heard, it does text manipulation generally better than bash, and has an incomprehensibly vast, centralized library of modules called CPAN. Regular expression syntax is a part of the language. It''s hard to read (wears out the keys on your keyboard in a balanced fashion :-). A smidgin faster than Python.

Python:
Very easy to read. More of the language utilizes object oriented concepts and syntax. Scales up very, very well. Does GUI applications better than Perl. Virtually unlimited introspection capabilities. Has Boost:ython, which is better than SWIG.

Others to look into are Tcl and Ruby, neither of which I''ve heard much about.
---New infokeeps brain running;must gas up!
Advertisement
I hear Ruby''s cool.

However, that''s really ALL I''ve heard about it
Ruby''s interesting - features like strict single inheritance and mixins are intriguing - but Python''s a much more mature and robust language (it has 12 years of active development behind it), and in my opinion much more feature-rich. It''s also easier to learn and use while remaining very flexible and powerful, but it lacks a lot of feature enforcements (it relies on conventions and good behavior by programmers to avoid certain types of errors).

Overall, I think Python is your best bet - and let me recommend you look into PyGame and wxPython for game development/prototyping and GUI development respectively, excellent libraries both.
I thought I''d toss my opinions in too =)

Perl is a solid language. It''s built in regex is nice as well as the fact you can find a module for just about anything you want to do from CPAN. However, I find it difficult to maintain over time since I often cut corners. I think you have to be a very disciplined coder to make structured, reuseable Perl programs. Not impossible, but hard considering most scripts are built out of that "get it done" mentality.

Python is my personal choice whenever there isn''t a module I would rather use from Perl. The language is simple and relies upon most of its functionality from its builtin modules (versus Perl which has a large list of built in functions). I find this is easier to use. Also, it''s EXTREMELY easy to override methods and classes in Python so you can tweak existing modules if you need to. The interactive interpreter shell is a god send if you''re looking to do some explorating of what does what in a module, API, or what not.

Bash. Avoid it unless you just want to do some simple scripts for manipulating the Unix environment.

Ruby. Never used it, doesn''t seem to get a lot of attention.

Tcl. Blah. =)

I guess technicallly awk and sed fall into the script language category for some people, but I think they''re outside of your question (pretty operation specific in what they do).

There''s also Rexx, but I never personally (or ever met anyone who does ) use it.

I find for work I use Python where possible, Perl when I find a module that''s too convienant or more mature vs one in Python. I find my Perl scripts are often hard to read after a few weeks, so I guess that idiom is true as they say. I also find I spend less time wresting with the Python language and more time with logic of my code so I guess that''s also a true statement from Python advocates. I do find Python easier to translate into C though, especially when you script heavily with functions.

Hope that helps.

Interim
Lua is my favorite, simple and fast. http://www.lua.org/
Advertisement
people, you''re forgeting Lisp''s variants..
i''ve never use it. but i heard is very good handling lists.
Lua is very fast, and easily integrated in C++, you can expose a C++ function to a lua script with one line of code...it''s very easy to seperate game logic and engine code with lua.
quote:
Original post by Interim
I guess technicallly awk and sed fall into the script language category for some people, but I think they''re outside of your question (pretty operation specific in what they do).

Sokoban written in Sed (the source is in the directory with that image). I think that''s about as far as one can push Sed though.

One language that hasn''t been brought up yet: OCaml (or just Caml, if you prefer).

I haven''t taken the time to have more than a basic understanding of OCaml (I like to learn new programming languages for no reason, so I''m sure I''ll get back to it eventually), but I''ve heard lots of good things about it.

It isn''t ''just'' a scripting language either, there are compilers for OCaml/Caml that output native code.

quote:
Original post by athos_musketeer
people, you're forgeting Lisp's variants..
i've never used it. but i heard is very good handling lists.

Python is nearly a Lisp variant, in that it's fundamental type is the list (Python's basic types are lists/sequences, tuples, dictionaries/associative arrays/hashes, integers, real numbers and strings; everything else is a complex type built from these) and the in-built functions filter, map and reduce exist to facilitate functional programming (reportedly they were introduced at the request of the Lisp crowd). It also makes no distinction between code and data, with eval and exec providing extensive reflection and introspection (the language is part of the language).

But of course there are many other variants, including Haskell and Scheme, which are worth considering. One thing to consider, though, is the level of penetration of the language - and thus the availability of support and assistance with those languages.

quote:
Original post by thehurricane
Lua is very fast, and easily integrated in C++, you can expose a C++ function to a lua script with one line of code...it's very easy to seperate game logic and engine code with lua.

True. Lua is a language with a fairly good reputation, but it seems to have been "pidgeonholed" purely as an extension language whereas some of the other languages mentioned are full-featured, standalone tools that can co-operate with or be embedded in other languages (remember, I'm not saying Lua isn't one these, merely that it seems to be the popular notion).

[Edit: Formatting.]


[edited by - Oluseyi on February 26, 2003 5:48:41 AM]

This topic is closed to new replies.

Advertisement