Fork me on GitHub
#off-topic
<
2022-09-15
>
didibus01:09:43

Doing greenfield Java again after doing lots of Clojure, and it's transformed how I write Java code. I'm a Java streams master now, haven't used a single for-loop yet 😂

🎉 8
seancorfield02:09:23

When Java 8 came out, there were a lot of new things in it that made me think that maybe, if I was forced to do Java again, I might keep my sanity on a completely greenfield project...

Daniel Craig02:09:37

Java 17 adds record types, which are rad. also kind of clojure-y

seancorfield03:09:33

Just reading about that... seems they were in 14 as a preview feature and became standard in 16. Nice. Switch expressions is also a nice addition (14). Text blocks (15) -- wish Clojure had that 🙂 var type (10, 11) so you don't have to specify types 🙂 It'll be interesting to see when pattern matching for switch moves from preview (17) to standard.

didibus03:09:29

Making extensive use of var as well, but still, so much visual noise left from so many @NotNull public final Type myType definitions everywhere haha

didibus03:09:50

A method that takes 3 arguments cannot fit a single 140 character line because of it

didibus03:09:41

Also, var doesn't work with Generic<>, so for app generics you're still having to define the generic either on the left or the right side of assignment.

didibus03:09:30

Record is not as cool as I thought, but I'm still using it a lot, it's nice for returning more than one type of thing, you can quickly create a record and return things wrapped into it.

didibus03:09:56

What I would like is for classes to get the concept of metadata. If by default all fields participated in the class equality, and if you didn't want a field to do so, you would mark it as metadata. Because I still find it's hard to go full immutable, returning deep copies of things all the time seems inefficient to me for some reason. I don't know, maybe I should try it one time, replace all usage of class with records instead that have methkds that return a copy of the record.

Martynas Maciulevičius06:09:48

Did you write everything in static (classes, methods and so on)? 😄 I remember that I did that for one interview 😄 I had the main (it used spring) mutable class that had reference to the current value and all other classes were static. I also used a PersistentMap that I found in some library but it didn't have a transient version. Did you also use something like this?

borkdude08:09:45

Object all the way ;)

👍 1
didibus23:09:49

I've also been using Object a lot more haha, the idea of a List that can only contain one type sounds ridiculous to me and so limiting now. Since Java has no union type, you gotta go Object! Haha, I've always been tempted to go static only, especially now with Java 17, static only + Records. but I'm also on a team of Java devs, in a mostly Java company, so I need to introduce things that can fool them all, if it looks too contrary to their Martin Fowler articles they are used too, they'll object too strongly and I won't be able to sneak it in 😛

Martynas Maciulevičius05:09:51

I remember my Java lecturer saying "don't use static", but he never said why 😄 oh well 😄

didibus17:09:48

Well, the biggest issue with static in Java is that they're not first class functions. So you can't pass them around. Also, they can't be mocked easily, which gets annoying in your tests. Another more subtle issue is, when all the data is mutable, it really is dangerous to modify it without proper encapsulation. And working with fully, deeply nested immutable data in Java still isn't easy at all, even now with Records.

Martynas Maciulevičius18:09:06

I think I was able to pass around static methods just fine :thinking_face: I don't remember that it was a problem :thinking_face: Maybe I just missed it

didibus18:09:30

Hum, ya I tried, you're right, you can do Static::method and it works. I guess tests and immutability is what's missing. If there was good deeply immutable support, I think it could be a nice way to write java, immutable state + statics everywhere. You can also technically use PowerMock to mock statics, so I guess that can solve the test issue,

Martynas Maciulevičius18:09:36

You can do immutability by using a library that implements persistent data structures

didibus18:09:11

Ya, but then its type-less, I think you need a deep-immutable record in Java to make it "acceptable" to java devs

didibus18:09:08

I might be ok going PersistentMap<Object, Object>, but it won't fly with others 😛

didibus18:09:33

Also, at that point, might as well use Clojure 😛

didibus18:09:24

I guess if you just define records of records, the problem is there is no update-in and company.

Martynas Maciulevičius18:09:38

You can do private final MyImmutableMap just fine 😄 Also appeal to Java devs wasn't ever an issue. It's still Java after all 😄

didibus18:09:44

Maybe there is a monad lib you could also use alongside records :thinking_face:, to get lenses and all that

didibus18:09:52

Ok, and what would you use for Spec?

Martynas Maciulevičius18:09:49

I would do immutable java records and use immutable data structures in place of regular ones. I think this is a good balance. Then use typesystem for spec.

Martynas Maciulevičius18:09:11

But yes. Then we're giving up DSLs, Homoiconicity...

didibus18:09:05

You can't use the type system for spec over the immutable data structures

isak14:09:43

Just saw this open source Figma alternative - it is written in Clojure/ClojureScript: https://github.com/penpot/penpot

👍 4
didibus23:09:26

I think its from the some of the same people releasing libs under the funcool github repo as well.

1
John Brown18:09:26

How come everyone is sleeping on Clojure? This is the greatest solution to Java's pain points I have seen, development teams are shooting themselves in the foot by not transitioning over. An argument against Clojure is the learning curve, but I think this is a weak argument... our jobs as software engineers involve embracing so many different skillsets and keeping up with the evolution of these skills. Object oriented programming is a huge mess and incredibly complected. Clojure codebases use a fraction of the amount of code and separate the data and the code. It's just common sense. So why is the industry so resistant to change? So many java developers talk about never going back to java once they are introduced to clojure. Why does this fact alone not carry any weight? Why are development teams against increased productivity? Oh why oh why?

💯 2
Ben Sless18:09:05

because people

😄 4
😆 2
maleghast18:09:25

This ^^ and also the Orthodoxy Fallacy which states that non-technical people are right when they insist that only technologies they have heard of should be used in the businesses that they run.

👌 3
pavlosmelissinos19:09:30

This year's reClojure has "Clojure growth" as a theme, might have some answers/solution. http://www.reclojure.org

Daniel Craig19:09:23

Because the story around installing Clojure on windows is not very good

☝️ 1
Daniel Craig19:09:59

Just my 2 cents

maleghast19:09:41

@U042622QS30 - I don't entirely disagree, but I develop on Windows with WSL2 for work and it's pretty seamless.

maleghast19:09:02

I can use Emacs + CIDER and the whole thing "just works"

maleghast19:09:34

My personal machine is Arch Linux on the metal, but I would not rule out Windows now that there is WSL 2

Omar19:09:54

I do most my work in WSL2 as opposed to my Macbook and it's perfect.

seancorfield20:09:51

After 30 years as an Apple customer, I've switched both my laptop and desktop to Windows/WSL2 (Ubuntu) recently. It's a really good experience -- and all the (Clojure) tutorials out there are written for macOS/Linux so everything "just works" this way.

seancorfield20:09:48

As for the OP's question, inertia is what keeps a lot of organizations on their current path: Java is wildly "popular" and the hiring pool is absolutely enormous, and many large corporations treat developers as fungible so they want average people that they can just swap in and out across projects. All other JVM languages are in a tiny minority compared to Java. We've also seen companies try Scala and fail and go back to Java so those companies are going to be even more wary of a true "fringe" tech like Clojure.

👆 1
seancorfield20:09:48

As for software engineers embracing "so many different skillsets"... as someone who has attended plenty of Java conferences over the decades (I first started using Java in '97 after years of C++), I've sat and listened to a lot of devs talk about their work environment -- and many of them are only at the conferences because either a) they view it as a "perk" so they can escape the office for a few days or b) their company "forced" them to attend. Neither of those categories really care about the content at those conferences. They like their nice, safe 9-to-5 jobs that aren't too demanding and they can be a cog in a large machine and basically have management ignore them.

seancorfield20:09:08

