r/programming • • Dec 08 '17

Clojure 1.9 is now available!

http://blog.cognitect.com/blog/clojure19
583 Upvotes

258 comments sorted by

25

u/romulotombulus Dec 09 '17

Good job Clojure team! Clojure is a fantastic language and I encourage anyone interested in learning to give it a shot. You will see some NPEs and some horrifying stack traces, but in time these won’t bother you much at all. The merits of clojure and dynamic languages have been debated elsewhere ad nauseum, but if you give yourself a month of working with the language I think you’ll see what the zealots like me are raving about.

5

u/[deleted] Dec 09 '17

[removed] — view removed comment

15

u/alexdmiller Dec 09 '17

There is tail call recursion with loop/recur, just not automatic TCO. In practice, most people typically use higher level operations like map/filter/reduce etc (which are written to leverage loop/recur or other ways of implementation) and find this to be completely a non-problem.

5

u/JavaSuck Dec 10 '17

There is tail call recursion with loop/recur

That only works for tail-recursive self-calls, though. If the last thing function A does is call function B, there is nothing a Clojure programmer can do to optimize that call.

4

u/[deleted] Dec 10 '17

Or, much worse, cases like (defn f [g x] (g x)) - this is a tail call, but JVM will fail realising it. This way you cannot dynamically chain arbitrary numbers of functions together, which is quite a common pattern in, say, Scheme.

6

u/alexdmiller Dec 10 '17

Actually, you can use trampoline for that.

2

u/[deleted] Dec 10 '17

Static tail recursion is the least interesting form of tail calls.

What is mostly useful in practice is dynamic tail calls, and this is what JVM cannot handle in any way.

So, this is a huge problem.

1

u/yogthos Dec 10 '17

Huge problem for accomplishing what tasks exactly?

4

u/[deleted] Dec 10 '17

Executing arbitrary semantically correct code without throwing a stack overflow exception.

3

u/yogthos Dec 10 '17

Can you state a concrete problem this is a requirement for?

2

u/[deleted] Dec 10 '17

You don't know much about functional programming, do you? For everything based on combinators it's pretty much a requirement. From parsing to interpreters.

5

u/yogthos Dec 10 '17

I asked you about what tasks you wouldn't be able to accomplish, not what style of code you'd have to use to accomplish them. It's only a problem if you want to solve a specific set of problems using a specific style of code.

2

u/jsjolen Dec 10 '17

That's a silly argument though, because of Turing completeness. I think /u/combinatorylogic is showing a fair point, it's idiomatic functional style to do what he says and Clojure calls itself a functional language, so why does the std impl. have an issue with it?

→ More replies (0)
→ More replies (5)

1

u/[deleted] Mar 10 '18

I have rarely in my 4+ years of usering clojure ran into this problem, and when I did, it was easily sovled by using loop/recur

2

u/[deleted] Mar 10 '18

Meaning you're mostly writing simple boilerplate code, instead of generating it from high level specifications.

1

u/[deleted] Mar 10 '18

Ah you are trolling, have fun with that.

→ More replies (1)

0

u/the_evergrowing_fool Dec 10 '17

Can anyone stated a problem from your dear language without you to be triggered? Is that possible?

5

u/yogthos Dec 10 '17

Nobody is being triggered here, and I honestly don't know why you keep following me around. I don't really care to interact with you, perhaps I didn't make that clear previously?

→ More replies (1)

1

u/TheHobodoc Dec 10 '17

There is via the recur keyword. The pro of having tailcall as a keyword is that the compiler can make sure that its a tailcall. That way you dont blow the stack by accident.

3

u/[deleted] Dec 10 '17 edited Dec 10 '17

Tail calls != tail recursion.

EDIT: and again, downvoters are exceptionally ignorant. Is ignorance a prerequisite for being a Clojure fanboy?

0

u/[deleted] Dec 09 '17

[deleted]

3

u/[deleted] Dec 10 '17

JVM is the only place to implement this. You cannot handle tail calls on a higher level.

2

u/JavaSuck Dec 10 '17

Yes, and the JVM architects have had tail recursion on their TODO list for 20 years, with very low priority.

75

u/AckmanDESU Dec 08 '17 edited Dec 09 '17

As a student I keep hearing about rust, clojure, kotlin... they all seem really cool but I honestly don’t know what to do haha. I’m learning web and android dev with Java, php, Javascript, etc.

I don’t even know how viable clojure is when looking for a job. Sure. It is popular. But how popular outside reddit sources?

Edit: thanks for the huge amount of response. Not gonna reply to each of you but I just wanted to say thanks.

22

u/OverTWERKed Dec 09 '17 edited Dec 09 '17

I work for a big company using mostly Java and Javascript for our projects. I learned Clojure on my own time and immediately wished I had learned it earlier. It changed the way I thought about programming and made me a better developer regardless of the language.

I use Clojure now at work too when I need to try out a new idea or build some helper tools for DevOps and stuff like that.

People I know who got into Clojure in college have gone on to work at Twitter & Facebook. I would ignore all these people that have a very narrow knowledge base that say that you should not learn a language because it shows up in less job posting than x y z. The best developer jobs won't dictate your tools anyways.

2

u/[deleted] Dec 09 '17

All anecdotal though, which is kinda what he wants to avoid.

2

u/OverTWERKed Dec 09 '17

Well if a primary source isn't enough perhaps we could take a look at a couple of results from the StackOverflow developer survey.

Clojure developers have highest average salaries in the world: https://insights.stackoverflow.com/survey/2017#technology-top-paying-technologies-by-region

Clojure among most loved languages: https://insights.stackoverflow.com/survey/2017#technology-most-loved-dreaded-and-wanted-languages

Also, I think you'd find that nearly every developer that knows Clojure is also employed.

20

u/ERECTILE_CONJUNCTION Dec 08 '17

Clojure is a dialect of lisp that compiles into java byte code. According to Wikipedia several companies (including Walmart) use it.

-5

u/pakoito Dec 09 '17 edited Dec 09 '17

It doesn't compile IIRC, it's all interpreted. That allows metaprogramming, which is one of the largest selling points for lisps :D Got it wrong.

25

u/ressis74 Dec 09 '17

It's strictly compiled.

It looks interpreted due to how it's compiled. The clojure.jar contains a java class loader that reads a .clj file and compiles it into byte code.

