Skip to content

Conversation

@tlgkccampbell
Copy link

Hello,

I saw your post on /r/gamedev the other day and was very impressed with your project, but since I don't work with Unity I wasn't able to make use of it. So I've taken it upon myself to create a Visual Studio solution and refactor what code was necessary to make the project run on the Microsoft CLR. I'm new to this whole github thing, so forgive me if I've screwed anything up.

By far the most significant change was that I renamed Smooth.Tuple to Smooth.Stuple in order to avoid conflicts with the System.Tuple type. I was hesitant to make a breaking change like this, but the alternatives seemed worse.

Other than that, only a few changes were necessary:

  1. A new flag, STANDARD_RUNTIME, is set by the VS project in order to identify a non-Unity environment.
  2. All references to the UnityEngine logging methods were replaced with calls to a new class in Smooth.Debugging, which uses System.Diagnostics.Debug in the standard CLR.
  3. Under the standard runtime, references to UnityEngine's RandomRange method in IListExtensions were replaced with calls to a thread-local static instance of System.Random.
  4. Alternative versions of the BasePlatform and PlatformExtensions classes are used which do very (very) simple platform checking based on Environment.OSVersion and which assume that JIT is always available.
  5. The Smooth.Compare Configuration class was updated to skip Unity types when STANDARD_RUNTIME is set.

I think that about covers it. Please let me know if you have any questions or concerns.

@pdo400
Copy link
Owner

pdo400 commented May 7, 2014

Interesting!

I can't apply this as, well, I'm using a decrepit version of .Net and I like using the name Tuple.  :)  It's really a language deficit of C# that this collision can't be fixed in a clean way with some sort of "using" statement here due to the generics.

Have you measured the performance of Slinq vs LINQ with the latest runtime and libraries?  It would be harder to factor in the deferred cost of GC than in the Unity graphs, but I'd be interested in the up-front differences.

And, yeah, the platforms only really matter for JIT.  Which I suppose would be important on MonoTouch.  And this library and especially Smooth.Compare could be useful for people on that platform as I believe it still has issues with generic value type comparisons.

Hmm...  Something like this may have to be applied after all.  And then maybe branched or have a script to create Unity builds.  Though Unity form is what I use and would be updating.

(Actually, I've decided to put an end to my "one programmer with no funding and no art" game development dreams and get a real job again, so brushing up on Scala and real world stuff will take priority over anything else for a while.)

On Tuesday, May 6, 2014 7:18 PM, Cole Campbell notifications@github.com wrote:

Hello,
I saw your post on /r/gamedev the other day and was very impressed with your project, but since I don't work with Unity I wasn't able to make use of it. So I've taken it upon myself to create a Visual Studio solution and refactor what code was necessary to make the project run on the Microsoft CLR. I'm new to this whole github thing, so forgive me if I've screwed anything up.
By far the most significant change was that I renamed Smooth.Tuple to Smooth.Stuple in order to avoid conflicts with the System.Tuple type. I was hesitant to make a breaking change like this, but the alternatives seemed worse.
Other than that, only a few changes were necessary:
1. A new flag, STANDARD_RUNTIME, is set by the VS project in order to identify a non-Unity environment.
2. All references to the UnityEngine logging methods were replaced with calls to a new class in Smooth.Debugging, which uses System.Diagnostics.Debug in the standard CLR.
3. Under the standard runtime, references to UnityEngine's RandomRange method in IListExtensions were replaced with calls to a thread-local static instance of System.Random.
4. Alternative versions of the BasePlatform and PlatformExtensions classes are used which do very (very) simple platform checking based on Environment.OSVersion and which assume that JIT is always available.
5. The Smooth.Compare Configuration class was updated to skip Unity types when STANDARD_RUNTIME is set.
I think that about covers it. Please let me know if you have any questions or concerns.


You can merge this Pull Request by running
git pull https://github.com/tlgkccampbell/smooth.foundations master
Or view, comment on, or merge it at:
  #1
Commit Summary
* Created solution and project for full runtime port
* Removed Unity-specific scripts and tests, refactored project to build under full CLR
* Renamed Smooth.Tuple to disambiguate from System.Tuple. Upgraded project to .NET 4 Client Profile.
* Added basic logging to System.Diagnostics.Debug
* Added basic platform checking for desktop platforms
* Basic cleanup/refactoring
* Added FULL_RUNTIME flag to Release build
* Checked in missing file
* Renamed FULL_RUNTIME to STANDARD_RUNTIME
* Fixes for Mono compatibility
* Apparently it's trickier to determine whether Mono is running on OSX than I originally thought, so I've simplified the platform check. It doesn't matter anyway; all currently-supported platforms are the same from a JIT perspective.
* Cleaned up logging methods
File Changes
* A .gitattributes (63)
* R Assets/Smooth/Foundations/Algebraics/Stuple.cs (274)
* M Assets/Smooth/Foundations/Collections/IListExtensions.cs (20)
* M Assets/Smooth/Foundations/Collections/IListStepper.cs (6)
* M Assets/Smooth/Foundations/Compare/Configuration.cs (29)
* M Assets/Smooth/Foundations/Compare/Examples/ExampleConfiguration.cs (3)
* M Assets/Smooth/Foundations/Compare/Factory.cs (17)
* M Assets/Smooth/Foundations/Compare/Finder.cs (15)
* A Assets/Smooth/Foundations/Debugging/Debug.cs (25)
* M Assets/Smooth/Foundations/Delegates/Tupled.cs (68)
* M Assets/Smooth/Foundations/Dispose/DisposalQueue.cs (13)
* A Assets/Smooth/Foundations/Platform/BasePlatform.StandardRuntime.cs (35)
* R Assets/Smooth/Foundations/Platform/BasePlatform.Unity.cs (2)
* A Assets/Smooth/Foundations/Platform/Runtime.StandardRuntime.cs (40)
* R Assets/Smooth/Foundations/Platform/Runtime.Unity.cs (6)
* A Assets/Smooth/Foundations/Properties/AssemblyInfo.cs (33)
* M Assets/Smooth/Foundations/Slinq/Collections/Lookup.cs (2)
* M Assets/Smooth/Foundations/Slinq/Context/ChainedOrPooled/ZipAllContext.cs (22)
* M Assets/Smooth/Foundations/Slinq/Context/ChainedOrPooled/ZipContext.cs (24)
* M Assets/Smooth/Foundations/Slinq/Context/Mutation/BacktrackDetector.cs (3)
* M Assets/Smooth/Foundations/Slinq/Context/Simple/IListContext.cs (24)
* M Assets/Smooth/Foundations/Slinq/Slinq.cs (18)
* M Assets/Smooth/Foundations/Slinq/Slinqable.cs (10)
* M Assets/Smooth/Foundations/Slinq/Test/SlinqTest.cs (104)
* A Assets/Smooth/Foundations/Smooth.Foundations.csproj (131)
* A Assets/Smooth/Foundations/Smooth.Foundations.sln (22)
Patch Links:
* https://github.com/pdo400/smooth.foundations/pull/1.patch
* https://github.com/pdo400/smooth.foundations/pull/1.diff

Reply to this email directly or view it on GitHub.

@pdo400
Copy link
Owner

pdo400 commented May 7, 2014

Btw, I would love to move this discussion to my (completely empty) forums so others may be able to see it and join in!
On , Patrick Whitesell pdo400@yahoo.com wrote:

Interesting!

I can't apply this as, well, I'm using a decrepit version of .Net and I like using the name Tuple.  :)  It's really a language deficit of C# that this collision can't be fixed in a clean way with some sort of "using" statement here due to the generics.

