Fork me on GitHub
#clojure-uk
<
2016-09-20
>
otfrom08:09:07

still mostly happy with this bit of testing with spec https://clojurians.slack.com/archives/clojure-uk/p1474322876000501

agile_geek09:09:22

Haven't we had that Clojure syntax conversation before? Biggest problem Java dev's seem to have is just that the syntax develops very dense code and it's disconcerting to have half a dozen transformations in one line of code to hold in your head. Java has more 'white space' in the form of patterns like getters/setters that need no cognitive load to grok.

otfrom09:09:25

changing reading speed was definitely the biggest change for me. You have to do the same for Rich's docs too

agile_geek09:09:19

otfrom: exactly. I think people take time to get used to 3 lines of code taking as much time and effort to read an 40-50 lines of other languages. However, once you get used to it you can see much more on one page.

thomas09:09:14

I am still surprised after several years of Clojure how much I can get done with relative few lines of code.

jasoncourcoux10:09:22

@thomas - Completely agree - I'm regularly surprised at how concisely I can achieve something...that is, until I go and look at someone else's code in the Clojure community and realise just how verbose my code still is!

jasoncourcoux10:09:44

@otfrom - I was struggling with some of the docs yesterday - I ended up resorting to the dictionary. Not sure if that is down to my ignorance of the English language, or given some of Rich's talks intentional!

mccraigmccraig10:09:25

ha, my previous main lang before clojure was ruby - and i found clojure much nicer in most aspects - but i did find ruby more concise

agile_geek11:09:51

@mccraigmccraig more concise? My Ruby is rudimentary but looking at a few languages I know better I find they often have core functions/methods where Clojure relies on a few simpler fn's and fewer forms and this sometimes leads to slightly more code? Still dense code though!

kevin4211:09:12

Yeah in Python we have lambda but it’s it’s very rare when people are using it see http://python-history.blogspot.co.uk/2009/04/origins-of-pythons-functional-features.html

dominicm11:09:41

@kevin42 The way scoping works with anonymous functions confuses the hell out of me

kevin4211:09:26

What was your error do you remember?

kevin4211:09:32

Something like response was set to cmsg?

dominicm11:09:51

@kevin42 No error, it didn't set response as it was out of scope.

dominicm11:09:10

You have to explicitly say that a variable belongs to the outer scope when creating closures like that

kevin4211:09:28

Oh I see you wanted a side effect explicitelly

kevin4211:09:11

I think to understand the code a bit more I need to have a look at nrepl.WatchableConnection

kevin4212:09:42

It might be the case around lexical vs dynamic scoping

kevin4212:09:55

is clojure lexical too?

thomas12:09:19

@jasoncourcoux yes… looking at the code of a real master (ztellman is a name that comes to mind) makes me realise I still have loads to learn

maleghast12:09:37

Totally off-topic, but do we know anyone in here who is “current” with development on top of Salesforce?

dominicm12:09:43

@kevin42 Yep, I was doing event-based programming. What I really wanted were clojure promises, but I couldn't find them in python's core. I think it's the lexical vs dynamic scoping, yup. I have never been able to grok dynamic scoping. Javascript uses lexical scoping, I expected python to work similarly.

kevin4212:09:05

Interesting thanks I’ll dig a bit more into clojure promises and see what I can take from here. I haven’t done that much event-based programming but my first guess would be to look at what the people says about it in the tornado or twisted communities.

dominicm12:09:38

@kevin42 tornado exists to facilitate, so it possibly includes something similar to clojure promises. But I'm unable to expect any python libraries to be included. The one I use is a git submodule.

agile_geek12:09:26

Quick question to those of you using or experimenting with Spec: Is it possible to retro fit spec into earlier versions of Clojure or is spec totally predicated on 1.9?

dominicm12:09:09

@agile_geek Somebody put spec in a lib

agile_geek12:09:44

I knew someone in this knowledgable community would know that without me having to resort to google! 😉

dominicm12:09:18

It was mentioned on the google groups early on. I tracked the spec conversation closely.

agile_geek12:09:42

