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?
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.
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."
The world does not need another scripting language. Enough is enough!
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
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.
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!
you'll see that Inline::CPR lets you do this.
tada! interpreted C.
Paul
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.
Write your Own Operating System [FAQ]!
no sig for you
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"?
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!
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.
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.
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"
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.
Hardware, software, and blinking lights!
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.
C interpreters have been around for a long time. Have a look at Scripting with C.
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.
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]...
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?
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.
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"
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.
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
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.
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.
Or am I just blind to some bigger picture?