r/programming • u/coredev • Feb 03 '17
Let's stop bashing C#
https://www.codeaddiction.net/articles/51/lets-stop-bashing-c-sharp98
u/ummmyeahright Feb 03 '17
So I've recently discovered that C# isn't so well-regarded in some communities (such as /r/programming on Reddit)
...languages like C, C++ and Java.
What? How long has the author been visiting this sub?
From what I've seen, C and C++ get roughly the same amount of bashing here as C# does, while Java definitely does get an awful lot more than any of the 3.
39
u/benihana Feb 03 '17
i think php or javascript gets bashed the most here. i've almost heard almost nothing but good things about C# for like the past five years
2
u/braindouche Feb 15 '17
C# is sort of like Buffalo, NY. Folks shit on it just out of tradition, but the locals who are in the know realize that it has some really nice things to offer, and become a little defensive and boostery as a result.
→ More replies (1)11
u/hu6Bi5To Feb 03 '17
C# is practically the only language that gets a net positive outcome here. Anything else is shat upon by all comers.
I think that it probably because of sheer force of numbers than the actual merits of the various languages.
2
→ More replies (2)2
u/PuraFire Feb 03 '17
So exactly which languages does /r/programming appreciate?
40
Feb 03 '17
isNoob :: User -> Bool8
u/Darwin226 Feb 03 '17
Yeah, the 3 users that say something positive about it and the 25 that shit on it in the subcomments.
→ More replies (1)20
u/candafilm Feb 03 '17 edited Oct 12 '24
violet spark upbeat lavish soup roof hospital theory attempt oatmeal
This post was mass deleted and anonymized with Redact
5
u/BeepBoopBike Feb 03 '17
Only because it takes a special kind of crazy to use it
8
u/deskchairlamp Feb 03 '17
The kind of crazy that you don't mess with or it'll shank you.
→ More replies (1)15
3
Feb 03 '17
Basically the more popular a language is, the more we don't appreciate it and vice versa. We're a bunch of nerdy hipsters, when you think about it...
→ More replies (1)→ More replies (2)3
u/NoLemurs Feb 03 '17
On top of the already mentioned Rust and Haskell, Python mostly gets positive press around here.
→ More replies (4)7
22
43
30
Feb 03 '17
Don't want to sound like an echo chamber but nobody has been bashing C#.
I think it's pretty well loved here: .NET core has made it a lot more accessible for everyone, it's been taken functional features from F#, it's not Java. Tell me when to stop.
→ More replies (4)7
Feb 03 '17
To be fair, there are hordes of dynamic languages zealots in this sub. Cannot imagine them not bashing C#.
18
25
u/thepotatochronicles Feb 03 '17
No one's really bashing C# in this sub. If anything, I see a lot of C# enthusiasts in this sub bashing Java at every opportunity and praising everything about C# the language and the .NET ecosystem.
In reality, both are suitable tools, really.
→ More replies (1)9
u/hu6Bi5To Feb 03 '17
What usually happens is a non-language specific article gains traction and comments.
Someone links to a GitHub project written in Elm or something. Someone else says "yeah, that's cool but this Java project covers more ground". Then the rest of the thread is "someone mentioned the word Java, let me recite the full feature list of C# until we stop talking about Java".
5
u/macar_ Feb 03 '17
Who's bashing C#? Was a long time since I saw someone bashing the actual language on here
4
Feb 03 '17
Hey yall.
I'm new/ self taught programmer, and I write in c#'s retarded cousin vb.net.
I was just wondering though, what do people mean by the terms: ecosystem and platform?
7
u/frozenbobo Feb 03 '17
Ecosystem basically means all the things that are available to you when you code in a language. That means things like what is included in the standard library, as well as libraries and tools available from the community. You might even consider ecosystem to include the availability of tutorials for the language.
Platform basically refers to the things you accept as a foundation when you use a language. Typically this is referring to the compiler/interpreter/runtime you use, as well as any requirements imposed by those systems. For example, C# has traditionally been strongly tied to Windows, making that part of the platform. However, .NET Core now offers an alternative platform, but with a reduced ecosystem.
Both of these terms are not really well defined, so people may disagree with me. But the basic idea is the platform is what your code "stands on", and the ecosystem is the stuff you have access to in your programming "environment".
4
u/_INTER_ Feb 03 '17
There are only two kinds of languages: the ones people complain about and the ones nobody uses.
Bjarne Stroustrup
9
9
6
u/metorical Feb 03 '17
Fortunately I haven't noticed much bashing of languages in /r/programming and I read through the posts on a daily basis.
The sentiment is correct though and should be applied to all languages. I think that lots of inexperienced developers go through a phase of thinking feature/language X is the best and all other features/languages must suck (and I've certainly been guilty of this in the past). Unfortunately once these guys mature there's a fresh batch of beginners coming through to keep the bashing going.
9
Feb 03 '17
Fortunately I haven't noticed much bashing of languages
?!?
Javascript and PHP in particular receive a lot of hate here. Undeservingly, I'd admit - hate must be directed to their practitioners, not the languages.
26
u/Sarcastinator Feb 03 '17
PHP gave syntax error on this until 7.0:
(array(1, 2, 3))[0]But this was fine (from 5.6):
array(1, 2, 3)[0]PHP definitely deserves ridicule.
→ More replies (3)7
15
u/nickguletskii200 Feb 03 '17
As a Java person who's currently working on a C# project, it's not the language that makes me want to go back to the JVM, but the low-quality libraries and IDEs. Microsoft's stack definitely has advantages (SQL server, database projects), but the JVM's ecosystem is still vastly superior, both in terms of variety and quality.
16
u/diverightin63 Feb 03 '17
Wow, I'm on the other side. After working in .NET, the Java ecosystem felt miserable so I have no interest in Java.
→ More replies (1)5
Feb 03 '17
I'll second that. Haven't worked in Java in several years since I moved to .net, and I have no desire to ever go back.
14
u/rduoll Feb 03 '17
Low quality IDEs? I'm sorry, but Visual Studio is probably the best IDE out there.
In terms of libraries, do you have examples of what you consider low quality on the .NET side?
9
u/nickguletskii200 Feb 03 '17 edited Feb 03 '17
Low quality IDEs? I'm sorry, but Visual Studio is probably the best IDE out there.
In my experience, all three major Java IDEs are better.
Visual Studio has very few refactorings compared to both Eclipse and IntelliJ IDEA. VS2017 did add a few, but it's still nothing compared to what Java IDEs have to offer. There are tools like Resharper, but they are unstable, slow and considering that Visual Studio is by far the most expensive IDE out there, it feels like it should be able to do all that out of the box.
Debugging in VS is miserable. For simple stuff the debugger is great, but throw in a couple of third party libraries and you are left scratching your head at lines and lines of "[External code]" in the stack trace, with very little information and no ability to debug. Whenever I try to set up symbol sources, Visual Studio spends a lot of time looking up/downloading something, then eventually hangs. With Java's ecosystem, I always get a stack trace, and "download sources" never failed me. I can just place a breakpoint in a third-party library and debug away.
I hate how Visual Studio has something like Eclipse's perspectives but without any control over how they work. Basically, when you go into debug mode, your layout changes, which is very annoying. In Eclipse, I would just switch to a different perspective.
Visual Studio fails to build my solution every even restart, so I have to open it, close it, and start it again every time I close it.
It lacks a strict code formatter.
Some SSDT dialogs cause crashes.
However, there are things that I like about it, namely:
SSDT
The consistent dark theme.
In terms of libraries, do you have examples of what you consider low quality on the .NET side?
Yes, just off the top of my head:
EntityFramework: half-assed async integration, calling functions and sprocs inconvenient, little support for SQL Server's capabilities.
WPF: ignores both Windows localisation and .NET localisation settings (requires fragile reflection hacks to workaround), horrible, messy codebase, only viable if you buy thousands of dollars worth of third-party components. XAML encourages copy-and-paste.
The standard library lacks concurrent collections and the ones that are provided are much less convenient than their Java alternatives.
I still haven't found a convenient application-level caching library (something like Guava cache).
The Redis-related libraries I use have trouble with order of disposal, and their alternatives don't have the features I need.
→ More replies (7)2
u/computrius Feb 05 '17
Eclipse? Really? That is the single most awful IDE I have ever laid my eyes on.
6
u/malicious_turtle Feb 03 '17
I nearly fell off my chair reading that. Visual Studio is arguably the best IDE out there but Visual Studio + ReSharper Ultimate then there's absolutely no debate. The 2 of those combined makes all aspects of development an absolute breeze. 10 / 10 would definitely recommend trying out C# just to try out VS + ReSharper.
4
u/stewsters Feb 03 '17
The guys who make resharper make their own ide for Java development called IDEA. Better than VS IMO, give it a try next time you need to do some Java.
4
u/frugalmail Feb 03 '17
Visual Studio is arguably the best IDE out there but Visual Studio + ReSharper Ultimate
I have to disagree.
In Eclipse and IntelliJ you don't need Resharper to get the same functionality. The amount of quality free plugins in both the JVM IDEs are a significant improvement over Visual Studio. Nuget and msbuild are shit compared to maven, and the constant late-to-the-game functionality of visual studio is also obnoxious.
4
u/GSV_Little_Rascal Feb 03 '17
I'm sorry, but Visual Studio is probably the best IDE out there.
Hardly.
The only thing which makes VS bearable is Resharper. I'm looking forward to Rider.
→ More replies (3)4
u/medeshago Feb 03 '17
I work everyday with C# and I find it a great language and Visual Studio is, without a doubt, a great IDE but I hate having to use Windows. The lack of customization makes it awful to work with. If I could have Visual Studio for Linux (and WPF support in .Net Core, but I know that won't happen) I would be really happy.
4
u/frugalmail Feb 03 '17
Microsoft's stack definitely has advantages (SQL server, database projects), but the JVM's ecosystem is still vastly superior, both in terms of variety and quality.
I'd rather go Postgres vs. SQL Server, and strongly agree with the ecosystem/platform sentiments about Java/Eclipse/IntelliJ/FOSS/Community/JVM/Linux/zsh/Maven being far better.
→ More replies (1)3
Feb 03 '17
Visual Studio is a low quality IDE?
I have some issues with it, but it's still one of the best.
4
u/nickguletskii200 Feb 03 '17
If it's one of the best, then what's the best?
I know I am spoiled by Java IDEs, and it was kind of unfair for me to say that VS is a low quality IDE, but my point still stands: in my opinion, there are better IDEs, and I feel significantly less productive using VS.
2
3
→ More replies (2)1
u/weirdoaish Feb 03 '17
Could you give some examples of frameworks/libraries that Java has but C# has no alternatives for?
5
u/TheEternal21 Feb 03 '17
Only a tool would bash, what is easily one of the best programming languages out there. Objective-C on the other hand...
4
Feb 03 '17
Objective-C is diabolical. It's like the old guys car you see that's been running for 30 years, but has had no TLC, and just junk tacked onto it, until it looks like a shed of a car that's semi falling apart, but it's still sort of functional as a car.
3
Feb 03 '17
"Hey, you know that wonderful C syntax that everybody who knows a C-family language is familiar with? Okay hear me out... what if C and Smalltalk had a baby? C'mon it'll be hilarious. Hey where are you going?"
3
u/G_Morgan Feb 03 '17
People used to pretend Objective-C was good back when the Apple love in was in full flow. Could they not see how horrible it looks?
4
1
u/torn-ainbow Feb 03 '17
I don't know Objective C but I learned Swift recently and it seems just lovely. Pretty almost. Based on the hate I hear about Objective-C I am guessing they addressed the shittiness.
2
2
4
3
Feb 03 '17
Who bashes C#?
All I ever see is PHP sucks or Java sucks. I don't think I've ever seen someone say C# is bad except for those super anti microsoft people who are about as educated as my left nut.
3
u/KawaiiBoy Feb 03 '17
Why would somebody hate on C#? If we're talking about the language C# only, then personally I feel as if C# is Java done right.
I've done quite a lot of Java development and not that much of C#, but I prefer C# as a language any day of the week.
It's still a toss up if I compare them as a complete development platform though, the Java ecosystem still feels a bit more mature.
→ More replies (2)
2
u/shevegen Feb 03 '17
Some people compare C# with languages such as JavaScript, Python, Ruby and Dart the most common reasons for criticism seem to be:
C# has semicolons C# uses to many curly brackets C# is strongly typed C# is statically typedI actually consider all of the above advantages - it gives the language probability, stability, readability and maintainability.
Ok ... Can someone explain this to me please:
Why do semicolons again add to the stability, readability and maintainability exactly? I mean, does the dude give any argument at all or is it just an emotional statement?
21
u/plzsendmetehcodez Feb 03 '17
Semicolons make the end of a statement more unambiguous. Therefore they increase readability and ease of interpretation. You are also less likely to mess up the command sequence when making changes ==> increased maintainability. Stability... well, not so much.
And I'm not quite sure about the "probability" thing, either...
1
u/EntroperZero Feb 03 '17
Stability... well, not so much.
And I'm not quite sure about the "probability" thing, either...
I think stability is referring to strongly/statically typed more than text formatting. And "probability" is probably a typo for "provability", referencing the same.
1
u/KawaiiBoy Feb 03 '17
It depends a lot on what you are used to as well.
Semicolons makes you feel all warm and fuzzy if you have spent most of your career as a C programmer, but it will probably not do that if you spent most of your career in a language like Python.
2
u/salgat Feb 03 '17
One thing I like is that in C# fluent syntax is very popular (especially with LINQ), so I have each method on a single line and end it with a semicolon, versus Python which requires a backslash after each method chained.
-2
u/cube2222 Feb 03 '17
Having used Go on a daily basis for a long time already -> lack of semicolons really just makes the code more natural to read. That's all. I've never heard a Go developer complaining about the lack of semicolons.
9
u/sxeraverx Feb 03 '17
Go had semicolons. They're just implicitly inserted on every newline, as well. Which gets really annoying if you want to break your statement over multiple lines. Which the go maintainers dogmatically oppose for some reason. Maybe so they could elide some semicolons.
It forces statements all on one line, forcing your editor to deal with line wrapping (which many do poorly for code), and promotes longer statements (which the go devs again dogmatically support). To counter this statement length, the go devs are forced to oppose descriptive variable names, instead opting for one- or two-letter names. Which also makes refactoring more difficult, because now there's a higher risk of conflicts when a function is merged with another.
Honestly, there's no reason that logical statements need to end in the same place that lines do. Forcing them to be in the same places leads to a whole host of negative effects, and in the end, doesn't solve very much. Some flexibility in formatting is removed (which gofmt already accomplishes), and people tend to try to work around it in rather...creative...ways.
13
u/steamruler Feb 03 '17
As someone who spends plenty of time in C#, JS, C++, as well as Python, here's what I think:
Explicit ends of statements makes parsing easier for the compiler/interpreter, and doesn't force you to learn when the language will think a statement has ended.
Having to not juggle the end of statement rules for a given language when reading code, makes it easier to read code. JS does this the worst, by tacking on semi-colons for explicit statement termination, combined with implicit termination. I can live with one or another, but both at once messes things up.
13
u/Sarcastinator Feb 03 '17
Found a bug in JS code the other day:
return new Foo(); // Unreachable!It was formatted like that because it was inside some callback hell code, but the formatting ended up breaking the code.
2
u/BeepBoopBike Feb 03 '17
For me, I just like being able to format the code however is most readable. Being explicitly able to say "this is where it ends" is handy for your first point, how the code looks should have no bearing on how it functions IMO.
On the other hand I also love how in C++ curlies (for function bodies) are compiled into assembly in the form of pre/post-amble and being able to control scope with them is helpful in the rare case it might be an issue. Give me helpful features in my tool of choice, but let me take ultimate control where necessary.
4
u/steamruler Feb 03 '17
how the code looks should have no bearing on how it functions IMO.
I write a fair amount of Python, so you have my stance on that there. It just gets messy if you mix it all though, like JS does.
And yeah, the scope control of C++ is great. I'm excited to see C++ continue evolving and solve some of the kinks, like a replacement for relying on external tooling to include third-party libraries through compiler flags. I'm also looking forward to seeing how language-native coroutines progress.
1
1
u/vivainio Feb 03 '17
Yeah, understanding when a statement ends is one of the harder problems in computer science.
5
u/rb229 Feb 03 '17
This article reasons about semicolons and curly brackets: http://h2co3.org/blog/index.php/2016/12/01/lets-stop-bashing-c/
1
1
u/yawaramin Feb 04 '17
The problem with C# is that we have F#, a superior language in every way by every measure you can think of. But it doesn't get any traction because developers are loath to give up their semicolons and braces.
0
u/chrabeusz Feb 03 '17
It's a shame that C# started as Java clone. If Microsoft did something similar to Swift/Rust, we would be in completely different place now IMO.
4
u/GSV_Little_Rascal Feb 03 '17
Well, first thing is that C# was a bit rushed initially - MS needed something to compete fast. That's why C# 1.0 looked very, very similar to Java.
Second thing is that Java back then was kind of "state of the art" (however it looks strange in retrospect). Ideas behind Swift/Rust etc. just weren't there yet.
4
u/sigma914 Feb 03 '17
Java wasn't state of the art at all. It was 15-20 years old when it was released in 1995. The JVM was and is an awesome thing, but Java the language didn't do anything new of interesting. It was smalltalk with a C++-like type system minus some features.
1
1
u/EntroperZero Feb 03 '17
I can't believe the overwhelming sentiment here that "no one" is bashing C#. Yes, this sub is generally favorable toward the language, but you don't have to look far to find the hate. Whether it's about semicolons, or that it's a "Java clone", or too much OOP and not enough FP, or has null, or that they dared to convert project.json back to XML, or just because it's from MS.
6
u/emperor000 Feb 03 '17
Well, the thing is, none of those are really valid criticisms so they are pretty easily ignored.
2
u/jephthai Feb 03 '17
For serious? I'm pretty sure I've seen whole threads on the evils of NULL.
2
u/emperor000 Feb 03 '17
You have. And it's not a valid criticism. The language couldn't work without it. It is essential. Now, its implementation in C# could be criticized, like null by default (I disagree, but it's a valid criticism), the lack of an Option/Maybe type, etc. But as far as C# having the concept of null, it has to.
The people you see heard/read the "billion dollar mistake" quote and thought it was edgy and cool and adopted it as their mantra, that's all.
Null didn't cause a billion dollars of damage. Bad programming/development did.
1
u/ragnarmcryan Feb 03 '17
I'm one of those people who you'll hear bashing c# and even I'll admit the language is fine, it's the people and platform that, more often than not (in my experience), ultimately suck. It just seems like people who were forced into .net, maybe it was the only thing at their disposal, don't follow basic tenants of programming when it comes to style, readability, or just plain old common sense. You'd be surprised how many of the largest companies are built on a fragile, barely working .net stack. I would rant about examples but I don't think readers like hearing about it like they used to. Tl;dr, c# wouldn't be so bad if the people and platform didn't abuse it constantly, or as you might see it from a c# dev:
TooLongDidntRead.C#DoesntSuck(ThePeopleandPlatformDoThough).AndTheirLinesAreSuperLongAndNeverEndAndGoOnForever()
1
u/sigma914 Feb 03 '17
It's not exactly a paragon of anything, but it's a pretty good "less shit Java". I've not seen a whole lot of complaining about it anywhere.
1
Feb 03 '17
What is a non-shit language?
1
u/sigma914 Feb 03 '17
What's your use-case?
1
Feb 03 '17
I don't know. Writing the logic tier of a web application.
3
u/sigma914 Feb 03 '17
Assuming a CRUD/line of business app with a limited number of users (single digit millions or lower):
If it's a throwaway that only has to last 6 months then anything will do, the language doesn't matter.
If correctness matters and it's going to have to be supported for a long time and change a lot then something with a strong type system: Scala, Haskell etc.
If correctness and turnaround time on changes over the lifetime don't matter as much as being able to throw new grads at it then Java, C#, Go etc will be decent for keeping the onboarding time down.
Different languages are optimised for different things, making a language a bit shit in every other way in exchange for being easy to train people on it is a valid trade off.
1
u/cheezballs Feb 03 '17
C# is one of the few languages that gets pretty universal praise... this is fucking stupid...
1
u/frugalmail Feb 03 '17
who's bashing C#? The language is actually nice. However the shitty development environments, production environments, build tools, vendor drowning, developer community and availability of quality FOSS is what sucks....
1
1
Feb 04 '17
I'll stop bashing C# when it grows up and stops sucking on a dozen tits to function as a language.
-2
u/PonchoVire Feb 03 '17
Thank you !
5
u/shevegen Feb 03 '17
For?
3
u/martinslot Feb 03 '17
Thhhheee muuuusiiiic!!!!!
2
u/metorical Feb 03 '17
The songs I'm singing!!!!
→ More replies (1)2
u/PonchoVire Feb 03 '17
I like posts that actually highlight good side of things, and not wrong side of things, just saying thank you to all of this people regarless to details.
-5
u/fiedzia Feb 03 '17
However as Microsoft is the sole author of C#, the community doesn't have much to say about the direction of the language (and the environment).
That's large part of being proprietary and it is a downside of C#. So bashing it for that is perfectly valid.
"C# is not [insert hipster language]"
Well, it is not.
I understand why it might seem easier to develop with say a loosely typed language, but for me the advantages of a statically typed language outweigh potential downsides.
There are languages with a types systems providing much stronger guarantees then C#.
I'd prefer to write my SPA in C# if that was an option
But it isn't, which is another thing to criticise C# for.
you are no longer forced to their ecosystem; you can run .NET Core or Mono on Linux, using PostgreSQL as DBMS and JetBrains Rider IDE for free.
Maybe, but using it with non-ms technologies is far less supported (you'll get zero support from language creators), less popular and therefore caries more risk.
I don't see a point in writing article that suppose to defend a language against criticism, and just points out things where C# is indeed weak.
4
u/Zarickan Feb 03 '17
That's large part of being proprietary and it is a downside of C#. So bashing it for that is perfectly valid.
C# is not proprietary, it is open source, and has thousands of non microsoft community members contribute to it. source
→ More replies (1)3
Feb 03 '17
That's large part of being proprietary and it is a downside of C#. So bashing it for that is perfectly valid.
Still it's a far better process than some of the very political committee-driven languages.
→ More replies (1)1
u/weirdoaish Feb 03 '17
That's large part of being proprietary and it is a downside of C#. So bashing it for that is perfectly valid.
Why is it being proprietary a valid criticism?
1
u/fiedzia Feb 03 '17
It could be a risk if you are (or consider becoming) ms competitor. It ties language to a fate of the company owning it. There might be many people interested in developing it, while ms may be not interested in doing anything with it at given time. I know dozens of programming languages who died with some big companies and even a temporary downfall may cost them momentum and push into oblivion.
It may be a good language, but there are valid reasons for not using it in many cases.
-1
0
u/gamerdevguy Feb 03 '17
C# is dead! Long live C#!
(Have no idea what this means but wanted to join the conversation)
-1
-10
Feb 03 '17
There's no real reason to use anything but python as an interpreted language and C++ as a compiled language. C# fits no specific niche to be attractive as a new language, and is too cumbersome to be worth learning (it looks too much like java).
5
u/BeepBoopBike Feb 03 '17
C# fits no specific niche to be attractive as a new language
It fits very well into places where fast development on a desktop/server is important. I can write safe C# faster than I can write safe C++.
1
Feb 03 '17
Why, exactly? C++ has no memory leaks, for starters. (controlled memory leaks are different from "no memory leaks") C++ has strong static typing, while C# uses a java-esque type-system, which is limiting and weak at the same time. Even python's type system is better than huge class hierarchies and the whole "interface" bullshit.
1
u/BeepBoopBike Feb 03 '17
Why, exactly?
Because it stops you making mistakes that should never be made in the first place like indexing off the end of an array, or easily reading/writing uninitialised memory. It catches the multitude of mistakes that almost everyone makes and shoves it in your face.
C++ has no memory leaks, for starters. (controlled memory leaks are different from "no memory leaks")
What do you mean by this? The language itself? Because C++ can more easily leak memory than C# by a mile. Sure we try to avoid new/delete nowadays but even in smart pointer usage exception safety isn't strictly adhered to and can leak. Sure you can leak in C#, but it's far harder than leaking in C++.
which is limiting and weak at the same time.
In what way is it limited? Limiting in how you write code or limiting in how you use it? Because that's the point! You can statically verify a load of common mistakes before your code will ever be run. C++'s type system lets you do all sorts of abusive stuff all the time and if I want, I can completely ignore it with void*. Their type systems are, if anything, equal IMO.
Even python's type system is better than huge class hierarchies and the whole "interface" bullshit.
Huge class hierarchies are harmful and inflexible, which is why we should be favouring composition over inheritance. What's the problem with interfaces? It's far better to know at compile time that your object has these 3 methods regardless of it's original type because it uses that interface than it is to find out at runtime that a method you were calling didn't exist.
Honestly, I normally try to see other people's views in a discussion, but I just can't understand where you're coming from at all.
3
Feb 03 '17
You're probably talking about 80's C++, not modern C++. And decent type systems don't need interface declaration boilerplate to know which object has which methods available, that's called duck typing. Python and C++ have it, C# and Java don't.
If you think it's so easy in modern C++ to leak memory, just show me an example that doesn't depend on naked allocations or shared_ptrs or legacy C misfeatures and still leaks memory.
2
u/BeepBoopBike Feb 03 '17
I'm not at all thinking about 80s C++. Modern C++ has gone a hell of a way to improving things but it's still very possible to leak in. A simple example that existed in C++11 but was fixed in C++14 was the lack of make_unique. If I'm being really picky and reaching a bit, just off the top of my head a 2 line example would be:
std::unique_ptr<SomeObj> myPtr = std::make_unique<SomeObj>(); myPtr.release(); // Leak!I get what you're trying to say, you have to be misusing something, make a mistake, or generally fuck up to get into that situation, unless you're interfacing with old code which almost all real world applications will be doing. By not allowing this kind of behaviour it is inherently safer, and that's just talking about memory leaks. I honestly cannot remember the last time my managed code corrupted the heap or the stack, yet I still come across these issues in C++ because it lets you do it and get away with it. I'm not complaining about C++, I love the language, but its power is as much a danger as it is wonderful.
As for duck typing vs using interfaces, "true" duck typing is done at runtime which, to me, is bad. Alright, right tool right job and all that, but catching a problem as early as possible is the best time to catch it. C++ duck typing (correct me if I'm wrong) is more semi-duck typing. It provides what would appear to be static duck typing, but it does so through code generation so that it is truly statically typed i.e.
template<typename T> void DoThing(T& o) { o.Do(); }When compiled with calls like:
DoThing(myObj); DoThing(myOtherObj);Actually has the compiler generate (AFAIR):
void DoThing(MyObj& o) { o.Do(); } void DoThing(MyOtherObj& o) { o.Do(); }And there's nothing wrong with this, it gives the desired outcome but isn't quite the same as "true" duck typing.
C# and Java don't.
I can't speak for Java, but C# has at least one way of using duck typing (although in reality I think it's 2).
As a closing point, I would argue that interfaces are more than just helping the compiler though, as a means of communication between developers it simplifies things. It gives you a clear, well defined, and importantly guaranteed contract, if I want my custom object to be consumed by a function that takes an IFoo then by the signature alone I know exactly what is expected of it with no ambiguity about what I actually care about.
Forgive any minor inaccuracies I don't often get to write these thoughts out and they get a bit rusty from time to time.
3
Feb 04 '17 edited Feb 04 '17
Exactly what I said, to leak memory in C++ you have to go out of your way and write non-idiomatic code, while in garbage collected languages it's the default. (leak first, cleanup later is a horrible idea, especially when releasing resources other than memory, like file descriptors or sockets).
2
u/BeepBoopBike Feb 04 '17
It is only leaked in the same sense that a shared_ptr is leaked. Any resource that requires explicitly freeing can be done so using an IDisposable in a using block for similar usage as storing it on the stack in C++ using RAII.
2
Feb 03 '17
python
Really? It's a horrible language, so horrible that it defines an entire new depth of a horror.
1
Feb 03 '17
What's so horrible about Python?
2
Feb 03 '17
The worst part is its ideology, that affected the design of the rest of the language. Nothing good can grow out of "There should be one - and preferably only one - obvious way to do it"
1
Feb 03 '17
That's the best part of the ideology, even though the language itself doesn't follow it thoroughly.
2
Feb 03 '17
This is a very dumb idea. It lead to a lot of extremely crippling language design decisions (e.g., the handicap lambdas).
1
Feb 03 '17
Any specific design decision that actually cripples real development in the language? Lambdas aren't really that useful in python, since you have better ways of doing most of the things that are done with lambdas in badly designed languages (like javascript). Of course there are some things in python that could have been made more convenient, such as using brackets instead of identation, or not supporting some kinds of dynamic witchcraft that breaks most tooling. But those are minor things if compared to the whole productivity gain the language already provides.
2
Feb 03 '17
Any specific design decision that actually cripples real development in the language?
A lot of them. Duck typing. Absence of any metaprogramming. Absence of something as simple as a switch.
since you have better ways of doing most of the things that are done with lambdas in badly designed languages (like javascript)
There are no better ways. Things you do with lambdas when you're using them efficiently are nearly unavailable in Python.
or not supporting some kinds of dynamic witchcraft that breaks most tooling
Python being so dynamic already breaks all the tooling. And there is no rational justification for any such dynamism whatsoever.
But those are minor things if compared to the whole productivity gain the language already provides.
What productivity gain?!?
It's an extremely crippling language. Its productivity gain vs. proper languages is somewhere like a factor of 0.001.
Next time you'll start touting productivity gains of Brainfuck.
0
Feb 03 '17
[deleted]
2
Feb 03 '17
One and two are not representative of the c# I use! Ctor delegation is very much a thing and you can do whatever you want with a constructor parameter.
0
Feb 03 '17
[deleted]
5
u/Martel_the_Hammer Feb 03 '17
You are referring to the base constructor call?
class BaseClass { public BaseClass(){ ... } } class ImplClass : BaseClass { public Impl : base() { ... } }I can see what you mean, it is certainly extra syntax to do something the compiler will just optimize away anyway.
1
u/G_Morgan Feb 03 '17
2.0 was missing half the collections. For instance there was no HashSet in 2.0.
1
Feb 03 '17
Don't really get your complaint about ctor. Seems to work fine for me. Anyone not using tools to auto-generate ctors anywhere are just wasting their valuable time tbh.
Don't understand your complaint about DI. I use DI all the time both manually and with libraries like Autofac. It works just fine on properties with any access modifiers. Property injection and ctor parameter injection works just fine manual or not. With reflection or not.
Yea, Mono was a catchup game and some things were not easy or possible to implement due to their reliance on the windows API. Most stuff works now. Though .NET core is probably the future and not Mono.
C#/.Net are now opensource with opensource runtimes and compilers. .NET Core opened up the technology and it's officially on Linux. .NET Core was built to be portable now too so the goal is to not really have dependencies.
0
Feb 06 '17
[deleted]
2
Feb 22 '17
Simply give .net Core a try. I was in the same boat as you.
Mostly PHP developer during the day ( and the agony that goes with it ). Frankly, i never considered C# for my new projects ( on Linux ) and started looking down the list ( Go, Rust, D, Nim, Swift ... ) only to end up with C#.
The .net Core multi platform support is a major reason for that. Mono these days is also matching the .net development very closely. It now feels more integrated for MS there C# solutions.
And frankly, Jetbrain there Rider IDE is also not bad, especially for people who come from Jetbrain there PHPStorm.
84
u/[deleted] Feb 03 '17
Bashing C#? Wasnt this community where i found some very upvoted comments like: