Recommended Posts

If your application consists mainly of boilerplate code like setting up forms and hooking up events, then there's not much that a functional language can do about it. You'll have the same boilerplate in a slightly different syntax. But if you have any sort of complexity beyond that then there's no doubt that at least being able to think functionally, regardless of language, helps tremendously. Few things have been as efficient in terms of improving my coding skills than learning a bit of F#. 

More generally, I'd say it can help a lot with thinking in terms of data-parallelism and getting the programmer out of a sequential frame of mind.

More generally, I'd say it can help a lot with thinking in terms of data-parallelism and getting the programmer out of a sequential frame of mind.

Yes, but even in sequential code, favoring pure functions has proved a very useful rule of thumb. I've often exposed existing bugs just by refactoring to use pure functions.

Yes, but even in sequential code, favoring pure functions has proved a very useful rule of thumb. I've often exposed existing bugs just by refactoring to use pure functions.

Unexpected state: the cause of 99% of bugs (Don't quote me on that though)  ;)

Even if the base framework doesn't support "HiDPI" you can always correct that through code.

Lol look at their "better security": Enhanced Support for NSA Suite B Cryptography

 

java is ####ing disgusting...

Research what it actually is before jumping to conclusions, because Suite B covers AES/ECDHE/SHA2, which are all really good and secure.

It is nice to know that Java now has lambdas, but it is very late in the game.

Java has nothing to offer for me to switch from C# .NET, the only advantages are slightly more powerful generics and interfaces.

 

I think I understand.  I guess I just don't see why you would do like:

Well lambdas are split into two categories, (C# side)

1. Functions take in parameters, if any, and return something.

2. Actions take in parameters, if any, and return void.

Ability to create functions and actions with ease and little code overhead is excellent.

For example,

 

public abstract class IImage<T> where T : struct
{
	// other code
	protected IImage<T> _mathOp(Func<T, T> _func, bool _parallel)
        {
            if (_parallel)
            {
                Parallel.For(0, this._data.Length,
                    i => this._data[i] = _func(this._data[i])
                        );
            }
            else
            {
                for (int i = 0; i < this._data.Length; i++)
                {
                    this._data[i] = _func(this._data[i]);
                }
            }

            return this;
        }
}
Note that I use a lambda (Action<int>) which accepts index i as input for parallel for loop.

Then I can just use that function, like so,

 

public class ComplexImage : IImage<Complex>
{
	// other code
		
	public override IImage<Complex> Log10(bool parallel = true)
        {
            return _mathOp(Complex.Log10, parallel);
        }
		
	// Complex.Sin, Complex.Cos, Complex.Tan, Atan, Sqrt, Exp...
}
Just one line of code. No need to create a class implementing an interface with

"public Complex Math(Complex c);" and pass it in.

Another example,

        public static IImage<Complex> Add(params IImage<Complex>[] images)
        {
            return Run((a, b) => a + b, images);
        }

        public static IImage<Complex> Subtract(params IImage<Complex>[] images)
        {
            return Run((a, b) => a - b, images);
        }
Edited by _Alexander

It is nice to know that Java now has lambdas, but it is very late in the game.

Java has nothing to offer for me to switch from C# .NET, the only advantages are slightly more powerful generics and interfaces.

 

Well lambdas are split into two categories, (C# side)

1. Functions take in parameters, if any, and return something.

2. Actions take in parameters, if any, and return void.

Ability to create functions and actions with ease and little code overhead is excellent.

For example,

 

public abstract class IImage<T> where T : struct
{
	// other code
	protected IImage<T> _mathOp(Func<T, T> _func, bool _parallel)
        {
            if (_parallel)
            {
                Parallel.For(0, this._data.Length,
                    i => this._data[i] = _func(this._data[i])
                        );
            }
            else
            {
                for (int i = 0; i < this._data.Length; i++)
                {
                    this._data[i] = _func(this._data[i]);
                }
            }

            return this;
        }
}
Note that I use a lambda (Action<int>) which accepts index i as input for parallel for loop.

Then I can just use that function, like so,

 

public class ComplexImage : IImage<Complex>
{
	// other code
		
	public override IImage<Complex> Log10(bool parallel = true)
        {
            return _mathOp(Complex.Log10, parallel);
        }
		
	// Complex.Sin, Complex.Cos, Complex.Tan, Atan, Sqrt, Exp...
}
Just one line of code. No need to create a class implementing an interface with

"public Complex Math(Complex c);" and pass it in.

Another example,

        public static IImage<Complex> Add(params IImage<Complex>[] images)
        {
            return Run((a, b) => a + b, images);
        }

        public static IImage<Complex> Subtract(params IImage<Complex>[] images)
        {
            return Run((a, b) => a - b, images);
        }

Ah okay.  I have a feeling I am going to need to read into this.   I have never had to deal with programming like that.  Been programming more or less the same for the past 4 years at my job.  Parallel computing and advanced math is something that's never been an issue.  For threads I just use either a thread or background worker and all is taken care of.   However I can definitely see where knowing parallel computing, functional programming etc, can be good to know.

This topic is now closed to further replies.
  • Posts

    • But building your own.. what? You can't build anything like the Steam Machine yourself. Even trying to get close costs a good deal more. Even just the CPU cooler in their price comparison is as big as the entire Steam Machine. If you want a regular gaming PC, then by all means, build that. If you want a a small console-like PC for the living room that is good for gaming, I'm not sure what else is a better deal. In the GN review, they only mentioned a small form factor Dell, which is like twice the size and hundreds of dollars more expensive.
    • Those are some popular multiplayer games. But hardly "all". Just those that don't work on Linux currently due to specific anti-cheat implementations. I think it's also fair to point out the literally thousands of games that don't work on the PS5. And it's not locked at 1080p. That's the default, which you can change.
    • Ubuntu Livepatch arrives on Arm64 to eliminate system reboots for kernel updates by Paul Hill Canonical has just announced that its Livepatch service now supports computers with Arm64 processors. For those who are not familiar, Livepatch allows users to apply important kernel updates without any service interruption or rebooting. While home users will benefit from this, it’s even more important for critical machines that absolutely should not be going offline at all. The feature is available as part of Ubuntu Core 26 for Arm64 and Ubuntu Core 20 and onwards for AMD64. According to Canonical, this will improve the security of systems that aren’t security-maintained daily or weekly, and it helps organizations work towards Cyber Resilience Act (CRA) compliance. If you are familiar with Ubuntu, you probably know that most packages can be updated without having to restart the system. There is one big exception to this, and that’s the kernel; it typically requires you to reload the system to boot into the new kernel. With Livepatch, Canonical has done something so that you don’t need to restart to begin using the new kernel. Aside from Ubuntu Core 26, users with Arm64 chips running Ubuntu 26.04 LTS can also use Livepatch. If you want to learn more about Livepatch, check out its product page. There, you can also find a button to join Ubuntu Pro (it’s free for several home devices) so that you can enable Livepatch. By linking your computer to Ubuntu Pro, you will also extend the life of your Ubuntu install from five years to ten years. If you are running Ubuntu, let us know in the comments if you have been looking forward to this feature on your ARM-based computer. If you’ve had a compatible AMD64 machine for a while and never used this feature, let us know why in the comments!
  • Recent Achievements

    • One Month Later
      nates earned a badge
      One Month Later
    • Week One Done
      Almohandis earned a badge
      Week One Done
    • Rookie
      dorf went up a rank
      Rookie
    • First Post
      mike_rumble earned a badge
      First Post
    • Dedicated
      tuben earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      +Edouard
      206
    3. 3
      PsYcHoKiLLa
      97
    4. 4
      Michael Scrip
      89
    5. 5
      neufuse
      71
  • Tell a friend

    Love Neowin? Tell a friend!