Clojurians
#parinfer
<
2016-02-02
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

cfleming04:02:17

I’ll take a close look tomorrow and do a code review.

chrisoakman04:02:51

great :simple_smile:

chrisoakman04:02:30

I have very little experience with the JVM ecosystem and haven't used a statically typed language in over 10 years

chrisoakman04:02:45

so I ran into some rough spots

chrisoakman04:02:22

but it passes all of the parinfer.js tests

chrisoakman04:02:36

that's a good sign

chrisoakman04:02:05

I'm curious to know how fast it is compared to the JS and Python versions; have no idea how to benchmark something like that on the JVM

chrisoakman04:02:14

What's the next language that needs a Parinfer implementation? Lua? #justkidding #butnotreally

chrisoakman04:02:01

Do you need any CLJS stickers @cfleming ?

snoe07:02:18

I've been thinking about my workflow a bit and I wonder if indent and dedent functions would be useful in indent-mode because moving things with space is slow and using 2-stop tabs is imprecise. Basically, ask where are the tab stops that cause structural changes? |(|let [|attrs {|:style {|:color "green"}]) Is parinfer in a better place to move the line around these stops (or expose the tab stop info) than editors themselves?

snoe07:02:32

I think it's a bit different than what https://github.com/shaunlebron/parinfer/issues/21 was getting at

cfleming07:02:50

@chrisoakman: Ok, cool, I’ll take a look. Criterium is the state of the art for JVM benchmarking, I’ll take a look at that too if you don’t get there first.

cfleming07:02:17

@chrisoakman: I’m good for stickers thanks, I’m not really a sticker kind of guy - my laptop is still pristine!

chrisoakman07:02:32

wonderful :simple_smile:

chrisoakman07:02:15

I'm very open to PRs and changes to that repo from someone with more experience on the JVM than me

cfleming07:02:07

Ok, cool. I think it makes sense to use nulls rather than your sentinel value, since nulls are first-class in the Kotlin type system, and you lose that support if you use some other value.

cfleming07:02:21

And at the end of the day you’re still using a value for “nothing to see here”.

chrisoakman07:02:22

I started off doing that

chrisoakman07:02:31

and just couldn't get it to compile

chrisoakman07:02:40

I don't know what I'm doing in a statically typed language

cfleming07:02:55

Sentinels normally make more sense if you might be dereferencing these objects and you can provide a sensible default behaviour.

chrisoakman07:02:19

I also wasn't sure whether to use Objects or HashMaps for everything

chrisoakman07:02:35

in JS and Python it was obvious to use JS Objects and Python Dicts

cfleming07:02:38

Ok, I’ll take a look - generally in my (painful) experience, it’s a matter of ensuring you use Type? where you might think you need just Type.

chrisoakman07:02:07

I don't understand how people get anything done in languages that don't have literal data types :wink:

chrisoakman07:02:27

yeah - I read about that

cfleming07:02:47

Since if you use null rather than your sentinel you can get rid of most of your init blocks (again, I think, just from a quick scan of the code)

chrisoakman07:02:49

the MutableResult gets mutated all over the place, everything else is essentially immutable upon creation

chrisoakman08:02:00

yes - that is the case

cfleming08:02:06

Data classes can use var too.

cfleming08:02:37

So I think MutableResult can use var and have default values in the constructor.

chrisoakman08:02:49

there is basically no logic in any class; it's all in the functions

chrisoakman08:02:58

not sure if you're looking at parinfer.js side-by-side

cfleming08:02:03

But I’ll take a look tomorrow in more detail and send a PR

chrisoakman08:02:23

awesome :simple_smile:

chrisoakman08:02:34

definitely take a look at parinfer.js if you haven't already

cfleming08:02:00

Yeah, I’ll look at them side by side, and I’ve spent a bunch of time reading the JS version and the algorithm doc.

cfleming08:02:15

Seems like Kotlin allowed a pretty natural translation though.

chrisoakman08:02:30

it wasn't the worst thing I've ever used :wink:

cfleming08:02:33

It’s pretty nice, Kotlin - I like it a lot.

cfleming08:02:44

High praise!

chrisoakman08:02:58

looking forward to anything you do on this

chrisoakman08:02:24

I did the tests in Clojure 1) for comfort and 2) to make sure it was usable outside of Kotlin-world

cfleming08:02:24

How do I run the tests?

chrisoakman08:02:34

just "lein run" in that folder

chrisoakman08:02:41

(I assume you have Leiningen installed)

cfleming08:02:48

Ah, ok, I see

chrisoakman08:02:00

and the testing "framework" could be much more complete

chrisoakman08:02:13

I literally slapped it together in a few minutes

cfleming08:02:20

I actually like the idea in parinfer of taking those sorts of tests from markdown.

cfleming08:02:33

I might have to do that in Cursive, I have a bunch of tests in strings which really sucks.

chrisoakman08:02:40

yeah - Shaun is very thorough

chrisoakman08:02:52

I think he got that idea from the .cljsdoc files we were using

chrisoakman08:02:10

basically: when you need a really simple data structure, but don't want to limit yourself to .json or .edn whitespace / string rules

cfleming08:02:44

Right, I investigated using EDN or something, but it doesn’t add much over strings when you need to look at indentation in the results.

cfleming08:02:03

But test cases in markdown is actually a really nice idea.

chrisoakman08:02:08

we "invented" that format

chrisoakman08:02:16

and I think it inspired what he did for the Parinfer tests

chrisoakman08:02:57

You have to be careful not to add too much "structure" to it else you're just re-inventing .edn

chrisoakman08:02:04

but in/out tests are a good case I think

cfleming08:02:27

Nah, I’m thinking title, description in a paragraph and then in/out cases

chrisoakman08:02:02

I think the .cljsdoc file or simple markdown would work great for that

chrisoakman08:02:40

that's where he's parsing the .md files

chrisoakman08:02:00

so glad you're looking into this :simple_smile:

cfleming08:02:25

I’m glad you wrote this, it was basically the next thing I was going to write

chrisoakman08:02:40

I thought if I did the grunt work to get all the test cases passing it might make it much easier to integrate

cfleming08:02:50

Ok, got to go but will look into that and send more feedback tomorrow.

chrisoakman08:02:54

great; let me know

cfleming08:02:58

Yeah, absolutely, thanks!

cfleming08:02:13

I’ll have to modify the result to work in Cursive but having the starting point will help a lot.

cfleming08:02:22

I already have parsers and lexers etc

chrisoakman08:02:39

yeah - I know you've mentioned that

cfleming08:02:40

Which take care of chars inside strings etc

chrisoakman08:02:48

that's one of the things I'm curious about - how fast is this?

cfleming08:02:58

Not sure, I’ll tell you tomorrow :simple_smile:

chrisoakman08:02:02

because in JS it's super fast

cfleming08:02:22

I’ll compare it to a version with a JFlex lexer too, be interesting to see the comparison

chrisoakman08:02:40

looking forward to it :simple_smile:

cfleming08:02:47

Cool, talk to you tomorrow

thomas20:02:21

Hi, can parinfer (in Atom) do block comment?

cfleming22:02:31

@chrisoakman: How are you currently creating the parinfer jar? Just with a command line invocation?

chrisoakman23:02:08

@cfleming: yes

chrisoakman23:02:17

the one in the README

cfleming23:02:36

Clearly I don’t know how to read instructions :simple_smile:

chrisoakman23:02:51

also when debugging I had a main function and would run inside of Intellij

chrisoakman23:02:20

I have no idea if that's the optimal way to make a jar or not?

chrisoakman23:02:27

it's just what I was able to get working

cfleming23:02:31

Ok. I’m just restructuring to build parinfer itself with Gradle so it will generate a proper artifact.

chrisoakman23:02:50

awesome :simple_smile:

cfleming23:02:54

i.e. can be installed into the local repo etc

chrisoakman23:02:59

double awesome

chrisoakman23:02:13

I knew I was not doing things as cleanly as possible (JVM inexperience)

chrisoakman23:02:23

once I got it working I said "ok - that's it! repeat those steps"

cfleming23:02:38

That sounds like me doing JavaScript :simple_smile:

cfleming23:02:57

It might be easier to add me as a contributor to the project rather than use pull requests, this is going to be a fairly large patch.

chrisoakman23:02:58

it's amazing how much "tribal knowledge" is baked into different development ecosystems

chrisoakman23:02:05

yeah; sure thing

cfleming23:02:24

cursive-ide

chrisoakman23:02:59

should be done