|
I bought one by a lesser-known brand, a couple of years ago, which cost about the same as the Go does now (I wasn't willing to invest in a Rift just to see if I liked it).
It was a lot of fun, for a while, but the novelty soon wears off, and you have to find room under the sink for it.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I've been digging into a javascript based application lately and tripped across some code that made extensive use of the arity (which is deprecated now), currying capabilities and anonymous functions. Took me a lonnnnnng time to understand what the intent and operation of the code was.
So, out of curiosity, I'm wondering what "advanced" features of people's favorite languages they use on a regular basis, how they use them, and why? Or, which ones do you seldom/never use because....
E.g:
....I like using lambdas in C++ because .... (I can't think of a good example because I avoid them!)
....I avoid lambdas in C++ because they are often used where a simple function would be clearer and more readable (truth in advertising).
|
|
|
|
|
I avoid using var and dynamic in C# because they are normally misused to resemble Dim in VB or shortcut strong typing because the developer is too lazy to think about maintenance...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'll toss the ViewBag into that bucket too.
|
|
|
|
|
OriginalGriff wrote: I avoid using var and dynamic in C# I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
ZurdoDev wrote: I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.
I used to hate it but got used to it now.
|
|
|
|
|
ZurdoDev wrote: I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.
If you have a framework of Interfaces then var makes far more sense.
It's very much related to Dependency Injection and flexibility.
Of course, var is abused since any dev can just allow the compiler to set the type for all vars now.
But, this is also the way newer (dynamic) languages go about things (Kotlin, Swift).
|
|
|
|
|
I like var, it removes a lot of unnecessary noise
|
|
|
|
|
RugbyLeague wrote: it removes a lot of unnecessary noise Like being able to look at the declaration of a variable and know what type of object it is?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
That's what intellisense is for.
|
|
|
|
|
Hover over each item each time you want to know what is?
If you think that's easier and worth it, I hope you never work on my team.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
The vast majority of the time when looking at code I don't need to know what everything is - so without var I am presented with a load of noise and redundancy. If I want to know what something is and it isn't immediately obvious then I can hover over it and it tells me and for the purpose of that session I don't need to do that again.
I prefer to concentrate on the code rather than a load of type declaration noise. Admittedly it is a fine line - I don't use var everywhere - int i = 10 never becomes var i = 10, for example. And using var has become something I have adjusted to over time - at first I didn't like it, then I used it to remove redundancy var l = new List<string>() rather than List<string> l = new List<string>(). Now I use it in most places other than the aforementioned value type decls.
|
|
|
|
|
Other than what it was invented for (linq statements and anonymous types) an example of a good use of var is:
var foo = new SomeReallyLongTemplateDeclaration<bar<loo<koo,ka,choo>>>;
Here, you know what type foo is because it's type is readily apparent on the right-hand side of the statement.
Basically if you can readily determine the type from the right-hand side, then it's ok to use var . Otherwise, declare the type instead of using var .
So here, not so good:
var boo = SomeFunction();
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
I only use var in cases where the type is either given elsewhere on the line of declaration
var frobables = new List<Frobable>();
var frobables2 = GetFrobables();
or is an intermediate value whose exact type is both nasty looking and whose explicit declaration doesn't add much value.
var temp = db.tableName
.Where(x => )
.Select(x => new
{
x.Property1,
x.Property2,
x.Property3,
x.Property4
});
I only use dynamic in one off code, eg single shot tools or data importers; like the fluffy languages it resembles, for anything that needs to be maintained the long term costs exceed the short term savings.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
And you get far too many who just go "sod it, I can't be assed":
var x = 6;
foreach (var x in y.GetAll())
...
There is a good blog post on it here: The Use and Abuse of the C# “var” Keyword[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
idiots can write unreadable code in any language.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
I use something called a "debugger". I always knew this was quite a maverick thing to do, but looking at the QA section I didn't realise just how maverick!
|
|
|
|
|
Interesting! I had forgotten some languages don't come with a debugger.
Good one!
|
|
|
|
|
rjmoses wrote: I had forgotten some languages don't come with a debugger.
... and those languages are hopelessly buggered at a result.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You have to wonder how any of these people manage to do anything useful.
I was sent this this morning: Cyanide & Happiness: Millenials[^] (possibly NSFW, very little of C&A is)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
They don't! If I see one more "I'm ugly. I bet I won't even get one share." on FB, I'm going to unfriend myself.
|
|
|
|
|
You rebel you.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Depends on what you think is advanced
I use lambdas in C# all the time, but they've been around for over 10 years and now also turn up in other languages like JavaScript and, apparently, C++.
I use named tuples in C#, they were introduced two or three years ago, I think.
I've used pattern matching too.
A comment above this one mentions var and dynamic , I use var quite often and dynamic when I need it.
Basically, if it's in the language, why shouldn't I use it if I have need for it?
Personally, I don't find lambdas difficult to read at all.
In fact, a simple lambda can much better convey what you're doing than a function and be better maintainable.
For example:
myCollection.Where(x => x.IsActive).ToList();
myCollection.Where(IsActive).ToList();
private bool IsActive(Something x)
{
return x.IsActive;
} If the specs change, for example x.IsActive && x.Status == Status.Done , the first is an easy fix, the second would become IsActiveAndStateIsDone or some such, which gets harder to read every time.
In the case when the lambda is an Expression , like with Entity Framework, a function can't even be parsed and you have to use a lambda.
|
|
|
|
|
I'm always fighting reading a lambda. How you would express "x => x.IsActive" in words? Maybe this can help me
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|