HNHacker News
TopNewBestAskShowJobs

Bogdanp

10,780 karma · joined July 2, 2009

https://defn.io/page/about

Submissions are not endorsements.

submissionscomments
Bogdanp··on Show HN: I Made an iOS Podcast Player with Racket
Sure! I have a whole library dedicated to integrating Racket and Swift and you can find some of the nitty-gritty details there[1]. The gist of it is:

1. You build Racket for iOS in an interpreted mode (regular Racket works a bit like a JIT in that it needs to load code into memory at runtime, which is a no-go on iOS)

2. You link to it as a regular static library.

3. You call Racket's C API[2] to load and run Racket code.

Here's[3] a somewhat outdated video I did a while back on using that library for Mac app development. Many of the things in this video are now much simpler/more straightforward, but maybe it serves to give you an idea. I also have some source-available Mac apps built this way that you can take a look at[4, 5].

[1]: https://github.com/Bogdanp/Noise?tab=readme-ov-file#usage

[2]: https://docs.racket-lang.org/inside/cs.html

[3]: https://www.youtube.com/watch?v=aTvU0j4hBR0

[4]: https://github.com/Bogdanp/remember

[5]: https://github.com/Bogdanp/Franz

Bogdanp··on Show HN: I Made an iOS Podcast Player with Racket
Thanks! It's built with Chakra UI[1] so I can't take full credit for it.

EDIT: Oh, I just realized you might be referring to my blog, in which case I _can_ take credit for that :P. Thanks again!

[1]: https://www.chakra-ui.com/

Bogdanp··on Distributed Locks with Redis (2014)
To counter some of the hate in this thread: I have used this to great success as an "opportunistic" locking mechanism to, for example, reduce load on a Postgres database. The winner of the race to acquire the lock would run the (expensive) query then cache the result. On lock release, the nodes waiting on the lock would then try to read the cache before trying to acquire the lock again.
Bogdanp··on Racket Language
In Racket, a vector is a fixed-size contiguous array of memory. The values in each slot of a vector are tagged pointers so values like fixnums don't require any indirection to reach (i.e. they're unboxed). Racket also has specialized vector types for storing fixnums (fxvector), floats (flvector), strings (string) and bytes (bytes).

Other Schemes and Common Lisp have similar constructs. Just because a language is a lisp doesn't mean its primitives have to be implemented using cons cells.

Bogdanp··on Racket Language
No, it binds to the frameworks I mentioned above directly.
Bogdanp··on Racket Language
It's GTK on Linux, win32 on Windows, and Cocoa on macOS.
Bogdanp··on Racket Language
Racket is my favorite language. It's fast, practical, has solid foundations and an extremely nice concurrency story (based on concepts borrowed and extended from Concurrent ML). It has an excellent documentation system, with an integrated package ecosystem, which means that most packages have high quality documentation with cross-references. It has a great backwards-compatibility story -- a lot better than Python's, for example, which I use in my current dayjob. So, my impression of the commenters saying it's too academic or not practical is that they probably never dove deeply enough, or they are former students who were only exposed to the teaching languages in the past. It's definitely not perfect: the community is small, the runtime has a high memory baseline, parallelism requires spinning up a Racket VM per system thread, among others, but these are things that will improve over time.

In the past several years, I've:

* built & run an e-commerce site written in Racket[1]

* built a native macOS and iOS reminders app, available on the App Store [2, 3, 4]

* built a cross-platform desktop client for Apache Kafka [5, 6, 7]

* built a `#lang` for Lua [8]

Among[9] other[10] things[11]. I think that's all pretty practical stuff!

[1]: https://defn.io/2019/08/20/racket-ecommerce/

[2]: https://defn.io/2020/01/02/ann-remember/

[3]: https://defn.io/2024/04/09/ann-remember-for-ios/

[4]: https://github.com/bogdanp/remember

[5]: https://defn.io/2022/11/20/ann-franz/

[6]: https://defn.io/2023/10/15/ann-franz-for-windows/

[7]: https://defn.io/2023/08/10/ann-franz-source-available/

[8]: https://defn.io/2022/11/12/ann-racket-lua/

[9]: https://docs.racket-lang.org/http-easy/index.html

[10]: https://docs.racket-lang.org/deta/index.html

[11]: https://docs.racket-lang.org/gui-easy/index.html

Bogdanp··on Calling Haskell from Swift
I've been doing similar things with Swift and Racket:

* https://defn.io/2023/03/19/racketfest-talk-2023/

* https://defn.io/2023/02/04/racket-foreign-callouts-to-swift/

I also started out using JSON to exchange data between the languages, but eventually wiring everything manually became an annoyance so I came up with a little Racket DSL[1] that automatically serializes and deserializes between the two languages (at runtime in Racket & using code generation in Swift). So far, I've built two apps with this approach, and I think it's great:

* https://github.com/Bogdanp/Franz (macOS, Windows, Linux)

* https://github.com/Bogdanp/remember (macOS, iOS)

[1]: https://github.com/bogdanp/noise

Bogdanp··on Show HN: Franz – A desktop client for Apache Kafka
In terms of code size, the repo is about 50/50 Racket and Swift:

  $ cloc FranzCocoa FranzCross core/ manual/ --include-lang=swift,racket
       355 text files.
       244 unique files.
       419 files ignored.

  github.com/AlDanial/cloc v 1.98  T=0.06 s (2511.1 files/s, 383637.1 lines/s)
  -------------------------------------------------------------------------------
  Language                     files          blank        comment           code
  -------------------------------------------------------------------------------
  Racket                          91           1235             79           9968
  Swift                           53           1148            132           9438
  -------------------------------------------------------------------------------
  SUM:                           144           2383            211          19406
  -------------------------------------------------------------------------------
But, if I include all the supporting Racket libraries I built for the app, the ratio changes to about 4/1 in favor of Racket:

  $ cloc FranzCocoa FranzCross core/ manual/ <more paths> --include-lang=swift,racket
      1644 text files.
       996 unique files.
      3334 files ignored.

  github.com/AlDanial/cloc v 1.98  T=0.35 s (1871.6 files/s, 168111.5 lines/s)
  -------------------------------------------------------------------------------
  Language                     files          blank        comment           code
  -------------------------------------------------------------------------------
  Racket                         598           5535            356          41295
  Swift                           65           1316            272          10779
  -------------------------------------------------------------------------------
  SUM:                           663           6851            628          52074
  -------------------------------------------------------------------------------
Bogdanp··on Ask HN: What apps have you created for your own use?
A really simple keyboard driven reminder tool for macOS:

https://github.com/Bogdanp/remember

I’ve been using it every single day since I wrote it.

Bogdanp··on This is Fine
I think we agree that MacPorts is doing the best it can here.

In my view[1], the issue is a package in one language introducing a dependency on an entirely different, uncommon, language runtime and toolchain. Until relatively recently (at least with respect to the post), the cryptography package did not require Rust at all. A secondary issue is the amount of dependencies actually involved in building a cryptography package. How many of those dependencies are compiler dependencies or not is not relevant to my mind; the cryptography package still transitively depends on them by way of the compiler (and by way of the package manager) and any one of those dependencies could probably read my SSH keys or do $deity knows what else to my computer.

[1]: I agree this isn't particularly well expressed by the post, nor perhaps by these comments here, but now I have to run get a haircut!

Bogdanp··on This is Fine
I would agree with you had I (the author) intentionally wanted to install Rust, but I didn’t. This was a Python dependency randomly bringing all of Rust along with it and that is insane no matter how you slice it.
Bogdanp··on Racket branch of Chez Scheme merging with mainline Chez Scheme
Thank you!
Bogdanp··on Racket branch of Chez Scheme merging with mainline Chez Scheme
I don’t know about “of note”, but here are a couple pieces of software I’ve built with Racket:

* https://franz.defn.io/

* https://remember.defn.io/

* https://defn.io/2023/08/10/ann-franz-source-available/

HN itself runs on Racket.

Bogdanp··on Ask HN: Could you share your personal blog here?
https://defn.io — I mostly write about Racket.
Bogdanp··on Managing State with Signals
I took a similar approach in my Racket library, gui-easy[1,2]. Though I opted to not defer any computations. Any observable (similar to a signal from the post) update propagates to observers immediately, and there's no incrementality -- observables are just boxes whose changes you can subscribe to. Regarding the disposal problem, I used weak references and regarding the where to take observables and where to take concrete values as input question, I decided that any place an observable can go in, a concrete value can as well and it's been a convenient choice so far. For fun, here's an example[3] that builds the todo UI from the post.

[1]: https://docs.racket-lang.org/gui-easy/index.html

[2]: https://www.youtube.com/watch?v=7uGJJmjcxzY

[3]: https://github.com/Bogdanp/racket-gui-easy/blob/364e8becaafa...

Bogdanp··on FUTO – An independent software lab and grant fund
It's unclear from the website whether or not applications are open to folks outside of the US. Are they? Either way, very cool.
Bogdanp··on Tips for a healthier Postgres database (2021)
My post doesn't assume bad intent. As the new entrant in a space, the onus is on you to show your work. So, if you want people to run their own benchmark then share the data and configs you used.

I actually tried to find the dataset you used yesterday to run my own benchmark, but the only official "Chicago crime database" I could find had only 300k rows and 19 columns, so I assumed it wasn't the same data you mention in your video.

Bogdanp··on Tips for a healthier Postgres database (2021)
One potential hint is the Postgres queries are being executed as sequential scans, as you can see from the explain output. The first query only returns 200k rows (out of 7M), so even without any config tweaks it should be using an index if one is present. So, my guess is those queries are being made against unindexed columns. Also, I'm guessing this is vanilla Postgres, so it's possible OP hasn't tweaked its config for the machine they're using, and the default config pg ships with is designed for fairly resource-constrained machines by today's standards. If the data is indexed, it's possible the rows are all over the place, and clustering could help.
Bogdanp··on Some insects I found inside dried Turkish figs from Trader Joe’s
Romanian also.
Bogdanp··on Ask HN: What are you working on this year?
My goal for this year is to continue building (mainly Mac and iOS) apps (like Remember[1] and Franz[2]) using Racket and to help improve the language and ecosystem in any way I can.

[1]: https://remember.defn.io [2]: https://franz.defn.io

Bogdanp··on Show HN: A native macOS client for Apache Kafka
Noted! I'll probably work on this in the next month or so, along with a couple other suggestions I've received from folks.
Bogdanp··on Show HN: A native macOS client for Apache Kafka
Currently, only SASL is supported since that's what's baked into the protocol, but I can look into supporting LDAP, too (pointers appreciated).
Bogdanp··on Show HN: A native macOS client for Apache Kafka
Thanks! I’ll be adding acl support in the next few weeks.
Bogdanp··on Show HN: A native macOS client for Apache Kafka
> It would been great if this was pure swift + C that would have made this much more publicly usable.

Can you say more? I don’t follow what you mean by publicly usable here.

Bogdanp··on Show HN: A native macOS client for Apache Kafka
Sorry about that! My audio recording skills are subpar. Yes, likely my next video will be a walkthrough of some of this code. I’ll do my best with the audio on that one.
Bogdanp··on Show HN: A native macOS client for Apache Kafka
I have yet to try RedPanda, but if it is API compatible with Kafka then it will work out of the box.
Bogdanp··on Show HN: A native macOS client for Apache Kafka
> Having to debug Kafka issues on topics with almost any volume of data is slow and frustrating, either with a GUI or command line/REPL tools.

Agreed. The scripting feature in Franz is born out of my frustration with some of this stuff and seems like a promising route for quickly visualizing and interacting with what’s happening on a topic (though it’s early days and I’ve got lots of work to do until it becomes truly useful).

Bogdanp··on Show HN: A native macOS client for Apache Kafka
Yes, if this gains some traction then I’ll probably do a Windows version down the line.
Bogdanp··on Show HN: A native macOS client for Apache Kafka
Thanks! Yes, I plan to eventually sell it. I’m debating with myself between doing a shareware model where it’s perpetually free with the occasional nudges to buy a license or a more straight forward trial plus $30-50 license. Probably the latter would be more sustainable.
← PreviousPage 2 of 7Next →