If you squint and turn your head, it's a JIT compiler. You can always opt for ahead-of-time compilation... but I don't bother.

7

u/pakoito Dec 09 '17

Out of the three corrections I prefer yours the better!

6

u/ressis74 Dec 09 '17

I appreciate that. I found Clojure's compilation strategy a bit confusing when I was first learning it. Once I got it, it made a ton of sense.

It was a similar epiphany to when macros clicked. Glad I could help.

14

u/ERECTILE_CONJUNCTION Dec 09 '17

Nope. Clojure "compiles" to Java bytecode. That's literally the reason it was developed; to use Lisp in the Java environment.

4

u/jsjolen Dec 09 '17

I doubt that Clojure is interpreted, almost no non-toy lisps are (at least exclusively). Macros are run at compile-time (well, OK, at macroexpansion-time, which is separate from run-time).

Consider this example:

; SLIME 2.19
CL-USER> (defun square (x)
	   (* x x))
SQUARE
CL-USER> (defparameter *x* 5)
*X*
CL-USER> (square *x*)
25
CL-USER> (defmacro square* (x)
	   (* x x))
SQUARE*
CL-USER> (square* *x*)
; Evaluation aborted on #<TYPE-ERROR expected-type: NUMBER datum: *X*>.
CL-USER> (defmacro square** (x)
	   (list '* x x))
SQUARE**
CL-USER> (square** *x*)
25
CL-USER> (macroexpand +)
(* *X* *X*)
T
CL-USER> 

Notice how square* doesn't evaluate to the same as square when passed x? That's because square* only sees the symbol x and not the number!

Oh and by the way, all of those expressions written at the REPL was compiled into native assembly :-).

2

u/fasquoika Dec 09 '17

I feel like this ignores the fact that most "interpreters" are actually bytecode compilers. Even "interpreted" languages are usually compiled

8

u/joequin Dec 09 '17

I learned clojure on my own while I was in school. I did some hobby projects in it and really got a feel for the language. I don't write in it anymore. I prefer statically typed languages. But what I learned by using it has helped me write better code in every language I use.

2

u/AckmanDESU Dec 09 '17

This is what I’m aiming for

27

u/ferociousturtle Dec 09 '17

I think every developer should eventually know:

  • A low-level language (C, C++, Rust)

  • A decent scripting language (Python, Ruby, etc)

  • JavaScript (you're almost certainly going to need it)

  • A LISP(ish) language (Clojure, Racket, chicken-scheme, etc)

  • A functional language (ML, Haskell, Clojure, etc)

Clojure is the most practical lisp, and it also checks off the "functional language" box, so it's worth picking up for that alone, in my opinion. I'd recommend also dabbling in at least one statically-typed functional language, too, since that's a pretty different mental space.

7

u/GNULinuxProgrammer Dec 09 '17

I agree with everything you said except with two changes. I think a decent developer should eventually be familiar with:

  • An assembly language (x86, MIPS, RISC-V, etc)

enough to navigate through low level code. Secondly , I can't see your point about Javascript. I don't remember one time I needed javascript. I do know javascript and so far used it in multiple projects in the form of nodejs; but it's nothing unreplacable. In what respect do you think every decent developer should know JS?

4

u/[deleted] Dec 09 '17

Well, every web dev needs to know it. No one else, really.

1

u/ROFLLOLSTER Dec 09 '17

If we get WASM DOM bindings soon there might not even be a need for that.

1

u/[deleted] Dec 09 '17

If we get WASM DOM bindings soon

Pretty sure there are no plans for that.

4

u/ROFLLOLSTER Dec 09 '17

It's always been part of the roadmap iirc, still in the proposal stage though.

1

u/vine-el Dec 09 '17

I found knowing the basics of JavaScript (by that I mean front-end HTML/CSS/JavaScript) to be helpful for getting jobs early in my career. It's a valuable skill that employers like to see even if you're going to be doing other kinds of development 99% of the time.

But it didn't make me a better programmer the way Clojure, Haskell, and C did.

3

u/[deleted] Dec 09 '17

What? Really?!? Every developer should know javascript?!? And for what reason, exactly?

7

u/gislikarl Dec 09 '17

The web uses Javascript only.

9

u/[deleted] Dec 09 '17

And why do you assume that everyone should care about web?

7

u/gislikarl Dec 09 '17

Because the internet is a huge deal today.

9

u/[deleted] Dec 09 '17

And? Oil is a huge deal too. Should everyone be proficient in drilling?

0

u/gislikarl Dec 09 '17

Well the fact is that the internet is such a big deal that every developer should at least be familiar with Javascriptþ

→ More replies (1)
→ More replies (4)

2

u/dangerbird2 Dec 09 '17

and wasm :)

1

u/PrimozDelux Dec 09 '17

put clojure in the lisp category and add scala to fp. Also with clojurescript, scala.js etc you might even skip javascript.

4

u/[deleted] Dec 09 '17

Nobody needs to learn Scala.

1

u/PrimozDelux Dec 09 '17

Articulate why

1

u/[deleted] Dec 09 '17

How about F#?

2

u/dangerbird2 Dec 09 '17

F# is a loose dialect of Ocaml designed to run on the Microsoft's dotnet platform. It's a good option if you want to get into functional programming, especially if you're already familiar with C# and Visual Studio.

1

u/[deleted] Dec 09 '17

I am familiar and I do want to learn some functional programming. Thanks man.

→ More replies (15)

7

u/irotsoma Dec 09 '17

Rust compiles to machine code, so it's used something like a replacement for C. Things that will run on a specific platform or be complied separately for different platforms.

Clojure and Kotlin both run on the JVM which supports many platforms with one set of code (for the most part). The disadvantage being that it's not native machine code and so doesn't perform as well.

Clojure is more a scripty, functional, and good for flexible manipulation of data among other things. I don't know it real well, but that's what I've seen it used for.

Kotlin is like an upgraded version of Java (IMO) with lots of extra features to reduce boilerplate code, reduce null exceptions, more strictly type variables, and adds lots of little extras.

I like Kotlin because I mostly do backend web stuff which could be deployed on various platforms, and I'm a very organized, OOP kind of guy who works mostly on larger projects.

I like data objects with basic validation built in, but then more abstract, functional stuff that can work on more than one, similar object to reduce code size. And having the strict typing helps keep me from causing stupid type exceptions.

I'm also often a top-down thinker since I usually am deeply involved in the design (I'm actually technically a Product Analyst, who codes and does architecting, etc.), meaning I design the abstract stuff at the top that covers as much as possible, then dig into details and split things up as much as it can be, but try to keep a strong understanding of integration points up front rather than building the pieces and then integrating them later. Hard to explain in words (I'm very visual).

Kotlin (as well as Java and similar) supports that pretty well having a mix of OOP and functional concepts. But since I've moved over from Java to Kotlin, it's hard to go back to the boilerplate of Java objects (especially Java 7 without things like lambdas). Kotlin really simplifies the OOP stuff among other things.

1

u/[deleted] Dec 10 '17

The disadvantage being that it's not native machine code and so doesn't perform as well.

I don't think that is always the case

1

u/irotsoma Dec 10 '17

There are exceptions of course, but they are rare. There is always the overhead of the JVM layer between your program and the OS/hardware, so it will never be as efficient as something running natively, overall.

1

u/[deleted] Dec 11 '17

it's rare the JVM JIT compiles? i see what you're saying overall though, but there are also time when jit compiling has advantages vs statically compiled machine code

10

u/cat_vs_spider Dec 08 '17

Learning new languages is a useful skill. In order to exercise this skill, you should try to learn languages that are not like any you currently know.

4

u/yogthos Dec 09 '17

It's valuable able to learn different families of languages because they teach you to approach problems in different ways. You end up having more different tools in your mental toolbox that you can apply to solve problems more effectively. Learning fundamentals is important, because the concepts are transferable from one language to another.

What I would caution against is investing a lot of time learning specific technologies until you actually need to work with them. For example, Angular became very popular a few years ago, and many people invested a lot of time into learning it. However, most of the knowledge is specific to how Angular works, and it doesn't have much general value. Keeping up with such knowledge can feel like you're being productive, but in practice you're not learning much of anything interesting.

Specific technologies come and go, and they rarely introduce anything groundbreaking. Fundamentals stay around and get reinterpreted in new ways. Being able to recognize them is an important skill.

11

u/devraj7 Dec 08 '17

No, Clojure is not popular. It's a very tiny niche language.

Since you're doing Android, Kotlin should be high on your list. And it will most likely end up being useful to you beyond Android too.

1

u/GNULinuxProgrammer Dec 09 '17

Tiny, niche doesn't necessarily mean anything. There are enough lisp jobs that if you're a quality lisp programmer, you'll be hired. Similarly, there are so many Java programmers that unless you have a lot of experience, you'll be just another "Java developer" and you might not be able to hired. I don't think programmers should learn languages based on their penetration to the industry. In order to be a good programmer you should have a lot of tools in a lot of field; one language cannot solve every problem. You should know low-level, high-level, imperative, functional, compiled, and interpreted languages.

3

u/evereal Dec 09 '17

There are enough lisp jobs that if you're a quality lisp programmer, you'll be hired.

I wish I lived in these amazing places. In my area, there are 0 lisp jobs. Hundreds of Java, and .NET jobs though.

1

u/freakhill Dec 09 '17

i got to be the first lisp programmer at my job :0

5

u/devraj7 Dec 09 '17

Tiny, niche doesn't necessarily mean anything. There are enough lisp jobs that if you're a quality lisp programmer, you'll be hired.

Yeah... I don't buy that at all. I bet a large majority of people who'd like to be paid to code in Lisp are coding in anything but Lisp.

Obviously, nothing stops you from writing Lisp if you like it, but good luck being paid doing so.

Which is why not being a niche language is important. Lisp never escaped that. And probably never will now that statically typed languages are taking over.

2

u/conseptizer Dec 09 '17

Which is why not being a niche language is important. Lisp never escaped that.

Wasn't LISP very popular in the 1980s?

→ More replies (1)

3

u/[deleted] Dec 09 '17

I bet a large majority of people who'd like to be paid to code in Lisp are coding in anything but Lisp.

Do you really think anyone cares about your ignorant opinion?

but good luck being paid doing so

Spoken like a true code monkey.

6

u/hamtaroismyhomie Dec 09 '17

Do you really think anyone cares about your ignorant opinion?

Spoken like a true code monkey.

What's the point of posting just to insult someone?

3

u/[deleted] Dec 09 '17

Do not intervene in an ongoing feud if you do not want to be counted as a collateral damage.

→ More replies (1)

2

u/devraj7 Dec 09 '17

Look at his posting history, he's mentally unstable. Just ignore him.

1

u/GNULinuxProgrammer Dec 09 '17

I bet a large majority of people who'd like to be paid to code in Lisp are coding in anything but Lisp.

What do you mean by this?

2

u/devraj7 Dec 09 '17

What part is not clear?

1

u/GNULinuxProgrammer Dec 09 '17

Did you mean that people who want to be paid for programming lisp are not experienced enough in lisp because they code other languages, or do you mean most such people code other stuff because they couldn't find lisp jobs?

If it's the former, than you're missing my point since I was talking about a certain expertize; not every lisp programmer has that.

If it's the latter, than you're right but it's hardly the thing we're discussing here. I never said there are enough lisp jobs for all lisp programmers; I said it's possible to work this way if you're good at it. As far as I know, companies who produce lisp code are complaining that they cannot find good senior lisp programmers, because everyone focuses on other technologies.

3

u/devraj7 Dec 09 '17

or do you mean most such people code other stuff because they couldn't find lisp jobs ...

If it's the latter, than you're right but it's hardly the thing we're discussing here.

It's exactly what we're talking about since my point was that Clojure is a niche language.

2

u/[deleted] Dec 09 '17

ROTFL. Every language is a niche language.

4

u/[deleted] Dec 09 '17

How viable is clojure in the job market? Not at all. But that doesn’t mean it’s not worth learning

11

u/cultofmetatron Dec 08 '17

if you want a job, go wit kotlin. People want android devs and ist either that, java or javascript./

rust and clojure are great and there are jobs out there but not as plentiful and are going to go to the guy whos been hacking on them for years. (I highly recommend you lean either of them in your off hours while ur doing your first job.)

-12

u/csman11 Dec 08 '17

That's quite absurd. Anything you can target with Kotlin you can target with Clojure. They are both JVM languages. Just because Kotlin is more popular doesn't mean you need to use it or Java for Android development.

'm just going to ignore the JavaScript part because you clearly don't know what you are talking about if you say JavaScript and Android development in the same sentence. Even with crap like nativescript or phonegap, Clojure is obviously a much more reasonable choice since it has an official compiler to JVM byte code.

As much as this subreddit loves Rust, less people use it than Haskell (according to the latest stackoverflow survey). It's the new definition of a language everyone seems to love and no one actually uses.

7

u/cultofmetatron Dec 08 '17

The context is that the asker here is gettign started and looking for his first job. Of course anything you can target with kotlin, you can target with clojure but he's looking for his FIRST JOB. IE: he needs to cast a wide net which means going for the types of jobs that are hiring. Go on any job board and you'll find plenty of jobs in react native or kotlin (java too). At his level, its less about being able to program in the perfect language and more getting his foot in the door and that's going to be much harder in clojure.

Please, let me know of a entry level programming job that lets you write clojure. Ive only seen them offered to senior level devs.

Javascript whether you like it or not, is a very loved contender in the native market. Its not perfect for every use case but if it demonstrates that I don't know what I'm talking about, then neither does airbnb, tesla, facebook, walmart labs, baidu, or ubereats. Additionally, most of the android gigs I and my contractor friends have come across have been in react native so its not like learning it isn't going to have immediate financial benefits.

ALSO: android does not use jvm, it has its own vm (https://en.wikipedia.org/wiki/Android_Runtime) that is optimized for low memory environments. Clojure is not an ideal environment for low memory devices for a number of reasons including its reliance on a large memory footprint.

A choice of technology (including language) comes down to more than just the technical merits. it's also the quality of tooling and ecosystem as well as the market for those services. PHP sucks but I won't criticize a php dev. They have a neverending supply of work because things get built in it.

My Original point is that as someone just starting out on his career, It'll be much easier to get his first job writing kotlin or javascript because in my experience, there are a lot more entry-level/junior friendly positions hiring for those.

2

u/csman11 Dec 08 '17

Yes it has it's own vm but you compile java byte code to it's byte code. That was what I meant.

Other than that I agree, you just didn't make it very clear in your first post. Sorry I misinterpreted what you were saying.

You can write code in Clojure without it being memory intensive. It just won't be very functional or idiomatic, but it is possible. Also, if you fully avoided using mutation, immutable, strictly evaluated programs have a much easier memory profile to garbage collect (because you can never have objects from older generations pointing to newer generations). This makes garbage collection as simple as starting at the current generation and copying only reachable objects into the next generation. Without profiling, there is no way you will know if this footprint uses more energy than that of an imperative program. In other words, you might save more energy on a simpler garbage collector than you do on less intensive allocations. Of course this doesn't really apply here since you would be using the same garbage collector anyway, but it isn't as simple of a problem as you are making it out to be.

You were making it seem like Clojure wouldn't even be an option for Android development, but that isn't true. That is literally all I was trying to say.

-1

u/csman11 Dec 08 '17

By the way, neither Kotlin nor Clojure are popular languages. Scala is more popular than both of those, and it isn't particularly popular itself. Groovy is probably the most popular JVM language after Java.

It may be that you found a job using Kotlin, that doesn't make it popular. I've been working on a codebase written in Perl since 2014. It wasn't difficult to find that job. But Perl isn't popular anymore. Anecdotal evidence and statistics are different things. Some people live in mining towns and mining jobs are extremely easy for them to get. Mining still isn't popular. If you are offering advice on the internet, it is best to go with statistical averages instead of personal anecdotes unless you know the person you are talking to has a similar enough background that your experience actually applies to.

3

u/cultofmetatron Dec 08 '17

my day job is javascript. I've been thinking of getting into mobile and now that kotlin is officially supported by google, I've had clients of mine and colleagues express interest in kotlin instead of java. Most of what I'm saying comes from having browsed job boards. I hardly see clojure and when I do, they are for senior level engineers which the asker here is not yet.

If we wanna be real as far as getting a job, you're best off with javascript as everyone needs a frontend engineer. Elixir is my PL of choice but its javascript that keeps paying my bill.

0

u/csman11 Dec 09 '17

Hey, I like Haskell and OCaml but my day job is JS and Perl.

There aren't very many people using the "good" languages in their primary work. Even at larger companies, it's uncommon to find anyone using these languages unless it's for an infrastructural or side project. Outside of financial firms and startups pretty much no one has their main codebase written in functional languages (Jet.com is probably the best known exception).

Personally I don't like the widespread acceptance and usage JS has. From a technical perspective it is probably the worst programming language ever created, but it is basically a requirement for everyone in the field to know it these days (even backend engineers need to be comfortable with JS and at least one front-end framework these days to work in web dev, unless they only work for companies that can also afford "full stack" people). Hopefully web assembly will help kill this monster over the next decade.

5

u/Jazonxyz Dec 08 '17

You can just check those languages out for a bit and see what sets them apart from other languages. Learning a bit of closure/rust/kotlin could make you better Java programmer since it helps you see things from a different perspective. IMO, it's always good to be pretty damn good at a mainstream compiled language and a mainstream interpreted language. I personally feel pretty confident in my C/C++ and JS. If you're pretty good in at least two mainstream programming languages, your job prospects start looking pretty good. After that, you can learn a 3rd language that you're attracted to (maybe rust?). If you get pretty good at that 3rd language, you can maybe use it professionally. I know of a guy that started learning erlang on the side and got pretty good at it. He eventually got hired by a fortune 500 company and he makes a ton of money working remotely maintaining an erlang codebase.

2

u/mingram Dec 09 '17 edited Dec 09 '17

I see a lot of people responding to you, but I agree with some of the posters that language isn't that important.

But a lot of schools now aren't teaching a lot of the lower level shit, and I've worked with these people and it is frustrating.

I'd honestly learn Rust, because it will make you a good coder. But you can learn any low level language like C, C++, Go (people hate it here but it is useful) and then learn a scripting language like Python or Javascript and learn how to webdev. You won't be looking for a job for long. But you also won't struggle to grasp a new language.

2

u/[deleted] Dec 09 '17

If you really want to do android dev I highly recommend kotlin

2

u/sw2de3fr4gt Dec 09 '17

Not sure how popular it is but according to StackExchange 2017 survey, it is the language that gives the top average salary. https://insights.stackoverflow.com/survey/2017#top-paying-technologies

2

u/HellkittyAnarchy Dec 09 '17

Use the language for the job ☺️

I've been taught clojure for AI and it's pretty neat thereand it's generally a pretty awesome functional language too (Being able to work with other Java programs with it is also very neat).

3

u/oweiler Dec 09 '17

Clojure is far from popular.

1

u/CodyEngel Dec 09 '17

Kotlin is good for Android and building backend services. If also let’s you compile to JS and native will allow you compile for basically anytime runtime.

-5

u/[deleted] Dec 08 '17

It's exceptionally stupid to be concerned with a language popularity and with shit like "jobs in a language X".

-7

u/agumonkey Dec 08 '17

if you want to program quantum computer learning lisp seems to be useful according to https://www.youtube.com/watch?v=f9vRcSAneiw

6

u/ThisIs_MyName Dec 08 '17

Is this bait?

0

u/agumonkey Dec 08 '17

unless you consider an actual talk about actual quantum computers

0

u/[deleted] Dec 08 '17

[deleted]

46

u/csman11 Dec 08 '17

I agree language is less important than architecture. It doesn't matter what language you use if you are going to just write a pile of spaghetti anyway. And by architecture I assume we are referring to system architecture not design patterns.

But language choice is very important to keep code expressive. It's very difficult to write maintainable code in Java without the codebase turning into a pile of abstractfactorystrategyvistorbeanentities. It is simply a fact that certain problems are "easier" to solve in certain languages (especially if you have a domain specific language on hand). Having a good or bad architecture won't change that.

20

u/eliasv Dec 09 '17

it's very difficult to write maintainable code in Java

If you found that difficult then I have bad news for you, you will find it difficult in any other language too.

25

u/csman11 Dec 09 '17

I don't think that is true at all. Java has a terrible type system that requires you to use loads of design patterns to keep programs well typed or to skirt the type system by using unsafe casts and messy exception handling to catch casting exceptions everywhere or do nasty instance of checks. You also need design patterns to implement pretty much any useful abstraction. Most other languages either provide language forms capable of implementing these abstractions or provide language forms that do implement these abstractions. Java is consistently 5 or 10 years behind other mainstream languages in implementing new features. I remember how upset people were with Microsoft for copying Java when they created C#, but today C# is 20 years ahead of Java in terms of language level features and abstractions that are available out of the box.

Java has a big reputation for being verbose. It's simply a fact that maintainable Java codebases are larger than the equivalent codebases in a similar language like C#. The worst is when you have to maintain a codebase littered in design patterns that the original author misapplied.

You are completely oversimplifying maintainability. It's relatively easy to learn a language like Java and that means most codebases written in Java have substantial contributions from lower skilled developers. That makes them very difficult to maintain. The whole language is built off of a poor design philosophy and complete disregard for traditional OOP principles. The original designers had 2 goals: make it run anywhere and make it easier to learn than C++. These goals led to the monstrosity that is Java is today.

10

u/csman11 Dec 09 '17

To make what I'm trying to say more simple and clear: I've seen two types of Java codebases. The first uses the abstractions built into the language and tends to suffer from problems like fragile base class that lead to a brittle codebase that is difficult to maintain. The second used an abundance of design patterns and frameworks, often either misapplied or overused, that lead to an over architected system. This second type is typically well covered in tests and possible to maintain. It just requires an additional amount of cognitive overhead to deal with all the abstraction, much of which is leaky and require reasoning about multiple levels of abstraction at once. So again, difficult to maintain.

I've never heard of anyone thinking a Java codebase of any substantial size (at least 20000 lines of code) is anything but a nightmare to maintain. The difficulty seems to be exponential in the number of lines of code. This is why large companies have to hire PhDs to come in and write static analysis tools and specialized compilers to turn their monstrous codebases, written and maintained by Junior developers straight out of university, into something that can work at their quite literally large scale.

2

u/disappointer Dec 09 '17

I guess I work on a relative rarity, then, but our main project is ~1.5m lines of Java and steeped in design patterns, but maintenance is really not that bad. I will consider myself lucky, I suppose.

1

u/[deleted] Dec 09 '17

Any language app is going to be a mess when you over-use and misuse design patterns.

0

u/[deleted] Dec 09 '17 edited Dec 09 '17

ROTFL. Do you realise that boilerplate harms maintainability, no matter how much effort did you put in your architecture? And Java code which is not over 90% boilerplate does not exist.

EDIT: downvoters apparently have no idea how a non-boilerplate code looks like.

6

u/muuchthrows Dec 09 '17

I think the downvoters realize that 'rofl boilerplate' is not an accurate summary of the problem with Java. You can remove all the boilerplate and it will still be difficult to write maintainable code in Java.

3

u/[deleted] Dec 09 '17

Java code is unmaintainable in general for the very same reason why Java is so.boilerplate-inducing in the first place.

2

u/[deleted] Dec 10 '17 edited Dec 10 '17

Now we're arguing semantics, but I would claim Java has tons of intrinsic boilerplate. If a class has four instance variables then between the variables and constructor definition you have ten lines of code. No literals for lists, sets, maps. No collections or IO packages in default scope. Checked exceptions galore. No sensible default implementations for equals or hashCode. No syntactic shortcut around

if (foo != null && foo.gerBar() != null 
    && foo.getBar().getBaz()...)

The list goes on and on. I pay my mortgage working on Java, and it's a slow death by inescapable boilerplate.

(Edit) Or to put it another way, you could rewrite a large Java program in Groovy or Kotlin without changing the core program logic, class names, or instance variables and cut your lines of code by more than half. Probably more than 80%.

0

u/[deleted] Dec 08 '17

[deleted]

14

u/csman11 Dec 08 '17

I agree. A great programmer can write better Java than a shitty programmer can write OCaml. When comparing across skill levels, nearly all other considerations are a moot point. The same goes for architectures, because a shitty programmer is not going to absorb the architecture and understand it, but instead work around it.

We are in the process of trying to figure out how we are going to rewrite our codebase at work and everyone keeps throwing out languages. I'm sitting there talking about architectural choices. I really don't care what language we use as long as it isn't an esoteric one and it isn't Java or Perl (The language it is written in now). Anything else I can deal with. If we are going to make a giant shit pile again though, we might as well just not rewrite it at all. I don't even dislike Perl that much, but I know if we rewrite the system in Perl people are going to copy and paste old modules instead of implementing stuff from scratch.

(Yes we are aware of the risks of rewriting a production system. It is beyond the point where it can be refactored because we would spend more time writing the tests we would need to do a judicious refactor than just starting from scratch.)

→ More replies (5)

2

u/ssrobbi Dec 09 '17

I’m also going to add that verbosity isn’t always a bad thing. Though I write a lot of Objective-C...so maybe I’m biased.

1

u/furych Dec 09 '17

It is not, but it is annoying. I'm doing a lot if code reviews and it is always annoying then I receive like 10 files to review and out of them only like 10 lines of code have some business value, others just abstractions /interfaces/helper functions etc.

2

u/disappointer Dec 09 '17

That sounds like a problem with the code review process (or tool) itself. I have the same problem, as our code review tool is revision-number driven, which is why I prefer in-person code reviews when possible.

2

u/vivainio Dec 09 '17

Well pretty typical code review process involves textual diffs in pull requests

2

u/Kaze79 Dec 09 '17

Not saying OP should learn it but a functional language is very different.

3

u/AckmanDESU Dec 09 '17 edited Dec 09 '17

At the moment I'm taking web dev classes which I joined in order to get a job in the field of programming.

But I also love learning overall...

Part of the reason why I asked my question is not just about getting a job, it's also to learn useful skills just for the hell of it. I've been doing basic programming for like a decade now so I have a pretty damn good grasp of the basics and same goes for what you called fundamentals (learning about them in class atm so I focus on other stuff in my free time).

I've even been learning to use vim for the past few months (but turns out I should be using emacs for lisps for whatever reason?).

Personally I started looking into Haskell recently and also Kotlin. I understand that switching languages is somewhat easy but I'm interested in learning how to apply the different programming paradigms. That's why Haskell and Kotlin interest me (although K also seems useful overall), that's why Clojure keeps catching my attention (because I wanna learn a LISP and clojure is somewhat related to what I study).

But sadly I don't have unlimited time.

I'll probably focus on Kotlin for now, since it's interesting and useful, as well as fun to use overall. Even if it doesn't get me a job.

Sorry about the parenthesis. I'm not great at the whole writing thing.

3

u/PrimozDelux Dec 09 '17

If you want to write lisps in emacs you can always use spacemacs, it's a very full featured version of emacs with vim movements. Might be worth checking out. If you want to try out a functional languague you can check out functional programming in scala (the red book). It's definitely not an easy read, took over a year until I was comfortable with all the material and I picked it up in my fourth year of my CS degree..

1

u/[deleted] Mar 10 '18

don't start with spacemacs when learning lisp, the learning curve is huge, any editor with support for automatic paren matching is good enough to learn lisps. IntelliJ with Cursive (the clojure plugin) is much easier to pick up

3

u/[deleted] Dec 09 '17

web dev classes which I joined in order to get a job in the field of programming

You're likely regret it later. Stay away from all this web stuff, there are dozens of much better fields in programming.

Surely, go after languages like Haskell and Scala, but you also must learn at least one proper meta-language. Clojure fits, though it can also be Forth, Scheme, Julia, Rust, and many others. Just pick any with a proper macros support.

Kotlin is just a nicer Java, you're unlikely to learn anything new from it.

3

u/JavaSuck Dec 10 '17

Kotlin is just a nicer Java, you're unlikely to learn anything new from it.

...which is probably why Kotlin gets so much love from Java developers, myself included ;)

1

u/the_evergrowing_fool Dec 09 '17

I think they plan to add macros or something macro-like to Kotlin.

2

u/[deleted] Dec 09 '17

Source?

1

u/the_evergrowing_fool Dec 09 '17 edited Dec 09 '17

2

u/[deleted] Dec 09 '17

Well, it did sound a bit lukewarm. Unlikely they're going to implement any proper macros with such an attitude - which is weird, with all their experience with MPS they should know better that macros can go really well with tooling.

1

u/the_evergrowing_fool Dec 09 '17

Yeah, though... I am not sure if MPS and Kotlin are the same team inside JetBrains. Their Git contributors mismatch.

2

u/[deleted] Dec 10 '17

Don't they even talk to each other? I always thought that JetBrains is a relatively small company.

→ More replies (0)

1

u/[deleted] Dec 10 '17

There are a lot of jobs in web work. What should the other person - or me - be focusing on instead that also has so many opportunities?

10

u/OverTWERKed Dec 09 '17

Thanks Clojure team! We appreciate all your hard work in making this great language even better!

48

u/[deleted] Dec 08 '17

great, i was just thinking of giving clojure another go but leiningen always leaves a bad taste in my mouth

19

u/euclio Dec 09 '17

As someone who knows nothing of Clojure, what's wrong with leiningen?

22

u/[deleted] Dec 09 '17

Clojure has egregious startup/load time issues above and beyond the jvm startup time. Unfortunately leiningen is built with clojure which leads to painfully slow cli interactions.

5

u/yogthos Dec 09 '17

On the other hand I find that you can literally leave your application running for days during development. Pretty much the only time I restart the app is when I change dependencies.

5

u/[deleted] Dec 09 '17

I very much dislike this argument, which is made every time slow repl starts are mentioned. I feel it looks past the core issue and really only happens because the startup times are so bad in the first place.

Restarting an app from clean state every so often is a really good thing, mostly so you know it actually will actually start. How many times have I had an app running fine in repl but it wouldn't restart because some var wasn't defined in the correct order. And repl sessions get dirty over time with old vars no longer needed as you build up an app.

And then there's component, and the only reason it's even a thing is that is because clojure is so slow in the first place, and it's a band-aid and yet another thing to deal with and learn using up another chunk of the complexity budget.

3

u/yogthos Dec 09 '17

I'm all for having faster startup times, bit even if startup time was instant I wouldn't be restarting the REPL often. My experience is that you really want to structure code in a way where you can reload namespaces easily, and it leads to cleaner overall code.

Component isn't a bandaid for slow REPL startup, it's an approach for managing stateful components in a sane way. You see this approach used in plenty of languages. Java Spring manages stateful components in much the same way. Personally, I far prefer mount though. It solves the problem of ensuring that var state doesn't get stale without forcing you to structure your app around it.

0

u/[deleted] Dec 11 '17

[deleted]

2

u/[deleted] Dec 11 '17

Yes, and it's because Leiningen is written in clojure.

The result is that there's ton of clj source code(10's of thousands of clojure vars specifically) that must be parsed/read/loaded on each and every startup. Doing just the clojure bare repl means you only need to load the clojure.core namespace(bloated to begin with). NREPL is one of the main culprits I seem to recall.

