BQN vs C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ค. 2024
  • A short video comparing implementing an algorithm in both BQN and C++.
    BQNPAD: bqnpad.mechanize.systems/
    BQN Solution: mlochbaum.github.io/BQN/try.h...
    C++ Solution: godbolt.org/z/aszxP3bfb
    C++ Flux Solution: flux.godbolt.org/z/qdPsxsY87
    Flux Library: tristanbrindle.com/flux/
    Chapters:
    0:00 Intro
    0:20 Algorithm Explanation
    1:07 BQN Solution
    3:05 BQN Under Modifier
    4:04 C++ Solution (for chunk_reverse)
    6:06 C++ Problem 1
    6:46 C++ Problem 2
    7:15 C++ Working Solution
    9:15 Outro
    Follow me on Github: github.com/codereport
    Follow me on Twitter: / code_report
    Follow me on LinkedIn: / codereport
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    we need more UIUA please

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

      Glad someone said it!

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

      I’m actually very curious about UIUA being so populair. What makes it so appealing and how do you guys look at BQN for example? :) I myself am deep into BQN and want to get really comfortable with array programming before exploring the other languages personally. I really love BQN so I’m curious how it seems UIUA attracted a bigger chuck of people. Not that I know a lot about the UIUA or the community

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

      @@davidzwitser I'm a newbie, but it's ability to write ASCII names instead of glyphs and lack of overloads seems great, and the debugging is easier with ?. With BQN I kept running into trains I couldn't parse. Tldr the developer experience is very nice.
      I enjoyed your episode of ArrayCast!

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

      ​@@TankorSmash Aah I can actually imagine that. I can see how BQN can have a steeper learning curve (tbh, for me it felt like a straight wall I needed to start climbing, luckily Marchall laid out a cool route and some good rope, aka the BQN documentation).Trains can also be very confusing indeed. After you get used to them they're super nice but I don't know how it compares to the stack based composition in UIUA. I kinda don't like that you write UIUA with ascii names for some reason tho. It makes the glyps feel second class to me but that's very subjective. I'll definitely be exploring UIUA some time tho! Thanks for sharing, and cool to hear that you enjoyed the episode! :)

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

      @@davidzwitser Yeah, the docs for BQN are great! Uiua's are 100% inspired by them too, which is awesome. I managed to write a few tiny things in BQN thanks to how good its pad and docs were too.
      I definitely understand the ascii vs glyph thing, and I think some people on the cast had similar feelings when hearing about it haha!
      By default the compiler formats your code and converts it for you, so it makes it easier to type, which is real handy!

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

    Problem with "just call it scan" is there also already are "std::inclusive_scan" and "std::exclusive_scan" and you sometimes want one or the other. So they will probably just call them views::inclusive_scan and views::exclusive_scan and have the same issue. The actual nice way of solving this would be for library implementers to add better error messages, but that isn't part of the standard (and I believe would in some cases also be against the standard but I'm not entirely sure) so there hasn't been too much work in trying to do that. Though in general I've usually gotten somewhat better errors from clang than gcc but also not actually significantly better

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

      I also think “just naming it scan” isn’t ideal. The committee chose std::views::transform (and not std::views::fmap) and similarly for reverse and iota.
      I’d hope the compilers can be smart enough to give “did you mean …” error messages.
      As for interoperability between std and ranges-v3 - I tend to agree it’s annoying, and tend to ‘blame’ ranges-v3.

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

    Thanks! Every comparison video like this helps me learn more about BQN.

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

    That was fun. Now compare the performance of the implementations 😀

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

    Wow, I really want to learn C++ after watching this.

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

    Love these comparison videos, especially when we're looking at real-life use-cases vs. code golf type items. Two questions: 1) Other than language familiarity are there any particulars keeping you from moving towards UIUA for daily driving vs. BQN? 2) If you're going to start using something like BQN for actual code, are there FFI bindings or other mechanisms you'll be employing to integrate your array lang work into C++ projects? (assuming that would even be necessary for your use-cases)

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

    Is there a standard foundation for array based programming languages? For example, there is lambda calculus for functional programming.

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

    If you had time a little intro to the bqn language might be a lot of fun.

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

    We really need to get to the point where standard ranges and third-party range libraries are all compatible with each other. It's 2024 and I still don't use standard ranges because I want things that are only in Range-v3, and I don't want the headache of mixing the two. Unfortunately I don't see that happening for Range-v3.

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

    Crazy coincidence! I had to build this in C++ 14 at work for image processing. I couldn't find it in algorithms and was sad.

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

    В последней версии питона 3.12 есть функция butched 😄
    ```
    from itertools import accumulate as acc, batched
    from operator import add, mul
    chunk_scan = lambda arr, n, f: [x for b in batched(arr, n) for x in acc(b, f)]
    arr = [1, 2, 3, 4, 5, 6]
    chunk_scan(arr, 3, add) # [1, 3, 6, 4, 9, 15]
    chunk_scan(arr, 2, mul) # [1, 2, 3, 12, 5, 30]
    ```

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

    do you work in cpp and do bqn and such as a passion project? like is cpp your main gig as far as languages go?

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

      Professionally I use Python and C++ the most, but I am starting to use BQN as a daily driver more and more.

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

      i was wondering, at that, if BQN and such were used for like paid work,@@code_report

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

      ok followup, @@code_report . you clearly like haskell as well, more than cpp, no? why not get a haskell job and do that full time? there's some jobs out there doing interesting stuff, i bet.

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

    You continue to make strong cases against using C++, which I appreciate. Note that I've programmed in C++ more than any other language--and am still forced to deal with it in Unreal Engine--so I feel justified in raging against it.

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

    wow. the reason why the C++ version broke is just.... so C++. incomplete std forcing people to use external libraries incompatible with std, spew of indecipherable template garbage, mysterious inexplicable segfaults - some things just never change i suppose 😅

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

      Typical experience with that pile they call a standard library. And the compile times with just a few lines of templates, you use this kind of code all across a real project and it can take an hour to compile on a fast machine. Staying far away from this language for the rest of my career.

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

    Please don't angry emoji C++ so hard :(
    Will you give OCaml a play in some future video? Seems to be rather trendy and an interesting combination of functional and imperative. Obviously not as concise as the symbolic languages.
    I'm actually really curious where these kinds of problems pop up? Something about matrix operations for cache locality? I actually think you should submit the BQN function to Lenny faces emote page.

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

    Given how much you like combinators and tacit programming, I'm surprised you don't like J more, since there you can even write modifiers tacitly! For example:
    ChunkScan =: ,@((/\\~)-)~

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

    C++ is pain.