Comments

You must log in or register to comment.

tedwards163 t1_iy6nyy3 wrote

This was a very good read. I am not a developer but have worked for a similar software company for some time. Anyone have suggestions on learning how to get into the functional programming?

−4

Ben_aid t1_iy6puwc wrote

Object-oriented and imperative programming aren't going away, but functional programming is finding its way into more codebases.

17

jphamlore t1_iy6qayo wrote

> The debate went on for more than a decade, but in the end, the GOTO went extinct, and no one today would argue for its return.

Has this person ever looked at Linux kernel code written in plain old C?

goto is used all over the place for cleanup after errors, and also frequently for restarting loops.

34

patriot2024 t1_iy6s2lk wrote

A guy found something that works for him and immediately claims it’s the future.

82

HMS404 t1_iy6sb9h wrote

This article reads like a LinkedIn post. Expected better from IEEE but maybe I'm naive.

30

cesium-sandwich t1_iy6sqa6 wrote

I didn't read the article, but do they address how immutability goes against the concept of caching? Also, FP relies pretty heavily on garbage collection, which has been one of my reasons for avoiding some FP paradigms in my work...

−6

superfes t1_iy6thjo wrote

What a waste of brain cells >_>

2

mandogvan t1_iy6twjg wrote

Having worked on functional codebases (legacy code which were actively replacing), I was ready to shit on this article. But it makes salient points, some of which I had not considered.

I think a functional codebase could be successful if architected intelligently and thoroughly beforehand. And everybody on board has to drink the koolaid.

That being said, the functional codebases I have seen have been steam piles of spaghetti. Could it work and work well? Maybe. I’m not going to try it though. Not again.

16

phdoofus t1_iy6u1ar wrote

If it's not good for high performance computing, I can't use it. Well, I might use it to do *some* things but not the main compute part that takes up the vast majority of the wall time.

1

z0mbietime t1_iy6whrd wrote

> I think a functional codebase could be successful if architected intelligently and thoroughly beforehand.

And there it is. This OOP vs functional argument is idiotic. The reality is either can work assuming they were well architected and implemented cause that's all that matters. So many think it's one or the other instead of using both and determining which with common sense.

Is it a thing that has attributes? Boom class. Are you trying to perform some sort of action? Boom function. Is that action coupled to retrieve or update the remote state of the class? Then you have a method. Can the implementation of the method be reused or broken out into smaller reusable pieces that are easier to test? Back to function(s) but maybe call it/them within a method to improve usability. If every engineer followed this simple flow life would be so much easier

11

FranticToaster t1_iy6woo6 wrote

Functional programming is the future of scrambling to solve a problem fast enough to make leaders think a project finished at the catastrophic expense of future users and the next iteration of your team who realize in agony that the application was never designed to scale.

16

Netmould t1_iy6xwx9 wrote

«I think a functional codebase could be successful if architected intelligently and thoroughly beforehand» You have waaaay too much faith in humanity.

You write some prototype code, it works 80% of time, it goes into production right away (because PM didn’t plan time/resources for any tests).

Now when you code works in production, 80% of your time is spent fixing bugs “as fast as possible” and “by any means necessary”.

That goes for some time (years in most cases) until you are getting new CTO (or manager high enough in food chain), who proposes “reorganization”, in other words someone (not you, because you left this company some time ago) has to make a new, “better” system instead of old one.

No one working in the company has the slightest idea about how this software works, so manager hires a subcontractor (some Indian or Philippine guys with accent so thick you don’t understand the word).

After some time (and money) spent, your “new” software works 50% of time, has 50% of old’s functionality, and needs to be translated into proper English.

At this point managers either:

  1. go with “new” system regardless of enduser complains.
  2. if backslash is big enough, they hire proper consultants who costs rocket science amount of money, and they make it work somehow.

Edit: I didn’t called out developers from Asia based on their race or something. Its just IT managers are going for the “cheapest option in the World” when they look for contractors, and (imo) some Asian bodyshops made up out of students are the cheapest. You get what you paid for…

4

ToughAd4902 t1_iy6ytsu wrote

you clearly dont understand what functional programming is. it has nothing to do with putting code into functions, and your example makes 0 sense, classes have functions too... you can not use a single class and not write functional code.

−16

z0mbietime t1_iy6zefh wrote

Oof you should Google before you comment. OOP and functional programming are design paradigms. There are languages that only supports a single paradigm like java. Also a Class "function" is a method...yup. unless you mean a static method but still a method. What I'm describing is a multi paradigm design (if that's the right term) and how to determine what to use.

So yeah, I'd say you clearly don't understand. Here let me Google that for you

https://www.imaginarycloud.com/blog/functional-programming-vs-oop/