Because of load time issues, clojure(jvm) is simply unsuitable for cli applications, serverless applications or anywhere resources are constrained or startup time matters. It's only really suited for long running server or batch processes where start times do not matter.

For fast startup, clojurescript is sort of an answer.

1

u/[deleted] Dec 11 '17

I'll agree with you on resource constraints: Clojure is a memory hog. But in terms of "unsuitable for cli and serverless applications"...I dunno, if you're just loading clojure.core and you're doing a shell script that can afford a half second or so delay, it works just fine I think. 10,000+ line apps start to get a little slow at startup, but if it's going to be running for awhile, it doesn't matter much to me. But yeah raw Clojure isn't that bad.

1

u/[deleted] Dec 12 '17

Here's a relevant link I came across today. https://twitter.com/nikitonsky/status/939786919952646149

I am thinking a pure cljs stack both server and client side is a better answer in the long run.

10

u/kankyo Dec 09 '17

Leiningen was one of my favorite things with Clojure dev. Sure it’s slow but it’s super convenient compared to the total mess that is Python dev.

8

u/OverTWERKed Dec 09 '17

Have you tried boot?

3

u/saint_glo Dec 09 '17

There are some online options for clojurescript, like replumb or quil examples that are quite useful for getting back. Zach Oakes's Lightmod/Nightcoders are nice too.

0

u/[deleted] Dec 09 '17

[deleted]

2

u/vanderZwan Dec 09 '17

This looks very nice! Nice introductory screencast too, I like the laid back pace and the lack of hyping things up.

0

u/[deleted] Dec 09 '17

[deleted]

3

u/yogthos Dec 09 '17

You might find tools deps useful in 1.9.

7

u/kinleyd Dec 09 '17

Awesome. Will upgrade rightaway.

10

u/lennoff Dec 09 '17

I know it's complicated, but I'd be more interested in improved start-up times.

4

u/GOPHERS_GONE_WILD Dec 09 '17

If you're restarting your REPL so much you're doing something very wrong. Have you tried checking out youtube videos of people's workflows? The only time it's ever mattered for me was database migrations. Literally everything else uses the same repl session until I'm done working.

6

u/1xltP3mgkiF9 Dec 09 '17

What if I want to call clojure programs lot of times because of usage in shell scripting? (btw, I'm a big fan of the language).

12

u/SimonGray Dec 09 '17

Then just use ClojureScript, that's what everyone else is doing. You can use Lumo or Planck for that specific purpose, for example.

5

u/1xltP3mgkiF9 Dec 09 '17

True. But then I can't use JVM libs. Can't have everything :)

3

u/[deleted] Dec 09 '17

No, but Lumo gives you NPM integration. If you're leaning on JVM libs that don't have an analogue in NPM, is it really a "script"?

3

u/GOPHERS_GONE_WILD Dec 09 '17

I'd say it really depends on what you're doing. You definitely wouldn't want to do that if it's a short script, but if the program spends more time running than booting (like a backup or something?) then it's whatever. People have been working on using ClojureScript for things like this because the startup time is basically instant compared to Clojure, but then you're locked out of using Java libraries and have to use JavaScript libs instead.

But yeah, not the best tool for the job unless it's for a project that's already in clojure.

1

u/troublemaker74 Dec 09 '17

Why not just use shell for shell scripting? That's what I do. Then I'll use Clojure or Ruby, or whatever else for APIs and web stuff.

Using clojure for shell scripting is the wrong tool for the job, IMO.

2

u/1xltP3mgkiF9 Dec 09 '17

Lot's of devops stuff, like migrating between databases, formats, quick batch tasks, data transformations often comprise of steps / tasks, some of which are easier to achieve either via clojure or unix tools. Thus combining them would be the most productive to me.

1

u/yogthos Dec 10 '17

I started using Lumo for any non-trivial shell scripts, and I find it's much more maintainable. Here's an example. Since node is available pretty much anywhere nowadays, using ClojureScript for shell scripting is quite viable in my experience.

11

u/hondaaccords Dec 08 '17

Clojure is by far the best mainstream high level language. Awesome news 👏

64

u/otakuman Dec 08 '17

Wait, mainstream???

22

u/[deleted] Dec 08 '17

I think Lisp has been ignored for so long in industry that in comparison Clojure seems mainstream.

11

u/yogthos Dec 09 '17

Walmart, Apple, Citi group, and Boeing, are among some of the companies using Clojure today.

0

u/[deleted] Dec 09 '17

[deleted]

18

u/alexdmiller Dec 09 '17

Walmart has more than one Clojure system. One takes all Walmart receipt data (Walmart Savings Catcher). It's not a 50-line script. https://www.youtube.com/watch?v=av9Xi6CNqq4

Boeing has a flight diagnostic and maintenance system that runs on the plane (not a flight critical system) that is 10k's of LOC. https://www.youtube.com/watch?v=iUC7noGU1mQ

-8

u/pellets Dec 08 '17

My employer has a small amount of clojure in production. So yes, mainstream.

39

u/ThisIs_MyName Dec 08 '17

My employer has a small amount of brainfuck in production.

11

u/awj Dec 08 '17

O.o

13

u/ThisIs_MyName Dec 08 '17

shrug it was added as a joke, but it's been solid for years. There's no reason to redo it now.

6

u/[deleted] Dec 08 '17

Wait, you're serious? What does it do?

13

u/ThisIs_MyName Dec 08 '17 edited Dec 08 '17

Match IP route prefixes received from routers against a whitelist to prevent https://en.wikipedia.org/wiki/BGP_hijacking

7

u/yawkat Dec 09 '17

That's amazing. How large is it?

→ More replies (1)

6

u/warriorlemur Dec 08 '17

I'd sell that stock asap.

5

u/jyper Dec 08 '17

That's what you want us to think, you're just trying to manipulate the market

2

u/throwaway27464829 Dec 09 '17

That's enough internet for today...

1

u/pellets Dec 09 '17

You're being snarky, but brainfuck is a relatively well known language. While not mainstream in production, it's mainstream in mindshare.

1

u/ThisIs_MyName Dec 09 '17

Certainly more mainstream than Clojure :P

2

u/Mattgame555 Dec 09 '17

Umm.. By what metric?

1

u/Double_A_92 Dec 12 '17

His personal hype view.

-14

u/zombarista Dec 09 '17

((((((((((((((((((((((((((((((((((((((((((((((((((print "cool"))))))))))))))))))))))))))))))))))))))))))))))))))

-13

u/[deleted] Dec 09 '17

Clojure is still the most disappointing language of all time (to me).

