Slashdot Mirror


C Styled Script - C-like Scripting Language

Exomorph writes: " C Styled Scripting (CSS) has just been released for Linux! (Already available for Windows, and OS/2) You can use CSS like an interpreter (Like Perl) or as a scripting engine within your own applications. It follows the C syntax very closely and has now been released under the GNU General Public License." Is anyone using this?

27 of 211 comments (clear)

  1. Re:How? And what's the point? by kinkie · · Score: 3

    Take a look at Pike, it's been covered here in the past.
    It has a c-like syntax, it has the preprocessor, and it has classes (full OOP), functional programming if you want, a nice runtime library. It doesn't have pointers, but it has references (no arithmetics though), and high-level constructs for strings, sets and associations. It does manage memory quite fine (refcount + garbage collector) and you can make it as pedantic as you want, even not at all (just use the mixed type everywhere).
    This said, you won't get rid of the C syntax anytime soon. It has an advantage over most other syntaxes one can come up with for an imperative language: it's concise. And if used with some discipline, it can be very readable which is one of the most important requirements for a programming language. By adhering to a c-like syntax, any other programming language can be instantly readable by a lot of people.

    --
    /kinkie
  2. Well, don't use it, then! by jcr · · Score: 3

    The purpose of making one language similar to another is to shorten the learning curve of the second language. That's why we have the C shell, and its also why Java looks so much like (bleah) C++.

    Now, I have no use for another C-like scripting language, but who says this language has to fit *my* needs to justify its existence?

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  3. Boycott CSS! by Louis+Savain · · Score: 3

    The world does not need another scripting language. Enough is enough!

  4. Re:C interpreters by Amokscience · · Score: 3

    Embedding scripting language into programs... you mean like SWIG?

    http://www.swig.org/

    --
    Fsck cluebie moderators. I'll say what I want, offtopic or not. And fsck having to qualify every bloody statement just
  5. Re:How? And what's the point? by Pedrito · · Score: 3

    Choice of programming languages comes down to what fits your needs and what fits your skills.

    I've been programming in C++ for 7 or 8 years, and find it to be fantastic for expressing what I want to produce. I find it much easier to write code that's easy to debug and maintain than any other language I've ever dealt with.

    Now, granted, a lot of that is due to a very detailed process that we go through before even writing the code, but well designed C++ systems can be quite easy to maintain.

    I've written several large systems in C++ and found it to be very easy to maintain and debug. My last major system had over 150 classes in a very well designed architecture. Although more than 30 people were involved at various times during it's implementation (over a 5 year period), in the end, there were two of us maintianing it and adding new features. And when I say new features, I'm talking about major additional functionality.

    Now, could Java do what this system did? Yes, but probably not at the same speed. This was a very mathmatically intensive system. It modeled cellular telephone networks (the antennas at base stations as well as the mobile phones).

    I still like C++. I like it a lot. It has made my life much easier. Until I find a language that's going to make my life easier, I have no intention of changing.

    That said, is C++ the best language for every task? Of course not, and I certainly don't use it for web scripts. Everyone has their own reasons for choosing a language, though, and as I'm very C++ oriented, a C style scripting language would probably be very easy for me to adapt to. Perl sure as hell wasn't easy for me to adapt to.

  6. CSS by portege00 · · Score: 3

    Am I the only one who's going to look at people funny now when they say CSS. Do they mean Cascading Style Sheets, or this? Argh, the headaches! CSL would've been better: C Scripting Language. Hey, that's practicality!

    --
    Trolls make great pets. Adopt one today!
  7. Already done -- CPR by paulschreiber · · Score: 3
    take a look at this article on perl.com.

    you'll see that Inline::CPR lets you do this.

    #!/usr/bin/cpr
    int main(void) {
    printf("Hello, world\n");
    }

    tada! interpreted C.

    Paul

  8. Small, the C scripting language. by YakumoFuji · · Score: 3
    I've been using 'Small' for a fair while now, here

    from the site;

    Small is a simple, typeless, 32-bit extension language with a C-like syntax. A Small "source" program is compiled to a binary file for optimal execution speed. The Small compiler outputs P-code (or bytecode) that subsequently runs on an abstract machine. Execution speed, stability, simplicity and a small footprint were essential design criteria for both the language and the abstract machine.

    • Small is a simple, C-like, language.
    • Small is a robust language with a robust compiler.
    • Small comes with an implementation of an abstract machine in portable C. The abstract machine is a set of C functions that you can easily link to an application or function library. By compiling the source code to P-code for an abstract machine (or "virtual machine"), Small is much faster than pure interpreters.
    • Small has a good interface to native functions (in C/C++); your application calls functions from -Small programs, Small programs call functions from your application.
    • Small is a 32-bit language, even when compiled with 16-bit DOS tools.
    • For porting purposes, Small is written in ANSI C as much as possible; Big Endian versus Little Endian is handled. -Small is quick (especially with Marc Peter's assembler implementation and/or his "just-in-time" compiler) -Small is, er..., small.
    • Small is free and it has a liberal license (you may use it for commercial applications, and you may also freely distribute modified sources or binaries ---though you take responsibility for those modifications).


    Write your Own Operating System [FAQ]!
    --

    no sig for you
  9. Re:EiC by istartedi · · Score: 3

    I can't believe I had to read this far down to see a mention of EiC. First, and this is important...

    ...one of the best things about EiC is that it is NOT merely "C-like". EiC tries to follow the ANSI/ISO standards as closely as possible and does a very good job of meeting C90. Last I heard, C99 support was in the works.

    Whenever I hear "C-like" I always get suspicious, and it almost always turns out that the syntax is not true C. Based on what other people are saying, it looks like the article is mentioning yet another one of those, and if that's true I have no use for it.

    As for the people who are wondering why people want scripting in standard C, here are my reasons:

    1. Code re-use. With a babel of scripting languages, you are duplicating functionality at times. When you do your scripting in C, you can take ideas that started out as scripts and easily incorporate them into powerful programs at a later date. Likewise, you don't have to translate the large body of C source code floating about into some other language--you can just use it.

    2. Rapid Application Development, which ties in closely with point 1.

    Long live C! Although I haven't actually tried it, I plan to use a C to Java translater, make, and javac to build Java applets without actually writing Java.

    The only new language I want to see is a metalanguage analogous to PBM so that I can maintain all my code in C, run CtoPBMlang and PBMlangtoFOO with make to build for whatever scripting environment is required.

    It's funny to think that programmers are trying to write translaters for human languages. We don't even have reliable automatic translators for the far simpler languages that we have invented for programming!

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  10. Re:Turing equivalence? by Laplace · · Score: 3
    The Template Metaprogramming mentioned in other posts illustrate the power of templates. While there may not be a facility for looping in the "linear iterative process" (see "Structure and Interpretation of Computer Programs for a definition) sense, there is in the "linear recursive process" sense. What happens is the proprocessor expands the templates. If a template has a template as a parameter, the embedded template is also expanded. This continues until an atomic (terminating) parameter is passed or until the preprocessor runs out of steam. Of course, for this to work on compilers like gcc, you need to increase the -ftemplate-depth-xx to obscene values. Since the preprocessor expands the code into new, legal, C++ code, you can write very fast loops. This is because the loop is unrolled, and you have explicit code (that the preprocessor wrote from your instructions) that usually smokes its competitors. Now for the obligatory link: Go to the Blitz++ web page to see a nice example (and some interesting papers on the subject).

    The thing I find amusing about this is that languages like Lisp provide this exact functionality without the truly cryptic syntax (although you could argue that parentheses are replaced by angle brackets).

    --
    The middle mind speaks!
  11. Re:Worst language ever! by depsypher · · Score: 3

    Ok, first of all why would you want pointers in a scripting language? It's a SCRIPTING language we're talking about here!!! Scripting languages are supposed to be an easy way to expose the functionality of a program, not a tool to create security holes and logic errors. Introducing pointers into something like this will create more bugs (both intended and accidental) and be a major pain in the butt for the script programmers to deal with.

    Also, since when is goto a major feature of C? One of its very few legitimate uses is to break out of a deeply nested loop. Ok, so other than this one use (which optimizes some code only some of the time), what is it good for?

    Finally, #defines are a nice feature of c, but again, this is a SCRIPTING language. If you just need a constant, declare one const. If you need a function that returns the bigger of two numbers, write the function! I fail to see what features they've left out that are really needed in a scripting language. p.s. I do agree with you that CSS is a pretty bad choice of acronyms.

  12. Re:Pascal is THE scripting language for UIs by DickBreath · · Score: 3

    I've never understood the wisdom of using Pascal for teaching.

    The wisdom of using Pascal for teaching was before there were Modula-2 and Oberon.

    Pascal was a great teaching language when there was Fortran and C. Late 70's, early 80's.

    Vendors extended Pascal enough to make it commercially useful. Thus creating many incompatible dialects.

    Modula-2 corrected many Pascal mistakes. But by that time C had achieved a lot of mass on the PC.

    A serious Pascal design mistake that Modula-2 corrected (and C did correctly already) was NOT to design I/O primitives into the language, but rather make them part of the standard library.

    As for today, there are far better teaching languages. Most young 'uns today were wearing diapers when some of us were learning Pascal/C/Modula-2/MS-DOS/Lisa/Macintosh, etc.
    --
    "Linux is a cancer" -- Steve Ballmer, CEO Microsoft.

    --

    I'll see your senator, and I'll raise you two judges.
  13. Re:Turing equivalence? by ryants · · Score: 3
    > Please provide some proof, or cite some reference

    Well, you can do template metaprogramming, but I believe it involves a little more than just the preprocessor. For example:

    template < unsigned N > struct Fact
    {
    enum { Val = N * Fact < N - 1 >::Val };
    };

    template <> struct Fact < 1 >
    {
    enum { Val = 1 };
    }

    #define FactT( n) Fact < n >:: Val

    Conforming compilers will reduce FactT(5) to a constant.

    References:

    * Chapter 1.2 of "Game Programming Gems" (that's where I got the example from)
    * "Using C++ Template Metaprograms", C++ Report, May, 1995

    Pretty whacky eh?

    Ryan T. Sammartino

    --

    Ryan T. Sammartino
    "Ancora imparo"

  14. Re:Turing equivalence? by Jennifer+E.+Elaan · · Score: 3
    This is actually in reference to the C++ template facility, not the old carry-over C preprocessor that is left in the C++ environment. The template system can actually do some looping if you're careful, it has to do something with using recursive template calls with an end-cap, similar to how you do loops in M4.

    I saw a paper a while back on numerical computing (I tried to look it up, but alas, I don't remember enough of it) that used these kinds of tricks to do all kinds of neat numerical analysis while compiling. Strange use of templates.

    -- Blore's Razor:
  15. Just use PHP... by Rambo · · Score: 4

    Why do we need yet another C-like language? I use PHP now for virtually everything (using the CGI version so you can write standalone scripts) It's great for little one-off scripts or whatever. Another C-interpreter type project is EIC, which is actually extremely close to standard C. It works well for most programs you don't want to constantly recompile.

  16. So what's new? by Argon · · Score: 4

    C interpreters have been around for a long time. Have a look at Scripting with C.

  17. Moderation??? by Compuser · · Score: 4

    Why is this comment rated "funny". The guy is
    proposing using GCC as a a just-in-time compiler.
    I was thinking of doing just that for an embedded
    app where you need users to script but you also
    need real-time code. OK, so maybe not with GCC,
    but the idea is valid and serious.

  18. #!/usr/bin/perl by rhet · · Score: 4
    Uhm, yeah. A cross platform scripting language distributed under an open license? It's called Perl. And if you really want C like syntax, there's always Inline::C and CPR.

    Seriously though, do we *really* need another scripting language? We've got perl, python, rebol, scheme, csh, bash, sh, ksh, [insert favorite scripting language here]...

  19. How? And what's the point? by rjh · · Score: 4

    Remember that C is a lot more than a language. A lot of people overlook one of the most important features of the language--namely, the preprocessor. In C++, the preprocessor by itself is a Turing environment; any computing task which you can think of, you can do in the preprocessor alone just by giving it some particularly weird templates to compile.

    How does a scripting language plan on implementing the preprocessor? If it doesn't, then should it really have "C-like" in the name?

    The other issue is... what's the point? I hate to tell people this, but C/C++ are two of the worst languages on the planet. I say this as a long-time C++ hacker and C++ enthusiast: the languages are awful. There are pointers all over the place, there's God-knows how many levels of indirection, there's detailed memory management... C/C++ are so powerful because they give you such fine-grained control over every aspect of the CPU. But they're cast-iron bitches to program in, because they're so intolerant of any error.

    Scripting languages, on the other hand, are inefficient. They're slow. But they're also wonderful to program in as a result--their syntax isn't as rigorous, there's very little memory management to be had, there's no need to know the difference between the register and auto keywords, or the difference an inline amd a macro.

    A C-like scripting language seems like the worst of both worlds. You've got the pedantic syntax and attention to detail of C, and the lackluster performance of a scripting language.

    What's the point?

  20. Re:C doesn't make a good script lang. by Erasmus+Darwin · · Score: 4
    you don't want to be bothered with such things when trying to write a quick one-off script.

    However, there are more uses for a scripting language than just quick one-off scripts. As mentioned in the article blurb, this language can be embedded within your own applications to provide scripting support.

  21. C doesn't make a good script lang. by ryants · · Score: 4
    I dunno. I took a quick walk around the manual and checked out some of the examples, but it seems to me that C (or C-like languages) just aren't all that suitable for scripts. Good scripting languages (like Perl and Python) tend to be "looser" (e.g. not having to declare variables) than C, and for a reason: you don't want to be bothered with such things when trying to write a quick one-off script. Not to mention the fact that Perl and Python form some pretty stiff competition in this sort of arena.

    Also, naming it CSS is pretty confusing, given that CSS already equals Cascade Style Sheets.

    Anyways, how can I get my SourceForge project on the front page of /.? :)

    Ryan T. Sammartino

    --

    Ryan T. Sammartino
    "Ancora imparo"

  22. Do it the right way by Waffle+Iron · · Score: 4
    Let's say you want your users to be able to script your application with the C language.

    If you're a pretender, you might write a wimpy interpreted version of C.

    If you're a real software architect, however, you'd #include the gcc source tree right into your app, compile the user's code on the fly, pipe the output into a memory-mapped file, and long jump straight into the results. Damn the torpedoes.

    Make no compromises on the performance of your users' macros. If they're worthy of your program, they need the speed. If they're not worthy, they'll write some lame pointer bug and dump core; I say good riddance to those lusers.

  23. RTFLanguageDescription by jbuhler · · Score: 5

    Several of the complaints posted here about how awful C is as a scripting language indicate that people aren't actually reading the language description for CSS. Among other things:

    * Variables must be declared but are untyped.
    Like Tcl, everything appears to be a string.

    * There are no pointers (though there are
    call-by-ref parameters).

    * There is no memory management, though there
    is a way to dynamically change the size and
    dimensions of an array object.

    * There are some extensions, such as
    exception handling and string concatenation

    * There is no "goto" construct.

    * There is a limited preprocessor facility
    (#ifdef equivalents, but no macros).

    Overall, it looks like a rather nice embedded scripting language, though it's not nearly as cool as embedded Scheme :-).

  24. C interpreters by YoJ · · Score: 5
    People seem to be down on this language, so I'll go for the positive spin. After a couple minutes of browsing the manual, it looks like a cool language. It is the sort of thing you add to your program to give it a scripting language. The advantage of CSS is that it is easy to learn if you already know C (or Java). C isn't the most suitable language for scripting, and they didn't use C directly. Variables are typeless (I think), it has automatic memory allocation, etc. Of course, my favorite scripting language of all time is Lua (check it out).

    Here's something I would like to see: an interpreter for C code that follows exactly what gcc would do. Then you could make a nice GUI environment for programming, where everything happens as you type it with no compile cycle. Then at the end you compile everything to get speed.

  25. I am by volpe · · Score: 5
    And I tried to post a copy of the flamewar, which I had saved years ago. But the quality piece of software that is Slashdot replied thusly:
    Easy does it!

    This comment has been submitted already, 276100 hours , 12 minutes ago. No need to try again.

  26. Re:Not to nitpick... by sconeu · · Score: 5

    Will my computer explode if I write DeCSS in CSS?

    --
    General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
  27. Not to nitpick... by crashnbur · · Score: 5
    ...but we have enough "CSS" already. Cascading Style Sheets seems to be widely accepted. Why name a programming language, or whatever this new CSS is, something that already exists?

    Or am I just blind to some bigger picture?