https://stackoverflow.com/questions/155609/whats-the-difference-between-a-method-and-a-function

12

ToughAd4902 t1_iy704p8 wrote

Holy shit, what, Java has lambda's, that is functional programming. There is no way you just made that statement and think you have even an inkling of an idea what functional programming is, like you didn't even google if Java supports functional programming. Yes, functions in Java are not first class in themself so you can't write fully functional code, but that doesn't mean it doesn't support significant parts of functional programming.

Also, a function is a method you dimwit, that's literally the same thing, you found some random online definition saying they were different once, but they are literally the same exact thing

Java has lambda's, C# has LINQ (implemented with lambdas) there are plenty of OOP designed languages with functional aspects.

−13

z0mbietime t1_iy71n2d wrote

Java has lambdas, cool? I haven't used it in years so I'll concede this is news to me but it's not a secret it was based on OOP. I think you're laying so hard into this one thing to save face when really you couldve just deleted your original comment.

> Also, a function is a method you dimwit

Yes a function... attached to a class...making it a method. Maybe lay off the name calling if you don't follow on the semantics

And as for linq in C# and lambda in java, congrats, you've successfully described a multi paradigm language. Spoiler alert: almost all of them are

5

ToughAd4902 t1_iy723ej wrote

In years? Java 8 was release in 2014, almost 9 years ago. How many years is "years" in this case? Your entire definition of what functional programming is has NOTHING to do with what actual functional programming is, you should be the one deleting your comment. Every language, literally ever, is going to put code into functions (or methods, if for whatever reason you want to name it that).

According to your definition, C is a purely functional language. Do you understand now how that makes literally 0 sense? C has no classes, nor "methods" with how you want to describe it, and all logic has to exist in functions, this is the first time I've ever heard of C being classified as a functional language

Since you still don't seem to understand the difference: functional languages treat functions as first class citizens. What does that mean? A first class function is when a function can be treated the same as a variable for all purposes. This means they can be assigned to variables, they can be passed as higher order functions and used as a higher kinded type.

Putting logic into a function does not make it functional.

−9

sandman8223 t1_iy729fo wrote

I found it to be non-functional /s

2

z0mbietime t1_iy733wq wrote

Well if you're really that curious, I haven't touched Java since college in like 2012.

Also, maybe read back over my original comment that you so eagerly misinterpreted. Everything I said was language agnostic.

I'm not sure what your goal is other than to look obnoxious honestly. If you want a recap on what I'd originally said it was to use classes where applicable and functions where it makes sense. There is no class concept in pure functional programming. And a function must be attached to a class (aka method) in pure OOP. In other words, nothing I said was wrong soooo what exactly is your problem here?

And yes I do want to call it a method because that is what it's called.

4

Clank75 t1_iy75u9m wrote

Oh no, is it that time again?

The functional programming fad comes round every decade or so, each time a new generation of developers enthusiastic about writing code but not yet old enough to think about actually maintaining it comes along. It was the wonders of ML in my day...

I thought we'd just excited the Scala fad though. Surely it's too soon for a new one?

2

shavetheyaks t1_iy78ycb wrote

I hate this article too (all the "examples" they give are exaggerated and abstract, and halfway through it turns into a not-so-subtle ad for their company), but I would argue that having to use goto for those things is a (soft) flaw in the C language.

My understanding of structured programming is that they took uses of goto and built them into the language to make it easier for the compiler/programmer to reason about them. Error handling and loop restarting are structured patterns that could have been added to the language itself.

Those patterns are so few and easy to reason about that I don't think there's any reason to add things like try/catch to C, but I don't think the presence of goto in C code means that goto is necesssary or desireable (except maybe for the crazy context-switching code you'd see in an OS).

7

random125184 t1_iy7lbfk wrote

Don’t listen to these twats downvoting you. Do what works for you. If it works, it works. If you wanna learn, you have to build. I’d start with python. It’s easy to pick up and you can learn a lot by just writing code to automate tasks. Python supports both OOP and functional programming, and anything in between. As long as the program does what you need it to do, it doesn’t matter. Fuck worrying about people maintaining your code. In fact, make it as unmaintainable as possible for anyone but you. That’s called job security. Anyone who says otherwise can suck your dick. Start here https://www.w3schools.com/python/. If not for anything else than just to get a basic grasp on the syntax and terminology. Then when you have questions, and you will quickly, Google it (properly). You’ll be visiting stack overflow quite a bit. Stick with what you know and never learn anything new until you absolutely have no other choice. Good luck.

2

dv_ t1_iy7mxte wrote

I wonder if scientists who read heavily diluted and oversimplified pop-sci web portal versions of scientific papers (for example, a paper that documents a weak correlation between obesity and stuff X -> web portal says "scientists find that X causes obesity") feel the same way.

7

dv_ t1_iy7n4qq wrote

It has been "the future" for decades now. In reality, aspects of functional programming have long since made their way into other, multiparadigmatic languages. I'm talking not only about primitives like map, reduce, fold etc. but also about isolating state, avoiding side effects, and making functions pure whenever possible. Functional languages enforce this, but you can do this in any language. Even C.

2

anzacat t1_iy7vnn3 wrote

Yet another article about how FP is going to save the world. Very poorly written article, naive at best.

2

mmarollo t1_iy7wgwo wrote

Pure functional languages have had a huge impact on computing. They’ll never “be the future”. They will remain one option in a range of programming modalities. That’s how it should be.

2

suhcoR t1_iy8362l wrote

> that works for him and immediately

Apparently he rather wants to sell his book; see for the statement "In my book, I provide guidance for obtaining proficiency in a functional language ...". If he had written a book about sandals instead, the title of the article would be "Why Sandals Should Be the Future of Footwear." It's unfortunate that IEEE Spectrum supports this sort of thing.

6

eras t1_iy84n7n wrote

> goto is used all over the place for cleanup after errors,

That is also the case in Xorg, and it has been a contributing factor for many resource release bugs.

2

msbic t1_iy893ly wrote

OCaml is functional-first, but also a fine imperative language if needed. Native compiler produces fast code, no null pointers, by default everything is constant. Haskell is too abstract for most people, including myself.

2

ToughAd4902 t1_iy8asu2 wrote

Haskell, the definition of a pure functional language, has classes, and then by your definition, methods. Scala, a primarily functional language, has classes. F#, a functional language, has classes. There is like 2 functional languages that don't, and that has no reason about it being functional or not. You are completely wrong, and this is my last response to this. Not a single point you've brought up has been about OOP or Functional, you need to learn them before you can argue them, that is all.

It's just hilarious you led with"you should Google before you comment" when everything you've stated is literally Googleable

2

celeduc t1_iy8ehas wrote

I love IEEE Spectrum, it treats the entire field of software development with the utmost contempt and deepest fear.

1

cesium-sandwich t1_iy8eqnb wrote

Yeah I can see FP working really well for fintech.. in fact, it being pretty vital.
Mutable state is exponentially more risky when there's literal money on the line.. and it's worth burning cycles to ensure consistency and accountability.

My background is in games which has different incentives/constraints.
Just skimmed the article and as I suspected, it addresses neither of my questions.

Appreciate the response, and lol at the haskellers downvoting my question.

FP/Haskell has been the "future" of programming for over 30 years now, but in the majority of popular use cases, it turned out to be C/C++/C#/Rust/Javascript.
Not exactly the cold fusion of computer science, but not the iphone either.

0

AutoModerator t1_iy8pxeg wrote

Thank you for your submission, but due to the high volume of spam coming from Medium.com and similar self-publishing sites, /r/Technology has opted to filter all of those posts pending mod approval. You may [message the moderators](/message/compose?to=/r/technology&subject=Request for post review) to request a review/approval provided you are not the author or are not associated at all with the submission. Thank you for understanding.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

chowderbags t1_iy8tb4n wrote

Yeah. I've got a similar memory from a programming languages class in my old college days in the late 00's.

And sure, there's some more built in functional type stuff in imperative languages nowadays, and I'm plenty happy to much about with it for a couple of elegant lines of code. But too much of that is just a mess to try to think about.

1

ToughAd4902 t1_iy9rten wrote

C does not support functions as first class citizens. You can do minimal amounts of things, like not writing mutable code, etc, but you can't do any form of true functional programming, as the language itself doesn't support it (though I guess you could write macros that unwrap everything, but that doesn't really count). The language itself has to have some support or it's just not possible

1

m64 t1_iya4wru wrote

Then go ahead and implement a game in Haskell

1

dv_ t1_iya5n0h wrote

You can do map, reduce etc. in C, albeit with a serious amount of macro trickery or function pointer usage. And yes, this does count. Is it practical? I doubt it. But it is possible.

1

ToughAd4902 t1_iyaa2lk wrote

my point that it didn't count is just that the macro will unwrap it to pure C, which doesn't have those constructs, so in terms of the language it doesn't actually support it, you're just adding a syntactic idea about it.

Though, to be fair, I guess that's all higher level languages do as well at the end of the day, so I guess my argument is kind of mute

1

shavetheyaks t1_iyagi6f wrote

The problem is that modern languages still don't target C's niche (systems and embedded) as well as C does. So we're stuck with it for those cases until something else comes along.

The only thing I know of that's trying for C's niche is Rust, and it's still not ready for it yet, IMO.

2