7

u/conseptizer Dec 09 '17

Why?

0

u/[deleted] Dec 09 '17

[deleted]

0

u/[deleted] Dec 09 '17

[deleted]

→ More replies (1)

-25

u/[deleted] Dec 08 '17

I thought clojure was dead!

21

u/alexdmiller Dec 08 '17

I assure you that it is very much alive.

https://clojure.org/community/companies

-14

u/StickiStickman Dec 08 '17

It's kinda dishonest to include companies who tried it once and never used it again.

23

u/alexdmiller Dec 09 '17

All companies are on here either because they did some public talk about it or they asked to be on the list. Admittedly, I'm sure there are some that have stopped using it (notifying us is probably not on the top of their todo list, but would be happy to edit if that can be verified). On the flip side, I also know of some large and well-known companies that use it but have not made their use public.

-20

u/[deleted] Dec 09 '17

Some day, we will integrate the syntactical efficiencies of Clojure and Python into a single wonderfully unreadable language!

0

u/[deleted] Dec 08 '17

[deleted]

4

u/frrarf Dec 10 '17

Actual question, why though? I've never used a Lisp language before, but everyone seems to be raving over them. I just don't get what's so special about them.

6

u/Matthew94 Dec 10 '17 edited Dec 10 '17

Macros mean that it's very easy to add language constructs with little to no overhead.

For example, you could add your own list comprehension in scheme which would be almost identical to the one in python in fewer than 30 lines.

This is possible due to s-expressions and their regular syntax.

This, beyond all other things that I could have mentioned, is lisp's big advantage. Many languages have used many of the other big features but it is very hard to come close to the macro system if you aren't writing the AST directly.

I wrote this naive implementation in SKILL++ (a mismash of common lisp, scheme and franz lisp).

(define_syntax lcmp
  (syntax_rules (for in if)
    ((lcmp expression for element in list)
     (mapcar (lambda (element) expression) list))
    ((lcmp expression for element in list if predicate)
     (mapcar (lambda (element) expression) (setof element list predicate)))))

You could then call it as

(lcmp (x + 1) for x in (list 1 2 3 4 5))

This kind of integration with the language is simply not possible in most other languages.

5

u/[deleted] Dec 10 '17

Usually people respond with macros. But I would add to that: readability (once you're used to the parenthesis), and ultra convenient syntax for higher order functions and partially applied functions.

But Clojure adds a lot to Lisp by what it makes default/idiomatic - immutability, simple Java interoperability.

1

u/[deleted] Dec 10 '17

Readability is almost always a red herring. Convention goes just as far as syntax rules for most languages.

1

u/[deleted] Dec 11 '17

Readability is subjective in most programming languages. But Lisp dialects have the simplest set of syntax rules of any programming language family.

Now, it may seem alien if you've spent the last ten or more years using a wildly different set of syntax rules. That's how it was for me when I tried to learn Lisp - it wasn't used at my university, at least not in the 1990s. So when I first tried to learn it I was comfortable with C, C++, Java, Perl, and Pascal and that syntax familiarity made Lisp seem bizarre.

But if you're completely new to programming, I would be shocked if any other language can beat Lisp for the syntax learning curve.

4

u/[deleted] Dec 11 '17

Readability is subjective in most programming languages.

When people say "readability", they are often saying more about themselves than the language they are talking about.

But Lisp dialects have the simplest set of syntax rules of any programming language family.

This is a lie that Lispers love to tell themselves.

The only truth to it is that, in Lisp, there is no need to learn rules about operator precedence. But the syntax is just as involved as any other language. A lambda must have a parameter list, followed by a body. A let binding must consist of a list of pairs consisting of an identifier and an expression, followed by an expression in which they are defined. Etc. etc.

Yes, it all parses out as S-expressions. But by the same token, all other programming languages are just strings. Just as not any arbitrary string constitutes a valid Java program, neither does an arbitrary S-expression.

And while it's certainly simpler to write a parser or evaluator for Lisp, it's not necessarily easier to learn. Students of the language have to learn how to express ideas that would be straightforward translations in other languages due to the in-fix nature of the language. It's a non-issue for virtually anyone to understand that 1 + 2 * 3 evaluates to 6 in Python, because we all learn order of operations in school. However, reading (+ 1 (* 2 3)) requires learning something new.

This isn't to say there aren't pitfalls the Python/Java/C way, since 2^3 is definitely not 8 in any of those languages, but you can't make the argument that in-fix is easier to learn just because it's intrinsically simpler.

The real value of Lisp is that it is easy to implement. Abelson and Sussman used Scheme for SICP for two very special reasons: it was unfamiliar territory both to incoming students with programming experience and those without, and because the keystone of the course, writing a full compiler for a large subset of the language, was doable in a semester or two's worth of work (due to the straightforward semantics and to the simplicity of parsing).

→ More replies (2)

2

u/phalp Dec 10 '17

It's not just one thing, but the total effect of combining many things. It's macros, yes, but it's also the way that the syntax interacts with macros. It's a number of things that other languages have slowly adopted, like higher-order functions and first-class functions, and garbage collection. It's a live image and a programming system as opposed to a lifeless "language". It's the interaction between all these things.

1

u/jsjolen Dec 10 '17

Best interactive development I've ever done has been in Common Lisp.

http://p-cos.blogspot.se/2014/09/why-i-like-common-lisp.html