Have you measured the performance of Slinq vs LINQ with the latest runtime and libraries?  It would be harder to factor in the deferred cost of GC than in the Unity graphs, but I'd be interested in the up-front differences.

And, yeah, the platforms only really matter for JIT.  Which I suppose would be important on MonoTouch.  And this library and especially Smooth.Compare could be useful for people on that platform as I believe it still has issues with generic value type comparisons.

Hmm...  Something like this may have to be applied after all.  And then maybe branched or have a script to create Unity builds.  Though Unity form is what I use and would be updating.

(Actually, I've decided to put an end to my "one programmer with no funding and no art" game development dreams and get a real job again, so brushing up on Scala and real world stuff will take priority over anything else for a while.)

On Tuesday, May 6, 2014 7:18 PM, Cole Campbell notifications@github.com wrote:

Hello,
I saw your post on /r/gamedev the other day and was very impressed with your project, but since I don't work with Unity I wasn't able to make use of it. So I've taken it upon myself to create a Visual Studio solution and refactor what code was necessary to make the project run on the Microsoft CLR. I'm new to this whole github thing, so forgive me if I've screwed anything up.
By far the most significant change was that I renamed Smooth.Tuple to Smooth.Stuple in order to avoid conflicts with the System.Tuple type. I was hesitant to make a breaking change like this, but the alternatives seemed worse.
Other than that, only a few changes were necessary:
1. A new flag, STANDARD_RUNTIME, is set by the VS project in order to identify a non-Unity environment.
2. All references to the UnityEngine logging methods were replaced with calls to a new class in Smooth.Debugging, which uses System.Diagnostics.Debug in the standard CLR.
3. Under the standard runtime, references to UnityEngine's RandomRange method in IListExtensions were replaced with calls to a thread-local static instance of System.Random.
4. Alternative versions of the BasePlatform and PlatformExtensions classes are used which do very (very) simple platform checking based on Environment.OSVersion and which assume that JIT is always available.
5. The Smooth.Compare Configuration class was updated to skip Unity types when STANDARD_RUNTIME is set.
I think that about covers it. Please let me know if you have any questions or concerns.


You can merge this Pull Request by running
git pull https://github.com/tlgkccampbell/smooth.foundations master
Or view, comment on, or merge it at:
  #1
Commit Summary
* Created solution and project for full runtime port
* Removed Unity-specific scripts and tests, refactored project to build under full CLR
* Renamed Smooth.Tuple to disambiguate from System.Tuple. Upgraded project to .NET 4 Client Profile.
* Added basic logging to System.Diagnostics.Debug
* Added basic platform checking for desktop platforms
* Basic cleanup/refactoring
* Added FULL_RUNTIME flag to Release build
* Checked in missing file
* Renamed FULL_RUNTIME to STANDARD_RUNTIME
* Fixes for Mono compatibility
* Apparently it's trickier to determine whether Mono is running on OSX than I originally thought, so I've simplified the platform check. It doesn't matter anyway; all currently-supported platforms are the same from a JIT perspective.
* Cleaned up logging methods
File Changes
* A .gitattributes (63)
* R Assets/Smooth/Foundations/Algebraics/Stuple.cs (274)
* M Assets/Smooth/Foundations/Collections/IListExtensions.cs (20)
* M Assets/Smooth/Foundations/Collections/IListStepper.cs (6)
* M Assets/Smooth/Foundations/Compare/Configuration.cs (29)
* M Assets/Smooth/Foundations/Compare/Examples/ExampleConfiguration.cs (3)
* M Assets/Smooth/Foundations/Compare/Factory.cs (17)
* M Assets/Smooth/Foundations/Compare/Finder.cs (15)
* A Assets/Smooth/Foundations/Debugging/Debug.cs (25)
* M Assets/Smooth/Foundations/Delegates/Tupled.cs (68)
* M Assets/Smooth/Foundations/Dispose/DisposalQueue.cs (13)
* A Assets/Smooth/Foundations/Platform/BasePlatform.StandardRuntime.cs (35)
* R Assets/Smooth/Foundations/Platform/BasePlatform.Unity.cs (2)
* A Assets/Smooth/Foundations/Platform/Runtime.StandardRuntime.cs (40)
* R Assets/Smooth/Foundations/Platform/Runtime.Unity.cs (6)
* A Assets/Smooth/Foundations/Properties/AssemblyInfo.cs (33)
* M Assets/Smooth/Foundations/Slinq/Collections/Lookup.cs (2)
* M Assets/Smooth/Foundations/Slinq/Context/ChainedOrPooled/ZipAllContext.cs (22)
* M Assets/Smooth/Foundations/Slinq/Context/ChainedOrPooled/ZipContext.cs (24)
* M Assets/Smooth/Foundations/Slinq/Context/Mutation/BacktrackDetector.cs (3)
* M Assets/Smooth/Foundations/Slinq/Context/Simple/IListContext.cs (24)
* M Assets/Smooth/Foundations/Slinq/Slinq.cs (18)
* M Assets/Smooth/Foundations/Slinq/Slinqable.cs (10)
* M Assets/Smooth/Foundations/Slinq/Test/SlinqTest.cs (104)
* A Assets/Smooth/Foundations/Smooth.Foundations.csproj (131)
* A Assets/Smooth/Foundations/Smooth.Foundations.sln (22)
Patch Links:
* https://github.com/pdo400/smooth.foundations/pull/1.patch
* https://github.com/pdo400/smooth.foundations/pull/1.diff

Reply to this email directly or view it on GitHub.

@tlgkccampbell
Copy link
Author

I had a feeling the Stuple thing would be a problem. I'm not a huge fan of solutions that would require branches or build scripts; that kind of complexity rarely seems worth the trouble, in my experience.

What I could do is revert the name to Tuple and change the shared library code to reference it by its fully-qualified name. People using Unity could continue to reference it by its unqualified name, and people using the CLR could resolve the conflict however they feel is best for their purposes. We would just need to take care not to use the unqualified name in any code that's shared between the Unity and CLR versions. How do you feel about that?

As for the performance, this is something that I wanted to explore more deeply when I had time. I did a few quick tests which seemed to indicate that Slinq's performance is usually either on-par with or significantly slower than CLR LINQ, depending on the exact query, but it wasn't anything extensive. My plan was to do more extensive profiling sometime this weekend and try to identify any bottlenecks that we might be able to address.

@tlgkccampbell
Copy link
Author

As you requested, I've created a thread on your forums: https://www.smooth-games.com/forums/showthread.php?tid=98

@pdo400
Copy link
Owner

pdo400 commented May 7, 2014

Sounds good, I should also get rid of the Assets folder.  At first I was going to check in more Unity project level stuff, but then I remembered that other people may be using this on other Unity versions or in MonoDevelop or VS or wherever and that I hate when IDE stuff is in a repo....  Though I noticed that you checked some in.  :)

Anyway, let's take this discussion to the forum thread for here on out.  Having some activity there will be helpful both for the project and for any potential employers who find the site while looking into what I've been up to since I left my last real job.  And having done some interesting C# with deep generics and all that jazz is much better than just having a programmer art game in development.  (!)

On Wednesday, May 7, 2014 9:01 AM, Cole Campbell notifications@github.com wrote:

As you requested, I've created a thread on your forums: https://www.smooth-games.com/forums/showthread.php?tid=98

Reply to this email directly or view it on GitHub.

createdbyx pushed a commit to createdbyx/smooth.foundations that referenced this pull request Apr 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants