Fork me on GitHub
#clojure-uk
<
2016-07-13
>
martintrojer09:07:05

I've now gotten to the point where all I see reading Clojure code is a sea of type errors.

thomas09:07:44

@martintrojer: time to move on…. start using Haskell and tell us what it is like on the other side

korny10:07:49

I’m enjoying being back in clojure-land for a bit - all I see is “stuff I won’t be able to do next time I’m forced back to a strongly typed language” 🙂

korny10:07:06

well, “forced back to Java or C#” is probably more accurate

korny10:07:43

Never had the joy of using a properly typed language in a professional environment.

mccraigmccraig10:07:18

@korny: what sort of stuff dyu mean ?

martintrojer10:07:36

Java, C# doesn't make it onto my list.

korny10:07:07

- Read in config as a map of stuff, some list some sets some vectors, then extract stuff from it as needed

korny10:07:42

- Merge two config maps, with custom rules about what to do when keys are in both

korny10:07:55

- Subscribe to a JMS queue, on each message try parsing it as an Int (which is expected) and conj it onto a list (in an atom). However, if I get something that isn’t an int, log it and conj it onto the list anyway, something later can handle errors for me.

mccraigmccraig10:07:56

surely you can do all that in a typed language, with appropriate use of sum or tagged types, or writers or whatever ? ?

korny10:07:04

You definitely can - but you would spend an age writing all those types. And you could only do it in a “good” typed language, which narrows the field a lot.

mccraigmccraig10:07:57

i guess the deal you are making is that you spend the time on defining types beforehand in exchange for not spending time hunting down bugs later

korny10:07:26

Yep - feels like premature optimisation to me. I don’t actually get very many type bugs. The ones I do get are generally short-lived - mistakes made during coding or refactoring - and even rudimentary unit/integration tests catch them.

korny10:07:09

This is all a matter of personal preference of course 🙂

martintrojer10:07:14

type bugs are a wide net for me. all the nil stuff, shape errors, keyword typos etc

mccraigmccraig10:07:15

could be - i can't judge - i haven't done a significant project in a language with a powerful type system - i would definitely like to

martintrojer10:07:12

event side-effect bugs are type errors in my book

martintrojer10:07:27

(since side effects clearly should be part of the type signature)

korny10:07:27

The closest I’ve done was Scala - and yes, there are things I miss from there. Type-based pattern matching, and type-safe Options (maybe monad) were great. Maybe I just haven’t spent enough time in “good” languages 🙂

martintrojer10:07:13

Yeah, people who say types are bad since they wasted too many years in Java doesn't know the whole story.

martintrojer10:07:39

Everybody needs to write an parser in Parsec and experience the week-long grin when the Applicative Functor penny drops.

korny10:07:45

The flip side is people who say “types are awesome” and then don’t offer up a language that implements them properly that is widely used enough for us to get paid using it 🙂

mccraigmccraig10:07:37

@korny s/types/lisps/g 😉

korny10:07:24

Generative testing is another thing I’d love to play with properly, if I were using a “good” typed language - I’ve seen some magic testing done in Haskell. I’ll be interested to see how well they work with spec - haven’t had a chance to play yet.

martintrojer10:07:32

schema can also output generators

martintrojer10:07:42

... nothing new here

korny10:07:12

Can it? Cool.

thomas12:07:46

yes, learning Haskell properly is on the list of things to do.. maybe one day.

glenjamin12:07:11

I’ve found generative testing difficult to use effectively for “business rules"

glenjamin12:07:46

I expected it to be really useful for testing validation rules, but had difficulty expressing good properties

korny12:07:50

… except of course, last time I asked a Haskell fan “can the type system do X” they said “ah, no, Haskell’s type system is not up to it, you should be using Idris” 😉

mccraigmccraig12:07:01

what was X @korny ? was it a dependent type thingy ?

korny12:07:41

I can’t really remember - it was a while ago, sorry.

thomas15:07:37

@yogidevbear: ask @otfrom I think Henry Garner works for Mastodon C.

thomas15:07:54

actually that might mean a very biased opinion...

otfrom15:07:21

We are working through it slowly in book club at work. We like it.

tcoupland16:07:56

i read half of it (before i joined mastodonC), and found it very interesting. It is quite a bit of work though!

tcoupland16:07:20

whether that is less biased i'll leave to you to decide

tcoupland16:07:43

I did find that once i got used to the format i could use it more as a reference when i got stuck doing stuff

yogidevbear16:07:46

Thanks for the feedback. How did you find the mathematical formula stuff? This is the part I think I'm most interested in. Is it easy to follow and learn with no prior experience?