Fork me on GitHub
#hoplon
<
2015-09-05
>
xifi19:09:52

I had code of form (body (div ... (let [...] (textarea ...) (div ...)))) which didn't show the textarea. My understanding is the let only returned the last thing, which is the div. So 2 questions really 1) I did [(textarea ...) (div ...)], is that ok? I mean that splices the stuff in but not sure if this is idiomatic 2) if the let holds cells, will they live on as the site goes?

micha20:09:47

sure, vector splicing is idiomatic, and the cells will live on as long as something references them (if nothing references them they'll be collected with the garbage)

xifi20:09:12

I also just noticed that I get nil from cljs repl on .-innerHtml call while I get a non-nil result in chrome console

micha20:09:35

what were you calling that on?

xifi20:09:39

makes sense, thanks! What should I hook on in a textarea

xifi20:09:48

to get incremental changes noticed

micha20:09:00

probably :keyup?

xifi20:09:05

I'm building a markdown editor, as a toy project

xifi20:09:30

hm, on a DOM element? 😄

xifi20:09:38

a textarea element

xifi20:09:53

I just found it has a value attribute

micha20:09:56

you want to do someting whenever the contents of the textarea are modified by the user, yes?

xifi20:09:54

yes, keyup seems to be working fine

xifi20:09:01

the last important part is that showdown has a makeHtml method which returns a string like <h1 id="Hi there">Hi there</h1>

xifi20:09:36

now I need to find out how to dump that in my div, apparently dropping it in as the last argument to div won't do the trick

micha20:09:07

this might be something you can use for wiring up inputs to cells: https://gist.github.com/380a072d8b69cbffebd7

micha20:09:29

that lets you do like (textarea :state some-cell ...)

micha20:09:38

and it's a 2-way data binding

micha20:09:52

like if the user updates the textarea the cell will be updated, and vice versa

micha20:09:29

for the "<h1>...</h1>" markup as a string you can use jquery

micha20:09:51

(aget (js/jQuery "<h1>hi there</h1>") 0)

micha20:09:52

forgot that returned a jQuery object, so you need to do aget to obtain the bare dom element

xifi20:09:26

(div :id "preview" :class "flex-auto col-6" (-> md-parsed js/jQuery (aget 0))) <- this still shows me text, not DOM elements

xifi20:09:41

md-parsed is the string

micha20:09:02

i don't see how

micha20:09:11

is it escaped?

micha20:09:35

"&lt;h1&gt;hi there&lt;/h1&gt;"

micha20:09:38

or soemthing?

micha20:09:26

if you do jQuery("<h1>hi there</h1>")[0] in the js console you see the right thing

xifi20:09:21

trying stuff out, I'm still very crude at this simple_smile

micha20:09:15

a fellow i3 fan, i see simple_smile

micha20:09:42

can i see your code?

xifi20:09:00

oh dear once I tried the wm I was like "why would I use a de again?"

micha20:09:30

hah i found ways to disable tabs in things like chrome

micha20:09:46

so it just opens new windows and i3 manages them

micha20:09:04

a tabbed i3 window is way better than chrome tabs

xifi20:09:37

I should really use refheap 😄 Is there a cli for it?

xifi20:09:37

btw this is the first time I'm running chrome in years. I'm an FF fan but apparently everyone recommends chrome for development

micha20:09:55

think you want (cell= (-> md-parsed js/jQuery (aget 0)))

micha20:09:08

actually, you probably want

xifi20:09:28

that shows the first line correctly, which is already a small success

micha20:09:29

(cell= (-> md-parsed js/jQuery .get vec))

micha20:09:57

yeah the .get vec business makes it a vector of them

micha20:09:09

instead of aget 0 which is just the first one

xifi20:09:32

any more tips on the code?

micha20:09:08

that's looking good!

xifi20:09:33

learning everything at once is sometimes extremely difficult, but it's fun to see some reward like this

micha20:09:47

take a screenshot of the working thing simple_smile

xifi20:09:10

by everything I mean everything. HTML/JS/CSS, CLJS, GCC, jQuery, cljs packages, ...

micha20:09:53

:thumbsup: looks great

xifi20:09:49

I figured this will be a simple enough project to get my feet wet. Just a few finishing more things I want to try and I'll pop it on github if you want to

xifi20:09:09

wanted to try playing with the css to have it horizontal on big screens and vertical on small ones

xifi20:09:32

add scrollbars, stuff like that

micha20:09:39

how is basscss?

xifi20:09:44

not too much though, this is really just a toy

xifi20:09:04

well I haven't used anything else before so I don't know what to compare it to

xifi20:09:21

but it feels nice to use in general

xifi20:09:31

the classes are quite simple and compose well

xifi20:09:24

I think it's a good choice for me for now since it makes working with css quite simple and since the whole thing is just a lot of small classes I can open up the css and check out what's in it

xifi20:09:49

so I can type away and if need arises look into the classes to see what is what exactly

micha20:09:56

yeah i need to get a better understanding of how css fits together

micha20:09:07

like in general

xifi20:09:19

what do you mean how it fits together

micha20:09:34

well like with hoplon you have the power to form real abstractions

micha20:09:51

but you need to understand how it all fits together conceptually to make useful ones

micha20:09:41

like i'd prefer to have the classes handled for me by some more general abstraction in my code

xifi20:09:42

so you're talking of a cljs css lib

micha20:09:58

or something that composes these basscss classes

micha20:09:21

i just don't know enough to see the big picture and which concerns are orthogonal and which aren't

micha20:09:40

seems like the whole css thing should be a lot simpler

xifi20:09:08

I understand what you mean, I feel like cheating too when space-joining classes in a string simple_smile

xifi20:09:25

the DOM elements are objects, are the attributes too?

micha20:09:36

and the special cases

micha20:09:54

like it seems as if css is endless special cases

micha20:09:24

there must be something simpler that can figure out how to arrange itself given general specifications

xifi20:09:40

well css is the "standard" so anything you build would have to boil down to that, right

xifi20:09:48

just like cljs boils down to js

micha20:09:54

well css is just properties on js objects

micha20:09:59

i mean in the DOM

micha20:09:24

the stylesheet language is parsed by the borwser, and the end result is properties of objects being changed

micha20:09:46

we can change object properties till the cows come home in a real programming language

xifi20:09:15

ok, nevertheless my point is still the same, even if it's js object props, you only have those props

xifi20:09:54

and since they are quite broken and inconsistent across browsers

micha20:09:17

ugh, yeah

xifi20:09:24

you probably want to rely on some abstraction that hides it

micha20:09:54

polyfills perhaps

micha21:09:24

i think a lot of that is because of the general uselessness of false programming languages

micha21:09:35

they don't provide a means of abstraction

xifi21:09:44

interestingly enough the generator of the site generated a css file that only contains the most common one

micha21:09:57

so they are forever forming committees to decide how the language syntax should be and what primitives they should have

micha21:09:20

in lisp we just write a function or a macro ourselves and go on about our business 5 minutes later

micha21:09:27

with the problem solved

micha21:09:50

the js guys have been working for years on a specification for let and => lol

micha21:09:53

it's pathetic

micha21:09:01

in cljs that's a 5 line macro, at most

micha21:09:11

and no committees needed

micha21:09:24

they're needing to update every browser in the world to support it

micha21:09:29

it's really sad

micha21:09:48

css is the same

micha21:09:16

if they don't provide a way to progam then they need to support every permutation of everything you could ever need, explicitly and individually

xifi21:09:22

it's funny for sure simple_smile

xifi21:09:56

I remember watching a crockford video

xifi21:09:41

where he said the sole developer of js (which he wrote in like 2 weeks) wanted to implement scheme but the higher-ups said "ugh that looks ugly, noone will want to write that. Make something that looks more like java."

xifi21:09:13

I'm still wondering what would the web be like had they let him implement scheme in the browser

micha21:09:17

they could have done it, i think the scheme thing is a lie

micha21:09:47

i bet he never really wanted to use scheme

micha21:09:02

i'm extremely skeptical of eich

micha21:09:27

i mean he implemented js as an implementation of this highly experimental prototypical inheritance thing

micha21:09:46

he didn't even use anything with any real background

micha21:09:17

scheme wasn't any weirder than the obscure research project he plundered for ideas on js

micha21:09:42

it also shows how crucial it is to support macros in a programming language that is expected to be widely deployed and long lived

micha21:09:07

if js had macros the es6 guys wouldn't need to upgrade every browser in the world to have let

xifi21:09:11

yeah, but his project looked like java

micha21:09:25

he could have used m-expressions, like mathematica

micha21:09:41

(foo bar baz) => foo(bar baz)

micha21:09:55

you can still have macros with that

micha21:09:05

and it looks deceptively like stupid things

xifi21:09:23

I like sexps

xifi21:09:29

I just can't help myself

xifi21:09:35

all the parens

micha21:09:51

haha yes, parens are the business

micha21:09:25

the clojure guys like to count them, and show that java source has more of them

xifi21:09:51

I had a funny path, I studied some programming at school, stuff like C++, Matlab, Mathematica. Then at work I had to pick up VBA. In my spare time I was looking around for other stuff and hit into clojure

micha21:09:02

foo.bar() vs (.foo bar), same # parens

xifi21:09:44

that meant 3 months until I "got" lisp, functional programming and laziness, at least the basics so I could solve the first 20 project euler solutions

xifi21:09:29

and then I tried a dozen other languages. python, CL, Haskell, OCaml, Java, JS, Julia, Racket

xifi21:09:37

and now I'm back at the beginning simple_smile

xifi21:09:46

yeah but there's a slight difference in 2 + 3 * 5 - 4 and (- (+ 2 (* 3 5)) 4)

micha21:09:35

but overall there is so much less code that you end up saving a lot of parens at the end of the day

xifi21:09:49

well, java is horrible 😄 I puke everytime I see it. public static void main

xifi21:09:41

you have to write like 20 loc before you start actually coding. And when you come back to the code you cannot see it in the midst of all the boilerplate

xifi21:09:54

the worst part is I use an even worse language at work 😄 I once rewrote a left-leaning red-black tree java implementation to VBA and it was like twice in lines of code

micha21:09:20

haha yeah

xifi21:09:22

and the performance was just awful simple_smile

micha21:09:37

i wrote a sort of CAD program in VB for excel once

xifi21:09:52

when I dropped 200k things on it it took like 3 seconds to build and 8 for the GC to collect

micha21:09:53

for designing boats

micha21:09:30

and a VB program to compute how to load a cargo ship from an excel spreadsheet of the various containers the ship will carry

micha21:09:43

they were all terrible programs

xifi21:09:22

they all are simple_smile If you saw what I have to deal with at work...

xifi21:09:36

spreadsheet transformation chains

micha21:09:41

excel is the ultimate interface to a program though

xifi21:09:42

ridiculous

micha21:09:57

like if you have some program that performs some complex calculation

micha21:09:05

feeding it from excel is amazing

micha21:09:24

because the user can preprocess the input and postprocess the output in their own formulas and graphs

micha21:09:38

it's the optimal ui for the user i believe

xifi21:09:59

Excel could be great if the non-VBA side had a bit more things

xifi21:09:22

and a REPL 😄

micha21:09:30

it is a repl

micha21:09:35

that's the awesome thing about it

xifi21:09:53

it's not, not in the sense I mean at least

micha21:09:13

we would do things like get an iterative solution to some problem really fast, by just pasting into the worksheet

micha21:09:24

pasting until it looked like the value converged

micha21:09:31

and then you have your number

micha21:09:51

like so solve certain differential eq or whatever

micha21:09:16

that's like what you'd use a repl for, but i think better ui

micha21:09:27

or like sometimes you can get an answer if you have some invariant, where leftside - rightside = 0

xifi21:09:35

what I meant is you can't type somewhere stuff like "copy the data where column C says "Y" to a new worksheet" or "filter to records that meet this and that"

micha21:09:40

you can play with the inputs for one side until it becomes close to 0

micha21:09:55

so you can find by bisection the root of something or whatever

micha21:09:14

yeah the excel formula language is lame

micha21:09:21

but like javelin cells though

xifi21:09:25

the spreadsheet part is cool, I would kill for local variables

micha21:09:26

they can contain anything

xifi21:09:36

but other than that it's OK

xifi21:09:45

and collections simple_smile

micha21:09:48

i imagine a spreadsheet where the cells are javelin cells

micha21:09:52

yeah that's key

micha21:09:01

the RANGE and whatnot are not real collections

micha21:09:19

also cells need to be able to contain functions

xifi21:09:43

looks like a new project for you simple_smile

xifi21:09:03

CloSheet or something

micha21:09:12

i started it back in like 2009, using perl

micha21:09:20

but i got sidetracked

micha21:09:31

the idea was to make an engineering spreadsheet thing

micha21:09:56

where you could generate all the documentation about your calculations automatically

micha21:09:22

and make powerful programs that use libraries for like ISO codes etc

micha21:09:09

i don't think there is much money in something like that though

xifi21:09:23

you could scrape up a small project where the UI would be a grid of cells that would look like a spreadsheet and work with javelin as the backend

xifi21:09:51

similar to excel, values are values, (= ...) is cell=

micha21:09:33

and instead of needing to go into VB land to make functions, you can just put a function in an input cell

micha21:09:52

(cell (fn [x] (inc x)))

xifi21:09:33

I'd totally use that, except that it wouldn't handle the mass of data people put into spreadsheets here simple_smile

xifi21:09:53

who needs databases

xifi21:09:05

when you have excel

micha21:09:09

i bet it could be as efficient as Excel for sure

xifi21:09:41

I don't know, all I know is LibreOffice Calc performance is horrible compared to Excel

xifi21:09:54

when it comes to tens of thousands of rows of data

micha21:09:27

it's like alan says, spreadsheets are what people use to make programs when they get tired of waiting for months for the engineers to write special-purpose programs

xifi21:09:42

oh yeah and VBA can only use 1 core, how cool is that in 2015

xifi21:09:06

it has many quirks and bugs simple_smile

xifi21:09:14

much like css now that i think about it simple_smile

micha21:09:26

i'm not surprised that libre office is slow for large things

micha21:09:31

i'm sure they don't ever test that

xifi21:09:33

the most used stuff is the most crappy one

micha21:09:00

but it also does a million things you don't need

micha21:09:22

like formatting fonts and videos and all kinds of nonsense

micha21:09:56

what you want is a separate program to format your presentation, i think

xifi21:09:02

yeah that's really bad in spreadsheets, because people tend to mix data and presentation together. And when that becomes my input I am truly, utterly disgusted simple_smile

xifi21:09:46

noone thinks how the data will flow, they just want to see nice views of the data and that's it

xifi21:09:16

@micha: is there any resources you can recommend (for cljs in general)? I'd love to e.g. see someone work with chrome, debug stuff etc. I watched your hoplon talk with Alan and most of the vids (if not all) on the old hoplon page

micha21:09:56

hmm not sure

micha21:09:10

we use the boot-reload stuff during development

xifi22:09:53

out of curiousity, what editor do you use?

micha22:09:14

i use vim

micha22:09:22

i switched to emacs for a year or so

micha22:09:29

ended up switching back in the end

xifi22:09:40

emacs right now

xifi22:09:59

didn't use vim too much, like the keys but not the program

micha22:09:10

have you seen spacemacs?

xifi22:09:13

I used evil-mode in emacs for a long time, now I'm back to plain old emacs bindings

xifi22:09:22

yes i know about it, haven't tried it though

micha22:09:35

a number of people at my work useit

micha22:09:43

i tried it, it's pretty cool

xifi22:09:52

the best concept I ever saw was this though - https://github.com/mawww/kakoune

xifi22:09:13

the key bindings and the selection concept is just awesome in this one

xifi22:09:23

IMHO of course

micha22:09:16

also neovim

micha22:09:30

i haven't tried it yet but it seems like a great idea

xifi22:09:43

yeah I hope it catches up

xifi22:09:06

I'd love to get the kakoune bindings in emacs or lighttable or something. But I don't have the time and will

micha22:09:24

does it have some kind of paredit mode?

micha22:09:27

kakune that is

xifi22:09:28

oh actually I was lying about plain emacs bindings, I use lispy

xifi22:09:40

unfortunately no

xifi22:09:15

the author is a C++ dev so most of the functionality is geared that way

xifi22:09:00

and writing plugins is, hm, interesting, since the editor doesn't have a scripting language. You should just use what you like and pipe stuff in and out

xifi22:09:40

still, if you like to try out editors I highly recommend this. I had trouble coming back to emacs after using kakoune since the editing is so great

xifi22:09:20

emacs has multiple-cursors plugin but it's just not the same

micha22:09:33

i like the piping method

micha22:09:36

very unix

micha22:09:16

i use the vim multiple cursors thing too

micha22:09:17

sometimes

micha22:09:22

it's not that incredible really

xifi22:09:38

this one is simple_smile

xifi22:09:14

and the basic bindings aren't that complicated. Shouldn't be that hard to reimplement in another, more full-featured editor

xifi22:09:22

have you ever tried lighttable?

micha22:09:20

it was a while ago

micha22:09:37

it kept crashing or locking up trying to evaluate things that were too big for it

xifi22:09:09

I checked the github commits, not as alive as I would hope

xifi22:09:19

also, last binary release from november :S

micha22:09:24

it's a monument to complexity fetishism

xifi22:09:15

I'd go for a modern editor/IDE that has lisp in its veins

micha22:09:36

alan and i were working on a thing, "parenthescope"

micha22:09:51

a structural editor where everything is paredit mode

micha22:09:55

including prose

micha22:09:35

but it's a lot of work to make an editor lol

micha22:09:06

the idea was that everything is structural and you can nest modes

xifi22:09:13

yeah, kakoune has >3k commits and the author has been working on it for 3+ years

micha22:09:16

each mode determines how to parse the structure

micha22:09:43

so like in a prose mode the expressions would be lines of text

micha22:09:58

and the atoms would be characters in the line

micha22:09:27

or rather words, then characters inside the word expressions

micha22:09:39

but you can express "foo\nbar baz\nbaf" as (((f o o)) ((b a r) (b a z)) ((b a f)))

micha22:09:37

if you have paredit everywhere you can write powerful functions to manipulate the content

micha22:09:52

because the api is completely defined by the paredit operations

micha22:09:23

so you can probably implement any editor interface you want on top of that

xifi22:09:54

sounds interesting

xifi22:09:12

so new spreadsheet and new editor, go micha

xifi22:09:19

you got some work to do!

micha22:09:06

the video is glitchy because of how it was recorded

micha22:09:10

we moved to a browser frontend later

xifi22:09:03

looks cool

micha22:09:16

maybe it's time to pick it up again

micha22:09:27

it's kind of entertaining editing your editor in itself

micha22:09:15

one thing it had was universal formatting rules, so no agonizing over whitespace

xifi22:09:44

that's when you know your editor is getting real simple_smile

micha22:09:20

it's pretty sweet to be able to have your editor exactly how you like it

micha22:09:45

like one thing it did was center the code in the window

micha22:09:51

which i find very soothing

xifi22:09:23

surely it can be done in emacs simple_smile

micha22:09:29

i couldn't figure it out

micha22:09:32

there is a fringe thing

micha22:09:40

but it can be at most 8 characters or something

micha22:09:52

neither of them can do it

xifi22:09:17

by centering code you mean your cursor is always at the center row?

micha22:09:26

no like the margins

micha22:09:48

like on my cinema display if i don't have vertical splits, the code is way over to the left

micha22:09:51

all lopsided

micha22:09:21

it's not a huge deal but it's surprisingly restful to have the text in the middle of the editor area

xifi22:09:03

now I'm wondering if you'll get back to it simple_smile

xifi22:09:10

gotta go get some sleep now

xifi22:09:22

thanks for the chat misha

micha22:09:28

likewise!

xifi22:09:35

micha I mean, oops