3 ms·
Sorry for my potentially VERY ignorant question, I only know functional programming at average joe level. Why can't you do the first in functional programming
by thrdbndndn 3y ago
Sorry for my potentially VERY ignorant question, I only know functional programming at average joe level.
Why can't you do the first in functional programming (not in this specific case because it's just how it is, but in general)?
And even if you can't do so for any reasonable reason in functional (again, in general), what stops us to just add syntactic sugar to equal it to the second to make programmer's life easier?
- Polygator 3y agoThe fundamental reason why many functional languages won't allow you to do the first is that they use immutable data structures. We could indeed introduce syntactic sugar (`y= (x[0]:=10)` maybe), but you'll still need to introduce a new variable to hold the modified list.
- thrdbndndn 3y agoIt's my understanding that, at least in Python, you can't change immutable data type but you can just assign a new data to the same variable and therefore overwrite it, right? So even if JAX makes list type immutable, you can still just re-use `x` to save the new modified list.
- deleted 3y ago[deleted]
- ajuc 3y agoThere's 2 different aspects people mean when they call sth functional programming: - higher order functions (lambdas, currying, closures, etc.) - pure functions, immutability by default, side effects are pushed to the top level and marked clearly The first aspect of functional programming has been already accepted by most OOP languages (even C++ has lambdas and closures). The second aspect of functional programming is what makes it useful on GPU (because GPU architecture that makes it so powerful requires no interactions between code fragments that are run in parallel on 1000s of cores). So you can easily run pure functional code on GPU, but you can't easily run imperative code on GPU. You can introduce side effects to functional programming, but then it ceases to be any more useful for GPU (and other parallel programming) than imperative/OOP.
- deleted 3y ago[deleted]