unusual question: how do you get morale?(or moral support)

1,677 views
Skip to first unread message

AtKaaZ

unread,
May 12, 2013, 3:34:22 PM5/12/13
to clo...@googlegroups.com
Hi. I've been meaning to ask (all of)you, how do you get moral support? How do you put yourself into that mood so that you're happy/willing to program? What motivates you to do it? Is it the people you surround yourself with or the financial support? Are they enough to subconsciously motivate you? What if you had no friends/contacts but you had time?

 Unusual question for this ML, I know, so I won't expect (m)any answers.
Thanks.

Simone Mosciatti

unread,
May 12, 2013, 3:52:41 PM5/12/13
to clo...@googlegroups.com
I code only for myself, and honestly coding is what I like to do.

I remember these days being in a very bad mood and all I wanted to do was to sit and code.

I believe that what motivate myself is my own EGO, code for me is only about solving problem, and more problem I solve better my ego is.

Anyway I am still a student and I don't have (m)any [I like that XP] financial issues.

I am weird, but friends usually don't help me when I have an hard time, neither does my family (no that they wouldn't like to help me, they try most of the time but they simply don't work), time helps.
For problems that I can not solve because they are not ups to me, I just don't think about, so I keep myself as busy as possible, until I don't feel great again.
For problems that I can solve, well those are just other forms of coding, so I just fix that for my ego.

:-)

Someone else want to share ? 

Softaddicts

unread,
May 12, 2013, 4:50:20 PM5/12/13
to clo...@googlegroups.com
I just put my ear buds and select music according to my mood and my task
choice.
I have around 10 days of music on my iPad, all sorts of styles.

Sometimes, however I need to select a pleasant task knowing that I am not
in a mood to tackle a p.i.t.a. subject. These times are very low on my mood
scale and do not occur often.

A good example, in the last three weeks I have been working on patching
rotten hospital accounting processes using Clojure. It's all event driven, asynch,...
but ultimately, you deal with debit and credits and money persistence in a
database which cuts the fun by a few orders of magnitude :(

It's been driving me nuts. I am competing with a messy front end and carving out
a way to get these things to run and balance properly.

These are rough times. Of course, I could have been forced to do this in PL/SQL,
it helps to put things in perspective a bit :))))

I have a pile of fun things waiting for me to do. Like they say, push back the
gratification as much as you can and think about the other worse options
(PL/SQL, Cobol, PL/1, ...) out there to keep you going...

Luc P.
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
Softaddicts<lprefo...@softaddicts.ca> sent by ibisMail from my ipad!

AtKaaZ

unread,
May 12, 2013, 4:52:31 PM5/12/13
to clo...@googlegroups.com
Hey, thanks for sharing.

 I think I am the opposite of that, I am unable to code just for myself, if no one else is directly (and immediately) impacted by what I do then I get bored fast (but this is probably coupled with the fact that I am unable to code the way I want yet like some editor where everything is based on a graph so ie. connected, explorable). If I am doing something for someone (other than just myself) then I'm all fired up and motivated although any kind of inconsistency/bugs/barriers or the need to compromise around them because of the system limitations are having a negative impact on my morale.
 This is likely still be ego related, but knowing that I am not the only one that I program for, boosts my morale. In a way this is always true that you program for others as much as for yourself but it's not directly obvious, for example all the improvements that you get from practicing/programming will help you and others in the future, it's for the best of all(and I consciously know that), but my subconscious seems to want something more immediate like knowing that are others (in the now) actively waiting on me and wanting me to code the stuff (ego xD). I find this  morale boosting. But just doing it for myself, I couldn't do it, even if I would know that sometime in the future some people would appreciate that I did that.
 I would guess that a good programmer(not me) knows how to program his subconscious (which is not unlike what you did Mosciatti) so that morale is never a problem. Either make the environmental conditions match the expected ones (ie. surround yourself with friends that appreciate what u're doing) or reprogram your subconscious (ie. so you don't need the friends that appreciate you, you appreciating yourself would be enough).
  Sometimes I am able to trick myself into believing that sometime in the future some people would benefit from what I coded (either from the code itself[less likely though xD] or from what the resulting program does) and this works for a while but it's still based on the fact that I code for others or in other words, my ego boosts morale when I know that I've done something for others (as opposed to just myself).

ok writing too much text, stopping



--

Rostislav Svoboda

unread,
May 12, 2013, 5:07:54 PM5/12/13
to clo...@googlegroups.com
Well everything in life - especially in engineering - has its ups and
downs. Teamwork is the key!
https://www.youtube.com/watch?v=Nebd9yoraac
:)

u1204

unread,
May 12, 2013, 7:03:49 PM5/12/13
to clo...@googlegroups.com, clo...@googlegroups.com
I can't answer for anyone else but, for me, it is simple.
I don't program. I AM a programmer. It is a lot like being an artist,
I guess. You see, think, and express in painting. Or a dancer.
See Ken Robinson's TED talk and his story about the dancer's education.
I see, think, and express myself in programs.

I want a program that "speaks the key letter" when I hit a key because
it is hard to type while driving. I want it to tell me what letter I
just hit so I don't have to look. Driving wastes time.

It is Sunday @ 6pm here and I've been coding since I woke up. Prior
to that I coded just before I went to sleep (@5am this morning).
I program because.... I breathe?

I have a LONG list of programming projects I want to do and not enough
time to do them. I'd like to have a group of people who would work with
me on them. I've often joked that I'm in the market for a dozen
"foreign brides" so I could teach them to program and help. Local laws
seem to frown on multiple marriages of convenience unfortunately.

I know a lot of people who "program" but I know very few "programmers".
They are easy to spot though. Just look for people who get fired up when
the watch Rich Hickey's "Are We There Yet" video. Look for someone who
thinks McDonalds is the canonical example of an operating system.

