• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Best of the Wurst 7

Status
Not open for further replies.
Level 23
Joined
Jan 1, 2009
Messages
1,608

After a small summer break we return this month with many bugfixes and improvements to WurstScript quality of life and overall user experience.

Make sure your wurst setup tool is up to date and then update your wurst installation to get improved handling of wc3 patch versions, some new code inspection warnings, and new optimizer features.

Tool updates

  • The VSCode runmap command now more reliably detects patch level - fixes several cases of "black screen" when starting the game.
  • Warnings and errors about *improper usage of @compiletime* have been added, which aids in avoiding some user level programming issues.
  • A handful of new wurst optimizer features (see below).
  • Valid function names in Wurst, such as 'set' and 'debug' no longer generate invalid output Jass.
  • We have updated JMPQ once again to improve performance and compatibility of wurst with maps not built with the vanilla world editor, e.g. YDWE and w3x2ini (Thanks to @WaterKnight)
  • Shoutout to users @dulingzhi and @DengSir for contributions to the VSCode editor experience: Highlighting improved (PR #36), and language-server now better starts automatically (PR #37)

Standard library

Many new features and many merged pull requests! The standard library is doing great - here are some notable changes:

  • The Upgrade Object Editing package has been improved and completed by #77
  • Missing extension functions and tuple wrappers have been added by #79, #80, #81, #82, #84, #85, #86, #87, #88, #89, #90, #91
  • The TerrainUtils package has been refactored for better integration and advanced functionality by #67
  • LinkedList#sort has been fixed to not have exponential performance anymore
  • ClosureEvents have been added to the standard library. A new package for easy encapsulated event listening.
    Code Sample:
    Wurst:
    EventListener.onPointCast(hero, MY_SPELL) (caster, target) ->
       forUnitsInRange(target, 256) victim ->
          caster.damageTarget(victim)
    Big thanks to all the amazing contributors!

 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,608
Spotlight: Code Optimizations

Did you know that the wurst compiler supports a number of automatic optimizations that keep your map script small & fast? (Discussed further in Wurst for vJass Users).

This month we have added numerous new optimizer improvements, making this feature of wurst more powerful than ever. Here's a summary:

  • The wurst package initialization now only uses one trigger for all inits.
  • Duplicate initial branch statements without side effects are now merged outside the branch.
  • Consecutive statements of set and exitwhen are now merged into one if applicable.
  • Sums of the same variable or function are now rewritten (a + a => a*2) which improves the effectiveness of other optimizations.
The great thing about new optimizations is that they cause something like an avalanche effect. Meaning that due to these 'minor' changes in the output code, other already existing optimizations can now be applied over again successfully, where they didn't change anything before.

You can always check the output code in the _build/output.j.txt file. Here is a small example:
Wurst:
let g = CreateGroup()
for u from g
    u.addHP(100)
Turns into:
JASS:
local group from = CreateGroup()
local unit iterUnit
loop
    exitwhen FirstOfGroup(from) == null
    set iterUnit = FirstOfGroup(from)
    call GroupRemoveUnit(from, iterUnit)
    call SetUnitState(iterUnit, UNIT_STATE_LIFE, GetUnitState(iterUnit, UNIT_STATE_LIFE) + 100.)
endloop
set from = null
set iterUnit = null

Thanks for reading, we hope you enjoy these posts - and as usual, let us know what you think.

p.s.: If you haven't starred the Wurst repository yet, please do so to help us get to 100 stars!

Cheers!

-Frotty
 

Deleted member 219079

D

Deleted member 219079

vjass
upload_2018-7-31_1-42-6.jpeg
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Frotty vs MindWorX (Wurst Vs vJASS)...

That is .. surreal, now that vJASS is officially supported in the latest PTR patch, although not likely to be maintained unless issues spring up otherwise (such as default 8190 allocation).

Uhm..?

awesome stuff! I love seeing these news batches.

about the "for u from g"--that is pretty neat--although i wonder if it should be more explicit that the group is being mutated. Unless you guys only compile it that way if g isn't referenced later in the scope?

Thanks Paf :) It's mostly for the example's sake. For in copies the group, keeping the original intact, For from mutates it.
Me personally I prefer lambda syntax and thus usually use closure variants like .forEach() element -> or .removeIf() element -> etc.
But the output code gets a bit more complex.
 
Thanks Paf :) It's mostly for the example's sake. For in copies the group, keeping the original intact, For from mutates it.
Me personally I prefer lambda syntax and thus usually use closure variants like .forEach() element -> or .removeIf() element -> etc.
But the output code gets a bit more complex.

oo got it. That makes sense.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Here only WURST language syntax? Can't support C language ?
Wurst also supports a vJass-ish dialect Jurst and vanilla Jass.

Sad :( Looks interesting, but ... I do not want to jam the head with junk, Jass vJass cJass wUrst ... (
Don't worry, you just need to get rid of your jass junk once.
But if a mere syntax stops you from using or learning something, you might not be ready to embrace the Wurst yet ;)
 
Status
Not open for further replies.
Top