What is Sputnik

From Sputnik Wiki
Jump to: navigation, search

Contents

What is Sputnik?

Introduction

This page is about the programming language I created called Sputnik.

It is basically a high level scripting language similar to PHP/Perl but with macro functionality on par with AutoIt and loads of additional and extra features that are totally unique and not found in other languages.

It also has a huge amount of functions in its core that are very fast (avoiding the user having to reinvent the wheel and having it spin slowly like most script languages).

There are very powerful arrays/classes and one of the largest amount of operators and language features seen in any language.

It was designed to be easy to use by beginners and simple in how much effort you need to do to accomplish tasks as such it uses the typical $Variable for all data types (even arrays) (unlike Perl where you must do @ and % and it can get confusing for a beginner).

Background

I have been programming since the 90s and have made several apps/games over the years and many mods for games.

I created Sputnik to solve the problems I was having since I was having to use Perl/PHP and AutoIt and often C# (and sometimes C) for various tasks and I just wanted a single language that would do everything I needed then some.

How to use Sputnik

Sputnik can be used stand alone by simply double clicking on the Sputnik.exe which will open the Interactive Shell and allow a person to simply type and see what happens.

In the interactive shell you can assign variables, make functions and do pretty much anything the shift + enter key can be used to type the *next line* without entering the information into the parser.

You can also run individual scripts by either dragging them onto the Sputnik.exe or by creating an association where .spk files directly open Sputnik.exe.

The final option is you can create a .bat file which runs "Sputnik.exe nameOfScript.spk" (without quotes).

Alternatively you can run Sputnik from an Apache (XAMPP etc) server on windows by simplying placing the

#!F:/Sputnik/bin/Sputnik.exe

At the top of your .spk file on the website.

How is Sputnik made?

Sputnik is programmed in C# and as such it benefits from the .NET language but it provides it's own stuff to the user to use.

How long has Sputnik been in development?

I would say it's been at least 4 years now.

Points of Interest

All variables, functions, classes are all case insensitive so it does not matter how the user types it which is awesome for beginners.

There is good support for multi-threading and it is very easy to use.

Sputnik has a crazy amount of string function (over 160), parsing functions and has amazing arrays (which can do integer and string index at the same time and dynamically expands never gives out of bounds error), powerful classes that can overload every operator and cast and multiple inherit as well as powerful binary functions with powerful functions for handling bits.

There are over a dozen data types including UInt16 etc etc of course Sputnik converts between them automatically and resizes if it needs to by default it prefers to use Int64 or Double but will convert to double if it detects you are doing something that will go into fractions. (Unless you are rounding)

You can all C/C#/Perl etc escapes in the string and even execute physical code inside the string (Sputnik's RegExp can do that too)

You can control the Mouse/Keyboard and windows/controls similar to AutoIt with familure function names and many new abilities.

You can define HotKeys for your application to use and it will execute Sputnik code/functions when the Hotkey is triggered you can also pass a param to the creation of the Hotkey such as a class variable then you can make the Hotkey trigger functions inside the class without needing a global variable.

You can cast like C.

You can dynamically add/remove/change functions/classes/enums etc in real time without needing to restart your program. For example you can totally remove functions/classes from your app and reload them from source code at runtime. Sputnik features many advanced dynamic code features like that and has a very powerful Eval() statement with many options.

There is a good preprocessor that supports everything one would expect including #if etc

The arrays are very similar to ones seen in PHP in that they dynamically grow/expand as needed and they are KEY based (a customzied dictionary behind the scenes).

It features Perl style regexes using either function based RegexMatch() etc or $var =~ m/\d+/; like Perl it can also parse using complex grammar sheets and can even be used to parse it's own source code.

Classes are somewhat similar to PHP in that it has __Construct() etc however it supports multiple inheritance and can overload every single operator and cast type that exists in Sputnik.

Class functions are public by default and do not require a public keyword infact the public keyword does not even exist however private keyword does exist this was done to keep the language simple and only use keywords it actually needs.

Classes can use properties just like C# where you can make a $var { get { } set { } } you can optionally include both or just one.

Classes do support abstract properties and abstract functions and any class that inherits must include them.

Classes can include static functions that can be called by name such as MyClass::FunctionName();

Classses support many __ magic functions including __Call() that allows you to use a class a function like $class("hello world"); as well as everything else you would expect to be available.

There are dozens of operators that dont exist in other languages as well as many that unique to other languages for example:

.. from Perl is included and expanded in features to work on arrays and all kinds of stuff.

[] from PHP exists to add elements the end of the array but also includes []! to add to the beginning of the array.

-> is used for class objects $a->$something;

->> and =>> are used to shift a variable into the first argument of a function and the one with = modifies in place which is very useful for chaining functions like

$return = $a->>substr(1)->>substr(0, 8)->>substr(1);

The Perl "my" is supported to make variables exists in the local scope only and every { } is considered a local scope you can also use @{ } instead of { } to avoid creation of a scope if you wish to speed up the app by a fraction of a microsecond.