We live in the first 60 years of a new science. Think big thoughts.
Try to throw yourself at a problem that will consume the rest of your
life. Think about your craft, understand where it has flaws, and try
to convince people there is a better way. Clojure is one example.
We won't mention literate programming.

Rich is trying to make the language he needs to cleanly express what
he wants to do and, as a side effect, he's changing the world around
him. You can do that too.

Grab the Firefox sources, strip out Javascript, replace it with
Clojure. That would completely eliminate the need for ClojureScript and
put you dead center in the pantheon of Clojure-ites. If we could open a
new browser tab, type Clojure in it, and then use it to drive the GPU
graphics hardware to present a new web page... that would be cool. We
want to open a Clojure tab and have a REPL. We want to drag-and-drop
the Clojure Ants demo into a tab and see it run immediately, locally,
and natively in the browser. Now we have Clojure everywhere on anything
using everything. Big win. Now we can socket connect your browser to my
browser and the whole world now is a Clojure supercomputer. Bigger win.
Who needs servers? It could change the world. (Hmm, where can I find
that signup sheet for foreign brides... it's around here somewhere.)

Tim Daly



Sean Corfield

unread,
May 12, 2013, 10:02:36 PM5/12/13
to clo...@googlegroups.com
+100 :)

I write code because I have to. If my job doesn't have me doing much
programming, I spin up OSS projects in my spare time. When my job has
me doing hardcore programming all the time, my urges are satisfied and
my OSS projects don't get as much love. If my wife's away for the
weekend, to fill the emptiness, I write code.

My wife has several friends who are writers and artists and they all
say the same thing: they write (or paint / draw) not because they want
to, but because they have to - they're driven by some overwhelming
need or desire.

Like Tim tho', I know a lot of "programmers" who are not like that.
For them, it's a job. When they go home, they don't think about it,
they don't read technical books for "fun", they don't write OSS. I'm
just glad people are willing to pay me for something I'd have to do
anyway to stay sane...

Sean
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Nelson Morris

unread,
May 13, 2013, 9:05:34 AM5/13/13
to Clojure
Development for money isn't a problem for me, however dev for open source can be problematic. The scarce resource for open source is mostly time, though occasionally motivation becomes low. Contributions and projects start off well, and energy might wane depending on time and life factors. Even contributing to tools used by many of the members of the community, like lein and clojars, doesn't prevent it. What helps is direct involvement by someone else.  Maybe technomancy makes a commit in clojars and it sparks me there for a couple weeks, or someone will have some problem with lein's dependency stuff and I'll spend a few days to make it better. Hanging out in irc sometimes helps, though it can also be a distraction.

Watching the small business software community from afar, I've seen several people talk about how mastermind groups are helpful. It seems like a weekly or bi-weekly call/hangout of 3-5 people who provide support and accountability would be a decent hack for those that need some external push.

Phillip Lord

unread,
May 13, 2013, 9:18:17 AM5/13/13
to clo...@googlegroups.com


AtKaaZ <atk...@gmail.com> writes:
> Hi. I've been meaning to ask (all of)you, how do you get moral support? How
> do you put yourself into that mood so that you're happy/willing to program?
> What motivates you to do it? Is it the people you surround yourself with or
> the financial support? Are they enough to subconsciously motivate you? What
> if you had no friends/contacts but you had time?

I have the advantage of not being a programmer; I write code to achieve
something that I want, or that will allow me to answer a question that I
want to answer. As the questions vary, so does the choice of language,
which is why code-wize, I'm a jack-of-all-trades and, indeed, master of
none.

For me the questions are often biological. How do we measure if two
genes are doing the same thing? How can we we analyse 10,000's of genes
at once? How can we describe the chromosomes that we see down a
microscope?

Of course, you could ask how I find the motivation to answer these
questions; can't tell you that one. I can't understand how anyone could
*not* be interested in how life, how they themselves, work.

So, more generally, my answer is, I care about what my code does;
without this, for me, it's solving a crossword puzzle.

Phil




Phil Hagelberg

unread,
May 13, 2013, 1:19:25 PM5/13/13
to clo...@googlegroups.com

Nelson Morris writes:

> What helps is direct involvement by someone else.

I'll definitely echo this. People are more important than programs.

If I'm writing code that I'm going to be the only one using, maybe it'll
hold my interest for a few hours. But even in the best cases it's
usually only motivated by extreme annoyance, which is not sustainable.

Code that matters is code that's used by other people. For me personally
the ability to share my code with others is the thing that makes
programming worth doing in the first place.

-Phil

Ulises

unread,
May 13, 2013, 2:09:31 PM5/13/13
to clo...@googlegroups.com
> Code that matters is code that's used by other people. For me personally
> the ability to share my code with others is the thing that makes
> programming worth doing in the first place.

This is a rather important point. One of the most asked questions
(random made up fact) by newcomers to a language is "what can I code?
what open source programs can I help?". All with the aims of getting
better acquainted with the language itself and, hopefully, helping
others. I normally direct people to Advice to Aimless, Excited
Programmers (http://prog21.dadgum.com/80.html). For those who'd rather
read the rest of this email, the tl;dr version is: got scratch your
own itch, you might be building an itch-scratcher for others.

The real question now becomes (at least for me): how do you know when
an itch is worth scratching? how do you know it's a shared itch?

I've seen more experienced programmers immediately recognise what'd be
useful at large and what wouldn't (when I presented them with a couple
"itches" of my own.) Interestingly enough, my judgement didn't
necessarily coincide with theirs.

Code to scratch your own itch? Sure, that's great. Code to scratch a
shared itch? Even better. But how do you know which is which?

U

Timothy Baldridge

