Fork me on GitHub
#clojure-europe
<
2023-02-25
>
genRaiy10:02:22

Good morning.

👏 2
borkdude10:02:05

Morning, good

💪 2
simongray11:02:42

Temba, his arms wide

simongray11:02:48

Love this thing!

otfrom13:02:52

Madainn mhath

TMac10:02:07

A bheil Gàidhlig agad?

otfrom10:02:57

@UJLF48QJC not yet (and not studying atm, but will do at some point)

TMac10:02:10

I was pretty surprised to see it in the wild in a Clojure context! I took a year of Gaelic at uni but am still very limited with it

otfrom14:02:45

Questions for today Do you find programming fun? Are some languages more fun than others? Which languages have you found to be fun? Can you use your fun languages to do serious things too? I'm guessing this will be a biased crowd but I'd still like to know.

borkdude14:02:22

Yes and clojure :-D

10
otfrom14:02:51

Any other languages?

borkdude14:02:20

I have dabbled with other languages just to learn: Haskell, Rust, C, JS, Prolog, etc, etc. To learn they are fun, but once I got past that, the fun was reduced :)

borkdude14:02:49

I also spent quite a while with Common Lisp during my master's thesis. It was fun, but never got to the point of actually using it for hobby projects since I couldn't get "into" the ecosystem somehow. I've done C#, Java etc too of course. It's fun to hack together something new in any language, but in any language projects can also become a drag, e.g. when dealing with other party's APIs and data, the language is less important

borkdude14:02:50

There's always the tedious, less interesting work that just has to be done in production projects

borkdude14:02:59

I've also done a bit of F# for a while: definitely more fun than C# while still being able to use the ecosystem. It was the language I was most into before Clojure

borkdude14:02:07

Come to think of it, that may be the closest language that is both fun and suited for serious things after Clojure for me, although I haven't used it in years

otfrom14:02:01

F# is ocaml ish?

borkdude14:02:03

yes, similar to Clojure being a Lisp-ish but deeply integrated with .NET (as Clojure is with the JVM)

👍 2
mpenet14:02:04

Very ish, f# lacks the best thing from ocaml: modules (esp functors)

borkdude14:02:02

Maybe I would enjoy ocaml too, but I haven't seriously attempted to use it

mpenet14:02:13

We were using it at my previous job. It’s great as a language but its ecosystem is a bit lacking and quite fragmented

borkdude14:02:41

They do have multithreading now since the latest release which might have been the biggest missing thing?

mpenet14:02:47

Or maybe I am just picky given my exp with the jvm

borkdude14:02:30

> ecosystem is a bit lacking and quite fragmented That's what I found with Haskell too. Lots of unmaintained stuff and no "the Haskell community" but lots of separate groups doing their own things

mpenet14:02:38

Multicore just landed, I am not sure I’d bet the house on it. It also doesn’t solve the issues I mentioned before

mpenet14:02:54

Back on the subject: I quite like fennel, simple, pretty, extremely lightweight and embeddable

👍 2
mpenet14:02:15

And superb ffi, lots of reach

mpenet14:02:09

It’s very fun oriented, most people write games with it

otfrom14:02:32

My own answer - clojure is fun and I built a business on it. It is the most fun I've had programming since learning logo. Looking at what is going on in scheme in guix and goblins (cweber's next thing after activity pub) looks like it might be fun

otfrom14:02:05

Fennel is a lua hosted lisp?

otfrom14:02:20

I suppose there is clojerl and lfe too

mpenet14:02:24

Lua transpiler

👍 2
lread14:02:58

I find babashka is much much much more fun than bash.

lread14:02:16

And Clojure is much more fun than Java.

borkdude14:02:51

Does fennel have a good REPL experience, e.g. it transpiles what you evaluate on the spot?

mpenet14:02:02

I thought we were supposed to mention other languages than clojure. In that case yes clj :)

lread14:02:38

I'm in a post-work chapter of my life. Programming is now my hobby. And Clojure makes that extra fun.

mpenet14:02:22

@U04V15CAJ it also has a reverse transpiler, antifennel, transforms lua to fennel

borkdude14:02:53

I think #C03U8L2NXNC (CLJS syntax -> JS) might be close to what fennel is for lua (but still new-ish and experimental and REPL is still improving)

mpenet14:02:52

cljs to elisp would be nice :)

❤️ 2
mpenet14:02:23

I hate elisp… but I love emacs

2
grav14:02:36

I wanted to create a midi sequencer for my old Raspberry pi 1, and found that Java and Nodejs were way too slow. So there went Clojure. So now the excersise of creating an app also involved learning a new language. So I went for Zig, since even if Python or C might have been more pragmatic, all parts of such a hobby language need to be fun!

borkdude14:02:05

I've thought about that too and have the same feelings about elisp and emacs

🎉 2
borkdude14:02:33

> Java and Nodejs were way too slow Define slow: slow how?

mpenet14:02:40

Lua (fennel) is great for this kind of use cases (rpi & co)

grav14:02:07

Well ... real-time simply not being an option. Latency above 500 ms

mpenet14:02:11

I had it run on a esp8266

borkdude14:02:29

Do you mean startup time of the application or something else?

grav14:02:40

So for NodeJS, I couldn't get the timing of midi notes to be decent, unless I worked with a buffer of around a second, meaning a latency between changing some midi note and hearing the result of around a second.

grav14:02:49

For Java, I believe startup time was an issue (or rather an annoyance), but also memory consumption. I think my Raspberry Pi has 256 MB Ram.

borkdude14:02:32

I recently discovered that the Java sounds API works with graalvm (given the right configuration). That would take care of the resource + startup time issues

grav14:02:13

Oh, that's pretty interesting. So I could develop on a powerfull computer and target the Pi with GraalVM. Is GraalVM able to target armv6?

borkdude14:02:14

so you need to run a 64-bit Pi OS

grav14:02:52

Raspberry Pi 1 runs armv6 which is 32 bit. But it is also quite old.

borkdude14:02:24

If you want to know if it would work on a Pi, you could try to run bb aarch64 static linux on that device

👍 2
borkdude14:02:43

yeah 32 bit won't work

grav14:02:31

I think even RPi2 is 64 bit, so generally it's not an issue. It seems the v1 was a bit underpowered. I think it sold mainly because it was a "new thing" 😄

borkdude14:02:35

I think you could even make that graalvm binary scriptable with SCI (similar to bb) so it can read programs from user input and make sounds

grav14:02:43

Yeah some live-coding! That's a nice idea 🙂

grav14:02:08

> the Java sounds API works with graalvm (given the right configuration). What are the challenges with getting it working? Do you know any examples? (java/clj)

borkdude14:02:46

https://github.com/oracle/graal/issues/2892#issuecomment-1381284504 I'll try to make a working minimal clojure demo now

🙌 2
😀 2
borkdude15:02:43

btw, is this about midi? having a minimal clojure snippet that plays a midi sound will help me...

borkdude15:02:57

got a fragment here which plays a midi file:

(ns borkdude.clj-native-sound-demo
  (:require [ :as io])
  (:gen-class))

(import '[javax.sound.midi MidiSystem])

(set! *warn-on-reflection* true)

(defn -main [& args]
  (let [sequencer (MidiSystem/getSequencer)]
    (.open sequencer)
    (.setSequence sequencer (io/input-stream (io/file (first args))))
    (.start sequencer)))

grav15:02:21

Beat me to it! This one doesn't need a midi file: https://gist.github.com/grav/37572295bde4540ed9edc92cf8855c52

borkdude15:02:08

ok, I've got one going here too: https://github.com/borkdude/clj-native-sound-demo I'll change it to your example. It doesn't quite work yet though

👍 4
lread15:02:56

Are you demonstrating that programming can be fun? Seems like it!

😅 4
borkdude15:02:18

@grav Shall we move it to another thread? :)

grav15:02:25

Let's do that 🙂

Mario Giampietri15:02:37

(to the initial question, not the interesting conversation that followed) yet another yes and Clojure (and potentially any Lisp) In general I am more productive if I find the tool enjoyable/fun, this often happens if there's: • functional programming or at least functions as first class citizen in a language; • a dynamic language; • an interactive experience; • data related ops is always enjoyable. So Clojure ticks all the boxes, but it's worth mentioning also: • JavaScript, I had my dose of fun with it before it was cool. I don't miss it nowadays (because of Clojure and Lisp) but it's been important to test my personal preferences; • SQL. Probably not an acceptable Lisp 😄 but still a fun interactive experience, I always welcome chances to mess with it. IMHO the combination of fun things and can be used to do serious things can be somewhat random and accidental and bound to personal preference (maybe even neurological traits), e.g.: not everyone finds SQL fun, I don't find bash/shell scripting particularly fun (despite it being somewhat dynamic / iterative), but sometimes you have no other choice.

genRaiy22:02:51

I generally find coding up stuff in Clojure fun. The problem is when stuff doesn’t want to work today ie everything else around the programming job like deployments. Mainly deployments.

Ben Sless06:02:50

Clojure is the most fun I've had programming, followed by Tcl Programming should be fun. Everything you do should be fun

2
pez06:02:55

I am at a point in my career where I demand fun from work. So yes to that. The most fun I’ve had coding I have had with PostScript and Clojure. It’s the interactivity, for sure, but also the way it shifts how I think and makes me feel like I blend with the machine.

simongray07:02:33

What did you do with PostScript, @U0ETXRFEW?

simongray07:02:17

Other than Clojure, I really enjoyed my first programming language, ActionScript, but that's mostly due to the application (Flash) built around it. I started animating using Flash 3 and first began programming with Flash 5... basically just wanted to put stuff on Newgrounds, but it eventually turned into interactive components embedded into HTML pages. Then that turned into PHP pages and so on. I don't really dabble too much when I learn new things, as I like to have a purpose for learning something, e.g. some project or learning goal. Even things I don't find fun initially can become fun with sufficient knowledge. I find that this is the case for almost everything, not just programming.

simongray07:02:41

So yes, things should be fun... eventually.

pez09:02:03

@U4P4NREBY I generated and produced marketing research survey results as diagrams. It was often employee surveys for big corporations. We had a quite big farm of printers working 24/7. The programs for transforming the data into diagrams, I wrote in PostScript. I mention a bit of this in my talk from this week’s sthlm.clj meetup (linked in #C8NUSGWG6) which happens to be on the subject of having fun programming.

👍 2
mpenet14:03:45

I noticed 🙂

mpenet14:03:41

from technomancy's experience I recall that the tricky bit is error handling when you interop with emacs via ffi

mpenet14:03:50

lots of crashing of emacs

mpenet14:03:12

he experimented with dyn modules with fennel

mpenet14:03:47

but I really hope he manages to work around that

otfrom14:02:49

Should programming be fun? Y/N/other

yes 41
2
🤷 4
2
borkdude14:02:38

Fun certainly makes it more sustainable

10
borkdude15:02:43

@grav Let's continue in this thread 🎵

borkdude15:02:08

For your example to work I think we first need to address:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/0x00000008002e1440 (file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0.jar) to method com.sun.media.sound.SoftChannelProxy.noteOff(int)
WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/0x00000008002e1440
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

borkdude15:02:36

Oh, already done:

(ns borkdude.clj-native-sound-demo
  (:gen-class)
  (:import
   (javax.sound.midi MidiSystem)))

(set! *warn-on-reflection* true)

(defn -main [& _args]
  (let [midi-synth (MidiSystem/getSynthesizer)
        _ (.open midi-synth)
        instruments (.getInstruments (.getDefaultSoundbank midi-synth))
        midi-channels (.getChannels midi-synth)]
    (.loadInstrument midi-synth ^javax.sound.midi.Instrument (first instruments))
    (.noteOn ^javax.sound.midi.MidiChannel (first midi-channels) 60 100)
    (Thread/sleep 1000)
    (.noteOff ^javax.sound.midi.MidiChannel (first midi-channels) 60)))

grav15:02:14

So the latter compiles with graalvm? I don't have it installed on this machine

grav15:02:25

Is it the use of first that results in the need for the type-hinting?

mpenet15:02:44

Joe Armstrong did some interesting work around midi scheduling for sonicpi btw

mpenet15:02:55

Might be worth looking into

mpenet15:02:46

It’s integrated into sonicpi iirc

borkdude15:02:20

@grav I updated the repo here: https://github.com/borkdude/clj-native-sound-demo It still has problems that were mentioned earlier in that graalvm github issue and I thought they were fixed. I'll bring this back to the github issue

👌 2