4 ms·
@snprbob86: I don't mind you moving comments from my blog to HN, but I do mind you misquoting and thereby lying publicly - it's not good for you and it's not go
by lbj 17y ago
@snprbob86: I don't mind you moving comments from my blog to HN, but I do mind you misquoting and thereby lying publicly - it's not good for you and it's not good for me.
Here the full quote:
"Hi all — I’m serving up the first comment!
I’ve received about 6 comments from C# developers all giving me their take on a better version of the liquid-value code above. A couple of them using Linq, which simplifies the code substantially. I’ve taken a drastic step in deleting all those comments — sorry guys!!
Not because they didn’t present valid points, but because they entirely missed the point — I tried to spell it out with the K example — We’re discussing principles here, not code examples. I have no doubt that my rusty C# can be written in a more idiomatic sense, using better libraries etc. But thats much beside the point. The point is, that while the language so freely permits and even encourages me to code that way — I will end up seeing that type of code in my systems. If I had the privilege of hiring a team of superior geniuses and unspeakable coding skills, then sure, they might consistently produce rock solid functional code even in C# — but that’s not a real world scenario.
So lets stick with the principles. And if anybody does provide examples, please connect them with something discussed in the post. That makes for a better discussion than just swapping code.
Thanks to all for taking the time, sorry for being so harsh
/Lau"
- snprbob86 17y agoNot reproducing the full comment does not constitute a misquote. Using Clojure doesn't enable you to magically write perfect code. You posted well written Clojure and poorly written C#. You can write poor code in any language. If you wished to remain on the topic of imperative vs functional, you should have avoided phrases like "using C# as the tool has added a huge degree of ceremony". You made a direct attack on the language, not on the coding style. You also make significant mention of the number of lines of code, but it seems as though you have intentionally included boilerplate to make your point. Being misleading and deleting comments are not ways to make an effective case for your cause. EDIT: Oh, and on the actual subject of functional style. I still much prefer the C# approach as it reads in order you perscribed: 1) calculate liquid value of each item 2) filter candidates 3) accumulate value (from asset in assets let liquidValue = GetLiquidValue(asset) // 1 where DoubleMargin(asset, liquidValue) // 2 select liquidValue).Sum() // 3 Compared to the Clojure which reads: (reduce (sum-field :productioncost) 0 ; 3 (filter doubleMargin? ; 2 (map attach-liquid-value assets))) ; 1 or the Python which reads: sum(liquid_value # 3 for liquid_value, asset in assets (get_liquid_value(asset), asset # 1 for asset in assets) if double_margin(asset, liquid_value)) # 2
- DanielStraight 17y agoAs they say, you can write fortran in any language, even Clojure if you try hard enough. Writing rock-solid functional code in C# is not nearly as hard or as strange as you seem to think. If it isn't a real-world scenario for you, that's just because you aren't interacting with the right C# developers. For starters, you could listen to the 6 comments (six? and you still say that it's not real world?) that were posted.