News for hackers. Stuff that matters.
Re:Achieving High-Performance the Functional Way by synergy20 on Sunday March 05, 2023 @01:14PM (#35032302)
They presented two new languages for functional programming, can we leverage existing popular languages that can do FP just fine for the same goal, e.g. python, javascript, or rust,etc?
Re:Achieving High-Performance the Functional Way by dgb23 on Sunday March 05, 2023 @01:19PM (#35032339)
The requirements include be high performance processing. That would exclude the first two.
Re:Achieving High-Performance the Functional Way by FrustratedMonky on Sunday March 05, 2023 @02:07PM (#35032813)
Is there a definition for 'high performance'. Does a .NET language like F# qualify. Or does it have to simply be compiled? I'm just not sure that Python wouldn't qualify.
Re:Achieving High-Performance the Functional Way by dgb23 on Sunday March 05, 2023 @02:14PM (#35032872)
From the examples they gave it’s clear you wouldn’t use python.
Re:Achieving High-Performance the Functional Way by richardjam73 on Monday March 06, 2023 @05:01AM (#35039262)
F# can use AOT compiling.
Re:Achieving High-Performance the Functional Way by nestorD on Sunday March 05, 2023 @02:07PM (#35032805)
Yes, for example JAX is a strictly functional language, designed for high-performance computing and embedded in Python.
Re:Achieving High-Performance the Functional Way by synergy20 on Sunday March 05, 2023 @04:57PM (#35034481)
I don't think JAX is a new language though, if it is, it's still Python?
Re:Achieving High-Performance the Functional Way by _kulang on Sunday March 05, 2023 @05:27PM (#35034826)
It’s not even really a language as much as it is an interop layer of sorts. It’s a collection of functional operations on numpy arrays, and a capable JIT. It’s main draw is honestly autograd, and if you’re using that, you often can’t use while or for loops effectively, can’t index numpy arrays without .at[], and should avoid side effects, so strangely it’s neither it’s own language or Python any longer
Re:Achieving High-Performance the Functional Way by pharmakom on Sunday March 05, 2023 @02:18PM (#35032918)
Those languages (except maybe Rust) cannot do FP just fine.
Re:Achieving High-Performance the Functional Way by packetlost on Sunday March 05, 2023 @02:23PM (#35032965)
LOL Python is not functional. We got a crumb of FP with `itertools`, `functools` and `lambda`
Re:Achieving High-Performance the Functional Way by synergy20 on Sunday March 05, 2023 @04:55PM (#35034460)
the reality is, general programming language with FP capabilities is what flies in practice, pure FP language might be perfect, it's just hard to find coders for them, we will have to live with that.

for HPC and ML, Python is dominant, I would expect to enhance python somehow with FP instead of anything else, then adding c/c++/rust/fortran libraries(e.g numpy) for intensive computing needs.

Re:Achieving High-Performance the Functional Way by karmakaze on Sunday March 05, 2023 @05:17PM (#35034714)
Python isn't popular for data only because it's imperative, there's also the vast numerical processing ecosystem. Scala/Spark is an example where FP fits well.
Re:Achieving High-Performance the Functional Way by noloblo on Sunday March 05, 2023 @05:08PM (#35034601)
what about GIL? https://wiki.python.org/moin/GlobalInterpreterLock

why python can't thread? impact of GIL on python https://pythonspeed.com/articles/python-gil/

Re:Achieving High-Performance the Functional Way by synergy20 on Sunday March 05, 2023 @05:33PM (#35034889)
My understanding is that even with GIL removed today, Python is still not a performant language for cpu-intensive tasks, be it single core or multiple-core.

Python is better used as a glue language and leverage numpy etc to do the heavy lifting, numpy can work with multiple-core just like c/c++/rust languages can.

If you really need launch multiple python processes, the multiprocessing module came to rescue.

While not ideal, I don't see a showstopper to use Python for HPC's high and parallel computation needs at all.

Re:Achieving High-Performance the Functional Way by bigbillheck on Sunday March 05, 2023 @08:29PM (#35036416)
We almost lost map/filter/lambda in the python3 transition: https://www.artima.com/weblogs/viewpost.jsp?thread=98196
Re:Achieving High-Performance the Functional Way by throwaway09432 on Monday March 06, 2023 @12:46AM (#35037881)
Python lambda syntax is ugly as hell.
Re:Achieving High-Performance the Functional Way by throwwaway8529 on Sunday March 05, 2023 @03:33PM (#35033658)
Python can’t even do multi line lambdas
Re:Achieving High-Performance the Functional Way by Iwan-Zotow on Sunday March 05, 2023 @07:05PM (#35035699)
sure it can
Re:Achieving High-Performance the Functional Way by pasquinelli on Sunday March 05, 2023 @10:06PM (#35037074)
it's been a while since i used python; have lambdas improved? i recall weird restrictions using them, but i can't quite remember what. this was pre puthon 3
Re:Achieving High-Performance the Functional Way by Iwan-Zotow on Tuesday March 07, 2023 @01:40PM (#35059263)
Assignment Expression were added, so you could do

x = 1 y = 2

q = list(map(lambda t: ( tx := tx, ty := ty, tx+ty )[-1], [1, 2, 3]))

print(q)

Re:Achieving High-Performance the Functional Way by fatneckbeard on Sunday March 05, 2023 @09:05PM (#35036675)
as an amateur rust admirer , looking at https://rise-lang.org/ .... i think its maybe possible. because their language / tools Rise + Elevate looks like its starting out with a chain of iterators, something we see often in Rust, like zip, reduce, map.

if i understand it, they then automatically analyze the iterator chain and rewrite some of it using parallel versions of the code, for example they change Map to MapPar

"In Rise, low-level implementation choices such as performing a computation in parallel are encoded with low-level patterns. For example, the map pattern that applies a function to each element of an array might be performed in a data-parallel fashion as indicated by the mapPar variant of the pattern"

https://arxiv.org/pdf/2002.02268.pdf

This reminds me a bit of how the Rayon crate in Rust works, where you can take an iter() and change it to par_iter() and instantly get parallelism in your program (depending on various details). but it seems like they have taken it "to the next level" and can output a CUDA program automatically , starting from their basic iterator chain.

Re:Achieving High-Performance the Functional Way by synergy20 on Sunday March 05, 2023 @09:47PM (#35036957)
Good to know Rise, it does not look like it is under active development since last May though.