Re: Conceptual difference between map and class

2020-04-05 Thread James Gatannah
"A language that doesn't affect the way you think about programming is
not worth knowing." - Alan Perlis

A lot  clojure's culture and philosophy is centered around Rich's talks.

I resisted this for a very long time. I'd rather spend 10 hours
reading a book than 1 hour watching someone speak. I was wrong.

Joy of Clojure is really a...well, maybe not an "advanced" clojure
book. But it also definitely isn't a beginner's introduction.

I've gotten rave reviews from very senior programmers about "Clojure
for the Brave and True." Its whimsical style isn't for people who just
want to dive into the nuts and bolts, but those people are almost
definitely going to miss the bigger picture.

Personally, I wound up loving clojure from the perspective of a python
programmer. I got to python from c++ because I got fed up with all the
stupid boiler plate code and time I wasted waiting on the compiler.

>From there, I ran across enough people raving about common lisp to
convince me to read http://www.gigamonkeys.com/book/

I spent a couple of years trying to do anything worthwhile with common
lisp in my spare time.

I kept hitting limitations in the C library layers. x can't work in
64-bit Windows. Y cannot compile on Thursdays. That sort of thing.

I really, really wanted to turn that into my goto, every day,
"my-time" programming language.

And I just couldn't.

The support base of people who are using it just is not broad enough.

This is why clojure's decision to embrace the "hosted platform" thing
is brilliant. Clojure on the JVM has access to anything that java can
get to. ClojureScript has the potential to be even broader, since
javascript.

I still treasure fantasies of going back to common lisp. But, really,
clojure has a better answer to a lot of modern computing problems.

When I ran across clojure for the first time (because people I
respected convinced me to look at it, even though I thought I knew
that common lisp must be better), I hated it. This was way before
lein, so you had to deal with all the baseline java stupidity to build
your CLASSPATH. And the way it manages state seemed idiotic. I was a
seasoned C programmer who thought I knew how to handle all the issues
that came with multi-threading.

I was wrong.

It gets more complicated. Things like AWS lambdas push back on the
problems that clojure solves.

In a lot of ways, they force you to do the same things that clojure
does naturally, because they're stateless. And they're a poor fit for
clojure because its startup time still isn't great.

This is all me rambling. I'm sorry.

Is clojure a good language for you to learn now?

Well, that depends on where you are and what you already know.

I work with a bunch of people who went through the same programming
101 course. It forced them to learn things like Haskell and Clojure,
because the professor is a technical programming weanie.

I feel sad for these people and have to fight against them constantly
because there is no way for them to appreciate what you get from a
functional programming paradigm until you've dug the trenches and seen
1st-hand just how awful the alternatives are.

I don't know where you are in your life/career, so I don't have any
justification for offering this opinion. I'm going to anyway.

 I think that may be the litmus test for your question: have you hit
the point where you think "there must be a better way to do this?"

It never hurts to learn a new language. That's always a good idea.
But, if you're still content with what you can do with python, then I
advise you to keep working in python. Just keep clojure in mind the
next time you hit an "OMFG! How did this bug escape into production?!"
moment.

It isn't a trivial transition. But it's almost guaranteed that
translating your web server from python to clojure will make it more
stable.

Clojurescript is awesome, but (in this scenario), it's also just icing.


On Sat, Apr 4, 2020 at 12:24 AM Dieter Van Eessen
 wrote:
>
> Thanks, I'm currently reading the book you mentioned (Joy of Clojure). Just 
> started on 'Types, protocols and records'...
> Still doubting if I should continue learning clojure. From my point of view, 
> the only major advantages of the language so far, are 'clojurescript' and the 
> idea that I can evaluate stuff that I've 'printed' (data is code is data).
> Other than that, they are messing with my head by redefining existing 
> abstraction and making them 'almost equal but slightly different'.
>
> kind regards,
> Dieter
>
> On Wednesday, April 1, 2020 at 6:44:07 AM UTC+2, James Gatannah wrote:
>>
>> It might be worth mentioning that, ultimately, python class instances are 
>> syntactical sugar built around an internal __dict__. It gets twistier, since 
>> classes are also instances of the base class object.
>>
>> It would be tricky (though I've seen an example...maybe in Joy of Clojure? I 
>> think the author's conclusion was that it was an interesting experiment, but 
>> not worth doing in practice) to 

Re: Conceptual difference between map and class

2020-04-05 Thread Ernesto Garcia
In my humble opinion, main benefits of Clojure:

- Development cycle: modifying and experimenting on a running program.

- Treating data as maps. Direct and efficient immutability.

- Macros: Though used very scarcely, it's good to know that you'll be able 
to extend the language from within if you need to.


> redefining existing abstraction and making them 'almost equal but 
slightly different'.

What do you mean here? Clojure, and practical languages in general, do not 
define new ways, they usually select what is considered more appropriate.


On Saturday, April 4, 2020 at 7:24:17 AM UTC+2, Dieter Van Eessen wrote:
>
> Thanks, I'm currently reading the book you mentioned (Joy of Clojure). 
> Just started on 'Types, protocols and records'...
> Still doubting if I should continue learning clojure. From my point of 
> view, the only major advantages of the language so far, are 'clojurescript' 
> and the idea that I can evaluate stuff that I've 'printed' (data is code is 
> data).
> Other than that, they are messing with my head by redefining existing 
> abstraction and making them 'almost equal but slightly different'.
>
> kind regards,
> Dieter
>
> On Wednesday, April 1, 2020 at 6:44:07 AM UTC+2, James Gatannah wrote:
>>
>> It might be worth mentioning that, ultimately, python class instances are 
>> syntactical sugar built around an internal __dict__. It gets twistier, 
>> since classes are also instances of the base class object.
>>
>> It would be tricky (though I've seen an example...maybe in Joy of 
>> Clojure? I think the author's conclusion was that it was an interesting 
>> experiment, but not worth doing in practice) to implement inheritance using 
>> clojure maps.
>>
>> For me, the conceptual difference has been that it's better to just write 
>> functions that work on simple data structures, rather than tying a few 
>> together into a unit that only work on a single data structure (plus its 
>> derived classes). Clojure's emphasis on functional purity is another major 
>> piece of this puzzle.
>>
>> Unit testing is one thing that becomes much easier with this approach.
>>
>> I deal with a ton of python code that has tests built around dozens of 
>> mock objects mimicking things like database records from an ORM. And then 
>> we mock out a few low-level HTTP calls in base classes so the class 
>> instances we're trying to test in isolation don't break when we run the 
>> tests with no web server to call. Then someone refactors the code, and all 
>> the tests break because they're tied to a specific package/module structure.
>>
>> By contrast, if you have your business logic in one set of pure 
>> functions, and you keep your side-effecting parts well isolated on the 
>> fringes of your system, you don't need any of that. Just call the business 
>> logic function with appropriate values and double-check the results.
>>
>> You absolutely can write python code that way. But your pythonic 
>> colleagues will hate you for it.
>>
>> Hope that helps,
>> James
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/2b0636c3-0b86-43a0-a1d9-955bc82f2076%40googlegroups.com.