other-languages

here be heresies and things we have to use for work
seancorfield 2020-01-13T19:50:10.000900Z

If we want to discuss the pros and cons of static typing vs dynamic typing 🙂

Jakob Riishede Møller 2020-01-13T19:50:22.001200Z

OK 😊

Jakob Riishede Møller 2020-01-13T19:51:19.003Z

I wrote the question in the Clojure channel because the documentation suggest that you should avoid type hints without any reason given

seancorfield 2020-01-13T19:51:40.003400Z

Right, and you got an answer from one of the core Clojure team on that.

seancorfield 2020-01-13T19:52:19.004200Z

In Clojure, type hints serve to avoid reflection (and improve performance) in some situations. But they are not like type declarations in other languages. They are just hints for the compiler.

seancorfield 2020-01-13T19:53:32.004900Z

https://binged.it/370ZmtD Rich Hickey Maybe Not

Jakob Riishede Møller 2020-01-13T19:53:47.005200Z

Thanks 🙂

borkdude 2020-01-13T19:54:55.007200Z

In general I do think it's nice to avoid reflection. Sooner or later you want that anyway is my experience. It also works better if you're going to run the code through GraalVM

borkdude 2020-01-13T19:55:37.008100Z

There is a flag *warn-on-reflection* which you can set. Then the compiler will warn you if it cannot infer the types it needs to avoid reflection.

seancorfield 2020-01-13T19:56:08.008700Z

In general, discussions about static vs dynamic typing are a bit pointless because most of the discussion is subjective: some developers prefer static typing because they believe the restrictions it places on your code are worth the avoidance of certain errors; other developers prefer to avoid those restrictions in exchange for losing the ability of the compiler to detect certain possible errors.

1👍
seancorfield 2020-01-13T19:56:53.009800Z

It's worth noting that static typing tends to prevent you from writing a certain class of programs that are correct at runtime but fail at compile time due to type checking.

2💯
hindol 2020-01-14T08:05:20.069500Z

That is an excellent read!

Jakob Riishede Møller 2020-01-13T19:57:44.011400Z

Well I like to have a high level of IDE support, and I am rather disappointed with the tools I have tried to set up for that (in VSCode)

borkdude 2020-01-13T19:57:58.011800Z

@jakob.riishede.moller Have you tried Calva?

seancorfield 2020-01-13T19:58:34.012700Z

Clojure has core.typed (aka Typed Clojure) that provides an optional static type checker based on annotations being added to the code. It's kind of painful to use tho' and there are certainly Clojure idioms that core.typed won't accept: you have to refactor to code that can be annotated to satisfy the type checker.

Jakob Riishede Møller 2020-01-13T19:58:46.013100Z

I use calva - I find it a little buggy

borkdude 2020-01-13T19:59:38.014800Z

You can also try Cursive / IntelliJ, it's been around for a while and is the most IDE-like. Disclaimer: I don't personally use it.

seancorfield 2020-01-13T19:59:42.015Z

Most editor integrations rely on runtime inspection -- code completion, docstrings, etc. But most editor integrations can also run static code checkers (linters) like Joker and clj-kondo.

Jakob Riishede Møller 2020-01-13T20:00:14.015700Z

Oh - nice to know 👍

seancorfield 2020-01-13T20:00:42.016400Z

Yeah, Cursive is the most IDE-like in terms of the features it provides -- but most Clojure developers prefer lighterweight editors (Emacs, vim, Atom, VS Code)

borkdude 2020-01-13T20:01:16.017Z

@jakob.riishede.moller An interesting podcast to listen to: S2 E2 - REPL with Stuart Halloway https://clojurescriptpodcast.com/ There one of the Clojure core team members explain sophisticated IDE tooling vs spartan tooling and why you need very little with Clojure oftentimes

seancorfield 2020-01-13T20:02:14.018300Z

https://www.surveymonkey.com/results/SM-S9JVNXNQV/ covers the State of Clojure results for 2019 -- Q12 shows the breakdown by editor choice

borkdude 2020-01-13T20:02:17.018500Z

It's probably a different philosophy: Clojure is a pretty minimal language with a small set of features that compose nicely. Compare that to e.g. Scala or C++ which is quite impossible to use without an IDE

seancorfield 2020-01-13T20:03:01.019300Z

Java is also virtually impossible to write without IDE support (totally agree on Scala and C++ too).

borkdude 2020-01-13T20:03:44.020800Z

The difference between these languages is also: Clojure is interactive, the REPL is your main tool, whereas with the other languages you have a write / compile / run cycle which gets tedious and you depend on external tooling to get things right before you can even run something

2020-01-13T20:04:41.022400Z

30% of clojure users still write their clojure in the biggest heaviest IDE going 🙂

borkdude 2020-01-13T20:05:24.023600Z

@jakob.riishede.moller If you want to get the most leverage out of Clojure without depending on other tools, learn to use the REPL well: https://clojure.org/guides/repl/introduction

Jakob Riishede Møller 2020-01-13T20:06:45.025800Z

I will try to - I'm not used to that though (programming PHP at work 😫)

seancorfield 2020-01-13T20:07:49.027Z

(and Clojure's REPL is fundamentally different to other languages' REPLs by the way -- in Clojure, the semantics of compilation match the semantics of the REPL: you could feed your entire program to the REPL in the appropriate order and it would be identical to how Clojure compiles the code from disk).

seancorfield 2020-01-13T20:09:11.028700Z

I think Stu talks about the semantics compared to other languages in his REPL-Driven Development talk (given to the Chicago Clojure meetup a few years ago)...

seancorfield 2020-01-13T20:09:31.028900Z

Link https://vimeo.com/223309989

seancorfield 2020-01-13T20:10:01.029500Z

He specifically compares Clojure's REPL to Java "new" shell on one slide.

Jakob Riishede Møller 2020-01-13T20:10:42.030500Z

I have bookmarked it 🙂

seancorfield 2020-01-13T20:11:53.031600Z

Even in languages that have some sort of add-on REPL (which is usually an interpreter, rather than compiled like regular code), the typical workflow is still edit-compile-test. In Clojure, the REPL makes it possible to edit & test your code in an expression-by-expression workflow: the tightest feedback loop possible.

seancorfield 2020-01-13T20:17:50.032800Z

@jakob.riishede.moller Other than PHP in your day job, what other languages have you worked in fairly extensively? Curious to draw comparisons with Clojure.

seancorfield 2020-01-13T20:19:32.033Z

@bfabry I wonder how much that 30% overlaps with the 30% that came to Clojure from Java?

2020-01-13T20:22:18.033200Z

good question. this data point at least came from ruby+vim and uses cursive

2020-01-13T20:23:22.033400Z

well. with an intermediate stop at lighttable and getting burned developing a bunch of plugins etc for a small editor that got abandoned 🙂

Jakob Riishede Møller 2020-01-13T20:32:48.035800Z

Well - it may look curious, but in later PHP versions some level of type hinting is supported and can be utilized for dependency injection and good IDE support

Jakob Riishede Møller 2020-01-13T20:33:25.036300Z

And I dont do the usual Laravel

seancorfield 2020-01-13T20:37:33.037700Z

Yeah, I remember PHP starting to develop a type system (I did a fair bit of PHP in the 3.x and 4.x days and stopped just into the 5.x days, if I remember correctly).

Jakob Riishede Møller 2020-01-13T20:37:52.038200Z

Now it is 7.3

seancorfield 2020-01-13T20:38:12.038600Z

A friend of mine became a PHP developer just as 7.x was coming along and his code looks a lot more Java-y than any PHP I ever wrote.

seancorfield 2020-01-13T20:38:34.039100Z

Well, Java that has been completely peppered with additional punctuation "noise" 🙂

Jakob Riishede Møller 2020-01-13T20:39:08.039800Z

I think, it requires a lot of discipline to use PHP in a sound way

seancorfield 2020-01-13T20:39:20.039900Z

My arc was pretty much Java -> Groovy -> Scala -> Clojure with Eclipse as my primary IDE until I got to Clojure.

Jakob Riishede Møller 2020-01-13T20:39:59.040500Z

(SOLID)

seancorfield 2020-01-13T20:42:07.042400Z

Clojure requires discipline too -- but it also makes it hard to write imperative, mutable code so that's definitely a win. Some people run into NPEs (null pointer exceptions) a lot in Clojure but I think that depends on coding style -- I run into that sometimes but nowhere near as often as I did when I first learned Clojure back in 2010.

Jakob Riishede Møller 2020-01-13T20:43:04.043500Z

I heard a rumour that Robert C. Martin spend 5 years getting happy with Clojure?

Jakob Riishede Møller 2020-01-13T20:43:31.044100Z

https://blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html

seancorfield 2020-01-13T20:43:58.044300Z

Uncle Bob loves Clojure 🙂

Jakob Riishede Møller 2020-01-13T20:44:24.045Z

Oh I meant spent - not spend

seancorfield 2020-01-13T20:45:02.045700Z

