3

I can neither code Bash nor Python (actually, I am only comfortable with C-like syntax), and, actually, am too busy and lazy to learn them now. But I would like to script some tasks. Is there a scripting language for GNU/Linux, having obvious and comfortable syntax for C/C++/C#/Java developers?

  • 8
    I don't understand why you're so focused on syntax. I'd think that a language with similar syntax but completely different semantics would be much harder to learn than one with different syntax but similar semantics. – sepp2k Jan 15 '11 at 15:58
  • You could try scripting in csh which is, as they say, neither C like nor sh like. – bahamat Aug 24 '12 at 23:55

12 Answers 12

3

If you're comfortable with Java, then try groovy, a scripting language based on the Java platform. There is almost zero learning curve.

14

Pike is a scripting language with a C-like syntax. You've never heard of it? Consider this a point against: it's rarely installed by default, it doesn't have many libraries, there's not much literature about it, there aren't many people who can help you with it…

Just pick Perl or Python, the two major scripting languages on unix systems (plus the shell, but it's a trickier language and has a less general scope.). The syntax is only 1% of learning a language anyway. I'd recommend Python as the simplest of the two.

  • 3
    +1 it's not common for me to like the prose style in someone's stack exchange answer. i really hope you write a novel someday. – ixtmixilix Dec 25 '11 at 21:11
10

If you really want to program in C but not have the long steps of compiling & linking, check out the TCC: the Tiny C Compiler. It even supports running via shebang.

2

Ch is a C and C++ interpreter, it can be used for scripting.

2

CINT is another C & C++ interpreter. I don't know if you'd want to have to wrap commands in

system("foo");

though. Maybe a macro like the following (untested)

#define S(cmd) system(cmd);

might be useful in that approach, e.g., S("cp a b")

Maybe not :)

  • +1 for CINT: It is part of the awesome ROOT framework which is used for most of the data processing at CERN, so you know it will be actively developed for a while to come. – Janus Jan 17 '11 at 4:51
2

You should search for "learn python in 10 minutes".

It covers the most useful python features: lists, tuples, dictionnaries, classes, and of course its awesome indentation system.

Learn it, I personnaly considering python as important after C\C++, because it does so much by default, and as a scripting language, it serves a lot.

Advantages:

  • Features everything you'll need as a programmer
  • A VERY clean and easy syntax, its author says it can be 3 to 4 times more productive than c/c++

Disadvantages:

  • Speed, but if you're not programming low level where performance matters, it's sufficient.
1

Install and try tcsh. You can also make it your default shell, if you want. Although I don't recommend it. ;-)

  • 2
    Recommending csh, even tcsh for scripting? Definitely not. (I'm not recommending Bourne-style shells either, but I'd recommend them over tcsh.) And for interactive use, bash and zsh overtook tcsh long ago. – Gilles Jan 15 '11 at 16:43
  • 7
    @Gilles - The question is not about recommendation, but about existence. csh is a shell scripting language with C-like syntax. The answer is valuable, even if csh is not. – mouviciel Jan 15 '11 at 17:58
  • 4
    @mouviciel Even though the word "recommendation" isn't in there, and the question is literally asking about the existence, it is apparent the author is intending to use one of the answers, thus, it is a recommendation. A disclaimer is definitely helpful. – Shawn J. Goff Jan 15 '11 at 18:17
  • While I agree that csh/tcsh should not be used for scripting it fails to mention existence of /dev/stderr and /dev/stdout – Maciej Piechotka Jan 16 '11 at 1:17
  • Despite its name and what its manual page states, csh syntax is extremely remote to the C language one. I have always been puzzled by that claim. Even awk is much more C-like. – jlliagre Jan 16 '11 at 13:51
1

php-cli, can be quite useful.

php has a bad reputation, but since php version 5 the language is actually quite ok. And the syntax is similar to C/C++/Java.

1

There is cling Cern's project of C++ interpreter based on clang.

Here is Google Talk: Introducing cling, a C++ Interpreter Based on clang/LLVM

  • cling seems dead, so many dead links on their website. Does it even work on Windows already? – lama12345 Mar 27 '16 at 4:35
0

There are some packages available for node that facilitate system scripting.

The node package manager is probably the easiest way to install such packages; node itself can be built from source (with the v8 engine it runs on) or installed via some system package managers.

You may need to learn to use evented I/O in order to get much done.

0

I haven't written it yet, but the best scripting language for C would be... C. Compilers are fast enough now that you could write a little script wrapper that would compile and run your program. Indistinguishable from a scripting language that loads in the source and parses it before executing. When I get a script working, I'll post it.

0

Perl has essentially the same syntax as C (it's at least as close as C++), and is quite widely installed / available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.