Hi, everybody.
I’m going to talk in this thread, my first one here, about the web programming language which I designed, SMPL.
But before I start, I would like to say that I really didn’t know where to post this thread, I decided to post it in this forum as it was the closest one to the topic for me, as the language is it self written in PHP and based on it.
SMPL is a light, free, open source programming language, designed to add a mixture of simplicity, organization and flexibility to the task of programming for the web.
SMPL is simple, easy and flexible! It is strong and dynamic typed, high organized and is characterized by high clarity, fixed naming patterns, easy debugging and supporting unicode from the core.
SMPL, from the inside, is based on PHP. So it can work correctly on any web server that has PHP 5 installed, without reinventing the wheel, allowing anybody to install it as easy as installing any other application built using PHP, it’s even easer, it needs no configuration (of DBs as an example).
SMPL Code Example:
<?smpl>
show "Hello World! " * 3
show "<br />"
my_array= [1, 2, 3] + [4, 5, 6] // Like writing [1, 2, 3, 4, 5, 6]!
show my_array * ' ' // Joining the elements of the array (the only implicit type casting in the language happens here, as it has no harms)!
<!smpl?>
Result (as it is viewed in a browser):
Hello World! Hello World! Hello World!
1 2 3 4 5 6
PHP is a very useful, popular and widespread programming language.
But:
- It is really has an inconsistent naming patterns (Like differences between these strings functions: 1- trim(), explode(). 2- strlen(), strpos(). 3- str_replace(), str_repeat(), 4- wordwrap().).
- Inconsistent parameters (Ex. Haystack first or Needle).
- Very strange function names (as in strnatcasecmp(), vfprintf(), strstr()).
- Wrong function names (as in addslashes() which addes back slashes and not slashes)!
- In function names: sometimes verb first and sometimes nouns first!
- It has no unicode support from the core (just some messy Multi-Byte functions which isn’t enabled by default).
- Its typing if weaker a lot more than the acceptable. I wanted a more organized language, weak-typing is sometimes just trying to guess the programmer’s intention!! Also the implicit casting in comparison looks very very random.
- I wanted a simpler, simpler not just easier, language which removes any additional non-needed parts.
- I wanted an easier and more powerful debugging methods.
- Many functions for nearly the same purpose: sort(), asort(), arsort(), ksort(), krsort(), natcasesort(), natsort(), rsort(), uasort(), usort(), uksort(), array_multisort(), array_shuffle() all of these are for arrays sorting! In SMPL you only need to use array_sort() with a parameter to choose the way you want.
- Some new concepts for databases in ArraysDB the database management system of SMPL. Which is powerful as the traditional SQL DBMS but it is not relational and uses functions instead of writing SQL (yes, also no injection of course), and treats the whole DB as an organized array, that is saved in a single small file!
- Also allowing any PHP programmer to edit the language, add extensions and make a lot of things with its core and functions!
- Other than all of that I wanted a lot of new features to the language it self, from the syntactic sugar to functions. For example you can see the allowing of adding, subtracting, multiplying, and even dividing non-numeric values. Summing two arrays merges them, subtracting them gives you their difference, dividing a string by another splits the first string into an array…
SMPL is a preprocessor, just like PHP. The whole process of browsing a web page written in SMPL can be summarized in:
- The web server receives the request from the browser, then passes the requested file to a file called smpl_translator.php.
- The file smpl_translator.php, after checking that the file can be reached by users, reads its contents then by transforms it into tokens, checks the correctness of the code, then generates the equivalent PHP code, the executes the code by eval(). Note: The generated code is cached and the cache is removed each 24 hours.
- PHP gets the code and processes it to its Byte-Code which is get executed by Zend Engine to get the result, which is returned to the browser.
SMPL functions are PHP functions, and its variables are PHP variables also, but all of them have certain prefixes when they are written in PHP, but they don’t have these prefixes when used in SMPL.
SMPL is not the only language that uses a translator from it self to another high level language, Dart from Google, CoffeeScript, Pascal and Eiffel all uses “transcompilers” or translators.
SMPL’s site wasn’t originally in English, but in the last days I translated the main parts of the web site to English. Most of the site is translated (not really a lot) except the manual, only the downloading & Installation chapter is translated until now! I will try to translate more and more and write more soon.
You can visit SMPL English Site or [URL=“http://smpl-lang.com/en/download.smpl”]Download SMPL.
I’m waiting for you responses, suggestions and comments about SMPL and its web site.
Thanks.