You do not need to include Global $Var; inside a function to access a global instead globals are always accessible by name and you can also access globals even if a local is taking its place by placing Global before its name such as print(Global $a);

There are a bunch of operators for joining arrays and even dictionaries together without ever having to use loops such as the [<>] and [<=>] operator both of which can be seen on the wiki.

x and xx are used for repetition the xx will specifically return arrays where as x will only repeat what it is given.

InstanceOf or C# "Is" is done in Sputnik using ~~ (or Is) to check if it is that type or !~ (or IsNot) to check if it is not that type you can also use add an additional ~ to the end of !~ and ~~ for strict checking.

Sputnik supports @"" for mult line static strings and is also static you can also use the Perl style of using q~hello~ (and a dozen other things instead of ~~) to easily place strings that may contain " and ' inside them without the need to escape.

There is also array("test", "cat") like PHP but also qw(Test Cat) (and qww for dictionaries) like Perl etc.

++ and -- can be used many times for example $a++++++; will increase $a by 5.

All binary operators and bit shifting work as expected and even ** exponents is available.

. is used to join strings and other objects into a string but also ..= can be used to join strings at the beginning of .= which joins at the end.

== is used to check if stuff are equal such as $a == "Test" is valid and checks the chars and not the instance also you can use === to check strictly (data types must match as well)

!= and !== same as above but in reverse.

The Perl <=> is supported fully.

The Perl Vec() is supported fully and functions just as good with all operators and everything but also supports 64-bits.

You can also use eq to test as a STRING mode only (case sensitive) and eqi to test case insensitively there is also the following ones neq, neqi. lt, gt, le, ge, lti, gti, lei, gei, lg, lgi these operators compare their values as String only but if you use on an array it will look inside the arrays and compare the elements as strings.

The usual < > >= operators exist and do also compare all elements of arrays (even recursively).

&& AND || OR can also be used and as expected the || to the right is not called if the || to the left is satisfied.

You can also do stuff like print("hello") if($a == "test") or die("failed"); which is a nice feature from Perl you can also do that with every loop type.

? : is supported such as print(1 ==2 ? "yes" : "no"); you can also negate it using !? for example print(1 ==2 !? "yes" : "no");

!! and ?? work just like C#.

Switch/Select exist the Select basically scrolls through a list of statements and see if they are *true* it does not compare them to anything its like a multi if but easier than doing tons of else if where as the Switch will compare a value against its cases.

The switch/select have several advantages over most languages first off you can do *ranges* on the case even provide an array to use (so it checks all values in the array for a match) there are also a dozen *named* labels you can jump to such as PREV/NEXT. You can also give your Case its own name so you can jump to it. These jumps are internal and are super fast (unlike goto) since it already knows where to jump to and does not need to resolve anything.

There is a Do...While(), Do...Until(), While(), Until(), For() and Foreach() the For() works the same as C but you can also use it the same as Perl like for( 0..10 ) and for (0..10 as $i) you may also include steps such as for(0..10 as $i by 2). Of course the loops all support Regexes and will loop through matches. Also the Foreach() can loop through chars in a string, arrays and pretty much everyhting you can also choose steps in that as well (every 2nd element in the array). Foreach is easy to type example Foreach($array as $value) dictionaries are Foreach($array as $key => $value).

There is support for LINQ and it works pretty much the same as does in C# which makes it awesome for processing classes.

There are thousands of @Macros similar to AutoIt but many AutoIt doesnt have such as @Hiragana for char sets and other useful features which are good for parsing data and what not.

You can also do Unless() and Else Unless() if you want a negative If statement.

Enums are pretty powerful and will automatically add the numbers for you but u can also place = in the enum and it will continue adding after that point you can also give enums a FLAGS rule that will automatically give binary FLAG values.

You can splice arrays like in Perl using the , in the [ ] index.

Binary in Sputnik is never *copied* and is always REFed so its super super fast to move around and do stuff with binary data and there are about 100+ functions directly related to binary management.

There is a very powerful Pack()/Unpack() that includes everything of PHP/Perl and a bunch of stuff they do not have.

Sprintf() and Printf() are also equally unique having dozens of features not found anywhere else including separators and you can use arrays for the %elements etc etc all kinds of cool stuff.

There are many many math functions that should satisfy most people.

There is about 300 string functions including serializers, jsons encoders, powerful CSV parser and other cool stuff that saves a LOT of time when working with String data they are also very fast.

There are many powerful array functions to make working with arrays a breeze.

You can dynamically call DLL files and Windows APIs similar to DLLCall() in AutoIt but with more complex feature set and support to convert DLL functions into *core* functions and even dump them as a DLL to load back later so super speed loading/calling of thousands of APIs.

There are many useful and easy to use file/directory etc functions.

There is built in support for MySQL and raw sockets even many examples of how to use such things.

Sputnik also includes a very simple to use socket library that is meant for Sputnik to Sputnik communications and as such provides a super easy to use socket library with examples for that.

You can dynamically allocate/free memory and read/write to allocated memory using functions or directly using [ ] similar to assembly for example you could do PTRWrite($addy, (float)100); to write a float or you could do [$addy]:f = 100; you can also += etc etc everything you would expect.

You can create C/C++ structures (literally) and get/set stuff from their structure similar to DLLStructCreate() in AutoIt but much more powerful and even supports structs inside structs and other complex things.

There is a decent GUI system (it is old and hasnt been deved in ages) that can be used to make simple GUIs no limit to how many window can be on screen at once.

Sputniks IDE is made in Sputnik (infact the IDE is made in the IDE) and features a decent editor with syntax+auto completion and visual GUI builder similar to Visual Basic 6.0 where you place button and add events such as OnClick() which get added to the source for you automatically.

You can search pixels on the screen and create aimbots or bots etc.

Sputnik has really powerful features to read/write memory of other programs even so much as making use of pack/unpack to make things even easier.

You can obtain detailed information on the current line of code and about a function by name or class etc.

You can do negative bit shifting 0xF0 >> -1 (translates to 0xF0 << 1)

Sputnik can work as a CGI and even includes a webserver example just for fun of it.

There have been games made in Sputnik including Pengo which is include in the Example folder it is a remake of the Amiga Pengo game by MartinSoft.

You can embed Sputnik in C# and other .NET languages quite easily and make it handle scripting support for you with callbacks etc.

There are many good examples in the Examples folder including Trainers and all kinds of cool stuff.

And many many more things.

How is Sputnik work internally?

The Sputnik scalar (SV) is a huge 8000+ line C# class that handles the vast amount of things the $Variable can do internally (but does not include any of it's functions such as string functions all that is seperate) such as converting double to int etc etc this can also be used in embedded from when the Sputnik.dll is referanced. It is a very nice variable type to use even outside of Sputnik itself.

The Sputnik array (AV) is another huge class of about 3000 lines and is basically a special dictionary that supports array indexes as well as string keys (just like PHP) and has a wide array of features and can be used in C# as a stand along array outside of Sputnik by referencing the Sputnik.dll.

Sputnik is good at being a stand alone scripting language or used as an embedded language in C# or something .NET.

Sputnik has a huge grammar sheet that is converted into BISON like objects and when a script file is parsed it is first preprocessed for stuff like #define #if etc then it is broken up into Tokens using the parser each token is a class object for example the entire definition of a Function it's params its statement is returned as a single class.

Sputnik then finds the entry point and begins executing it running each statement at a time it keeps a stack of global variables per Sputnik inteperator however a local variable scope is created every time a { } is encountered.

Every single Function also creates it's own variable scope totally independant of anything else (aside from globals which are univsersal) this means even if 50 threads were running the same function they wouldnt share local variables or get in each others way (You can of course thread-lock Sputnik code to avoid issues).

When Sputnik wishes to call a function is creates everything it needs resolves all params and runs the function it does not push stuff onto the stack like Lua etc instead everything is contained within the Function itself.

Sputnik core functions are very very fast as they are raw C# code.

A class in Sputnik is actually an Array with a name (there is a real class object of the original type but everything that creates an instance of it only needs an array and the name of the class) so when you do printr($class) you will notice it prints just like an array but with the name of the class.

All of the parsing stuff that Sputnik uses to parse the code you write can also be used by YOU since you create your own parser with an easy to use beginner friendly way that Sputnik provides it basically this is for people who want something stronger than RegExp can use the parser engine (The same one Sputnik uses internally) to parse anything you desire.

Compile your code

You can compile your Sputnik code into a .EXE for easy sharing.

You will notice there is a Compiler.exe and a CompilerW.exe.

The first one makes a CONSOLE based application that will show the console (You can of course hide/show the console at runtime using the ConsoleHide() and ConsoleShow() functions).

The second one will provide a windows application that does not show the console since there is no console any errors will appear as a message box instead.

Help Sputnik

Do you wish to help the project out? That would be nice. I need people willing to play with and test Sputnik and make stuff in Sputnik which will help locate any issues and provide new things we can add/improve.

Another thing I need is people who are willing to make *test* cases as you can see in the Lib/TestCases folder I started making some but I need a test case for every feature and function that exists in Sputnik so I can run the tests and make sure everything is working good.

My current tests are very helpful in making sure any updates I make dont break things.

Future

I don't know what the future for Sputnik is however it is a good language and if people would give it the time to try it out properly they would like it.

I make Sputnik because I personally use it and I enjoy coding in Sputnik it is nice and easy and very powerful and gets things done that I would otherwise not have fun doing.

I would like to see people take an interest in Sputnik but the hard people is getting people to realize just how useful Sputnik can be.

Sputnik is a good language and if people would give it a chance they would see it's good too.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox