Fork me on GitHub
#beginners
<
2016-11-04
>
markx15:11:33

@agile_geek Hi, thanks for the comment a few days ago about that I don’t need to learn ‘Java’ to use Clojure. I googled about this and found many had the same opinion. However as I moved forward, I found it really hard to do anything without java knowledge.

markx15:11:48

I’m still struggling about parsing a binary file. I learnt about File, Inputstream, ByteBuffer, even if I’m trying to avoid all this by using a wrapper.

markx15:11:41

I found that, most projects that are wrapping java api, if not all, don’t have a complete document explaining the background knowledge. They seem to assume that you already know all the java related knowledge.

markx15:11:21

I believe that, while some use those wrapper libs to be more idiomatic, there are still people like me, that want to use them as the abstraction above Java, so that we don’t get blocked by java.

seancorfield15:11:15

@markx I think it’s fair to say you don’t need to “learn Java” to use Clojure but you do need to learn Clojure’s interop features and you do need to learn some of the (Java) Standard Library. You also need to know something about the JVM ecosystem that Clojure is hosted on.

seancorfield15:11:08

You need to be able to read Java and figure out the equivalent Clojure — but that shouldn’t need much specific knowledge of Java itself. Much will depend on what other languages you already know, of course.

markx15:11:45

In my own experience of learning Clojure, I found the process enjoyable and exciting. However when I tried to actually build something in Clojure, I ended up learning more about Java, instead of Clojure.

seancorfield15:11:07

If you’re completely new to programming then, yes, there’s a lot to learn in order to write useful real-world Clojure programs. If you know Python or Ruby or something, then reading Java should be relatively familiar — although the ecosystem itself will have some new “warts” to learn.

seancorfield15:11:03

We have over 40K lines of Clojure and there’s only a handful of places where we rely on Java interop — but we don’t do a huge amount with files, just databases (and there are libraries for that).

pat.fogarty15:11:24

@markx for binary file i/o, have you looked at buffy? https://github.com/clojurewerkz/buffy

markx15:11:41

I really hope that some day, you can do everything you want in pure Clojure, without knowing anything about java ecosystem more than the fact that it’s hosted on jvm. I really wish that that the interop would be optional.

markx15:11:24

Otherwise, I feel that I would be always thinking in Java, but not Clojure.

markx15:11:08

@pat.fogarty Yes, this is lib I am trying to use. I spent a few hours to find out that it’s only a wrapper around the ByteBuffer. However, the problem how to read a bin file, and how to use a ByteBuffer, is not taken care of.

markx15:11:41

@seancorfield I believe I’m quite fluent in js and Python, and I’m not new to programming at all. But I still feel very lost learning Clojure.

markx15:11:08

I’m wondering if there’s anyone that uses Clojure well without Java knowledge. I tend to believe that those claiming that you don’t need to learn much java to learn Clojure, are actually fluent in Java beforehand , and just don’t realize that.

dpsutton15:11:53

i know almost no java

dpsutton15:11:59

i'm a C# background at work

dpsutton15:11:05

I live almost exclusively in clojure

dpsutton15:11:10

and have never written java for a clojure project

donaldball15:11:22

I dunno. Any time you’re doing I/O you’re already hitting the boundary between language and its host environment. That’s always a point where you have to learn more than just the language, I think.

markx15:11:12

@dpsutton That’s comforting and encouraging to know! Do you know how to read and parse a binary file?

dpsutton15:11:28

i have never run across that requirement

loganmhb15:11:22

@markx in my experience @donaldball is right — file i/o accounts for pretty much all of my use of java interop in clojure

markx15:11:00

hmm. What do you do mostly?

markx15:11:49

@loganmhb That’s also good to know… Maybe I just happened to choose the wrong challenge to tackle.

loganmhb15:11:31

Reading a binary file is probably the optimal way to have to do java interop in clojure haha

markx15:11:08

@pat.fogarty It’s actually helpful and introduced me all the concept of File, inputStream… which is why I got more lost and frustrated.

markx15:11:55

@seancorfield Thanks. I’ll come back when I have more questions.

agile_geek16:11:56

@markx I agree with @seancorfield on this. In fact you're a little unlucky in the use case you choose as file I/O is one of the only places where nobody felt it particularly useful to wrap every http://java.io API call in Clojure equivalents and Java interop shows through. Although the namespace wraps a lot of that too. https://clojure.github.io/clojure/clojure.java.io-api.html

agile_geek16:11:52

You certainly don't need to know Java syntax, OO concepts, or most of the J2SE API to use Clojure. You need a handful of Java specific things but this, to me, is the same as; you need to learn a handful of Clojure collection functions. Just more stuff to learn.

agile_geek16:11:47

The most awkward thing is probably stack traces from the JVM as they're not that friendly.

mehrad-rafigh18:11:38

hey guys, I am new to clojure and trying to check it out. I am looking for a reference to :refer-marcros

mehrad-rafigh18:11:57

cannot find anything on http://clojure-docs.org or similar pages

jswart18:11:13

:require-macros is something you have to do in ClojureScript, because even though ClojureScript looks like Clojure syntactically, it is not the same thing.

jswart18:11:19

ClojureScript doesn’t have macros.

jswart18:11:32

using refer-marcros

mehrad-rafigh18:11:34

oh i get it now

jswart18:11:37

you can pull one in

jswart18:11:44

“pull one in"

jswart18:11:51

i use the phrase loosely

mehrad-rafigh18:11:50

thank you very much for that

markx22:11:40

Hey guys, so I’m trying to use clojurewerkz/buffy, and got a question. How do I create a spec that includes , say int32_type, and a frame-type?