unread,
May 13, 2013, 2:17:14 PM5/13/13
to clo...@googlegroups.com
I doubt I'm unique in this area, but for me, programming is a drug. I have to code, or the ideas and thoughts build up in my mind. For me, actually writing down and implementing these is a stress relief. Just ask my parents when I was growing up, or my wife today. Keep me in a room without a computer for a week, and I'll start writing code on paper just to get the thoughts down.

So I guess you could say I'm an addict.

Timothy Baldridge 



U

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)

Erlis Vidal

unread,
May 13, 2013, 3:35:33 PM5/13/13
to clo...@googlegroups.com
Let me share this tale with you guys, hope you like it as much as I do:

It is said that
Socrates met a worker who asked: what are you doing good man? "Don't you see I'm cutting a stone to earn my salary and so I can eat" the worker replied. He moved on and later found another worker questioning the same way as the previous one, he replied "I'm building a wall," continued Socrates finding their way to a third worker, also questioning, the answer was "I'm building a beautiful palace "

Zack Maril

unread,
May 13, 2013, 5:03:10 PM5/13/13
to clo...@googlegroups.com, er...@erlisvidal.com
One of the reasons I program is because I'm furious. 

By most accepted metrics, I went to one of the best technical public high schools in the country. I was average there and I was taking graph theory and multivariable calculus as a senior my last semester. The smart kids though? They were doing real analysis, topology, and winning international competitions for mathematics and science. I'm just finishing up college now and I'm watching the geniuses from my high school go from MIT and Stanford to high frequency trading firms or work for places like palantir and facebook. They're using their gifts to remove liquidity from the markets[0], to help fight wars based on lies[1], and to maximize the amount of money they can sell my privacy for[2]. Most of them use programming to indirectly decrease the quality of my life. I'd love it if I could invest money without fear of the markets going crazy because of a tweet[3], if I could support the government without worrying about them killing innocent citizens[4], and if I could connect with my friends and family without worrying about my privacy being sold to the highest bidder. My former classmates are and will be using computers to indirectly prevent me from doing the above with any sort of peace of mind. It is infuriating. 

When I sit down to program, I now make a conscious effort to build tools that I can use in the future to fight against the trends above. I use Clojure because it's the language I've been able to get the most done in the shortest amount of time. If there were a language that let me do as much as fast, I'd drop Clojure like a rock and learn that. If I want to stem the negative effects the geniuses are having on my life, I'll need to use the best tools possible. That means constantly learning more powerful concepts and building better tools. I've been on a graph theory and network science kick lately because I noticed that google, palantir, and facebook got where they are by virtue of being really good at graph theory. The concepts are crazy powerful and provide immense power to the people who can successfully employ them. 

So, when I sit down to work on certain projects, the main motivating factor for me is that I'm furious that my classmates are worsening my life. There's a ton of work that I need to do before I can do anything about it though. I'm obviously on a futile crusade fueled by my youth and naiveté, but for the moment, that's why I program.  
-Zack

Softaddicts

unread,
May 13, 2013, 6:56:47 PM5/13/13
to clo...@googlegroups.com
+1 :)

Michael Klishin

unread,
May 13, 2013, 7:51:56 PM5/13/13
to clo...@googlegroups.com
2013/5/12 AtKaaZ <atk...@gmail.com>

How do you put yourself into that mood so that you're happy/willing to program? What motivates you to do it?

When it comes to work projects, I am personally motivated by building something useful and
making a good living out of it. The process of programming is fairly interesting to me,
but not all of the time.

When it comes to open source, I almost always work on something because I am

 * Really annoyed or infuriated by something
 * Really interested in something

So, have an enemy [1].

This is how ClojureWerkz and http://clojure-doc.org were started: I was really unhappy about
the state of some libraries and the attitude towards documentation in the Clojure community.
As time goes, seeing how other people use your projects becomes another important
reason to continue working on OSS. 

Finally, there aren't many ways to get your name known
in the technical community if you are not based in an area with an active 
technology community (Bay area, NYC, London, Berlin, etc) and did not attend a fancy
school. Open source and other side-projects is pretty much the only way.

Armando Blancas

unread,
May 13, 2013, 11:38:13 PM5/13/13
to clo...@googlegroups.com, er...@erlisvidal.com
Zack, you've probably come across this profile on Jeff Hammerbacher, but just in case.

"The best minds of my generation are thinking about how to make people click ads," he says. "That sucks."

Phillip Lord

unread,
May 14, 2013, 5:17:44 AM5/14/13
to clo...@googlegroups.com, er...@erlisvidal.com
Zack Maril <thewi...@gmail.com> writes:

> I'm obviously on a futile crusade fueled by my youth and naiveté,
> but for the moment, that's why I program.


Yes, you are. Long may it last, and good luck to you!

Phil

Phillip Lord

unread,
May 14, 2013, 5:18:55 AM5/14/13
to clo...@googlegroups.com, er...@erlisvidal.com

Thanks a funny piece, although I'd debate his self-deserving description
of "best minds". People who cannot distinguish between important and
well-paid are not the best minds.

Phil
> --

--
Phillip Lord, Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: philli...@newcastle.ac.uk
School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower, skype: russet_apples
Newcastle University, twitter: phillord
NE1 7RU

Joel Ericson

unread,
May 14, 2013, 10:30:12 AM5/14/13
to clo...@googlegroups.com, er...@erlisvidal.com
My life is mostly about music and playing with structure. Programming falls into the second category.
Right now, I'm having difficulty getting a job since it's much more fun to play the violin and program than to apply for jobs.
If I were to get a programming job where I were to do mundane tasks in a programming language I disliked, I would probably do it for the money. For a while, at least.

Allen Johnson

unread,
May 15, 2013, 9:27:20 AM5/15/13
to clo...@googlegroups.com
I've recently been wondering about this. I'd say that I'm coming out of a burnout period that I've been in for at least the last few months. Also, reading things like hacker news gives me this feeling that I'm not doing enough with my time -- which adds to the weight that I already feel on my shoulders.

Lately, I have been coming out of this slump and have begun looking at work as fun again instead of as a chore. Of course there are still chore aspects but overall it's become very enjoyable. I don't receive any moral support from friends or family since they are not familiar with programming and most of them aren't tech savvy.

I've recently made some life style changes which might have contributed to my personal turn around. My primary life style change is sleep. Instead of treating sleep as a luxury that I can skimp on -- I have given it equal importance to eating healthy and exercise. I used to stay up late after a long day of work to catch up on all of the fun/interesting things that continue to be developed in this field. After all, that is part of why I enjoy this line of work. But now I limit that activity to go no later than 10pm. I've also relaxed on the drinking. While alcohol can help you fall asleep, I believe the quality of sleep you have is greatly diminished.

Now I'm an early-to-bed / early-to-rise type which is a huge change for me. I find myself excited to start the day and am more productive at work. The curiosity, creativity, and motivation has returned. :-)

Allen



--

Phillip Lord

unread,
May 15, 2013, 12:23:01 PM5/15/13
to clo...@googlegroups.com

I'm still a bit confused on the use of set!

I would like to define a configuration variable that is easy to change,
but which is not critical to my infrastructure; it's will set some
default behaviours.

Now, I can do things like

(binding [*warn-on-reflection* true]
(do-some-function))

and it does the right thing. Similarly, I can do

(def ^{:dynamic true} *my-test* false)
(binding [*my-test* true]
(do-some-function))

and this all works.

However, while I can do

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

I cannot do

(set! *my-test* true)

because I cannot change the root binding. What I confused about is how
does this work with *warn-on-reflection*? Where is the root binding? And
how come I am not trying to set it also? Can I get similar behaviour for
one of my vars? Or do I need to do something like:

(def *my-test* (atom true))
(reset! *my-test false)

but then I loose my dynamic binding?

Phil

Jim - FooBar();

unread,
May 15, 2013, 12:28:47 PM5/15/13
to clo...@googlegroups.com
On 15/05/13 17:23, Phillip Lord wrote:
I cannot do

(set! *my-test* true)

(alter-var-root  #'*my-test* (constantly true))

Jim

Jim - FooBar();

unread,
May 15, 2013, 12:33:06 PM5/15/13
to clo...@googlegroups.com
here explains what you're asking:
http://clojure.org/Vars

scroll down to until you see

(set! var-symbol expr)


HTH,

Jim


AtKaaZ

unread,
May 15, 2013, 6:19:44 PM5/15/13
to clo...@googlegroups.com
I think the answer is in RT 's doInit
Var.pushThreadBindings(
            RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.deref(),
                   WARN_ON_REFLECTION, WARN_ON_REFLECTION.deref()
                    ,RT.UNCHECKED_MATH, RT.UNCHECKED_MATH.deref()));

it basically does a
(binding [*warn-on-reflection* currentvaluehere])
where currentvaluehere is false

so it's like:
(binding [*my-test1* *my-test1*]
  (set! *my-test1* true))

basically set! works because you're not seeing the root binding, you're inside a binding already, at least that's what I'm getting out of it.

Which leads you to the following:
user=> (.start (Thread. (fn [] (do (set! *warn-on-reflection* true) (println "inthread")))))
Exception in thread "Thread-12" java.lang.IllegalStateException: Can't change/establish root binding
 of: *warn-on-reflection* with set
        at clojure.lang.Var.set(Var.java:233)
        at user$eval1176$fn__1177.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Thread.java:722)
nil




Phillip Lord

unread,
May 16, 2013, 6:33:19 AM5/16/13
to clo...@googlegroups.com
"Jim - FooBar();" <jimpi...@gmail.com> writes:
>>> (set!*my-test* true)
>>
>> (alter-var-root #'*my-test* (constantly true))
>
> here explains what you're asking:
> http://clojure.org/Vars
>
> scroll down to until you see


No, this only explains why


(def ^{:dynamic true} *my-test* false)
(set! *my-test* true)

causes an error. What it doesn't explain is why

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

works just fine. Is the REPL running inside a binding? Is it possible to
add other forms of this binding? Or not? And if it is okay to use set!
on *warn-on-reflection*, why is it not okay to allow me, as the library
developer, to define similar properties for my library which work in a
similar way.

Phil

Jim

unread,
May 16, 2013, 6:41:38 AM5/16/13
to clo...@googlegroups.com
You can do (set! *warn-on-reflection* true) because *warn-on-reflection*
is already thread-locally bound...

> Is the REPL running inside a binding?
essentially yes...

> Is it possible to
> add other forms of this binding? Or not?
as Atkaaz pointed out yesterday these vars are in Java code so I'm
presuming you can't...

Jim

ps: I remember seeing a SO post not too long ago about exactly what
you're confused by...a quick look turned this up which is answered by
Chouser:

http://stackoverflow.com/questions/10986293/how-to-set-a-dynamic-var-in-another-namespace

however, this is not the one I remember!

Neale Swinnerton

unread,
May 16, 2013, 6:43:36 AM5/16/13
to clo...@googlegroups.com
On Thu, May 16, 2013 at 11:33 AM, Phillip Lord <philli...@newcastle.ac.uk> wrote:
"Jim - FooBar();" <jimpi...@gmail.com> writes:
causes an error. What it doesn't explain is why

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

works just fine. Is the REPL running inside a binding? Is it possible to
add other forms of this binding? Or not? And if it is okay to use set!

This was discussed here a couple of months ago:


 

Jim

unread,
May 16, 2013, 7:21:15 AM5/16/13
to clo...@googlegroups.com
On 16/05/13 11:33, Phillip Lord wrote:
And if it is okay to use set!
on *warn-on-reflection*, why is it not okay to allow me, as the library
developer, to define similar properties for my library which work in a
similar way.

well, nothing stops you from providing bindings at the main entry point of your library, much in the same way that Clojure does...then consumers can use set! as you expect. That said, I wouldn't go down that road simply because it gives that 'global-state' smell...

Jim

Phillip Lord

unread,
May 16, 2013, 7:45:48 AM5/16/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:

> On 16/05/13 11:33, Phillip Lord wrote:
>> And if it is okay to use set!
>> on*warn-on-reflection*, why is it not okay to allow me, as the library
>> developer, to define similar properties for my library which work in a
>> similar way.
>
> well, nothing stops you from providing bindings at the main entry point of
> your library, much in the same way that Clojure does...then consumers can use
> set! as you expect. That said, I wouldn't go down that road simply because it
> gives that 'global-state' smell...


I don't have a main entry point. And, yes, I want global-state for
exactly the same reason that Clojure does. I have a process that
produces logging output, and I want the user to be able to define
where that output goes. Basically, the same as doing:

(set! *out* some-sensible-value)

but different because I also want to be able to choose between a
GUI output, and text.

So, I guess, my two options are:


(def
^{:dynamic true}
*can-we-change-it* (atom "John"))

(println @*can-we-change-it*)

(reset! *can-we-change-it* "Paul")

(println @*can-we-change-it*)

(binding [*can-we-change-it*
(atom "George")]
(println @*can-we-change-it*))


(println @*can-we-change-it*)



(def
^{:dynamic true}
*can-we-change-this-one* "Mick")

(println *can-we-change-this-one*)

(alter-var-root #'*can-we-change-this-one*
(fn [x] "Keith"))

(println *can-we-change-this-one*)

(binding [*can-we-change-this-one*
"Bill"]
(println *can-we-change-this-one*))

(println *can-we-change-this-one*)



Of which, I think, the former is the best option, although it's going to
break my existing code which uses binding forms.

Phil

AtKaaZ

unread,
May 16, 2013, 7:52:26 AM5/16/13
to clo...@googlegroups.com
why not ref and dosync?



Jim

unread,
May 16, 2013, 7:56:26 AM5/16/13
to clo...@googlegroups.com
On 16/05/13 12:45, Phillip Lord wrote:
> I have a process that
> produces logging output, and I want the user to be able to define
> where that output goes.

or you can define a multi-method or a tiny protocol with 2-3
implementations (for GUI, raw-text or file-output) and let your user
select what he needs and potentially extend the functionality...why does
this have to be a statefull call? dynamic scope should be treated with
care....

Jim

ps: multi-methods allow for :default implementation which sounds to me
like it would suit your needs...

Jim

unread,
May 16, 2013, 8:01:48 AM5/16/13
to clo...@googlegroups.com
On 16/05/13 12:52, AtKaaZ wrote:
> why not ref and dosync?

a bit heavyweight isn't it?

A bit off topic but I remember when Clojure came out, STM was the big
selling point! I've been programming Clojure for more than 3 years now
and I've yet to write code that uses STM but that wasn't intentional...I
just did not need to (slightly ironic I find)... :)

dynamic scope is another story though...I very much intentionally stayed
away from it!

Jim

AtKaaZ

unread,
May 16, 2013, 8:56:44 AM5/16/13
to clo...@googlegroups.com
you're right, I somehow didn't read what he was using it for, just looked at the examples he gave and assumed generic var

In a way I'm in his shoes, but I always assumed that the user would use binding even if that meant encompassing the whole program in it. Like if you wanted to disable asserts  ok bad example since set! works for this too, but I have something like that and I was ok with the idea that the user would use binding around the whole code to set that.
 Maybe I should consider other alternatives... but now I can't think:)


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.

Jim

unread,
May 16, 2013, 9:24:13 AM5/16/13
to clo...@googlegroups.com
On 16/05/13 13:56, AtKaaZ wrote:
> In a way I'm in his shoes, but I always assumed that the user would
> use binding even if that meant encompassing the whole program in it.

personally, I find it rather unpleasant to depend on a lib that forces
me to use 'binding' in such a top-level fashion...Clojure does this
internally to provide convenience knobs for certain static resources
(e.g. *in* & *out*) and for vars that don't really get involved in your
business logic (e.g. *warn-on-reflection* & *unhecked-math*) but I don't
think I've ever seen code that binds these "from top to bottom". *in* &
*out* usually appear in a limited 'binding' expression (2-3 lines) and
*warn-on-reflection* & *unhecked-math* usually appear to be set at the
top of a namespace. For state that your actual logic depends on, people
seem to be in favour of atoms (including myself) or in fact any
reference-type depending on your use-case semantics....It just is more
transparent... :)

that said, I think the OP is not looking for state but for polymorphic
behavior...hence, my previous suggestion.

Jim

Phillip Lord

unread,
May 16, 2013, 10:07:06 AM5/16/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:

> On 16/05/13 12:52, AtKaaZ wrote:
>> why not ref and dosync?
>
> a bit heavyweight isn't it?

Yep, that's the problem. The library in question
(https://github.com/phillord/tawny-owl) is meant to be usable by people
who don't want to know that they are writing clojure.


>
> dynamic scope is another story though...I very much intentionally stayed away
> from it!
>


It's useful, but scary. It mixes with laziness badly, but then, so do
exceptions.

It's nice, though for use in test fixtures....

(defn ontology-reasoner-fixture [tests]
(binding [r/*reasoner-progress-monitor*
r/reasoner-progress-monitor-silent]
(tests)))

for instance. This prevents the code from either poping up a GUI or
generating lots of spam output, which is not good in a test.

Phil

Phillip Lord

unread,
May 16, 2013, 10:10:42 AM5/16/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:

> On 16/05/13 13:56, AtKaaZ wrote:
>> In a way I'm in his shoes, but I always assumed that the user would use
>> binding even if that meant encompassing the whole program in it.
>
> personally, I find it rather unpleasant to depend on a lib that forces me to
> use 'binding' in such a top-level fashion...Clojure does this internally to
> provide convenience knobs for certain static resources (e.g. *in* & *out*) and
> for vars that don't really get involved in your business logic (e.g.
> *warn-on-reflection* & *unhecked-math*)

And having established a clear use case, which appears well motivated
and sensible, Clojure prevents me from providing the same convenience
knobs for my own library; at least in the same way.

Okay, so I can use atoms. My question, why does clojure.core not?

>
> that said, I think the OP is not looking for state but for polymorphic
> behavior...hence, my previous suggestion.
>

Pretty much. Or what you might call "slow" state. The user might want to
switch between the defaults, but the code itself never will.

Phil

Phillip Lord

unread,
May 16, 2013, 10:14:04 AM5/16/13
to clo...@googlegroups.com
And which is the right default to pick? This is the problem. On my big
screen, the GUI is okay. On my netbook, it's a pain. On travis, running
headless, I want /dev/null.

I could use a multi-method, but then it would have to dispatch on the
basis of some thing stateful; back to square one.

I think I have a solution, now, though. Still not convinced that
clojure.core has got this right. But, I can move forward and, thanks to
this discussion, I don't think I have missed anything obvious.

Phil

Jim

unread,
May 16, 2013, 10:31:27 AM5/16/13
to clo...@googlegroups.com
On 16/05/13 15:07, Phillip Lord wrote:
Yep, that's the problem. The library in question
(https://github.com/phillord/tawny-owl) is meant to be usable by people
who don't want to know that they are writing clojure.
Funny that you're writing an ontology lib - my research is increasingly driving me towards using ontologies and therefore I may actually be your first user! (assuming that the lib is still in construction and has no users yet). :-)

It's useful, but scary. It mixes with laziness badly, but then, so do
exceptions.

It's nice, though for use in test fixtures....

(defn ontology-reasoner-fixture [tests]
  (binding [r/*reasoner-progress-monitor*
            r/reasoner-progress-monitor-silent]
    (tests)))

for instance. This prevents the code from either poping up a GUI or
generating lots of spam output, which is not good in a test.
I'd write it like so:

(defn ontology-reasoner-fixture
[tests & {:keys [monitor]
              :or {monitor r/reasoner-progress-monitor-silent}}]
  (tests monitor))) ;;tests fn needs to accept an arg


And having established a clear use case, which appears well motivated
and sensible, Clojure prevents me from providing the same convenience
knobs for my own library; at least in the same way.

Okay, so I can use atoms. My question, why does clojure.core not?

many of these settable vars point to something mutable in the first place (e.g. *in* & *out*). It wouldn't make sense to wrap them in atoms - it would be a waste of semantics. Imagine wrapping an arraylist with an atom...what is the point?


And which is the right default to pick? This is the problem. On my big
screen, the GUI is okay. On my netbook, it's a pain. On travis, running
headless, I want /dev/null.

I can't express any opinions on that I'm afraid...I thought that your 'default' behaviour was clear to you..something like "always use silent monitor unless the user says otherwise". The way you're describing it now it sounds like the ability to specify profiles in leiningen is what you need...since you can't avoid this particular type of 'deployment-specific' state, a config-map wrapped in an  atom would suffice I think.

HTH,

Jim



Phillip Lord

unread,
May 16, 2013, 11:48:53 AM5/16/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:
> On 16/05/13 15:07, Phillip Lord wrote:
>> Yep, that's the problem. The library in question
>> (https://github.com/phillord/tawny-owl) is meant to be usable by people
>> who don't want to know that they are writing clojure.
> Funny that you're writing an ontology lib - my research is increasingly
> driving me towards using ontologies and therefore I may actually be your first
> user! (assuming that the lib is still in construction and has no users yet).
> :-)

I have one main user at the moment, although she is my PhD student; I
claim no coercion.

Give me a shout if your are more interested. I'm more interested in
ontologies than in clojure. Clojure just happened to be a good solution
to the problem I faced with tawny.

>> It's nice, though for use in test fixtures....
>>
>> (defn ontology-reasoner-fixture [tests]
>> (binding [r/*reasoner-progress-monitor*
>> r/reasoner-progress-monitor-silent]
>> (tests)))
>>
>> for instance. This prevents the code from either poping up a GUI or
>> generating lots of spam output, which is not good in a test.
> I'd write it like so:
>
> (defn ontology-reasoner-fixture
> [tests & {:keys [monitor]
> :or {monitor r/reasoner-progress-monitor-silent}}]
> (tests monitor))) ;;tests fn needs to accept an arg
>


I can't. This is use the clojure.test. The fixture gets passed a closure
that runs all the tests. It doesn't take an argument. Even if I could,
it would just pass the problem onward.

If I am doing this:

(r/isuperclass? p/FourCheesePizza p/CheesyPizza)

I really do not want to have pass in the progress monitor, at this
point. Worse, the reasoners are actually created as a side effect, and
this happens lazily. So, it's hard to know when.

All of this is very non-clojurish of course. I am just using it wrapper
around Java with a highly flexible syntax.


>> And having established a clear use case, which appears well motivated
>> and sensible, Clojure prevents me from providing the same convenience
>> knobs for my own library; at least in the same way.
>>
>> Okay, so I can use atoms. My question, why does clojure.core not?
>
> many of these settable vars point to something mutable in the first place
> (e.g. *in* & *out*). It wouldn't make sense to wrap them in atoms - it would
> be a waste of semantics. Imagine wrapping an arraylist with an atom...what is
> the point?


Indeed. Same in my case.


>
>> And which is the right default to pick? This is the problem. On my big
>> screen, the GUI is okay. On my netbook, it's a pain. On travis, running
>> headless, I want /dev/null.
>
> I can't express any opinions on that I'm afraid...I thought that your
> default' behaviour was clear to you..something like "always use silent monitor
> unless the user says otherwise".

Oh, sorry, I just meant that the default is arbitrary. The user needs to
be able to set it up, sometimes at the repl, and sometimes dynamically.

> The way you're describing it now it sounds like the ability to specify
> profiles in leiningen is what you need...since you can't avoid this
> particular type of 'deployment-specific' state, a config-map wrapped
> in an atom would suffice I think.

Hadn't thought about that; will investigate. I need to extend lein
anyway, so I can auto deploy ontologies.

Phil

Jim - FooBar();

unread,
May 16, 2013, 1:53:32 PM5/16/13
to clo...@googlegroups.com
On 16/05/13 16:48, Phillip Lord wrote:
> I have one main user at the moment, although she is my PhD student; I
> claim no coercion.
I am a Ph.D student myself and that's exactly where I will most likely
need ontologies...
Something tells me we're going to be in contact soon :)

> Give me a shout if your are more interested. I'm more interested in
> ontologies than in clojure. Clojure just happened to be a good solution
> to the problem I faced with tawny.
You can count on that! In addition, whenever I find some free time I'd
like to have a look at the lib and familiarise myself with it...and who
knows, I may even have some (humble yet constructive) comments/feedback.
Also, I think you'll find Clojure is a joy to work with in most domains
(my main discipline is NLP but anything that involves
'heavy-data-lifting' is also a good candidate).

> I'd write it like so:
>
> (defn ontology-reasoner-fixture
> [tests & {:keys [monitor]
> :or {monitor r/reasoner-progress-monitor-silent}}]
> (tests monitor))) ;;tests fn needs to accept an arg
>
> I can't. This is use the clojure.test. The fixture gets passed a closure
> that runs all the tests. It doesn't take an argument. Even if I could,
> it would just pass the problem onward.
>
> If I am doing this:
>
> (r/isuperclass? p/FourCheesePizza p/CheesyPizza)
>
> I really do not want to have pass in the progress monitor, at this
> point. Worse, the reasoners are actually created as a side effect, and
> this happens lazily. So, it's hard to know when.

aha! I see what you mean...how about 'with-bindings' then? something
like this should run the tests just fine:

(defn ontology-reasoner-fixture [tests]
(with-bindings {#'r/*reasoner-progress-monitor*
r/reasoner-progress-monitor-silent} tests))

...shorter, same behaviour and as a bonus you're not limited to vars
declared as dynamic. This should work with vanilla 'def' too :)

Jim



Phillip Lord

unread,
May 17, 2013, 6:00:23 AM5/17/13
to clo...@googlegroups.com
"Jim - FooBar();" <jimpi...@gmail.com> writes:
> You can count on that! In addition, whenever I find some free time I'd like to
> have a look at the lib and familiarise myself with it...and who knows, I may
> even have some (humble yet constructive) comments/feedback. Also, I think
> you'll find Clojure is a joy to work with in most domains (my main discipline
> is NLP but anything that involves 'heavy-data-lifting' is also a good
> candidate).


It's a nice language, I think. It inherits however the some of the
nastiness of Java, in particular it doesn't integrate at all into the
OS; the makes it not a good fit for little scripting, one-off jobs which
form the basis of a lot of scientific computing.


> aha! I see what you mean...how about 'with-bindings' then? something like this
> should run the tests just fine:
>
> (defn ontology-reasoner-fixture [tests]
> (with-bindings {#'r/*reasoner-progress-monitor*
> r/reasoner-progress-monitor-silent} tests))
>
> ...shorter, same behaviour and as a bonus you're not limited to vars declared
> as dynamic. This should work with vanilla 'def' too :)

Which gives me the dynamic scoped behaviour, but not the global
resetting behaviour.

Phil

Jim

unread,
May 17, 2013, 11:02:14 AM5/17/13
to clo...@googlegroups.com
On 17/05/13 11:00, Phillip Lord wrote:
> It's a nice language, I think. It inherits however the some of the
> nastiness of Java, in particular it doesn't integrate at all into the
> OS; the makes it not a good fit for little scripting, one-off jobs which
> form the basis of a lot of scientific computing.


aaa yes indeed...the jvm is indeed very heavy-weight for such scripting
tasks...on the other hand have you looked at clojure-py? I'm not
up-to-date with its current state/features but it should be viable for
little scripting jobs... :)
> Which gives me the dynamic scoped behaviour, but not the global
> resetting behaviour.
well, the thing is that Clojure in general is not well suited for
imperative style code. There are some constructs that make it easier
(e.g. with-local-vars), but for the most part you are expected to follow
the 'functional-transformation' route instead of the
'imperative-mutation' one...If you absolutely need the global resettable
behaviour I can only suggest an atom. Then, when you want to use that in
tests, a little try-finally macro which swaps the atom and resets it in
the finally clause would simulate your dynamic scope. I quickly wrote
the following but I get an exception which I don't have the time to sort
at the moment...maybe later this evening... :)

(defmacro abinding [bs & body]
(let [pairs (partition 2 bs) ;;partition the bindings
old-values (map (comp deref first) pairs) ;;save the original
values
_ (doseq [[b v] pairs] (reset! b v)) ;;introduce the new values
restore (fn [] (map #(reset! (first %1) %2) pairs
old-values))] ;;define the restoring fn
`(try
~@body
(finally (restore))) ))

Jim

Phillip Lord

unread,
May 17, 2013, 11:49:54 AM5/17/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:

> On 17/05/13 11:00, Phillip Lord wrote:
>> It's a nice language, I think. It inherits however the some of the
>> nastiness of Java, in particular it doesn't integrate at all into the
>> OS; the makes it not a good fit for little scripting, one-off jobs which
>> form the basis of a lot of scientific computing.
>
>
> aaa yes indeed...the jvm is indeed very heavy-weight for such scripting
> tasks...on the other hand have you looked at clojure-py? I'm not up-to-date
> with its current state/features but it should be viable for little scripting
> jobs... :)


Well, I an proficient in python, so it's probably easier just to use
python. Even if the documentation sucks.


>> Which gives me the dynamic scoped behaviour, but not the global
>> resetting behaviour.
> I quickly wrote the following but I get an exception which I
> don't have the time to sort at the moment...maybe later this evening... :)


It's okay! I have a workable solution now, even if it still seems a
little unfair that I cannot take the same approach that clojure.core
does under the same circumstances!

Phil

atkaaz

unread,
May 21, 2013, 10:08:39 AM5/21/13
to clo...@googlegroups.com
The following idea came to me in the shower, sort of out of the blue, and I don't know why I didn't think of it before(I'm disappointed with myself) so, why not use the same thing as clojure does? even though it does it in java, you can do it in clojure, the only thing is that you have to do it once, probably where you define the var, such as(well unfortunately it doesn't work O_o maybe someone can explain?):
(I was gonna try java interop but I notice there's clojure.core/push-thread-bindings)

=> (def ^:dynamic *test4* false)
#'cgws.notcore/*test4*
=> (push-thread-bindings {#'*test4* true})
nil
=> *test4*
false
=> (pop-thread-bindings)
nil
=> *test4*
false

=> (def ^:dynamic a 1)
#'cgws.notcore/a
=> (push-thread-bindings {#'a 2})
nil
=> a
1
=> (set! a 3)
IllegalStateException Can't change/establish root binding of: a with set  clojure.lang.Var.set (Var.java:233)

(defn push-thread-bindings
  "WARNING: This is a low-level function. Prefer high-level macros like
  binding where ever possible.

  Takes a map of Var/value pairs. Binds each Var to the associated value for
  the current thread. Each call *MUST* be accompanied by a matching call to
  pop-thread-bindings wrapped in a try-finally!
 
      (push-thread-bindings bindings)
      (try
        ...
        (finally
          (pop-thread-bindings)))"
  {:added "1.1"
   :static true}
  [bindings]
  (clojure.lang.Var/pushThreadBindings bindings))
nil

=> *clojure-version*
{:interim true, :major 1, :minor 6, :incremental 0, :qualifier "master"}


so if this worked as I expected then the following two statements would be in the same place:
=> (def ^:dynamic *test1*)
#'cgws.notcore/*test1*
=> (push-thread-bindings {#'test1 "default value here"})
nil

;and the third could be anywhere (in current thread, 'cause just as clojure's *warn-on-reflection* when on a different thread you still can't set! it)
=> (set! test1 "user value")
IllegalStateException Can't change/establish root binding of: test1 with set  clojure.lang.Var.set (Var.java:233)

So, is push-thread-bindings broken(unlikely) or am I missing something(most certainly so) ?



Phillip Lord

unread,
May 22, 2013, 5:33:06 AM5/22/13
to clo...@googlegroups.com

Ah, okay, I see the idea. I'm not sure why it doesn't work.

For now, I think, using an atom and reset! seems to do the job!

Phil

atkaaz <atk...@gmail.com> writes:

> The following idea came to me in the shower, sort of out of the blue, and I
> don't know why I didn't think of it before(I'm disappointed with myself)
> so, why not use the same thing as clojure does? even though it does it in
> java, you can do it in clojure, the only thing is that you have to do it
> once, probably where you define the var, such as(well unfortunately it
> doesn't work O_o maybe someone can explain?):
> (I was gonna try java interop but I notice there's *
> clojure.core/push-thread-bindings*)
>
> =>* (def ^:dynamic *test4* false)*
> #'cgws.notcore/*test4*
> => *(push-thread-bindings {#'*test4* true})*
> nil
> => **test4**
> *false*
> => (pop-thread-bindings)
> nil
> => *test4*
> false
>
> => (def ^:dynamic a 1)
> #'cgws.notcore/a
> => (push-thread-bindings {#'a 2})
> nil
> => a
> 1
> => (set! a 3)
> IllegalStateException Can't change/establish root binding of: a with set
> clojure.lang.Var.set (Var.java:233)
>
> (defn *push-thread-bindings*
> "WARNING: This is a low-level function. Prefer high-level macros like
> binding where ever possible.
>
> Takes a map of Var/value pairs. Binds each Var to the associated value for
> the current thread. Each call *MUST* be accompanied by a matching call to
> pop-thread-bindings wrapped in a try-finally!
>
> (push-thread-bindings bindings)
> (try
> ...
> (finally
> (pop-thread-bindings)))"
> {:added "1.1"
> :static true}
> [bindings]
> (clojure.lang.Var/pushThreadBindings bindings))
> nil
>
> =>* *clojure-version**
> {:interim true, :major 1, :minor* 6*, :incremental 0, :qualifier "master"}
>
>
> so if this worked as I expected then the following two statements would be
> in the same place:
> => (def ^:dynamic *test1*)
> #'cgws.notcore/*test1*
> => (push-thread-bindings {#'test1 "default value here"})
> nil
>
> ;and the third could be anywhere (in current thread, 'cause just as
> clojure's *warn-on-reflection* when on a different thread you still can't
> set! it)
> => (set! test1 "user value")
> IllegalStateException Can't change/establish root binding of: test1 with
> set clojure.lang.Var.set (Var.java:233)
>
> *So, is **push-thread-bindings broken(unlikely) or am I missing
> something(most certainly so) ?*
> --

--
Phillip Lord, Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: philli...@newcastle.ac.uk
School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower, skype: russet_apples
Newcastle University, twitter: phillord
NE1 7RU
Reply all
Reply to author
Forward
0 new messages