Python vs Swift | Prime Reacts

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2023
  • Recorded live on twitch, GET IN
    / theprimeagen
    Links
    Video: • Python vs Swift | Chri...
    Author: / @lexclips
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact
    Kinesis Advantage 360: bit.ly/Prime-Kinesis
    Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
    turso.tech/deeznuts
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 218

  • @ciscoserrano
    @ciscoserrano 6 หลายเดือนก่อน +189

    More Swift videos are needed! To answer your question in the video. Yes, you can write Swift anywhere using whatever tool you like. Contrary to popular belief it’s not an Apple only language and you can use it anywhere from Windows to Linux to the web.
    You can write in Vim and also use the LSP for some really nice language features. (:

    • @zadintuvas1
      @zadintuvas1 6 หลายเดือนก่อน +8

      Isn't the available standard library much smaller on other platforms? I think I heard that this is the case.

    • @deathlife2414
      @deathlife2414 6 หลายเดือนก่อน +13

      ​@@zadintuvas1yeah. Tool support is low

    • @kosnowman
      @kosnowman 6 หลายเดือนก่อน +1

      I learnt Swift because I am an Apple fanboy but I still hard to find a use case outside of SwiftUI, I am pushing myself to use it after college and get a job, I really enjoy the idea of server-side Swift!
      And I feel that learning Java really helps me understand Swift better

    • @slippydouglas
      @slippydouglas 6 หลายเดือนก่อน +3

      @@zadintuvas1 You don't get the portions of the ”standard library“ that are part of the Foundation module- the stuff that's Swift wrappers for Objective-C stuff. But IMHO that's a good thing, since those Obj-C-bridged types & functions can cause unexpected performance, memory semantic, & multithreading issues (everything but primitive value types is an object in Obj-C, like Ruby and Smalltalk). I *wish* for iOS development we could set a flag that disallows pulling in all the old Foundation stuff by default because of how much code reviewing and fixing I have to deal with at my job when code is written by devs who used to do Obj-C and don't know the difference between Obj-C-bridged and pure-Swift.

    • @MarquisKurt
      @MarquisKurt 6 หลายเดือนก่อน +5

      @@slippydouglas I believe there’s also a roadmap to have a new Foundation for Swift, and I think that one isn’t reliant on ObjectiveC.

  • @slippydouglas
    @slippydouglas 6 หลายเดือนก่อน +49

    8:29 Swift collections are pass-by-copy, _but also_ Swift has good copy-on-write analysis by the compiler. So a pass-by-copy when the caller never uses that value again (only the callee uses it) is often a fast pass of ownership without the programmer having to annotate or do anything extra.

    • @JohnR436
      @JohnR436 6 หลายเดือนก่อน +1

      Bingo!

    • @TremereTT
      @TremereTT 5 หลายเดือนก่อน

      so swift cow and arc works like Delphi records(structs), dynamic arrays, strings ?

    • @slippydouglas
      @slippydouglas 4 หลายเดือนก่อน

      @@TremereTT i'm not terribly familiar with Delphi or Object Pascal, but yes, looks similar in some ways (it's notable that Object Pascal originated at Apple with Larry Tesler leading the team). So it seems some of the same reference-counting ideas also made their way into Objective-C, but around 2009 Apple went hard with ARC in Objective-C, updating and converting the language to use ARC exclusively, eventually all-but-deprecating Manual Retain Release. Then in 2014 Swift 1.0 was released and inherited Obj-C's ARC memory model for all object types (and COW for value types).

    • @TremereTT
      @TremereTT 4 หลายเดือนก่อน

      @@slippydouglas Well at least in Freepascal and in Delphi it's COW + ARC, yet you can also ALLOC all those data structures your self and they will then need to be freed by you and they will no longer show COW behaviour then. This is usefull if you want to use Records and Recordreferences to access protocol headers or file headers in Bytestreams ... just like in C.

  • @isodoubIet
    @isodoubIet 6 หลายเดือนก่อน +33

    A typeclass in Haskell is not the same as a class. It's closer to Rust traits; a family of types for which certain functions are defined. The closest thing to a class in Haskell would be a Record (essentially a struct with godawful syntax).

    • @m4tt_314
      @m4tt_314 5 หลายเดือนก่อน +2

      Almost got it 😄 Traits are type classes, but somewhat limited. IMO it goes something like this: Rust's trait < Type class < C++ concept

    • @somenameidk5278
      @somenameidk5278 5 หลายเดือนก่อน

      @@m4tt_314 i haven't really played with c++ concepts. i used it once when making my own shitty std::map, but that was just using a built in partial ordering concept i think. i think i'll look into them now.

  • @junebash
    @junebash 4 หลายเดือนก่อน +4

    Swift collection types (array, dictionary, set, string, etc) are copy on write, but this is not built into the language itself; they are implemented in the standard library that way. In essence, they are reference types under the hood, but before any mutation, the reference count is checked, and if there is more than one reference, it makes a new heap allocated copy before performing the mutation.

  • @slippydouglas
    @slippydouglas 6 หลายเดือนก่อน +5

    10:53 _”I'm curious how you do like shared references, ones where 2 functions can mutate a value without copy on write.“_ A couple of options:
    1. Pass by reference (&-prefix) to a function with an inout arg (like C# and many other languages).
    2. Much more commonly, wrap your value type instance in an object type (a class, as opposed to a value primitive type or a struct or enum, like C++ and many other languages).
    3. Use closures to get/set the original value. A bit esoteric, but sometimes this is the mechanism under custom type-erasing types or custom property wrappers attributes (again, drawing some similarities to C#).

  • @austinsiu2351
    @austinsiu2351 6 หลายเดือนก่อน +14

    One thing I like about swift is how the language can constantly offer features to you that you need, but not flooding them all to you on day 3 of learning. On the other hand, if you suddenly need some advanced feature, it is difficult for you to know what are the prerequisites because it just suddenly feels like a foreign language

    • @kvherro
      @kvherro 5 หลายเดือนก่อน +1

      Nailed it

    • @jtpotato
      @jtpotato 5 หลายเดือนก่อน

      i remember starting out with playgrounds many years ago, when I had first started coding... I thought I got it! and then recently I started using SwiftUI 😵‍💫. Suffice to say i did not get it

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน +1

      It is a productive language and has been built from the ground up for that purpose.

    • @vince14genius
      @vince14genius 4 หลายเดือนก่อน +2

      so true
      ResultBuilder DSLs and macros lmao

    • @alltaxationrequirescops
      @alltaxationrequirescops หลายเดือนก่อน +1

      skill issue

  • @kaljsdlksjfd3286
    @kaljsdlksjfd3286 5 หลายเดือนก่อน +6

    Swift is the most ergonomic safe language in existance

  • @burarum1
    @burarum1 6 หลายเดือนก่อน +11

    In deep learning context tensors are n dimensional arrays BUT what separates them (and what the degen twitch chat did not mention) from lets say vanilla Numpy arrays, if we are in python land, is that tensors have the additional machinery to be part of a computational graph and gradient computations in the graph using automatic differentiation that all deep learning libraries usually implement. For example in Pytorch all tensors have requires_grad attribute to imply if gradients should be calculated for said tensor.

    • @isodoubIet
      @isodoubIet 6 หลายเดือนก่อน +3

      Not necessarily true; e.g. the xtensor library in C++ is essentially trying to emulate numpy. AFAIK it has no autograd.
      The _real_ difference between n-dimensional arrays and tensors is analogous to the difference between an array with 2 elements and a vector in the 2d plane. An array with 2 elements is just a pair of arbitrary numbers, but a vector must transform in a very specific way when you do coordinate transformations. For example, if you rotate the coordinate system counter-clockwise by 45 degrees, the vector at (sqrt(2), sqrt(2)) will be transformed into (2, 0).
      neural net practitioners decided to call arbitrary n-dimensional arrays 'tensors' because they don't understand the above. I don't really care that much, call it what you like, but if you look for an intentional difference between 'tensor' and 'nd-array' in the machine learning world you're likely to end up confused.

    • @burarum1
      @burarum1 6 หลายเดือนก่อน +2

      ​@@isodoubIet Ok, sorry to you good sir for being too absolute in my wordings. I tried to give a practical explanation that relates specifically to the topic of this video and deep learning frameworks in general and not how they are viewed in differential geometry etc. since the connection is pretty loose I would say. The _real_ difference between n-dimensional arrays and tensors is obviously a skill issue.

    • @isodoubIet
      @isodoubIet 6 หลายเดือนก่อน +2

      @@burarum1 That's what I'm trying to say, there is no difference in the machine learning world. People just give these names and there isn't much rhyme or reason to it.

  • @JorgetePanete
    @JorgetePanete 6 หลายเดือนก่อน +28

    Swift has UTF-8 checks for identical characters, I like that

    • @pinkorcyanbutlong5651
      @pinkorcyanbutlong5651 2 วันที่ผ่านมา

      swift imo has god tier string/character handling

  • @JohnR436
    @JohnR436 6 หลายเดือนก่อน +23

    Would love to see more Swift content. It’s one of my favorite languages ❤

  • @jacktabomb
    @jacktabomb 5 หลายเดือนก่อน +1

    Need more videos like this of prime reacting to Lex interviews 🔥🔥🙌🙌

  • @sylarfx
    @sylarfx 6 หลายเดือนก่อน +4

    primeagean: ... right now swift has everything what I want ...
    me: hmmm, where did I hear this before?

  • @rickdg
    @rickdg 6 หลายเดือนก่อน +3

    When you start searching for Swift, both the content creators and the tooling seemed to be focused on publishing to the App Store. There is movement on the server side, but it doesn’t bubble up to where people can feel it.

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน +1

      You will find the most productive software engineering languages are platform specific be it C#, Kotlin or Swift. Try using a non specific platform language for software development and you will defund them to not be the best choice for software engineering.

  • @kosnowman
    @kosnowman 6 หลายเดือนก่อน +7

    I didn't realize the danger of passing an object as an argument is actually by passing the reference value (address/pointer) and any changes will mutate to the root of the object until 2 weeks ago at my college was talking about this in detail during the Java lecture.
    Shamefully enough I was working as a JS dev full time and I didn't know that until now

    • @s3rit661
      @s3rit661 6 หลายเดือนก่อน +4

      It's not even your fault, it's the fault of the tutorials that didn't teach that, or yours to have taken the wrong one, but at the end how could you knew which one was the correct one

    • @alexm9104
      @alexm9104 6 หลายเดือนก่อน

      It's called shallow copy (passed by ref) and deep copy (actual clone).
      In JS mostly you have shallow copy unless you convert object to JSON and then parse it to another var. Or use structuredClone().

    • @kosnowman
      @kosnowman 6 หลายเดือนก่อน

      @@s3rit661 I did a bootcamp and they never go deep on that topic.
      People say colleges are useless, but I relearn lots of fundamental knowledge from college, and it is just 3 months in! The knowledge is useless until you reach beyond the surface

    • @isodoubIet
      @isodoubIet 6 หลายเดือนก่อน +2

      Yeah that's one of the pitfalls of starting with a high-level language. They all try to shield you from having to think about it, but you always end up having to think about it.

  • @aus10d
    @aus10d 5 หลายเดือนก่อน +7

    Swift does seem VERY appealing. I'm interested to learn it better too

  • @jeffrey5602
    @jeffrey5602 6 หลายเดือนก่อน +4

    It’s always real fun when data scientists create cool bugs when dealing with pandas dataframes, passing them around like everything is a copy. I was one of those data scientists once. Luckily I am naturally curious and also once dabbled a bit in C after which everything got a bit easier. But the minimum is to once read a blog entry on shallow and deep copies in python.

    • @azmah1999
      @azmah1999 6 หลายเดือนก่อน +1

      I recently wrote some numerical code and I tried to understand why it didn't converge. So I added some statements to compute some helpful intermediate values and print them. Doing so crashed the code.
      That's when I remembered Python is a garbage (collected) language and that basically everything is passed by value. Yeah, wasting a few hours on that wasn't fun.
      Knowing C++ definitely help debug that issue but it was still a pain. I'll never understand how people that decided that pointers were too complicated also decided that the best way to get rid of them was to make nearly all variables pointers in disguise (with even the ability to be set to a null pointer)

  • @martinvuyk5326
    @martinvuyk5326 6 หลายเดือนก่อน +5

    When prime learns Mojo's language features... Imagine this same dude learnt all of the lessons fron building LLVM, Swift, Tensorflow XLA "generalization" (which became MLIR as far as I understand), and then went and built a programming language that mixes Rust, C++ , and python concespts with a pragmatic take and letting the programmer decide how to use the features

    • @arjix8738
      @arjix8738 5 หลายเดือนก่อน

      Eh, mojo doesn't look that impressive

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      @@arjix8738
      How would you know at this stage?

    • @arjix8738
      @arjix8738 4 หลายเดือนก่อน +1

      @@Art-is-craft it has been as disappointing as bun for me
      Both incomplete and a pile of promises

  • @Yupppi
    @Yupppi 5 หลายเดือนก่อน

    CppCast had Dave Abrahams as a guest after he had worked with creating Swift, when he moved to Adobe tech lab, and he talked a bit about that stuff - getting defaults right etc. He pretty much started the talk about the importance of const things in C++ world I suppose. It was pretty fascinating.

  • @MrAbrazildo
    @MrAbrazildo 5 หลายเดือนก่อน

    3:00, in low-level, you can chose any way you want to pass. The only barrier is that, when passing by copy and wanting to edit the thing, having the changes valid for the original, a 2nd step must be done later: to copy the copy back to the original.
    12:05, just like C++: full control of who changes who and who can be changed.

  • @gjermundification
    @gjermundification 6 หลายเดือนก่อน +2

    8:29 Swift makes a distinction between value types; struct and reference type; class. Basically you can do both heap and that other thing. Borrowing approaching recent releases of the language.

  • @M4AH1990
    @M4AH1990 หลายเดือนก่อน

    In case anyone wants to know the details of Swift's CoW, here's what I know:
    Generally speaking, for any value type (any structs or enums), if you make an immutable copy of it, (like if you pass it as a param to a function, or do `let arr2 = arr1`), the compiler passes a reference to that instance. However, if you make a mutable copy, (`var arr3 = arr1`), the compiler makes a copy of it and send it. You can neither modify the value of an immutable value-type property nor mutate any of its members.
    Swift's collections are value types, so they're passed by value, but they have copy-on-write semantics, and that's handled by the implementation.
    So, if you make an immutable copy of an array, then you're sharing the reference to the instance itself. If you make a mutable copy, then a copy is made, which is, in reality, just the reference to the underlying storage. When you get to actually mutate the values within the array, a copy is made of the underlying storage, and then the copy gets the changes.

  • @tapashmajumder2377
    @tapashmajumder2377 6 หลายเดือนก่อน +29

    Swift is awesome! I wish you could use it for more things.

    • @ryanleemartin7758
      @ryanleemartin7758 6 หลายเดือนก่อน +2

      Yeah! It's the language I didn't know I needed but still kinda can't have. "Easy mode Rust"

    • @mistymu8154
      @mistymu8154 5 หลายเดือนก่อน +2

      I love Swift too. While Apple actively encourages developers to use Swift for everything, Apple's main focus is adding new features that will benefit Apple platforms. They are always adding new features every year, but I would love for them to just take a break on adding new stuff and focus on bringing Swift on Linux and Windows up to parity with Mac. They are obviously pushing the C++ interop thing hard, but they do need to improve the tooling cross-platform, especially on Linux.

    • @tapashmajumder2377
      @tapashmajumder2377 5 หลายเดือนก่อน

      @@mistymu8154 totally. Although they needed many iterations to get the language to mature and to iron out the kinks. Now is a great time to make it cross platform properly.

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      @@mistymu8154
      Why on earth would Apple want to help Linux or Windows. It would be like asking Mercedes to help GM build a better engine.

    • @ConernicusRex
      @ConernicusRex 4 หลายเดือนก่อน +1

      @@Art-is-craft Swift is open source. Also Apple is a consumer hardware company, they compete with neither commercial software companies or open source operating system collectives. They make their own devices and they make the things that run on those devices. That's it. They don't have to compete with anyone who makes software and to think they do is such a fundamental misunderstanding of technology I have to wonder what you're doing here at all.

  • @bpo217
    @bpo217 5 หลายเดือนก่อน +3

    Totally doesn't matter but I really like in Swift being able to write a list of lets or vars without re-writing the let/var. It's silly but I miss it when I switch languages. I think the only other language compiled language I could do this in was Nim?

  • @ruanpingshan
    @ruanpingshan 6 หลายเดือนก่อน +12

    Swift has the nicest closure syntax of any language I've used. Especially how it gives you implicitly defined parameters like $0, and $1, etc. Makes it really compact to just map to some property of the objects in the list.

    • @isodoubIet
      @isodoubIet 6 หลายเดือนก่อน +1

      Unfortunately, it also has the worst syntax for passing a closure to a function.

    • @mamai_eth
      @mamai_eth 5 หลายเดือนก่อน +1

      @@isodoubIetwhy tho?
      You either assign it to a variable and pass like a regular argument or you can use a shorthand syntax which is far better than any other language.

    • @isodoubIet
      @isodoubIet 5 หลายเดือนก่อน

      @@mamai_eth The shorthand syntax is precisely what I'm complaining about. It's a function, not a command, let's not mix the two.

    • @mamai_eth
      @mamai_eth 5 หลายเดือนก่อน +1

      @@isodoubIetswift has literally built a UI framework, regex framework, I have used a parser framework and a html/template frameworks based on function builders which are based on shorthand syntax.
      Like if you don’t wanna use it, nobody forces you to.
      Btw what a heck is a command in programming? Never heard such a concept.
      Is there a language which has commands?

    • @isodoubIet
      @isodoubIet 5 หลายเดือนก่อน

      @@mamai_eth That makes zero sense. A shortened syntax is not responsible (and not even important) for any of these things.
      "Like if you don’t wanna use it, nobody forces you to."
      Exactly, I will never use swift partly for this reason.
      If you meant "don't use the construct" instead of "don't use the language altogether", you should know better.
      "Btw what a heck is a command in programming? Never heard such a concept.
      Is there a language which has commands?"
      It's the same thing as a statement. Don't be silly.

  • @CaptTerrific
    @CaptTerrific 6 หลายเดือนก่อน +7

    Granted I last took intro to CS 19 years ago... but do JS devs really not know when a value vs a reference is passed? I have a hard time believing it's even possible to program without keeping track of your function calls.
    Honest question: does the language even allow values to be passed? Can the value be a pointer?

    • @axisaligned9799
      @axisaligned9799 6 หลายเดือนก่อน

      For your question, no you cannot implicitly pass by value that can be done by optimization but not by you. As for pointers they are implicit for any non-primitive data, not really something you control. Maybe if you count the typed arrays and buffers JS offers?

    • @fenndev
      @fenndev 6 หลายเดือนก่อน

      Javascript is pass-by-value. Objects are weird in that they're passed by value, by reference; you can reassign an object argument within in a function and modify that variable without altering the original object. But you can also modify parameters on the argument object directly and it will affect the original one.

    • @axisaligned9799
      @axisaligned9799 6 หลายเดือนก่อน +1

      @@fenndev that’s not how pass by value works lmao. Everything is passed by reference. The variable re-assignment you are talking about is reassigning the variable reference

  • @PaulSebastianM
    @PaulSebastianM 6 หลายเดือนก่อน +1

    technically, and this is where the confusion comes from, "pass by copy" is most often called pass by value, for example JS is a pass by value language, but the difference is in what that value is, where in JS that value is what the language treats its data types as: primitive types are copied when passed by value, while non primitive types are treated as pointers that are automatically dereferenced when used, i.e. you don't need to write * before an object when accessing values inside of it, like with C++, so what gets copied is that pointer, so both outside the function and inside of it, you have two different variables that point to the same object.
    languages like C# are also like that but it also provides you with modifiers that can change how things are passed into functions, like the ref keyword which end up creating a ref (explicit pointer) to the variable passed in, which can be a primitive type or not, and in the case of a non-primitive type you get a pointer to technically another pointer, instead of a pointer to the same object, meaning it's something like temporarily moving the variable into the function while it's executing.

  • @adamsmith9727
    @adamsmith9727 6 หลายเดือนก่อน

    Can swift apps run on Windows 11 reliably yet?

  • @ConernicusRex
    @ConernicusRex 4 หลายเดือนก่อน +1

    16:07 you trying to correct the guy who built the language itself is pretty fucking funny, dude.

  • @ferdynandkiepski5026
    @ferdynandkiepski5026 5 หลายเดือนก่อน

    What do you think of using R for plots?

  • @varunsharma5582
    @varunsharma5582 5 หลายเดือนก่อน

    You pass by value in case of the objects as well, the value is a pointer, so you copied the pointer and passed a copy of it. But as both the original and new pointer and pointing to the same memory address, you'll edit the exact same object inside the function which is in turn a call by reference.

  • @cbbcbb6803
    @cbbcbb6803 6 หลายเดือนก่อน

    Start, or end, position and length?

  • @HypothesisI
    @HypothesisI 6 หลายเดือนก่อน +1

    Go is pass by value although the "value" when you are handling an array is a pointer, so you pass a value of a pointer when you pass an array in Go

  • @KangoV
    @KangoV 5 หลายเดือนก่อน

    Java's new Vector APIs will now create SIMD (AVX2, AVX512) instructions under the covers (if available) with huge performance gains for graphics and large scale computations. There are only a few compilers that have support (GCC and VStudio does though).
    Java will reuse strings via the String Pool. The JIT will only reference them once.
    Groan (new Java):
    void main() {
    System.out.println("Hello World");
    }
    These people need to keep up!

  • @ea_naseer
    @ea_naseer 6 หลายเดือนก่อน

    4:30 me and a friend argued about argmax i kept telling him it's mode of a continuous distribution he kept saying it's the index of highest number in an array i was confused.

  • @keco185
    @keco185 6 หลายเดือนก่อน +11

    Swift is nice, the unfortunate part is all the legacy Objective-C code you need to interface with when developing for iOS. At least that's how it was when I tried it years ago.

    • @dealloc
      @dealloc 6 หลายเดือนก่อน +8

      Still happens, but not as much anymore. A lot of the APIs are re-written in Swift (Foundation, Networking, parts of UIKit etc.) while others are still Objective-C (Cocoa, CoreGraphics, parts of AppKit, etc.). On top of that Apple also has some open source projects on GitHub that further provides rich Swift APIs.

  • @gjermundification
    @gjermundification 6 หลายเดือนก่อน

    16:22 This is in Swift. extending an Int or a Sequence do what you are asking for.

  • @russellmgptx
    @russellmgptx 6 หลายเดือนก่อน +25

    Swift is easy mode programming, and that’s not a bad thing.

    • @shreyanshmishra6613
      @shreyanshmishra6613 6 หลายเดือนก่อน +4

      Couldn't be more wrong on that one.

    • @oleg4966
      @oleg4966 6 หลายเดือนก่อน +2

      Did Apple finally fix XCode or something?
      Because back in 2020, when I was trying to get started with iOS development, working in XCode didn't feel like easy mode _at all._
      The developer experience was closer to playing a Soulslike in Early Access.

    • @russellmgptx
      @russellmgptx 6 หลายเดือนก่อน

      I've been working in Xcode for over a decade, so I couldn't comment on it it's been "fixed". I've adapted to the way it works. Someone who's not using it all the time might feel differently.
      But Xcode & Swift aren't the same thing. @@oleg4966

    • @JohnR436
      @JohnR436 6 หลายเดือนก่อน

      @@oleg4966Mobile dev since 2016, iOS only since 2019 here: Xcode has been nicer since 14.3.1, I’ve heard there have been some big improvements in Xcode 15 as well.
      Although I found Xcode to be intimidating with sharp edges at first, once you learn how to navigate those (knowing when to clean your project vs delete derivedData, manually fixing pbxproj merge conflicts, learning to NEVER use playgrounds or Storyboards) it’s actually a really nice & thoroughly integrated IDE experience.

    • @riley1636
      @riley1636 หลายเดือนก่อน

      @@oleg4966You don't need Xcode for swift. It's cross platform and can be written in anything with an LSP.

  • @thompson9451
    @thompson9451 4 หลายเดือนก่อน

    as a newbie this was super helpful! TY!

  • @RTouch10
    @RTouch10 6 หลายเดือนก่อน +8

    I love how prime discusses with his chat what Swift does even though no one there knows what is going on, and to finish it the guy in the video doesn’t do the greatest job at explaining what *type semantics* is even supposed to mean

    • @ConernicusRex
      @ConernicusRex 4 หลายเดือนก่อน +1

      The guy in the video is the inventor of the Swift language, the LLVM compiler, and half of Rust, Chris Lattner.

  • @joeltrent
    @joeltrent 6 หลายเดือนก่อน +2

    Python pass by reference and mutability gave me trust issues in early University, particularly when copy and deepcopy often wouldn’t actually allocate a new list/array 😂
    I still haven’t encountered a better solution for force allocating a new collection than doing copy_of_foo = foo * 1

    • @higorhi72
      @higorhi72 6 หลายเดือนก่อน

      copy_of_foo = foo.copy() haha

    • @joeltrent
      @joeltrent 6 หลายเดือนก่อน

      That sounds about right thank you haha

  • @Whateverworksism
    @Whateverworksism 5 หลายเดือนก่อน +2

    Lattner is great. His three interviews with Lex are worth a listen.

  • @tornoutlaw
    @tornoutlaw 5 หลายเดือนก่อน

    To complicate things further, Python does neither pass by value nor pass by reference, but pass by assignment. That entails behavior like this:
    a called function can mute mutable objects (like lists) of the caller by using object functions (like .append or slicing), but not by making a new assignment to the parameter:
    ```python
    def alter_list(mylist: list) -> None:
    print(f"got list: {mylist}")
    mylist.append("d")
    mylist[0] = 42
    mylist = ["x", "y", "z"]
    print(f"muted list: {mylist}")
    mylist = ["a", "b", "c"]
    print(f"list before passing: {mylist}")
    alter_list(mylist)
    print(f"list after passing: {mylist}")
    '''output:
    list before passing: ["a", "b", "c"]
    got list: ["a", "b", "c"]
    muted list: ["x", "y", "z"]
    list after passing: [42, "b", "c", "d"]
    ```
    but immutable objects like strings will not change for the caller:
    ```python
    def alter_string(string: str) -> None:
    print(f"got string: {string}")
    string += " was concatenated"
    print(f"muted string: {string}")
    string = "this string"
    print(f"string before passing: {string}")
    alter_string(string)
    print(f"string after passing: {string}")
    '''output:
    string before passing: this string
    got string: this string
    muted string: this string was concatenated
    string after passing: this string
    '''
    ```

  • @colemichae
    @colemichae 6 หลายเดือนก่อน +2

    Lex pretending to know once again, or is it just the way he talks. 😂😂😂

  • @tylermfdurden
    @tylermfdurden 5 หลายเดือนก่อน

    Given your love for Go, I would expect that if you gave Python a project or two, you would really get into it and enjoy it.

  • @ivanjermakov
    @ivanjermakov 6 หลายเดือนก่อน +16

    I think Swift would've been a lot more popular if it was not limited to MacOS for so long.

    • @slippydouglas
      @slippydouglas 6 หลายเดือนก่อน +2

      Swift 1.0 came out on September 9, 2014 for macOS, and Swift 2.2 released with Linux support on March 21, 2016. Native Windows support (as opposed to Cygwin or WSL) came along in Swift 5.3 on September 16, 2020.
      So (unless you're talking about native Windows support), 1 1/2 years from initial release for a language now 9 years old isn't very long.

    • @wi1h
      @wi1h 6 หลายเดือนก่อน +2

      @@slippydouglas it's not very well known that it's cross platform. no big (non-mac) projects really use it or anything. also, like it or not, native windows support matters a lot

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      There are zero good cross platform languages in software engineering. You are either producing for windows, Apple, android or some other niche system. Apple is never going to be Windows or Android.

    • @ivanjermakov
      @ivanjermakov 4 หลายเดือนก่อน

      @@Art-is-craft what do you mean? Every major language except low-level languages and Swift are cross platform.

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      @@ivanjermakov
      A VW Beetle can actually drive around a track but does not mean it can compete in Formula One. Just because a language is capable of some type of of systems usage does not mean it is suitable. Python is a fantastic language but it rarely gets used to build application software. I cannot see Swift getting used on windows or android for development.

  • @daniel-wood
    @daniel-wood 6 หลายเดือนก่อน +1

    I've enjoyed tooling around with Swift, but I'd rather code in vanilla Vi or even Nano than XCode.

  • @szmr
    @szmr 6 หลายเดือนก่อน

    3:57 yeah to be fair I have a bachelors in software engineering and we didn’t cover “under the hood” stuff

  • @MI08SK
    @MI08SK 6 หลายเดือนก่อน

    scalar-0d array, vector-1d array, matrix-2d array, tensor-3d array

  • @sadBoiDev
    @sadBoiDev 5 หลายเดือนก่อน +1

    More swift content please, as a swift developer I some times feel I’m not even a real programmer 💀
    Your making me want to learn rust

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      You are probably not a programmer but a software engineer. You will find amazing programmers who would not have the first notion about developing software application.

  • @lcarv20
    @lcarv20 6 หลายเดือนก่อน

    3:01 - Lex Fridman interviewing The Grinch

  • @brandonw1604
    @brandonw1604 6 หลายเดือนก่อน +1

    Should do the next AOC in Swift.

  • @eliaperli2485
    @eliaperli2485 6 หลายเดือนก่อน +7

    A tensor is a multilinear map between the product of dual of a vector space V with itself p times and the vector space q times to the field of the vector space V. By the way

    • @RawFish2DChannel
      @RawFish2DChannel 6 หลายเดือนก่อน +2

      what

    • @kb_dev
      @kb_dev 6 หลายเดือนก่อน +2

      @@RawFish2DChannel Just some guy that feels the need to show everybody how smart he is. Don't worry about it.

    • @apestogetherstrong341
      @apestogetherstrong341 6 หลายเดือนก่อน +4

      @@kb_dev insecure people always think others are just showing off their intelligence

    • @bbajr
      @bbajr 6 หลายเดือนก่อน +5

      that might be case in some physics or other field. in data science, tensor is just a n-dimensional array, usually n>2. for n=1, it’s normally called vector and n=2, it’s normally called matrix.

    • @eliaperli2485
      @eliaperli2485 6 หลายเดือนก่อน +1

      Well I don't buy your philosophy. This is the definition of tensor, someone can think of them as "fancy n-dimensional tables" but he doesn't get the whole picture.
      Of course it's completely fine if a programmer doesn't know the general definition. But in my opinion if you know it you can't say that they are a different thing if viewed by different people.
      In fact why they call them tensors while they could call them "n-dimensional arrays"? Because they are an istance of a bigger structure.
      Anyway mine was just a "by the way" joke, I don't see how many of you didn't get, it's a comment under a Primeagen video, the "I work at Netflix btw guy" hahah@@bbajr

  • @somebody-anonymous
    @somebody-anonymous 6 หลายเดือนก่อน

    I guess this is why I never commented any (javascript) code, because I had the nagging feeling that there was something like ownership out there which was so important and impossible to infer from code in a typical javascript project, that as somebody looking at a codebase for the first time, you want most of the comments to be about that.
    Just kidding, tomorrow "code that has to be fast because while it runs it has locked this or that resource" is the next big thing to comment and I'll throw out all my ownership comments, better stick to not commenting at all and have copilot/chatgpt explain it (?)
    Btw I kinda like that when using array.sort, that seems to hint at that sort will change the array, whereas array2=mysorter(array) should probably not change the array or otherwise it deserves a comment.

  • @elirane85
    @elirane85 5 หลายเดือนก่อน

    Here's a very basic, oversimplified explanation of what a tensor for programmers without all the "formal mathy" stuff:
    You can think about a Tensor as a multi dimensional array, and the "Degree" of the tensor, is the amount of indices the array has, NOT the amount of items in the array. Here are a few examples:
    - Tensor with a Degree of 0, is just a single number (no indices).
    - Tensor with a Degree of 1, is a basic array, since it has 1 index, notice that it does not mention how many items are in the array, only that it's a 1 dimensional array.
    - Tensor with a Degree of 2 is an array with two indices, which is basically a matrix, again, it does not mention how many rows or columns, just that it has 2 indices.
    - Tensor with a Degree of 3, is a 3d array, so 3 indices.
    And so on....
    And there are rules on how to perform mathematical operation between tensors with the same/different degrees.
    So it allows you for example to "multiply" a 3d array with a 2d one, or a 1d with 2d, and so on, in a way that makes mathematical sense and is consistent.
    Again, there is A LOT more to Tensors, and this is super simplifying the topic, but this is pretty much all you need to know for computer science.
    P.S. Tensors were mostly just a "pure math" thing, until Einstein used tensor analysis for EVERYTHING in General Relativity which popularized it made it a vital tool for any physicist since then.

  • @alexpyattaev
    @alexpyattaev 5 หลายเดือนก่อน

    So in swift a data type is either pass by value, or pass by reference, and never both. This is quite silly, as this means I have to encode the pass semantics of a datatype in the datatype itself. I much prefer encoding the lifetimes...

  • @MrEo89
    @MrEo89 5 หลายเดือนก่อน

    I mean isn’t all ML basically linear algebra computation (under the hood) to compute data der stats.

  • @vladimiryoung2035
    @vladimiryoung2035 5 หลายเดือนก่อน

    Latner nowadays is in Mojo development, that would I learn next

  • @s3rit661
    @s3rit661 6 หลายเดือนก่อน +6

    3:40 Wait what? As computer scientist i'm confused by that statement, why is CS dying? In Italy the people who start a cs degree are greater and greater each year, my courses didn't even had enough space for all the new students, and they are hired sooo much faster than the one who don't have a cs degree, i strongly disagree with that, and if someone's a programmer and he doesn't know what passing by value vs passing by reference means, he's taking the wrong choice of life.
    And btw, yes, in CS courses they teach what passing by reference and by value means, because we both study the LOW level and the HIGH level of programming languages, the full stack, and we all say whenever a language passes by reference and by value and in which cases it does that.
    Python also uses a thing called caching, also java uses that, basically whenever you say variable = 5, it keeps a space in memory containing the number 5, whenever a new variable called variable2 = 5 it's declared, python uses the previously space in memory to avoid instantiating a new space in memory and keeps track of the variables that reference this space and how many variables do that, yeah just like rust pointers. Java does that for numbers lower than 256 (don't remember the exact number).
    Whenever we say that Java always pass by value it's true, but you basically "pass by value" the address that it's inside the reference, they're using pointers without knowning it. I'll try to explain better: Let's say i have a class Home, and an object Home home = new Home();, whenever i pass the variable (reference) home to a function, i pass the address of home as value. If people start studying C and what a pointer is, they would actually understand all of that pretty easly, a cs student has hard time understanding that concept right there, simply put, there are cases in wich you can do both thing, value or reference, and cases in which the language does all of that under the hood for you. The language that allows to fully understand the whole passing by reference and by object in my opinion is C.
    Also we need to explain something about Python, everything in Python is an object, that does not happen with Java, primitives in Java are not Objects, and primitives in Java are passed by value in the pure sense of the term, meanwhile references to Objects in Java are passed by value, not the value of the Object itself, so also Java has the real pass by value thing, with primitives, and I still think that a programmer *should* know that

    • @s3rit661
      @s3rit661 6 หลายเดือนก่อน +2

      @@luca4479 In Italy we have 2 different degrees, Computer Science and Computer Engineering, the first one teaches code, with just ONE exam about Hardware, and 5-6 exams about high level programming (ALL of Java, the whole thing), and low level programming (UNIX: Posix vs System V, C, etc.), the second one, engineering, it's basically the opposite, low coding, a lot of engineering, saying i can understand how it works just because i know how it works behind the scene doesn't make sense to me, cause you can understand how to use the language without having to know how it works behind the scene, i'm still confused. An Engineer would know so much more about the low levels (plural) of the Hardware, i know what i have to know to understand how the language works, but i don't think neither CS students and programmers should be confused by the whole passing by reference vs value thing.

    • @kb_dev
      @kb_dev 6 หลายเดือนก่อน

      How long should I wait? And why do you feel the need to tell people to wait while you work something out? Main character syndrome.

    • @macaroni_italic
      @macaroni_italic 6 หลายเดือนก่อน +3

      @@s3rit661 I think his more general, perhaps unstated, point is that CS is no longer THE way to get into coding as a career (at least not in the US). So a lot of people are getting into it without ever having gotten that fundamental knowledge about low-level details. So they're like "pointer? huh?" and their understanding of reference vs. value semantics is largely limited to "oh, I must remember that if I update an element in this array, it will change it everywhere." They don't necessarily know why that behavior happens, or any sort of general rule about it, but maybe just think it's a special case.

    • @s3rit661
      @s3rit661 6 หลายเดือนก่อน

      @@kb_dev What that does even mean? When did i ask you to wait for me to work on something? Saying "Wait what" it's a matter of say, it's like saying, "wait a minute", it's like saying "i don't agree with that", i'm not english native, so i always thought that was the meaning of it, at least from where i heard those words

    • @zachmoring284
      @zachmoring284 6 หลายเดือนก่อน +4

      I've interacted with lots of CS students both domestic (US) and international in my current MS CS program. There are lots who had departments which taught them everything in a single language and they never learned anything from outside the paradigms of that language. Often Java or Python depending on the department. So they're generally very good at that one lang they have experience with and OK with theory, but have absolutely no experience translating their theory understanding to a different language or paradigm.
      IME these people often come out of large schools whose faculty aren't teaching-focused and want to enforce a very specific knowledge-path through their department.
      I can definitely imagine many of this type of student having no idea how anything low-level works beyond possibly a vague definition. You then also have people developing software out of bootcamps who likewise only know how to do one specific thing; the "React Andy"s that Prime often mentions.
      CS as a field definitely isn't dying, but there's often a significant knowledge gap between inexperienced and more experienced developers and especially between theorists and software engineers, with many institutions confused about where they want to fall along those axes.

  • @electrostatic1
    @electrostatic1 4 หลายเดือนก่อน

    Pass by reference does not copy. It's a pointer under the hood.

  • @ElementResources-rp8ox
    @ElementResources-rp8ox 6 หลายเดือนก่อน

    Well done.

  • @TheBestNameEverMade
    @TheBestNameEverMade 6 หลายเดือนก่อน

    Python is the same way for me, just use it when I need to process some data like once every 4 months.

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      When it comes to data Scheme is superior.

  • @randomlegend631
    @randomlegend631 6 หลายเดือนก่อน +1

    More Python videos 😎

  • @loganlandonline
    @loganlandonline 6 หลายเดือนก่อน

    work or whitepapers. is this the first time Prime uses this?

  • @lukaswalker2342
    @lukaswalker2342 8 วันที่ผ่านมา

    I like my pass by references

  • @kaljsdlksjfd3286
    @kaljsdlksjfd3286 5 หลายเดือนก่อน

    Arc and cow and structs are value semantics

  • @Tomyb15
    @Tomyb15 5 หลายเดือนก่อน

    So basically, he's describing part of the reasons Haskell is great

  • @ShaqarudenGames
    @ShaqarudenGames 6 หลายเดือนก่อน

    @ThePrimeTime you should definitely learn swift!

  • @nathanpotter1334
    @nathanpotter1334 6 หลายเดือนก่อน

    Yall need to hear 4:00 - 5:55. You're right 100% Prime.

  • @wywarren
    @wywarren 6 หลายเดือนก่อน

    I thought in this day and age CS basics to a certain degree would still be common knowledge even if you didn't study in traditional post-secondary institutions. I wonder if the bootcamps are weeding out the a lot of the important stuff to keep the attention span of the new learners. It then comes back later like a slapshot to the shins.

    • @lpprogrammingllc
      @lpprogrammingllc 6 หลายเดือนก่อน +1

      You are assuming that it is taught in traditional post-secondary institutions. It is not. Not reliably anyway, and certainly not in the 100 or 200 level classes. I was in my discrete structures class (probably the most useful class if taught well), with some comp-sci students. They were on their 4th semester of comp-sci and struggling to understand why a C++ function took out parameters as pointers. I had noticed the students finishing 2 semesters of comp-sci didn't have a clue how to actually program, so I'd actually signed up for the CS101 at the same time as discrete structures.
      At this point, if you are going to university to learn to program, my general recommendation is to get a math degree. You can learn everything the CS-half would teach you in a long weekend once you know the math, but the inverse is not true.

    • @alejowtf917
      @alejowtf917 5 หลายเดือนก่อน +1

      Legit my first programming class in my freshman year was intro to programming with C, and one of the first things we did was create functions that used pass by value and pass by reference, so there is definitely institutions that teach this stuff. Perhaps they could be doing more but this is extremely basic and common knowledge

  • @gjermundification
    @gjermundification 6 หลายเดือนก่อน

    Remember Swift is not by Apple, Swift is by Chris Lattner. Most the frameworks for the Swift language is by Apple though ...

  • @newsofthenerd
    @newsofthenerd 5 หลายเดือนก่อน

    Haskell slow? When did that happen. I thought it was marginally slower than c . Its a compiled language it's not like an interpretated language. I think it test it is slightly slower than c and like 30 to 40 times faster then the SLOW languages.

  • @ikuwilld
    @ikuwilld 6 หลายเดือนก่อน

    Full time dev on Swift for iOS. It is fine, nothing seems annoying or great about it.

    • @Art-is-craft
      @Art-is-craft 4 หลายเดือนก่อน

      It is designed to be productive.

  • @ConernicusRex
    @ConernicusRex 4 หลายเดือนก่อน +2

    Lol, "this guy" like Chris Lattner isn't a modern day legend.

  • @dewigesrek5651
    @dewigesrek5651 5 หลายเดือนก่อน

    swift really is a great language. i wish to bring it to my system but the environment 😭

  • @Serioustroop
    @Serioustroop 6 หลายเดือนก่อน +1

    Isnt swift a programming language for apple app

    • @eHcOZaX
      @eHcOZaX 6 หลายเดือนก่อน +3

      yes but it can be used for everything

  • @MG-nn8dy
    @MG-nn8dy 6 หลายเดือนก่อน

    Pinescript baby

  • @woolfel
    @woolfel 6 หลายเดือนก่อน +4

    I'm calling BS. I've met plenty of CS grads that don't understand the difference. I'm self taught and I learned all o this stuff on my own back in the 90's. It's not about BS degree, it's about the person. Some of the best programmers I know do not have a CS degree and didn't need spoon feeding.
    Swift is a nice language. With the most recent version, it has nice support for serializing/deserializing JSON data. Back in Swift 1-2, only having dictionary support for JSON data kinda sucked. Swift definitely fixes a lot of ugly bits of Objective-C

    • @s3rit661
      @s3rit661 6 หลายเดือนก่อน

      All cs degrees nowadays face both low level and high level languages and uses C as a way to teach the concept of reference and value, i've seen the program of 4 different cs degrees here in italy of 4 different unis and all of them teach that

    • @ea_naseer
      @ea_naseer 6 หลายเดือนก่อน

      bro thinks we were spoon fed

  • @d3vilscry666
    @d3vilscry666 6 หลายเดือนก่อน +2

    Do swift please! There’s almost no good videos from a theoretical point on YT.

  • @madman777656
    @madman777656 5 หลายเดือนก่อน

    This is great and all, but are we not going to mention that PHP is great? Like guys, you can write PHP and it will instantly work on your web server!! OH SHUCKS. It gets me excited just talking about it

    • @claudiusraphael9423
      @claudiusraphael9423 5 หลายเดือนก่อน

      Thought - i saw you that one time, yeah - in that Miura, right?

  • @mmmhorsesteaks
    @mmmhorsesteaks 5 หลายเดือนก่อน

    I'm trying to think when i last needed to copy.copy() or copy.deepcopy() in python 😂 what a non-issue.

  • @jdotseven
    @jdotseven 5 หลายเดือนก่อน

    Swift has structs with methods!

  • @mvargasmoran
    @mvargasmoran 6 หลายเดือนก่อน

    Easy Breezy.

  • @quarteratom
    @quarteratom 5 หลายเดือนก่อน

    So what was the original video about? I didn't catch it among all the pausing. Seemed boring.

  • @briankamras2913
    @briankamras2913 6 หลายเดือนก่อน

    Everything points me to Go, the dumbest, middest, but best designed language ever.

  • @CaseyStrouse
    @CaseyStrouse 24 วันที่ผ่านมา

    I think we need some F# or Clojure in your life bud.

  • @felixjohnson3874
    @felixjohnson3874 5 หลายเดือนก่อน +1

    "Pass by copy" that ISN'T a synonym for "pass by value" is quite possibly the most useless CS term I have ever heard. A CPU literally ONLY copies, the "mov" instruction *_is_* a copy.

  • @tusharsnx
    @tusharsnx 6 หลายเดือนก่อน

    You say your audience is JS devs, then ask them a Go question, they answer, and you accept it as the right answer. lol

  • @gjermundification
    @gjermundification 6 หลายเดือนก่อน

    6:30 This is Elementary Linear Algebra; You can put a matrix inside a tensor.

  • @quarteratom
    @quarteratom 5 หลายเดือนก่อน

    Noone knows Rust, why would they reference it?

  • @fojico1234
    @fojico1234 6 หลายเดือนก่อน

    So this is a 3-year-old video on how awesome Swift is for AI, yet most of its AI toolings till now are only for Apple. Yuck or am I wrong?

    • @DjStanislav
      @DjStanislav 6 หลายเดือนก่อน +1

      There's been Swift for TensorFlow, where they implemented differentiable programming right into Swift. They later split into two companies, one of them is PassiveLogic and Modular (where Chris Lattner, the guy in the video, is currently). Watch PassiveLogic's launch event, especially the part about Differentiable Swift: th-cam.com/video/xr8sV3GdhVk/w-d-xo.html

    • @fojico1234
      @fojico1234 5 หลายเดือนก่อน

      @@DjStanislav Thanks I'll check it thoroughly later

  • @sacredgeometry
    @sacredgeometry 2 หลายเดือนก่อน

    All the people saying that its just a copy of rust ... yeah except swift is older than rust ... so I guess we know which is the copycat.

  • @darkdudironaji
    @darkdudironaji 6 หลายเดือนก่อน

    If you don't know the difference between pass by reference and pass by value, you shouldn't be a programmer. You're taking jobs from people that will actually accel in the field long term so you can be a junior forever.

  • @Nayias37
    @Nayias37 4 หลายเดือนก่อน +1

    Man, it’s humbling when you can only pick up on a few things being said…. Think I’m gonna have to research more CS….

  • @kaljsdlksjfd3286
    @kaljsdlksjfd3286 5 หลายเดือนก่อน

    Cow

  • @dixztube
    @dixztube 6 หลายเดือนก่อน

    Learn go first then js

  • @kimitawanjohi7993
    @kimitawanjohi7993 6 หลายเดือนก่อน +5

    first commit

    • @cds5506
      @cds5506 6 หลายเดือนก่อน +4

      You better get a review before you merge that.

    • @azeek
      @azeek 6 หลายเดือนก่อน

      LGTM

  • @indiesigi7807
    @indiesigi7807 6 หลายเดือนก่อน +1

    There is no shame in not knowing python. There is only pride in not knowing python.

  • @quarteratom
    @quarteratom 5 หลายเดือนก่อน +1

    Swift is Apple sheep language.

    • @mattieboombatti
      @mattieboombatti 3 หลายเดือนก่อน

      Absolute braindead take.

  • @InfiniteQuest86
    @InfiniteQuest86 6 หลายเดือนก่อน +1

    Anyone who thinks CS is mostly whiteboard has definitely never gotten a CS degree. By the end, you have implemented every aspect of an OS by hand. It's an insane amount of programming. It's this type of misinformation that make people believe they can go through some coding bootcamp and have more experience and ability than someone with a degree.

    • @ea_naseer
      @ea_naseer 6 หลายเดือนก่อน +1

      Depends most students in my class including me would never build an OS most students just want to build a webpage not work at OpenAI.

  • @quarteratom
    @quarteratom 5 หลายเดือนก่อน

    Erlang is better than Elixir, and also all languages ever.