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
  • НаукаНаука

Комментарии • 92

  • @markusmachel397
    @markusmachel397 Год назад +91

    Prime´s hate for c# got Garbage Collected

  • @scosminv
    @scosminv Год назад +73

    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.

  • @paulsanchez5030
    @paulsanchez5030 Год назад +129

    I feel professionally validated hahahahaha, dude I use so much C# in my current job, I like it now.

    • @alissoncandatem1896
      @alissoncandatem1896 Год назад +2

      true

    • @publicalias8172
      @publicalias8172 Год назад +54

      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

    • @davidbottiau5408
      @davidbottiau5408 Год назад +41

      @@publicalias8172 it's so far better than Java. I don't know how this thing still proliferate.. I mean, I know why but still..

    • @airman122469
      @airman122469 Год назад

      Still hate it. I like knowing when my memory will be freed.

    • @OcarinaOfVali
      @OcarinaOfVali Год назад +28

      ​@@airman122469so you hate any language with a garbage collector.

  • @serdookr
    @serdookr Год назад +48

    love c#, feels like a more high-level c++ (EUGH) done right + linq my beloved

    • @YourMom-rg5jk
      @YourMom-rg5jk 10 месяцев назад +12

      it feels like java but like not total dog shit

  • @sacredgeometry
    @sacredgeometry Год назад +62

    Best language you have featured so far

    • @CallousCoder
      @CallousCoder Год назад

      🙄It’s a cancer! It’s a Microsoft tumor eating away on your resources. Byte code, Garbage Collecting shit show.

    • @reddragon2358
      @reddragon2358 Год назад +3

      ​@@CallousCoder Nah, it is good

    • @CallousCoder
      @CallousCoder Год назад

      @@reddragon2358 agree to disagree 😉

    • @reddragon2358
      @reddragon2358 Год назад

      @@CallousCoder ;)

  • @reddragon2358
    @reddragon2358 Год назад +36

    Let's go C#

    • @Bourn77
      @Bourn77 11 месяцев назад +14

      It already did

    • @anthonysteinerv
      @anthonysteinerv 11 месяцев назад +3

      U live under a rock? That happened like 5 years ago.

  • @davidbottiau5408
    @davidbottiau5408 Год назад +42

    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.

    • @sps014
      @sps014 Год назад +8

      There is an ongoing proposal and source generator lib to help you with discriminated union.

    • @davidbottiau5408
      @davidbottiau5408 Год назад +3

      @@sps014 ah yes, I can see how using Source Generators simplify this.

    • @q1joe
      @q1joe Год назад +2

      You can use a to string attribute to get a string value that’s custom

    • @MrOnePieceRuffy
      @MrOnePieceRuffy Год назад +1

      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.

  • @justgame5508
    @justgame5508 Год назад +34

    Linq is great btw, easily my favourite feature of C#

    • @YourMom-rg5jk
      @YourMom-rg5jk 10 месяцев назад

      it really is the only memorable C# feature

    • @FilipCordas
      @FilipCordas 8 месяцев назад +1

      @@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.

  • @cheebadigga4092
    @cheebadigga4092 Год назад +35

    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.

    • @SimonBuchanNz
      @SimonBuchanNz Год назад +12

      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.

    • @cheebadigga4092
      @cheebadigga4092 Год назад +1

      @@SimonBuchanNz ah, true. Dang it. Should've looked at the docs first. Anyway extension methods are beautiful! :)

    • @scosminv
      @scosminv Год назад

      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 :)

    • @anon-fz2bo
      @anon-fz2bo 11 месяцев назад

      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.

    • @cheebadigga4092
      @cheebadigga4092 11 месяцев назад +1

      @@anon-fz2bo please read up on extension methods... they are not instance methods at all.

  • @quachhengtony7651
    @quachhengtony7651 Год назад +15

    benchmark the lexers in every languages, then we'll see who's laughing

  • @istovall2624
    @istovall2624 Год назад +36

    C# is best all hail c#
    Edit. Its pronounced c tic tac toe btw.

  • @metaltyphoon
    @metaltyphoon Год назад +13

    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

  • @DrewryPope
    @DrewryPope Год назад +6

    C# is good now

  • @donutdude246YT
    @donutdude246YT 6 месяцев назад +3

    C# is amazing! Do more video with it! :D (C# dev for 8 years, lately in games)

  • @clingyking2774
    @clingyking2774 Год назад

    What colorscheme is he using?

  • @godelcio
    @godelcio 26 дней назад +1

    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.

  • @md.redwanhossain6288
    @md.redwanhossain6288 Месяц назад +1

    OutputType exe means its an executable, not window's .exe. This is a horrible and confusing naming.

  • @spacewad8745
    @spacewad8745 Год назад +15

    69 likes 0 dislikes. balanced as all things should be

  • @balasubramanianvaidyalinga487
    @balasubramanianvaidyalinga487 11 месяцев назад +2

    IEnumerable allows for iteration, IQueryable allows for LINQ although it’s easy to mod it with AsQueryable.

    • @dineingergaro7589
      @dineingergaro7589 11 месяцев назад +8

      LINQ is, in the default dotnet, implemented with IEnumerable. And as far I know they wrote another implementation for IQueryable in the Entity Framework.

  • @polic72andDrD3ath
    @polic72andDrD3ath 18 дней назад

    C# eh? gonna have to give it a button-down / Logitech Wave

  • @quachhengtony7651
    @quachhengtony7651 Год назад +7

    built-in compile to binary out of 10

  • @anon-fz2bo
    @anon-fz2bo 11 месяцев назад

    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.

  • @user-cr3dn9vt6h
    @user-cr3dn9vt6h 9 месяцев назад

    F# tho, I'm new here, have you reviewed it?

  • @asadbeksindarov6833
    @asadbeksindarov6833 4 месяца назад

    I would recommend checking out F# too

  • @andarba2148
    @andarba2148 Год назад

    Where is C?

    • @SimGunther
      @SimGunther Год назад +1

      They literally posted a vid on it here an hour ago

  • @WillEhrendreich
    @WillEhrendreich Год назад +5

    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..

  • @thijsyo
    @thijsyo Год назад +6

    I rate this video a strong khakis/9-5

  • @fenkraken
    @fenkraken Год назад +5

    F# would've been so much better, but that's if you are wiling to use Micros*ft language.

    • @fenkraken
      @fenkraken Год назад +15

      Then again, Prime uses Typescript all the time, so...

  • @gimmedatcake4785
    @gimmedatcake4785 Год назад +2

    To me this video felt a bit Guid.Empty

  • @spudhead169
    @spudhead169 9 месяцев назад +1

    Lol, it's quite clear these guys could use some programming lessons.

  • @ZeykaFX
    @ZeykaFX Год назад +8

    Corporate# 🤢

    • @scosminv
      @scosminv Год назад +7

      C# actulally wanted to be a more concise C++. The # is the ++ overlapped :D.

  • @NullboyCode
    @NullboyCode Год назад +3

    Theprimeagen doesnt have C# lsp 😮, very noob

  • @cariyaputta
    @cariyaputta Год назад +4

    Why don't M$ just get rid of XML already?

    • @davidbottiau5408
      @davidbottiau5408 Год назад +10

      Still better than YAML. But everyone has their opinions. :)

    • @alexisauriac7941
      @alexisauriac7941 Год назад +5

      @@davidbottiau5408 Not a high bar to clear...

    • @SimonBuchanNz
      @SimonBuchanNz Год назад +1

      YAML is the least bad format if a human has to interact with it, change my mind.

    • @ShadoFXPerino
      @ShadoFXPerino Год назад +1

      XML is the best

    • @shreyasjejurkar1233
      @shreyasjejurkar1233 Год назад +1

      FYI React syntax is also XML

  • @alihammadshah
    @alihammadshah Год назад +1

    What's that vim feature that shows the current scope ie the current Class and method or if block etc while scrolling.

    • @shylex7660
      @shylex7660 Год назад +3

      nvim-treesitter-context

  • @Ryuujin1024
    @Ryuujin1024 Год назад +3

    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...

    • @OcarinaOfVali
      @OcarinaOfVali Год назад +13

      Like virtually almost any language?

    • @scosminv
      @scosminv Год назад +1

      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.

    • @FilipCordas
      @FilipCordas 8 месяцев назад +3

      Because it's not a ridiculous language that uses new lines so much easier to read and understand.

  • @Crcs-1997
    @Crcs-1997 Год назад +3

    Atrocious language

    • @raylopez99
      @raylopez99 Год назад +22

      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).

    • @reddragon2358
      @reddragon2358 Год назад +1

      ​@@raylopez99Agreed

    • @anthonysteinerv
      @anthonysteinerv 11 месяцев назад +7

      Skill issue.

  • @cubbucca
    @cubbucca Год назад +6

    as a C# dev I rate this Men's Corduroy Pants out of GUID.default

  • @socialkruption
    @socialkruption Год назад

    php #1