Log in

View Full Version : A new age of code!?



ZERO
07-15-2012, 05:32 PM
Sourcemod 2 is on the way. This will result in major reprogramming of most mods to take advantage or new features and better performance:


Why?

The original SourcePawn compiler is extremely old. It was written by ITB CompuPhase in the 1990s and was originally based off a 1984 journal submission. It is nearly impossible to maintain. The binary format (".smx") is also archaic and inflexible, inhibiting almost any modern language feature or performance improvement.



Tell me more!

SourcePawn 2 runs plugins directly from source. That means you can drop ".sp" files in your plugins folder and they just work. Offline syntax and type checking is also supported. There are no plans to remove .smx support, however, .smx files will not be able to take advantage of SourcePawn 2.

My goal is to support enough SourcePawn language features that 70% of plugins on the forums will work. From there I'll evaluate what features are remaining and whether they're worth adding. In this initial prototype, enough features are working to write very simple plugins, though #include does not work so you must declare natives manually.

Here are the known language features I have not implemented, but will implement:

Const with non-refs
Array literals
Float comparison
Non-branching comparison
Global variables
Dynamic arrays
#include <>
Array slicing
Float comparisons
Booleans
The any: tag
Optional semicolons
Chained relational operators
Ternary expressions
Passing functions as variables/parameters
SortCustom2D, SortStrings
Very limited, specific uses of #if and #define


Eventually, if/as the language reaches maturity, I will start adding new language features that people have been requesting:

Resizable arrays
Global dynamic arrays
Structs
Classes
Closures/nested functions
Discriminated unions
Dynamic types
First-class FFI


SourcePawn 2 includes garbage collection. I've implemented a very basic garbage collector that only runs on map changes. For most use cases I've managed to maintain SourcePawn's performance and memory guarantees surrounding arrays, which is great.

Aside from that, the entire architecture is much more amenable to high-powered performance optimizations than SourcePawn 1. Although the implementation right now is simple (GC is not realtime, and the execution mode is an interpreter), the entire architecture is geared toward making an advanced GC and an optimizing JIT very easy.

Now for the bad part:

There are many language features I will not implement. They are either too difficult to support in a modern design, or they are inherently bad features that may impede progress. Next to each I've listed what the eventual replacement will be:

Enum structs (replacement: actual structs)
#pragma semicolon (replacement: none, semicolons cannot be required)
#define X Y (replacement: use "const" or "static const")
#define X() ... (replacement: none, use functions)
#pragma (none, #pragmas are unneeded and will be ignored)
funcenum (replacement undecided)
Anything in <functions.inc> (replacement: module system like Java/C#)
Variadic arguments (replacement: alternate syntax I can talk about later)
Using String: as a non-array tag (replacement: none)
Tag mismatches as warnings (replacement: none, these are bugs)
#include "" ("use" keyword)
Enums with non-uniformly typed values (replacement: none, these are bugs)
Naming enums "Float", "String", "bool", etc. (replacement: none, these are bugs)




#pragma semicolon (replacement: none, semicolons cannot be required)

http://nooooooooooooooo.com/vader.jpg

Programing without semicolons!? IMPOSSIBLE!!!!!!!!!!!!!

https://s3.amazonaws.com/data.tumblr.com/tumblr_lwdap8GGU51qzr075.jpg

StarsMine
07-15-2012, 05:44 PM
So use commas in your loop initialization instead?

H3X
07-15-2012, 05:53 PM
Well, I used to code for AMXX(pawn). How much different is sourcepawn?

inthebutt
07-15-2012, 06:15 PM
Sourcemod 2 is on the way. This will result in major reprogramming of most mods to take advantage or new features and better performance: Now for the bad part:#pragma semicolon (replacement: none, semicolons cannot be required)http://nooooooooooooooo.com/vader.jpgPrograming without semicolons!? IMPOSSIBLE!!!!!!!!!!!!!https://s3.amazonaws.com/data.tumblr.com/tumblr_lwdap8GGU51qzr075.jpg"written by ITB" your welcome people.

taz1stP
07-15-2012, 06:51 PM
so is this gana rebrake wcs?

ZERO
07-15-2012, 09:09 PM
No it is reverse compatable but things that have a LOT of code like wcs will want to be reprogramed for this b/c it will run MUCH FASTER AND MORE STABLE.

ZERO
07-15-2012, 09:27 PM
Wait after reading more closely:

Here are the known language features I have not implemented, but will implement:

Optional semicolons

taz1stP
07-15-2012, 09:53 PM
so how long will it take to reprogram all this?

yours' truely
07-16-2012, 07:29 AM
Are we there yet?

Chef C Green
07-16-2012, 02:30 PM
Is this going to be a sudden change (ex: BAM! it comes out, and automatically get uploaded to the servers), or will you be setting it up on the test servers to play around with before initilizing the changes on the servers?

Also, you mentioned putting in a "basic garbage collector that runs on map changes". Does this pertain to random data or are you talking about the actual mapvote code? I guess what I mean is; will you be able to reprogram some of the mapvotes to better circulate the maps (most noticeable on zmod I feel, it tends to go towards the escape maps and older cade maps that were put on the server furthest back) when this new system is put in place?

Steamer
07-19-2012, 11:03 AM
"written by ITB" your welcome people.
http://www.mememaker.net/static/images/memes/493224.jpg
:icon_mrgreen:


Wait after reading more closely:

Here are the known language features I have not implemented, but will implement:

Optional semicolons

http://www.mememaker.net/static/images/memes/493211.jpg

Seriously though, all for faster and stabler. Seems like a decent amount of added work to do though.

CYBER
07-19-2012, 11:15 AM
im all for faster and more stable, but my main concern is wcs.
we just broke even with reprogramming the races to work on the server, would your priority to finish making the races THEN start upgrading each one to SP2 (tedious process), or will you halt the race making, go SP2, and THEN carry on making the races automatically compatible with the new system?

and as chef asked, will this be an instant upgrade, where the server would go down a bit, then replaced by a new version of it, or is it progressively upgraded part by part while live?

will this help you for example find a non-hardcoded fix for the left hand glitch? since we established that the most problable cause for that glitched is the source engine itself?