| A better C C is a fantastic language. C compiles insanely fast, is the fastest language there is, is very clear, is native to all systems, and is useful for all purposes.
Some people, e.g., Bjarne Stroustrup, consider that C is `not good enough`, and make languages like C++ or D (or thousands of others) This is not necessary. There is no reason to use Python instead of C for `simple scripting tasks` Some functions can be used as methods Makes for an excellent `scripting language` (which is really just native C without things making it slow) 1 String Interpolation "String interplation like this #{foo} " Calls the join() function (talked about below to join strings, delim is a static global in each module called `sep`. Make sure you free() the string after. The string is stored in a static global variable called `last`.
So you could do puts(...); free(last); 2 ew i.ew "Foo", a.ew "bar" | char ends with another char? 3 sw i.sw "Foo", a.sw "bar" | char* starts with another char*? 4 == Comparison of strs, "foo" == "bar" 5 strip Returns pointer to string that was stripped, in place 6 chomp void function, chomps end of string of spaces, i.chomp or chomp(i), in place 7 gsub Just like ruby, there is a gsub function.
The preprocessor detects if you use and adds -lpcre2-8 to the link flags if you use it. Use $" for substitutions in argument 3 gsub(a, b, c) 8 join Joins an array of strings, to split(), use C's strtok (very fast) 9 Lightweight regexes are added, almost 15 times as fast as C's built in regex. They are very simple, they only have bracket expressions, like [a-z].
To use it, you need to pass a buffer of the size of the expansion of the regex. Foo[a-fA-F] would be Foo[abcdefABCDEF]. That would be stored in a buffer.
From testing, 15x times faster than C's regex POST COMPILATION, if compilation keeps happening, it might be hundreds of times faster.
Uses static inline functions, NO HEAP MEMORY unless you malloc before(). 10 print Like old python print "Hello"(fputs); 11 print_int prints a number and returns the
number, can be chained 12 each_line, Perlish, different names, by_line(s) or each_line(s), iterate over all lines, free after 13 NOTE You can use open_memstream() on UNIX to easily concatenate strings.
asprintf() is another useful function which is UNIX-centric. open_memstream() could be an alternative to std::string.
It works very well with each_line or by_lines (see above) These features seem simple, but they can make C programming much, MUCH easier For example (insignificant example) int main() { stdin.each_line { |line|
print line;
}
free(line);
}You can iterate over the standard input like Ruby The thing with this is that it has 100% speed. The resultant preprocessed program becomes a normal C program The compile and run time for a program (if you use tcc and not gcc) can be about 24 milliseconds, which is faster than Ruby to run. ( Licensed under the BSD license ) |