9 ms·
Sorting algorithms visualized using the Blender Python API
- pkz 4y agoThis was a nice intro to the Blender Python API. Thank you!
- chrismorgan 4y agoWarning: this page loads 120MB of animated GIFs. Do not use GIFs like this. Use a proper video codec. (I’ve actually flagged this submission, because 120MB is far, far more than anyone reasonable would expect to be downloaded automatically by visiting a page, and expensive for some people—there have been multiple occasions for me in the past few years when it would have literally cost me around $10 to load the page.)
- hdjjhhvvhga 4y agoWe had the same problem in Europe before 2016, it was awful - you needed to watch every step and being careful what sites you visit, what apps you open (and many used mobile data without you even knowing it) - people were being charget tens and in extreme cases even thousands of euros. It was even worse with a laptop. Abolishing roaming changes was a huge gamechanger. Of course for intensive internet usage you'd still probably want to buy a local SIM card, but apart from that you can forget mobile charges and just use your regular €5/month mobile plan for everything. The only exception is when you get very close to the borders of the EU and there is a chance of connecting to a non-EU tower.
- danuker 4y agoI always used a prepaid SIM. For me, the knowledge of not getting into debt accidentally is worth the hassle of charging it myself every 3 months or so.
- moritonal 4y agoCries in sorrow from the UK All our carriers said they wouldn't introduce roaming fee's pre-Brexit, then did to the surprise of no-one but the Brexiteers.
- V__ 4y agoThis was especially frustrating when living near a border (which in Europe is not unlikely). Depending on the weather (or the maintenance schedule), sometimes the foreign tower was strong enough for the phone to connect. I don't (want to) remember how much money I lost that way.
- blensor 4y agoI just landed in Zurich and forgot that it is not part of the EU with respect to roaming charges. Just opening twitter and answering a whatsapp shot through my automatic roaming charge cutoff limit of 60€ (1MB is roughly $16 here). So that page would have cost me roughly $2k to load if there were no automatic limit :)
- PeterBarrett 4y agoOn the off chance that you're staying for more than a few days I'd recommend dropping into a Salt or Sunrise store and buying a pre-pay e-sim. They're reasonably priced and should give you 5g everywhere you go.
- lucideer 4y ago> Do not use GIFs like this. Use a proper video codec. Not a defense, but worth noting in the interest of full advice here that Github's README preview (what's showing here) does not support embedded videos, which is why GIFs are a popular choice. That said, a good workaround for this is simply putting something like: [](path/to/video/file/or/youtube/link) This has the double advantage of not hitting your gpu/cpu on load (especially good for mobile) since there's no autoplay.
- andrewingram 4y agoI believe this is no longer the case: https://twitter.com/natfriedman/status/1383169112948449286 https://twitter.com/natfriedman/status/1383169112948449286
- lucideer 4y agooh wow they should advertise that more obviously via the ui, but I guess that kind of feature discoverability has never been github's style
- cturtle 4y agoYep! And it also works for images too! So you no longer need to host images externally, in an issue, or in an assets directory in the repo. I wish this were more well known.
- est 4y agoChrome supports "many" animation formats than gif - mjpeg - apng - WebP Animation
- chrismorgan 4y agoAnd you shouldn’t use any of them for things like this. They’re semantically clearly videos, and benefit from things like a pause/play button and scrub bar. (Incidentally: why are you mentioning Chrome? All mainstream browsers support these.)
- cusx 4y agoThis reminds me of the audible sorting algorithm video. https://www.youtube.com/watch?v=kPRA0W1kECg https://www.youtube.com/watch?v=kPRA0W1kECg
- teddyh 4y agoSorting out Sorting from 1981: https://www.youtube.com/watch?v=HnQMDkUFzh4 https://www.youtube.com/watch?v=HnQMDkUFzh4
- rchiang 4y agoNot earlier than this, but Marc Brown's ACM Distinguished Dissertation from 1987 on Algorithm Animation: https://mitpress.mit.edu/books/algorithm-animation https://mitpress.mit.edu/books/algorithm-animation I know I saw a video from around that time, but I couldn't find one online.
- asicsp 4y agoSee also https://github.com/tayllan/awesome-algorithms https://github.com/tayllan/awesome-algorithms for a list of interactive visualizations, learning resources, etc.
- jve 4y agoWell, visual representation helps convey information for sure. However animation speed is not to be corelated with sorting performance. Bubble sort is lightning fast compared to merge sort if you judge by animation :) Luckily they have array access and comparison count listed.
- xcambar 4y agoThanks for pointing that out. I was initially very confused and like you, I've had to read the metrics below the animations to get a better understanding
- blooalien 4y agoI never even considered using the Blender Python API in this way before. Funny, bein' I'ma huge fan of both Blender and Python, yet strangely never connected the two in my mind in this manner. I'm now looking at Blender in a whole new way. Also, thanks to you folks who posted other links to further interesting related research paths. Love Hacker News because of you folks who do that sorta thing. :)
- dlivingston 4y agoSame here. T-minus 5 seconds until someone writes a Blender backend for Matplotlib or a Blender plotting library...
- faizshah 4y agoI also never considered this, I have been looking for a python video editing api and I’m pretty sure blender has some video editing stuff built in. Gonna have to give the blender python api a spin this weekend.
- jazzyjackson 4y agoI used Blender for years before noticing the workspace drop down, changing it from "Default" to "Video Editing" In hindsight it makes sense, people make whole animated films with blender, but it never occured to me to import MP4s into the timeline.
- arafalov 4y agoAnd, the Blender's install ships with a bunch of Python modules as well, not just pure runtime. So, you have access to - for example - SQLite as well.
- fimdomeio 4y agoThis just made me wonder how is it like to script in Blender. Found this video https://www.youtube.com/watch?v=r8hqLh_HE08 https://www.youtube.com/watch?v=r8hqLh_HE08 which seems to give a good quick overview. The info window that shows ui interactions as code seems incredible ergonomic if you just want to fool around with scripting without a big learning curve.
- nkozyra 4y agoIt's nice having it all together, but if you're used to VSCode or Jetbrains it's somewhat of a frustrating experience. Little things like code completion, a weird run window, errors that aren't caught until running, etc., can be annoying.
- victornomad 4y agoyou can use VSCode and Blender :) I just mentioned it above but this training in the Blender cloud is very good! https://studio.blender.org/training/scripting-for-artists/ https://studio.blender.org/training/scripting-for-artists/
- nkozyra 4y agoOh no doubt, but then you lose the big benefit of doing it in blender!
- victornomad 4y agoI think you can do everything in VSCode. You can get also autocompletition and autoreload with a vscode plugin
- nkozyra 4y agoWell I mean that you'd have to tile your windows instead of having the I part of the IDE.
- 4y ago
- shetill 4y agoyet another sorting visualizer
- shellfishgene 4y agoNot a CS guy: These animations are always nice, but which of all the sorting algos are actually used in practice?
- nkozyra 4y agoSurprisingly, it's pretty varied, but Timsort and quicksort are pretty common in language implementations. I don't know that people are reimplementing these in practice all that often rather than using std library but writing and comparing them was part of my earliest CS education at least.
- bvinc 4y agoPeople just use whatever their programming language provides. There's a concept of sorting "stability" in which equal elements stay in their original order relative to each other. If stability is important, then usually some variant of merge sort is used. If it's not, then some variant of quick sort is used. If the list, or sublist you're working with is small enough, insertion sort is used.
- chazeon 4y agoI recently start to play with Blender + Python to render molecular dynamics results. As long as you program properly, and have a large enough memory, you are able to produce very beautiful renderings. Many MD trajectory software from academia does not give you the freedom to use Python or only allow it in very-expensive paid-tier.
- victornomad 4y agoIf you want to learn about Python API and Blender I really recommend this excellent training in Blender Cloud https://studio.blender.org/training/scripting-for-artists/ https://studio.blender.org/training/scripting-for-artists/
- remram 4y agoThis gives the impression that Quick Sort is awful and Counting Sort should be used instead. What a weird conclusion.
- boppo1 4y agoThis is sick. I've been getting into programming and just rediscovered Blender and its awesome API (admittedly have no frame of comparison to Maya or Max, but IMO it's WAY WAY better than the web/mobile APIs I have experience with). I was thinking of making almost exactly this as I dig into more seriously learning to program.
- naet 4y agoThe images are a bit misleading by using different timescales. Bubblesort appears to finish significantly faster than Quicksort if you are just watching the animations... I think the visualizations would be a lot more meaningful if you could visually compare speeds.