473,241 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Re: Lambda expressions: Dangerous Madness

On Aug 14, 1:37*pm, raylopez99 <raylope...@yahoo.comwrote:
Took a look at all the fuss about "lambda expressions" from Jon
Skeet's excellent book "C# in Depth". *Jon has an example, reproduced
below (excerpt) on lambda expressions.

My n00b take: *it's like SQL and those 'high level' languages that try
to be too clever by half and pack a lot of syntax in as short a space
as possible. *Like Egyptian hieroglyphics, like Chinese, like those
non-alphabet languages, it's just way too much information in too
short a space. *Sure, writing a program with this syntax will reduce
your source code from 100 pages to 10, but at a cost of readability.

But what do I know? *I only have a couple months real experience in
the language. *Don't listen to me.

RL

"To try and outstrip each other in the arms race, or to expect to win
a nuclear war, is dangerous madness." - Leonid Brezhnev

this is equivalent: *from C#1.0
ArrayList products = Product.GetSampleProducts(); //fills arraylist
(fanciful example)

foreach (Product X in products) {
* * *if (X.price 10m) { Console.WriteLine(X);} } [suffix m =
decimal]

now redo in C#2 mode:

ArrayList products = Product.GetSampleProducts(); //fills arraylist

Predicate <Productproducts test = delegate (Product p) {return
p.Price 10m;} ;
List<Productmatches = products.FindAll(test);

Action<Productprint = delegate(Product p) {Console.WriteLine(p);};
matches.ForEach (print);

which is actually equivalent to (lambda expressions):
ArrayList products = Product.GetSampleProducts(); //fills, as before

foreach (Product product in products.Where (p =>p.Price 10))
{Console.WriteLine(product);}

*//Jon humorously states "the combination of the lambda expression
putting the test in just the right place and a well-named method means
we can almost read the code out loud and understand it without even
thinking" HA HA HA! *Right. *I guess beauty is in the eye of the
beholder.
You are, of course, entitled to your opinion, but lambdas are a part
of C# 3.0, and any C# developer has to know their ins and outs if only
to be able to maintain other people's code.

Also, every time I hear such sentiments - "generics/closures/type
inference/... are hard to understand and compromise
readability" (there were plenty of such as new major language features
were introduced, and not just in the C# land - come read some stuff
people write about Java generics, or the Java closures controversy), I
can't help but think that similar arguments took place back in 60s
during the transition to structured programming ("bah, those
newfangled loops are for lazy people who can't even be bothered to
type proper IF/GOTO - and of course, they result in utterly unreadable
code; look, the condition is checked without any IF present!"), and
then later from procedural to OOP (still plenty of flame on the Net
regarding this topic).

Luckily, there's no stopping the progress. You can invest some effort
to keep up, and join the ride, or you can retire to the same role as
people maintaining legacy COBOL systems today.
Aug 14 '08 #1
0 1189

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions...
26
by: Steven Bethard | last post by:
I thought it might be useful to put the recent lambda threads into perspective a bit. I was wondering what lambda gets used for in "real" code, so I grepped my Python Lib directory. Here are some...
30
by: Mike Meyer | last post by:
I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem to make both...
23
by: Kaz Kylheku | last post by:
I've been reading the recent cross-posted flamewar, and read Guido's article where he posits that embedding multi-line lambdas in expressions is an unsolvable puzzle. So for the last 15 minutes...
5
by: Octal | last post by:
How does the lambda library actually works. How does it know how to evaluate _1, how does it recognize _1 as a placeholder, how does it then calculate _1+_2, or _1+2 etc. The source files seem a...
15
by: Matt | last post by:
Hi There, Can anyone explain me the real advantages of (other than syntax) lambda expressions over anonymous delegates? advantage for one over the other. delegate int F(int a); F fLambda = a...
21
by: globalrev | last post by:
i have a rough understanding of lambda but so far only have found use for it once(in tkinter when passing lambda as an argument i could circumvent some tricky stuff). what is the point of the...
11
by: ssecorp | last post by:
I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that somehow means that the modified list is part of the environment and not the...
20
by: raylopez99 | last post by:
Took a look at all the fuss about "lambda expressions" from Jon Skeet's excellent book "C# in Depth". Jon has an example, reproduced below (excerpt) on lambda expressions. My n00b take: it's...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.