someobject => doThis() => doThat() => dontForgotToFinishUp()
then you could also possible send multiple objects into that pipe: obj1, obj2 => doThis() => doThat() => dontForgotToFinishUp()
you'd have to have some semantics for sending them separately, as an ienumerable or as parameters but perhaps that could be done (obj1, obj2) => doThis() => doThat() => dontForgotToFinishUp()
[obj1, obj2] => doThis() => doThat() => dontForgotToFinishUp()
add on top of that something that could abstract away multithreading/tasking in certain cases (automatically assigning them to tasks) and I'd be a happpy coder :)`data | groupby, "author" | mean`
Would create a graph object, which could be lazily evaluated, run in Dask, TF, etc.
It started to get ugly when passing in multiple parameters into a function. I had to watch out for left and right associativity, and manage casting of arguments.
It was a fun little experiment but I'm not sure how much it would actually improve workflows. If that sounds interesting, let me know and I'll poke at it again.
1) Coconut: http://coconut-lang.org/
2) https://github.com/JulienPalard/Pipe
3) Pandas also has a new dataframe pipe method. https://pandas.pydata.org/pandas-docs/stable/generated/panda...
I would look at those before rolling out a custom solution.
My point is that FORTH is point-free!
https://en.wikipedia.org/wiki/Tacit_programming
Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments. Tacit programming is of theoretical interest, because the strict use of composition results in programs that are well adapted for equational reasoning. It is also the natural style of certain programming languages, including APL and its derivatives, and concatenative languages such as Forth. The lack of argument naming gives point-free style a reputation of being unnecessarily obscure, hence the epithet "pointless style."
https://en.wikipedia.org/wiki/Concatenative_programming_lang...
A concatenative programming language is a point-free computer programming language in which all expressions denote functions, and the juxtaposition of expressions denotes function composition. Concatenative programming replaces function application, which is common in other programming styles, with function composition as the default way to build subroutines.
(-> id
get-account-details ;; {:plan "premium"}
:plan ;; "premium"
get-plan-details ;; {:price "$100.00"}
:price) ;; "$100.00"
It's equivalent to something like this in Python: account = get_account_details(id) # {"plan": "premium"}
plan_name = account.get("plan") # "premium"
plan_details = get_plan_details(plan_name) # {"price": "$100.00"}
return plan_details.get("price") # "$100.0"(
grep stuff file | wc -l &
expensive_task in/ out/&
)
join
ls out/ | parallel reducers > result
someObject
|> doThis
|> doThat Thing
|> doThat OtherThing
|> dontForgetToPayTheBill
or let getErDone =
doThis
>> doThat Thing
>> doThat OtherThing
>> dontForgetToPayTheBill
someObject |> getErDone
[not just pseudo-code, that can be compiled with the right definitions]The temporary variables are eliminated,and the type-based chaining self-verifies for new modifications, neither of which you get in C#. Also, thanks to better support for higher-order programming, common post-launch activities like performance upgrades and async tweaking happens with stronger guarantees and oodles less code.
In terms of essence: namespace shielding and modular composition gives numerous opportunities for logical encapsulation and complexity management that are not feasible thanks to C#s extension semantics and extension method requirements. All of the above can be defined in one type, for example, instead of multiple... The end product is just wildly more cohesive in F#/OCaml, with more options throughout to produce more maintainable solutions.
F# can also use (a slightly improved), version of C#s extension semantics, as needed. But the functional composition, currying, Discriminated Unions, and exhaustive pattern matching in conjunction with the module syntax yield a final product that is markedly smaller and distinctly more maintainable than it's C# counterpart.
Not to mention: from a syntax and readability perspective this just destroys its Fluent Interface counterpart, in about a third as many LoC. Start looking into things like custom operator support, DSL support, computation expression support, etc, and the maintenance improving possibilities just blow the .NET baseline out of the water.
I tend to look for general competence in new devs, because that persists across platforms and pivots. In general it's odd that we expect devs to know every language, tech, and cloud platform under the sun but draw the line at basic mathematical concepts mapped into programming decades ago... Using both sum and product types is fundamental to proper modelling, IMO.
I also think comparison between C# and F# based on "tricky" FP concepts is really odd in modern times...
On the one hand: if a new hire can't grok FP in F#, how can I trust them to do serious work in C#? OOP & FP synergize wonderfully, and the language has been openly trending towards FP ideals for a decade now. Those FP concepts are now modern idiomatic C# and also very important in tricky domains...
On the other hand, if I'm doing work that makes me think correctness is even a little important why would I want to do it in a language almost-as-good that provides no guarantees and requires more complexity? Why bring a footgun to the party if I'm already worried about quality and some rando new hire? Seems like people who don't grok the basics would do better in a stricter environment with less room for f-ups.
For my money I'll readily take a mild bump in on-boarding costs for productivity, production, and correctness guarantees forever. Not to mention the improved caliber of candidate one gets from finding self-selected A-grade techies and advertising an aggressive dev environment.
Right now I'm hiring developers right out of school and put them through a mentor program, hoping that they turn out good.
fun foo() =
Runtime.getRuntime().apply {
addShutdownHook(Thread { println("Bye!") })
traceMethodCalls(true)
exit(404)
}Never understood the FUD and 'considered harmful' screeds against it. Yes I'm aware of the performance/optimization concerns, but honestly, the whole javascript language is a massive performance/optimization concern and we've managed pretty well.
Simple things like changing style properties on DOM elements:
with(element.style) {
display = "block";
marginLeft = "5px";
background = "green";
}
And of course with 'with', everything is a fluid interface, and with the flexibility of being able to enter code between the function calls.Why is it elegant here, but deprecated there?
Smalltalk also solved this problem with the semi-colon, but for some damn fool reason we followed C syntax but didn't find an alternative. And now we're trying desperately to replicate `&.` in every library and language, but we still don't have an easy way to write: