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

    • It's about to become harder to turn off your Samsung TV, thanks to Instagram by Aditya Tiwari Meta announced that its Instagram for TV app has arrived on Samsung TVs in the US as part of its latest expansion, giving users one more way to scroll through Reels. The social media giant often comes under scrutiny for the "addictiveness" of its features, which leads people to spend excessive time on the platform. Interestingly, Instagram boss Adam Mosseri described spending 16 hours on the platform as "problematic use" but not "clinical addiction." Mosseri also compared scrolling on Instagram to binge-watching a show on Netflix. Instagram for TV is now available on Samsung TV models released in 2020 or later. The app is already available on Amazon Fire TV and Google TV in the US, which together account for the majority of connected TV devices. The company said it will test several new features to improve the living room and family experience while using Instagram on the big screen. Watching vertical videos on a big screen isn't something many would be excited about. Probably that's why Meta is testing a dedicated home for horizontal videos. Creators will get the opportunity to design content for TV screens and get more ways to reach audiences, according to Meta. If you found an interesting Reel while doomscrolling on your phone, you'll be able to cast it to your TV. The feature is available for testing on Instagram for TV on Google TV and Amazon Fire TV, and it will also support videos from the Saved tab. Instagram for TV will be testing Channels organized around user interests, across genres such as comedy and sports, as well as content from favorite creators. Moreover, you can watch Stories on your TV. While Instagram is known for short-form videos, it's knocking on more doors to keep the audience hooked. The company said it's exploring new content formats for the big screen, including long-form creator content to cover topics in detail, episodic series to build suspense across multiple episodes, and creator live sessions on TV. All of the new updates put Instagram in competition with established giants like YouTube (and Netflix), which already have a robust presence on the big screen. In recent updates, Instagram added the ability to write an individual caption for each carousel image, manually re-order posts, and a paid version of the app.
    • I know RAM and storage prices are high right now, but I think it would have been better to have 1TB as the base level storage, especially as it's supposed to be for gaming. Plus a 2.5gbe ethernet port rather than only 1gbe.
    • I have installed the debloated version of Windows 11 25H2 Pro. I obtained the apps from store.rg-adguard.net. The size of the Photos app window is quite problematic for me; it consistently displays in a 16:9 aspect ratio, resembling a movie theatre screen, and cant remeber its last size and position. The Snipping Tool cannot capture the taskbar. When I select "Window" in capture mode, it allows me to capture menus or individual windows, but I am unable to capture just the taskbar. This functionality was available in version 24! I am on the same version numbers (latesst).
    • I'm already seeing my steam library, still swallowing the 16 Gb of RAM, then looking at the SD storage expansion and saying "what?".
  • Recent Achievements

    • Dedicated
      tuben earned a badge
      Dedicated
    • Week One Done
      mnsgroup earned a badge
      Week One Done
    • Conversation Starter
      sumytbe earned a badge
      Conversation Starter
    • One Year In
      B4dM1k3 earned a badge
      One Year In
    • One Year In
      DarkWun earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      511
    2. 2
      +Edouard
      203
    3. 3
      PsYcHoKiLLa
      97
    4. 4
      Michael Scrip
      82
    5. 5
      neufuse
      67
  • Tell a friend

    Love Neowin? Tell a friend!