@dominicm the difference between being a professional Clojure dev and a tinkerer like me! I don't have the focus, incentive or time to follow this stuff that closely!

maleghast12:09:10

That is kinda awesome

dominicm12:09:34

@agile_geek My interest stemmed more from writing a similar library at the time. Spec never scratched my itch though, so I'm back working on it.

agile_geek12:09:57

@dominicm I was interested in spec as I'm still very ambivalent about types vs dynamic verification (for want of a better phrase).

glenjamin12:09:44

aiui python is also lexically scoped, but the new-variable vs scope-variable default is inverted from most other langs?

glenjamin12:09:07

and in python 3 they switched it over

dominicm12:09:04

@agile_geek I get most of my clojure email list read before I'm into the shower. As I only read things I'm interested in.

mccraigmccraig12:09:24

@agile_geek both please. i want to know at compile time when i've failed to handle a branch, and at runtime when a json doc fails to conform

agile_geek12:09:51

Here's something to ponder. Recently we've seen a few notable Clojurians moving from clj/cljs to other languages, most notably Elm and Haskell. I gave a talk based around a lot of Rich's talks recently that emphasised that developers are now the most expensive part of software production rather than CPU/memory, etc. Given this, and accepting that good developers can switch languages reasonably easily, there is still a huge investment in an existing language that's being devalued when an org switches. Are things like a good typing system worth this cost? Especially as if you've got good enough developers to rapidly become effective in a new language they're probably good enough to use other tools/techniques to make their code reasonably 'type safe' anyway?

agile_geek13:09:58

of course this is the argument against switching from Ruby, Java, Python, etc. to Clojure in the first place so it's a little self defeating!

dominicm13:09:17

I guess there's a "pain factor"? Sometimes the effort to write maintainable/good code in Java (to a Clojurians standard) is just too painful.

dominicm13:09:08

Whether types are a big enough pain factor is what needs pondering. Your question is worth asking when answering that.

thomas13:09:19

what I like most about Clojure is the fact that it is a Lisp… and that simplicity is one of its main goals, this in turn means that I can concentrate more on the problem at hand and I have to deal less with implementation details ( i in loops for instance are boilerplate ultimately)

thomas13:09:40

Haskell et al. seem rather complicated to me (haven’t really looked at them in great detail)

thomas13:09:01

the typing thing is almost detail in this context for me

thomas13:09:24

that said I have never worked on a large clojure code base with (lots of) other people.

thomas13:09:34

I guess I will find out soon what that will be like

kevin4213:09:14

Seems to me unittest can make sure it’s type safe. You have testing libraries which can send a bunch of different data and see what happens.

glenjamin13:09:15

I don’t write tests that send junk into my functions. In a good statically typed language these things get checked for me. In a dynamically typed language I just trust/hope

agile_geek13:09:36

@dominicm exactly my point. Is the 'damage' caused by not having types worth the investment in re-write...and I guess that depends on the system but in my experience the cost and risk of accurately rewriting a working non-trivial system in any new language is much greater than what I can perceive that types give you. I think Clojure is MUCH more productive than Java but I would never suggest that a massive Java legacy system be rewritten in Clojure unless there were other reasons for a rewrite ...and even then the cost is huge. I've been involved in 10 rewrites in my time...1 was a success...8 never even got released. The successful one was a rewrite in the same language with almost the same team (80% of the team the same) and it was within 3 years of the original write PLUS it was in government 20 years ago when the world moved at a snails pace compared with now. I really consider it a big refactoring exercise.

glenjamin13:09:27

i might test boundary conditions from the expected types, but I wouldn’t verify behaviour under incorrect types

agile_geek13:09:02

@glenjamin I'm not saying types don't bring benefits. I like typed languages. I just contest that a rewrite from Cljs to Elm is an expensive thing to do and does it bring enough benefits given the learning curve and mistakes that will be made?

glenjamin13:09:37

frontends tend to get rewritten every few years anyway

agile_geek13:09:39

I suspect committing to rewrite in the same lang would have brought more benefits?

otfrom13:09:40

agile_geek: I don't think static typing short of Haskell (or similar) brings much benefit.

glenjamin13:09:59

i agree that rewrite in a new lang is rarely worth it in isolation

otfrom13:09:17

I've been really happy with the spec stuff I've been doing lately. I can almost see my self doing (type|test|spec) driven development with it.

glenjamin13:09:32

the best choices, especially in JS-land, allow an incremental rewrite

agile_geek13:09:03

@glenjamin I would say an incremental rewrite is just about the only way to be successful

glenjamin13:09:21

i’m currently working on a full rewrite 😄

glenjamin13:09:31

although it is one app in a suite of products

agile_geek13:09:43

The catch-22 here is, if you have a disciplined team who have a shared understanding of their problem, good tests, well structured/modularised code, etc. then a rewrite can succeed. However, if you have that do you need to rewrite or would you be better spending effort on improvement elsewhere? Conversely, if you have a big ball of untested mud you need to rewrite but you're unlikely to be successfull!

thomas13:09:24

re-writes are hardly ever worth it as you point out @agile_geek

agile_geek13:09:25

The real investment required always comes back to one thing in my mind....people.

agile_geek13:09:22

If you have the right people and their invested then it doesn't matter what you use you'll be reasonably successful.

glenjamin13:09:08

motivation is an interesting topic

agile_geek13:09:35

@glenjamin yep and actually one of the major reasons I might consider a language change in an org

thomas13:09:48

re-writing is hardly ever motivating I suspect

glenjamin13:09:14

if you’re knee deep in mud, I can see how a rewrite might be motivating

glenjamin13:09:18

at least initially

thomas13:09:56

but has the problem that caused you to be knee deep in mud been addressed?

thomas13:09:15

most likely not, as it is unlikely to be a technilogy problem

agile_geek13:09:26

@glenjamin I think changing language in this case may be a good excuse to get rid of the less flexible members of an org and recruit some better talent.

thomas13:09:28

and more likely to be an organisational problem

glenjamin13:09:59

in this current case i’m brand new to the company and i’m leading the re-write

thomas13:09:10

@agile_geek if that is a side effect then the organisational might be addressed

glenjamin13:09:10

and mostly staying out of existing politics and practices

thomas13:09:36

@glenjamin that sounds like a wise thing to do

agile_geek13:09:41

@thomas: true and again another reason why you may want to throw out the current language, tooling and processes in order to force an organisational rethink

agile_geek13:09:41

Using a lang change as a catalyst for changing organisational thinking (and personnel) is one of the only valid reasons to change lang.

glenjamin13:09:57

I’d expect lang to be too much of a low-level change to enact org change

agile_geek13:09:46

@glenjamin agreed. Process change is a bigger catalyst but lang can force change in development people.

glenjamin13:09:59

it’d shake up your dev team, but if the same approaches exist at the management level then i’d expect the same patterns to re-emerge

kevin4213:09:16

that’s a good point

agile_geek13:09:45

I used to try and do incremental transitions of process change in orgs....hardly ever works unless staff turnover is high anyway. I've found being as radical a possible and leaving those who can't keep up behind is a better approach but it requires real support at board level

glenjamin13:09:24

I like to find some relatively isolated project, and carve out a team to work on it in a new way

glenjamin13:09:42

and then if that sees success, either spread those practices or those people back to the mothership

agile_geek13:09:16

Done that too but usually doesn't change the org, just buys support at board level for the radical stuff!

kevin4213:09:29

If you enforce a lang change for a team, wouldn’t you expect for a few good dev to just leave the boat?

thomas13:09:23

radical change is really difficult to achieve… my current employer could do with some… but very unlikely to happen IMHO...

thomas13:09:29

hence me leaving 🙂

minimal13:09:13

From my experience the devs on board with a change to a new shiny language are also the ones that leave before it gets the go ahead fully, then the movement to the new lang slows down

minimal13:09:55

and the remaining couple of devs who wanted the new lang are sad and eventually leave as well

agile_geek13:09:19

@kevin42 I wouldn't enforce anything. I would start with a project similar to @glenjamin's suggestion and ask the good dev's to try out a new language...also ask them to choose, with a bit of prompting!

agile_geek13:09:50

I've usually found the good dev's rise to the challenge

kevin4213:09:58

Are you trying to achieve something like this as a consultant or within a team?

kevin4213:09:11

We’ve had in the past some people willing to move but the deadlines mostly stopped us. If someone external was hired to to the transition it would’ve been better maybe.

agile_geek13:09:17

@kevin42 I've done both. As a consultant you usually have buy in from higher up and more resources as you cost more and you're targets have probably been signed off by someone with the power to make real changes.

maleghast13:09:45

@kevin42 - You’ve just described what I want to do with my career next; consultant agent of technical change… 😉

agile_geek13:09:18

I went to a great talk from Woody Zuil a few weeks ago about Mob Programming. He was hired as dev manager by CEO to make big changes to an org. He said he would only do it if he and the teams were left alone to decide what they were going to do for a whole year with no interference!

agile_geek13:09:50

That's a whole year with the dev teams deciding what would be released...if anything!

agile_geek13:09:59

not many orgs can do that!

kevin4213:09:54

Yeah impressive and it sounds very interesting. @maleghast I understand 🙂

agile_geek13:09:24

@maleghast I have one piece of advice, sell to the board or C-level and charge a really high day rate. Nothing to do with making money but it ensures you will get the right buy in to make real lasting change.

otfrom13:09:44

and if you don't charge the high day rate then they won't listen to you

agile_geek13:09:00

Does mean you may have to go a long time between gigs sometimes!

agile_geek13:09:41

+1 @otfrom - it's almost the only way to be successful if the change is radical

kevin4213:09:07

Cool it sounds like great advice guys. I’ll have a look about the programming mob.

agile_geek14:09:37

Also reason why my bid for a bit of consultancy is taking until next year for approval...I insisted on high day rate and talked to c level person. It's happening but it takes time for bureaucratic stuff to go through!

thomas14:09:51

hmmm I can charge a high day rate… no problem...

thomas14:09:13

and just for good order.. what is a high rate? > 1000 a day?

maleghast14:09:49

@agile_geek - Thanks for the tip; will do:-)

seancorfield14:09:56

At World Singles I first got involved (in 2009) when they kicked off a complete rewrite in the same language. They had 10 years of old code. It took three of us three years to build a complete replacement and roll it out.

seancorfield14:09:10

We had one particularly thorny problem that they'd failed to solve effectively in that language and in two other languages they had tried. That's how I got Scala in. But it didn't work well enough and was too alien to the team's culture (static types, compile/package/deploy), so I switched that piece to Clojure (dynamically typed, compile-on-demand like a scripting language).

agile_geek14:09:26

@thomas depends on the job and location. I'd say for a major transition > £1000 in London, less elsewhere in UK.

seancorfield14:09:12

We've been doing a slow, piecemeal rewrite of the whole system to Clojure ever since (five years -- although we really only agreed it was a rewrite a year or two ago 😈 ).

thomas14:09:53

@seancorfield we have something going on here and it is called “refactoring” as not to upset the original team.

seancorfield14:09:12

Yes, we've been know to "refactor" code from one language to another...

maleghast15:09:32

I am going to have to try and refactor by reformatting the code into the language of my choice.

kevin4215:09:43

you can start with an interpreter for that language

agile_geek18:09:12

@mccraigmccraig what was context for that comment...sounds fascinating!

mccraigmccraig18:09:27

@agile_geek we send out websocket notifications which cause our app to refresh content... a bunch load of users (~250) were actively participating on one piece of content (voting in a poll with a short deadline) - 250 users voting caused 65k refreshes and 65k deletes to all hit cassandra within a few seconds - nothing terrible happened, but there were some timeouts

mccraigmccraig18:09:22

slightly less dumb websocket notification messages and a smarter way of recording recent-traffic can turn 65k refreshes into 0 and 65k deletes into 250, which will make cassandra much happier i think

agile_geek18:09:04

Ooooh interesting problem!

agile_geek18:09:22

Sort of thing I like to think about.