Code Review: C# + Some Banter
HTML-код
- Опубликовано: 30 май 2023
- LIVE ON TWITCH: / theprimeagen
Check out Teej!:
/ @teej_dv
/ teej_dv
Get in on Discord: / discord
Get in on Twitter: / theprimeagen
Got Something For Me to Read or Watch??:
/ theprimeagenreact - Наука
Prime´s hate for c# got Garbage Collected
If you want to tacle performance with C# you can perform pretty low level optimizations with ease.
C# has structs, ref structs, Span, ArrayPool, StructLayout (to control the physical layout of your data in memory) and many others.
I feel professionally validated hahahahaha, dude I use so much C# in my current job, I like it now.
true
It gets wayyy more hate than is necessary.. we get it, it's basically Java# who cares? The important thing is; it's not Java lol
@@publicalias8172 it's so far better than Java. I don't know how this thing still proliferate.. I mean, I know why but still..
Still hate it. I like knowing when my memory will be freed.
@@airman122469so you hate any language with a garbage collector.
love c#, feels like a more high-level c++ (EUGH) done right + linq my beloved
it feels like java but like not total dog shit
Best language you have featured so far
🙄It’s a cancer! It’s a Microsoft tumor eating away on your resources. Byte code, Garbage Collecting shit show.
@@CallousCoder Nah, it is good
@@reddragon2358 agree to disagree 😉
@@CallousCoder ;)
Let's go C#
It already did
U live under a rock? That happened like 5 years ago.
Unfortunately, you cannot put data into enums (other than a numeric value). That's pretty much the main impediment with C# and if you need to do something like that, you have to write class with static properties. It's clearly not cleaner than Rust enums but it works.
There is an ongoing proposal and source generator lib to help you with discriminated union.
@@sps014 ah yes, I can see how using Source Generators simplify this.
You can use a to string attribute to get a string value that’s custom
and THANKS GOD this is the case. There can't be other data in an enum. If you can save other data than that, you program with real cancer for Computers.
Linq is great btw, easily my favourite feature of C#
it really is the only memorable C# feature
@@YourMom-rg5jk async came from c#, Observables are a c# invention. Async enumerables are a c# invention. Events as much as people hate on them are awesome in c#. using statement is from c#. extern import is an underused feature.
Edit: Got corrected via comment, IsDigit is not an extension method, it's just a static method. But still extension methods are beautiful!
In C# you can have "extension methods", basically attaching methods to types. Signatures being: public static ReturnType SomeMethod(this SomeType someInstance) - for char, this looks something like this: public static bool IsDigit(this char c). This has the advantage that the types themselves - especially primitive types like char, int, etc - are just that, types. They don't have any methods themselves. The runtime can attach these extension methods, either the ones provided by Microsoft (like IsDigit), or you can write your own. I think that's really beautiful about the language. It borrows this idea from Python, where you can simply add a method to a class just by writing "myobject.mymethod = SomeMethodHere", but without the downsides like overwriting methods that class already has. If your C# extension method would overwrite an instance method, then, at least the compiler will warn you or throw an error. Not sure which one happens but it for sure does not just let you do it like Python would.
I have no idea why people were saying this in chat, let alone here where you have time to think about it.
char.IsDigit() has nothing to do with extension methods, it's just a plain static method on the char type. That's why there's a type on the left, and the actual character value is passed in as a parameter.
@@SimonBuchanNz ah, true. Dang it. Should've looked at the docs first. Anyway extension methods are beautiful! :)
you can easily create an extension method in a static class that you bring in scope with a using statement like this:
public static bool IsDigit(this char c) => Char.IsDigit(c);
Now you can invoke it like this:
bool isDigit = c.IsDigit();
so no reason to debate here :)
i dont even code in C# and i knew that isDigit is a static method. its not hard to differentiate between instance and static methods. please dont call instance methods extension methods either its far simpler to refer to a method that takes in self or this as an instance method since you create an instance of the class then invoke the method on that instance.
@@anon-fz2bo please read up on extension methods... they are not instance methods at all.
benchmark the lexers in every languages, then we'll see who's laughing
C# is best all hail c#
Edit. Its pronounced c tic tac toe btw.
c hashtag
C Octothorpe
I’m going to have to push my PR, that code does too much string creating for no reason. I actually benchmarked mine against this and it used half less memory and it was 20% faster
C# is good now
C# is amazing! Do more video with it! :D (C# dev for 8 years, lately in games)
What colorscheme is he using?
Good video. Meanwhile, yes, the .net .sln files are ugly but In the current Visual Studio beta, there is the possibility to save a way better and cleaner solution file, saving it as the extension .slnx . It will be a lot better for building tooling around it, we can expect it for the next VS release.
OutputType exe means its an executable, not window's .exe. This is a horrible and confusing naming.
69 likes 0 dislikes. balanced as all things should be
IEnumerable allows for iteration, IQueryable allows for LINQ although it’s easy to mod it with AsQueryable.
LINQ is, in the default dotnet, implemented with IEnumerable. And as far I know they wrote another implementation for IQueryable in the Entity Framework.
C# eh? gonna have to give it a button-down / Logitech Wave
built-in compile to binary out of 10
the code in the thumbnail makes no sense. if position == 0 then any string invoked in Lexer.ParseTokens("1aB") would start an infinite loop + other things.
F# tho, I'm new here, have you reviewed it?
I would recommend checking out F# too
Where is C?
They literally posted a vid on it here an hour ago
2:30 they would have that expressiveness .. If they just used fsharp with Discriminated Unions... Like in Ocaml.
OK.. I'll try to keep my fsharp fan-boying to one comment..
I rate this video a strong khakis/9-5
pretty good
F# would've been so much better, but that's if you are wiling to use Micros*ft language.
Then again, Prime uses Typescript all the time, so...
To me this video felt a bit Guid.Empty
Lol, it's quite clear these guys could use some programming lessons.
Corporate# 🤢
C# actulally wanted to be a more concise C++. The # is the ++ overlapped :D.
Theprimeagen doesnt have C# lsp 😮, very noob
Why don't M$ just get rid of XML already?
Still better than YAML. But everyone has their opinions. :)
@@davidbottiau5408 Not a high bar to clear...
YAML is the least bad format if a human has to interact with it, change my mind.
XML is the best
FYI React syntax is also XML
What's that vim feature that shows the current scope ie the current Class and method or if block etc while scrolling.
nvim-treesitter-context
I will never understand why C# kept the ; at the end of lines. Copying Java a bit too hard on that one. Just im a spoilt Kotlin fanboy so...
Like virtually almost any language?
it's a statement - based language. It accepts expressions in limited situations.
It would be nice if it would adopt Rust's approach with ; for statement, no ; for expressions.
It would make return keyword an option...
to return value x from a function you would either use:
...
return x;
}
or:
...
x
}
currently only first option is available.
Because it's not a ridiculous language that uses new lines so much easier to read and understand.
Atrocious language
Great language, MSFT's version of Java, GC, works very well with WFC, super fast (`3-4x of C/Rust), what's not to like? And you help my favorite corporation, that made my family even richer, MSFT baby. Not that MSFT makes money off of C# (or even selling OSes anymore, I think less than one-third their revenue comes from Windows licenses these days).
@@raylopez99Agreed
Skill issue.
as a C# dev I rate this Men's Corduroy Pants out of GUID.default
great rating
php #1