It's definitely got a learning curve -- and a lot of people never get comfortable with it. I've used dozens of languages over my 35 year professional career and I enjoy Clojure more than any other language.

seancorfield 2020-01-13T20:45:30.046300Z

And, in addition to the dozen or so languages I've used in production, I try to learn a new language for fun every year or two.

Jakob Riishede Møller 2020-01-13T20:45:54.046800Z

I'm a little familiar with TypeScript too

Jakob Riishede Møller 2020-01-13T20:46:53.047600Z

(I am a web-developer, but have spent most of the time doing backend stuff)

seancorfield 2020-01-13T20:48:02.048600Z

Elm is a great frontend alternative to JS. It achieves its guarantees by being very opinionated about architecture and generally very restrictive overall via types and the deliberate design constraints in the language.

Jakob Riishede Møller 2020-01-13T20:48:46.049900Z

Yes - I am impressed by the little I know about Elm

seancorfield 2020-01-13T20:49:48.051Z

If I had to do frontend work, I'd probably go with ClojureScript so I could share code between the front and back end (and share data easily too as EDN). But if I wasn't doing Clojure on the backend and needed to do frontend stuff, I might consider Elm (although when I built a little web app to monitor my solar panel system, I did get pretty frustrated with how restrictive Elm feels to me).

Jakob Riishede Møller 2020-01-13T20:50:16.051800Z

Why not TypeScript?

seancorfield 2020-01-13T20:50:24.052100Z

If I couldn't do Clojure on the backend and still wanted to be on the JVM, I'd probably go to Kotlin. I've done Scala and wouldn't really want to go back to that.

seancorfield 2020-01-13T20:50:46.052600Z

Because TS is JS + types and I absolutely detest JS as a language.

Jakob Riishede Møller 2020-01-13T20:50:58.052900Z

I know how you feel

seancorfield 2020-01-13T20:51:25.053600Z

(my background is in language design and compiler/interpreter systems so I tend to have very strong feelings about languages 🙂 )

Jakob Riishede Møller 2020-01-13T20:51:43.053900Z

I think TypeScript is an improvement though

Jakob Riishede Møller 2020-01-13T20:52:10.054700Z

But the webpack circus...

seancorfield 2020-01-13T20:52:14.054800Z

Oh sure... almost anything is an improvement on JS 🙂 I mean, CoffeeScript is an improvement too but I still find CS horrible to write programs in!

seancorfield 2020-01-13T20:53:18.056300Z

In some ways, I'd have liked Haskell to take over the world as the #1 mainstream language -- because my PhD work was on ML-family syntax languages and type inference -- and then we probably wouldn't be having any of these discussions :rolling_on_the_floor_laughing:

Jakob Riishede Møller 2020-01-13T20:53:42.056800Z

Can you imagine a compiler from Clojure to webassembly?

seancorfield 2020-01-13T20:54:05.057200Z

But I also grew to love Lisp back at university so I would always have had a soft spot for something like Clojure too...

Jakob Riishede Møller 2020-01-13T20:55:00.058200Z

I am a Ph.D. in applied probability - so - I like the functional approach

1✔️
seancorfield 2020-01-13T20:57:30.059100Z

Does WebAssembly have managed GC yet? That seemed to be the stumbling block when Clojure to wasm has been discussed in the past...

Jakob Riishede Møller 2020-01-13T20:58:09.059800Z

I don't know - I just find the idea to replace JS promising 😎

borkdude 2020-01-13T21:00:48.060200Z

@jakob.riishede.moller Considering your background, maybe https://probprog.github.io/anglican/ is interesting to play with

seancorfield 2020-01-13T21:01:30.060700Z

https://github.com/WebAssembly/gc/issues/36 -- fascinating read, and includes feedback from the Scala.js and Elm maintainers.

Jakob Riishede Møller 2020-01-13T21:02:51.061800Z

It was great chatting - but I have some housekeeping to do (I am single 😄) and it is 10pm in Denmark

borkdude 2020-01-13T21:03:13.062100Z

@jakob.riishede.moller Greetings from The Netherlands (same timezone)!

Jakob Riishede Møller 2020-01-13T21:03:51.062700Z

@borkdude Greetings - over and out 🙂

1
orestis 2020-01-14T20:21:54.071200Z

Greetings from Copenhagen! Consider joining #copenhagen-clojurians , it’s fairly quiet but it doesn’t have to be :)

gklijs 2020-01-13T21:23:37.067600Z

Jusr reading the last things. I guess it would be possible to use rust to compile Clojure to wasm.