zinif is an object-oriented, typeless programming language, following the principle of "everything is an object", like unix's "everything is a file". In theory, a language with a small but complete instruction set should be easier to learn and extend.
Be the first to post a text review of zinif. Rate and review a project by clicking thumbs up or thumbs down in the right column.
Well, hello world. Announcing zinif, v0.1. zinif is (yet another) interpreted programming language. The interpeter, at the current time, is written in C++, and does not use bison or yacc. zinif is object-oriented, and it is designed around a philosophy of "everything is an object". Yes, that is correct -- *everything* is an object, from operators to blocks to method calls to methods to . . . well, you get the point. Everything. zinif's syntax is remarkably similar to that of C's, though not identical. If you picture a C program, with minor modifications it will be a zinif program. The most major differences are (at the current time): - No main() function, simply starts executing at the top of the file. Much like Python in this respect. - if() syntax is not 'if(<condition>) <statement>', but rather 'if(<condition>).then(<statement>)'. Note that you can pass blocks to zinif methods, since blocks are methods. ;) - Currently, periods are required when calling any methods -- 'a = 5;' becomes 'a.=(5);'. This gets confusing when you start doing things like 'a = (5 * (2 + 3));' -- 'a.=(5.*(2.+(3)));'. Also, there is no operator precedence at the moment, so you must encase everything in paranthesis. - Spaces (or any kind of whitespace) are required around everything. This is a very major drawback and limitation, but it's on the drawing board to be fixed (or at least, patched slightly ;) ) very soon. This means that 'a.=(5);' has to become 'a . = ( 5 ) ;', which is a little heavy on the spacebar. Those of you who put spaces around everything anyhow will feel right at home. ;) What is currently implemented: - blocks - method calls - numbers (currently uses C++ doubles, though I'm looking into the GMP.) - booleans - if().then() statements - assignements - addition (though there's no reason why multiplication and division and powers and subtraction and square roots etc. can't be implemented, just laziness on my part.) - internal references (you can't declare your own yet, though it would be quite simple to implement . . .) What is not currently implemented: - defining your own methods (support for this is actually implemented, but I'm not certain if it works, as I haven't tested it in a while. Last time I checked it didn't work.) - strings (not too difficult, actually. No need for strings ATM, that's all . . .) - modules (like Python's modules, though there's not much work that needs to be done before these are working) - a decent tokenizer (so that you don't need spaces etc. It's quite a ways away, but it'll be here someday. I promise. ;) ) - mathematical operators (see my note about addition . . .) - operator precedence (tricky one -- not sure how this is going to work out . . .) - loops (though these will be easy once block breaking/continuation is working -- combine a if().then() statement with a continue, and away ya go.) - comments (these will be stuck in with the new tokenizer . . .) - references (see my note about internal references.) Note that much of the zinif interpreter output is debugging information. In fact, all output is debugging information. Ya just have to know how to read it. ;) Note that the INSTALL file that in the dist is slightly out-of-date, though it's basically the same. Same thing goes for the TODO file. I maintain a list of things to do elsewhere, on a sheet of paper that I sincerely hope I don't lose. The first step is to, of course, get zinif's source code. You have two options: git (for the most recent version), or SF.net's file release system. Either works. You'll also need CMake, at least version 2.4. To clone the git repo. Install git if you don't already have it. I'll leave you to find out how to do that on your own. The git repo is located at git://zinif.git.sourceforge.net/gitroot/zinif. Or, the zinif source tarball is available at https://sourceforge.net/project/showfiles.php?group_id=255743. Once you've accquired the source, build zinif. You can use ./build.sh if you like, or you can run something like this: user@host:~/src/zinif$ cmake . user@host:~/src/zinif$ make And that oughta build zinif for you. If you recieve any errors during compilation, let me know. I compile zinif with g++ 4.3.3-8 and cmake 2.6. Once zinif is built, try it out on one of the tests included in the tests/ directory. Note that some segfault zinif, and some are old tests that shouldn't be in there . . . user@host:~/src/zinif$ cat tests/assign.zi variable . = ( 5 ) ; user@host:~/src/zinif$ ./zinif tests/assign.zi You should get a slew of debugging information. 90 lines, in fact, for assign.zi. The part you're interested in is in the last few lines: reference 'variable', target: '': zinif_object_number [5] . . . showing that zinif has set a variable called 'variable' to be a zinif_object_number of a value 5. Feel free to modify the test -- since it uses C++ doubles, you can read in numbers such as 4.3e-12 if you want. While assignments are all very well, there are more exciting things available for you. If you try conditional.zi, you'll find a nice if().then() statement working. In this case, the statement sets the variable c to 42 (the Answer ;) ) if the variable c is true. If not, it leaves it at zero. By looking at the examples, you should be able to figure out the basic zinif syntax. It's basically C syntax. I'm assuming that you know C. ;) While I do realize that this is *nothing*, really (the zinif interpreter is currently only 2368 lines!), it is the basic kernel of the zinif interpreter and language. However, once a few more things are implemented, zinif will begin to come into its element -- here's just one example. Loop breaks. ;) while(<condition).do({ { __block__.break(); /* break out of the current block */ } __loop__.break(); /* break out of the loop */ }); This allows you to break out of blocks selectively. With references, you can name blocks and break out of several blocks at once . . . { outer.=(&__block__); { { outer.break(); } } } Or whatever your imagination cooks up, including breaking out of nested loops, etc. There is doxygen-generated documentation available. If you have doxygen installed, simply run doxygen with any arguments you want in the root directory of the project. Documentation is put into doc/. Note that the default Doxyfile assumes that you have dot (part of graphviz for Debian) installed. I do hope that you have fun with zinif, whatever you do with it. This is a pre-alpha-style release, just to let people know that this exists. For those of you who are frustrated with the more pedantic languages like C and C++, but (like me), don't want to switch to a full interpreted language like Python, zinif just might be the answer to your problem. Or maybe not. It's yours to decide. ;) If you wish to contact me for any reason, feel free. My email is currently kawk256 at gmail. Happy hacking! - kawk, 26/04/09
Be the first person to add a text review.
Thanks for your rating!
Would you also like to write a review?
Thanks for your review!
Get credit for your review by logging in via OpenID. Click your account provider: