7 Replies - 936 Views - Last Post: 05 November 2011 - 08:16 AM

#1 sitesmaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-November 11

SMPL - new web programming language

Posted 05 November 2011 - 04:40 AM

Hi, everybody.

I'm going to talk in this thread, my first one here, about the web programming language which I designed, SMPL.
--------------

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 Download SMPL.


I'm waiting for you responses, suggestions and comments about SMPL and its web site.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: SMPL - new web programming language

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,577
  • Joined: 08-June 10

Re: SMPL - new web programming language

Posted 05 November 2011 - 06:13 AM

does smpl support OOP/Design Patterns? Databases? Sockets? Exceptions? Iterators?
Was This Post Helpful? 1
  • +
  • -

#3 sitesmaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-November 11

Re: SMPL - new web programming language

Posted 05 November 2011 - 06:28 AM

Hi, Dormilich.

SMPL currently is only procedural, it doesn't support OOP or functional programming. I thought a lot of adding an OO support, but I didn't decide yet. It won't be that easy to create a language, were everything is an object and OOP where not everything is an object is worth nothing.

I don't really understand what do you mean by supporting design patterns!

For DBs, SMPL currently supports only ArraysDB management system, anyway SMPL is only at the Alpha version 0.3. I may try to add MySQL and SQLite support soon.

SMPL has no exception handling currently and doesn't support sockets.

Surely, it supports iterating arrays.


Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,577
  • Joined: 08-June 10

Re: SMPL - new web programming language

Posted 05 November 2011 - 06:44 AM

View Postsitesmaker, on 05 November 2011 - 02:28 PM, said:

It won't be that easy to create a language, were everything is an object

something like Javascript but without the twisted history?

iterating arrays is rather simple, iterating lists and objects is what it makes interesting.

View Postsitesmaker, on 05 November 2011 - 02:28 PM, said:

I don't really understand what do you mean by supporting design patterns!

speaking in examples, how would smpl implement the composite pattern? or the decorator pattern?

This post has been edited by Dormilich: 05 November 2011 - 06:46 AM

Was This Post Helpful? 0
  • +
  • -

#5 sitesmaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-November 11

Re: SMPL - new web programming language

Posted 05 November 2011 - 08:05 AM

Hi.

Arrays in SMPL are lists with keys, just like PHP. Something like an array, with each element an array with two elements one for the 'key' and one for the 'value'..
Anyway, that's just the interpretation, SMPL arrays are not more than normal PHP arrays.
You can iterate arrays using the 'for' statement in SMPL, it is like 'foreach' in PHP with some differences.

I'm sorry. I don't really know anything about the patterns you named, but from a fast look on Wikipedia I could understand that they are related somehow to OOP.

But if I could understand something about the 'composite' pattern then you should know first that the only compound type in SMPL is 'Array'. The only way to process each element of the array is to loop through the elements of the array and make the process you want on each element. But you can search or sort the array without looping.

Thanks.
Was This Post Helpful? 0
  • +
  • -

#6 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: SMPL - new web programming language

Posted 05 November 2011 - 08:06 AM

While I think it is impressive you created your own language I can't see much use for it if you can't implement OOP or even functions for that matter.
Was This Post Helpful? 0
  • +
  • -

#7 sitesmaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-November 11

Re: SMPL - new web programming language

Posted 05 November 2011 - 08:13 AM

View PostJstall, on 05 November 2011 - 08:06 AM, said:

While I think it is impressive you created your own language I can't see much use for it if you can't implement OOP or even functions for that matter.


Thank you for your reply.
For the OOP, it's not really the matter that I can't, I'm somehow lazy to do a major development like that now and like most developers I'm used to the procedural paradigm, and find it useful and satisfies my needs.

OOP, as implemented in PHP, is not so difficult to implement, I have two ways:
  • To depend on the PHP model.
  • OR to implement it myself in a creative way..


I like the second one more.

But I don't like to support a paradigm partially in the language, 100% or not.

Thank you, and I promise I'll think more about the OOP.
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,577
  • Joined: 08-June 10

Re: SMPL - new web programming language

Posted 05 November 2011 - 08:16 AM

you donít need to use the PHP-style OOP, you can also use the Javascript-style OOP.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1