(and, yes, being in this industry since the very early '80s has made me pretty cynical... 🙂 )

😄 5
Martynas Maciulevičius20:09:00

I've heard about a bank that uses Clojure and Datomic too but now tries to rewrite something in Java because their data doesn't fit into memory (won't name them). I haven't had much details on this but there is a bank that does this. I know a guy who works there. I could ask some questions. Maybe he meant that they want to split the system and not rewrite it. I don't remember fully.

Ben Lieberman20:09:17

I have no substantive industry experience but this subject interests me. Why do you suppose companies that test out other JVM languages fail and go back to Java? Do they attempt full-scale rewrites into Scala or Kotlin (etc)? It seems to me one thing for a company with a huge C++ codebase to say "alright we are using Rust or Go now" and then experience catastrophe when they combine learning said language with the rewrite; another thing entirely to do little drop-in replacements of code that is running in the same environment and is fully interoperable

Annaia Danvers20:09:52

A significant factor in the mass adoption of Java that is often underestimated is that Oracle spends a shitload of money pushing Java teaching materials into schools and universities, which means that almost every student now comes out of CS knowing Java ... which means there is every year a fresh batch of cheap juniors to grind through the enterprise mills. I have genuinely seen Clojure lose out to other languages on client projects simply because the perception is that Clojure will be too expensive to maintain, because Clojure developers expect more of a salary than a junior or intern fresh out of school.

2
☝️ 4
1
Annaia Danvers20:09:35

Convincing bosses isn't the only problem, you gotta convince schools, and that's even harder.

seancorfield21:09:50

@U03QBKTVA0N My experience at Java conferences, talking to rank and file enterprise developers, is that they just aren't very good developers but the enterprise environment doesn't need them to be -- but those devs are going to struggle with Scala (I used Scala for a couple of years and went to a lot of local conferences and user groups for that too, so I ran into some wide-eyed Java devs from enterprise-land that had been sent there to see what all the "better Java" fuss was about). I spoke to one Java dev at a Scala event who worked at a bank (and they were considering moving some of their work to Scala), and she said the conference had given her a really bad impression of Scala because of the very academic talks and the attitude of several Scala devs.

💯 2
seancorfield21:09:37

People who choose Clojure kind of self-select, in terms of being the type of developer who does want to learn new stuff and wants to keep on improving. People who want something substantially better than Java's level of expressiveness. Clojure's never going to be mainstream. It'll continue to grow (slowly) as the overall developer "pie" grows but I think it will support a healthy (but small) ecosystem for many years to come.

💯 7
Martynas Maciulevičius21:09:52

Or maybe we're just running away from problems. Maybe we're actually weak 😄 Maybe we couldn't fix the situation so we became cowards... 😄

Daniel Craig21:09:26

Thanks for the WSL2 advice above, that's given me something to think about.

seancorfield21:09:37

"I'll just go and hide in my Clojure safe space and hope the nasty ol' IT industry leaves me alone!" :rolling_on_the_floor_laughing:

❤️ 7
respatialized21:09:55

https://apstudents.collegeboard.org/courses/ap-computer-science-a A coordinated effort to get a pedagogically superior language to Java in high schools would be extremely worthwhile, but I would not recommend Clojure for the job. Racket has had more effort put into its educational resources - How to Design Programs is an ideal high school level CS textbook IMO. You'd get to recursion way faster than 10 modules in!

👆 2
seancorfield21:09:21

@USDPTD3FY If you have any Qs about a Windows/WSL2 dev setup, feel free to DM me. I've set it up a few times now and it's my "daily driver" for work (140k lines of Clojure, with nearly 100 Polylith components, producing about two dozen deployable apps).

Daniel Craig21:09:30

I'm teaching Clojure at BYU Idaho currently and so far it's going pretty well. They're excited to learn how to 'jack in' as opposed to running clj in powershell. It's still just week 1 of the course

seancorfield21:09:59

Nice! I'd heard about BYU teaching Clojure -- is this the first year of it?

Daniel Craig21:09:34

I think it's been maybe 2 years now? I graduated in 2019 and at that time we were still using emacs lisp at BYU Idaho

Daniel Craig21:09:01

but I knew that the changes were coming for those that were in later graduating classes

Daniel Craig21:09:47

For what it's worth, BYU Idaho teaches 2 classes in clojure, and none in Java.. Bold move 🙂

1
👍 2
1
seancorfield21:09:59

That's awesome!

Jacob Rosenzweig21:09:52

People are addicted to ALGOL syntax and I don’t know why.

Jacob Rosenzweig21:09:13

also types, the programming community really loves static typing atm.

Gabriel Kovacs21:09:20

@USDPTD3FY is the course material public?

Daniel Craig21:09:37

You can read the course materials at the github site where it's hosted. I'm not the author but I'd be pleased to see what you think, constructive feedback welcome. EDIT: I took the link down because someone vandalized a github wiki that was part of the course instructions with urls that appear to be malicious.

🙌 1
didibus00:09:14

Ya, WSL2 is the way to go for dev work on Windows. But Clojure can also be super easily installed using Borkdudes bb based replacement for Clojure's CLI bash script: https://github.com/borkdude/deps.clj Basically, just run this command: PowerShell -Command "iwr -useb | iex" And you have Clojure installed (assuming you have Java installed already) Only difference is the command line is called deps.exe instead of clojure . That's so that it doesn't interfere if you also want to have the standard powershell CLI

didibus00:09:46

I think the truth is, most developers are below average, and most teams optimize for the least common denominator. That's why its always the "easy" or "full of guard rails" languages that become mainstream. Even the way most team grow, good developers are not tasked with being in charge of writing or maintaining more and more of the code, generally as developers get better they become tasked with reviewing more and more of the code written by more junior or worse developers. That means most of the actual code is written by below average devs almost all the time, either because they are junior (so below average in terms of the full experience band), or they are simply not good enough which is why they are only trusted with writing code, and not with any mentoring, decision making, design or processes.

didibus00:09:35

Java is easy because of IntelliJ Idea and Eclipse IDE, and of just how many books, tutorials, stackoverflow, training programs, and school using it there is. It strikes a balance between guard rails with the static typing, but also not too complex type system.

didibus00:09:02

I think for Clojure, the lack of guard rails is a challenge for sure. That's why the not too powerful static typing languages are most popular, because they optimize for enough types to make it easier, not too much that it makes it hard (like Scala or Haskell). But I think a big issue with Clojure as well is the lack of maturity in some way. In Java, you don't need to know what you are doing, you can just Google copy/paste everything. Even all the OO patterns and enterprise patterns, they're all there already, a google away, and you get shown some code to copy/paste and then bash in-place a little until it works for you. I think this is something Clojure lacks a lot off, you can't survive on Googling alone, you have to know what you are doing and how things works. And with Clojure, we haven't had all the debates yet, for everything. There's still many ways to do things, we haven't hammered things down to the point where for each problem you have, a quick google will show the established, used everywhere, talked about in all the books, mentioned the same in all the articles, solution for. Java development is super frameworky as well, which is similar, people just copy/paste. From one Spring Boot app to another, copy/paste, no idea what all these beans do, just copy/paste. Copy existing code structure, patterns, do it all the same. Pretty bad library even just become defacto, Jackson has an atrocious API, but its just what it is, no one cares, they copy/paste how to use it from one project to another 😛. What that means is, the good developers who know what they are doing, they provide the initial code structure and frameworks, and than 90% of all other Java dev just copy/paste from that and leverage those frameworks.

didibus00:09:25

Oh, and there's one more thing I've observed. This remind me of how in the old days, scribes were paid by the letter, so they made words longer or have double letters just to be paid more. In a lot of languages, you will be writing a lot of code that actually makes zero progress towards the task at hand, like the actual behavior you want you've barely progressed on it, and yet you spent all day doing things, coding, setting things up, etc. Like in Java, you spend half your time just writing class definitions, interfaces, annotations, overriding dumb things like toString, setter/getters that don't do anything, etc. This actually make most developer feel very productive. It's like actively spinning your wheels, but at standup it looks like great progress and ton of work you did, look at the size of your PR! It's also weirdly satisfying, like eating candy, you get the reward but no real nutrients. This leads to things like you get a PR where some engineer added final to every variable. And they feel so smart about it, so proud, like this makes them the best engineer on the team, they think they deserve a promotion, I mean, they added final to all variable, that is the best of all best practices, can't achieve anything better, what accomplishment! 🤌 Everyone buys into this cool-aid though, so its a self-fulfilling prophecy. I don't know how many managers I had to fight to tell them that progress is measured by how much is left to do and not by how much work was done. But the truth is, even execs, if you show them, look, devs are working 10hours a day, look at all this code, all these changes, we're working really hard! It just takes a long time, so we have to push the deadline 😛 Well its convincing, what can then say, they see a lot of work being done, can't really ask for more. Working smart on the other hand can appear to not be working at all, spending the day thinking in the hammock, people think you're taking a break, it makes exec worried, if the deadline is missed, they'll say you didn't work enough 😛

andy.fingerhut02:09:20

I'm probably out of it, but what does "sleeping on X" mean?

Ben Lieberman03:09:39

@U0CMVHBL2 being unaware of something

Martynas Maciulevičius05:09:16

There are two meanings: 1. ignore, fail to appreciate 2. take time to consider https://idioms.thefreedictionary.com/sleep+on+something

Wanja Hentze06:09:17

@U03QBKTVA0N > It seems to me one thing for a company with a huge C++ codebase to say "alright we are using Rust or Go now" and then experience catastrophe when they combine learning said language with the rewrite; another thing entirely to do little drop-in replacements of code that is running in the same environment and is fully interoperable At the risk of veering into off-topic, I'll quickly remark that Rust and Go are quite different here: Rust inherits the environment of C++ and C, and its arguable raison d'être (replacing pieces of Firefox) was to be used interoperably within a C++ project. Go on the other hand loudly rejects the C environment and does away with exactly all of it. Not even the C stack is used. It's pretty unique in its position as a new language that invents a genuinely new environment. As a consequence however, interfacing with C (e.g. via cgo) is painful and inefficient.

Ben Sless08:09:55

It's also worth remembering some have not so fond memories from school when they were forced to use scheme There's also no hype (rust), crazy backing (java, go), or ubiquitous app to spark interest (go)

agile_geek08:09:00

With regards to @U04V70XH6's comment: > Clojure's never going to be mainstream. It'll continue to grow (slowly) I think he's correct but I'd go further and say we might be in danger of losing the cultural aspects of Clojure that make it what it is if we had sudden mass adoption.

Wanja Hentze09:09:39

I have not-so-fond memories from school when I was forced to use Java :D

Wanja Hentze09:09:31

they were painful enough that I never went into JVM stuff to begin with, so I also didn't run into Clojure (or Scala, Kotlin etc. for that matter) for a long time

Martynas Maciulevičius09:09:48

I think a person can get painful memories if they're forced into anything. Even Clojure. And that's the interesting part about it -- if we would be finding Java after C/C++ and nobody would be forcing anybody then we may think the same about Java or the same about Go/Rust.

Daniel Tan14:09:13

Usually boils down to a few things that pushes people away: 1. Lisp (Unfamiliar syntax = perceived time cost to learn) 2. Types (No types = omg what about X types of errors) 3. Java (Ew, java is bad so clojure must be bad)

👆 3
respatialized15:09:03

I wish the thread author hadn't deleted the original post for things like this; it destroys the primary context for a long discussion and makes it confusing for readers coming across it later.

😞 4
pavlosmelissinos16:09:17

For what is worth it was (and I'm obviously paraphrasing here) about Clojure's reach and why people insist on using more complicated languages like Java when there's Clojure ("why are people sleeping on Clojure?" was one of the questions pondered in the OP)

borkdude16:09:30

A small correction: https://clojurians.slack.com/archives/C03RZGPG3/p1663286594237199?thread_ts=1663266266.061059&amp;cid=C03RZGPG3 deps.clj doesn't use bb, but bb does use deps.clj. If you have bb installed, you can run Clojure with:

bb clojure
and this uses deps.clj. Also bb uses deps.clj to fetch bb deps

👍 1
seancorfield17:09:31

Thanks @UEQPKG7HQ -- that way we don't lose context for this (interesting) discussion. Not sure why @U042622QS30 deleted the OP.

🙂 1
Martynas Maciulevičius18:09:30

In that case it's weird that you have a photo of yourself and you also revealed your name. And then didn't use a burner account... There is no moderation who can join these channels so burner accounts should be fine to use here. Edit: It's enough to have 16x16 picture of a face to identify a person

Martynas Maciulevičius18:09:45

So use a burner account to ask

Martynas Maciulevičius18:09:11

Disclaimer: I'm not a moderator and I don't know if this kind of accounts are what the admins would suggest. It's not good when people remove messages. Then the whole thread gets fully derailed. We should all create burner accounts and anon squirrel will chat with anon plane... Maybe we should have a matrix chat server for this purpose?

seancorfield20:09:14

@U028ART884X Did I miss some post in this thread that was since deleted, that prompted you to make those comments about a "burner account"?

Martynas Maciulevičius05:09:28

Yes. OP posted several messages where he mentioned that he didn't like his identity scattered around in questions so that he "wouldn't discredit his account with 'silly' questions and comments". So I suggested to not use his primary account if he doesn't like that. And then he deleted the messages 5 minutes later. Maybe that means that slack channel backup could somehow be anonymized. This would increase confidence but at the same time it would still allow moderation. Because if we (even partially) move to matrix chat then I think identities would be easy to spoof and therefore moderation wouldn't be able to be happening well. And this would fracture the effort (we also have Zulip and maybe other means too).

Martynas Maciulevičius07:09:28

I've read in a book that generally when a person allows himself to dress-up colorfully (i.e. not suit&tie etc) then arguments with reputable people (the ones with suits&ties) carry the person "up" -- bring value (at expense of the reputation of the suit&tie person). This is not true in all occasions but mostly it's true. And when this suit&tie person tries to protect his reputation and worries about it then it's possible that he may lose it even more because he's in some local maximum state that is not sustainable. And those that don't worry about their reputation somehow still keep their reputation and it somehow works out for them (well they can still care about it but don't think about it constantly) I think a good example could be this guy: https://youtu.be/DjZB9HvddQk?t=197 Or this guy: https://www.youtube.com/results?search_query=richard+stallman