This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-05
Channels
- # aws (6)
- # beginners (10)
- # boot (33)
- # cider (23)
- # cljs-dev (50)
- # cljsjs (2)
- # cljsrn (10)
- # clojars (1)
- # clojure (215)
- # clojure-czech (1)
- # clojure-dev (5)
- # clojure-italy (23)
- # clojure-russia (18)
- # clojure-spec (11)
- # clojure-uk (53)
- # clojurescript (157)
- # core-async (29)
- # cursive (12)
- # data-science (15)
- # datascript (16)
- # datomic (68)
- # graphql (2)
- # jobs (5)
- # jobs-discuss (1)
- # juxt (17)
- # lein-figwheel (2)
- # luminus (3)
- # off-topic (155)
- # om (3)
- # pedestal (1)
- # portkey (1)
- # re-frame (7)
- # reagent (4)
- # ring (3)
- # ring-swagger (2)
- # rum (11)
- # unrepl (11)
- # vim (1)
- # yada (2)
if you wanted to verify that someone was good a clojure / clojurescript - how would you do it?
have them read some clojure code and explain what it's doing
and have them suggest what improvements they would make
I was wondering if checking their github account is likely (mine is something of a shambles of project started and lost)
I was also wondering if people take the completion of all of the 4Clojure problems as a proxy for knowlege
I haven't done all of them - I'd be more likely to evaluate their answers for quality rather than just counting their answers
@noisesmith having them review describe and enhance some code - thats a good idea
One of the “benefits” of having a certification program - is you can be sure that the person has been exposed to a survey of important ideas
I kinda like the idea of these programs, J2ee architecture certification is something I worked towards
Still without some kind of external individual assessment, it is hard to tell where you really stand … rockstar or cargo culter being the extremes
@bherrmann ask them about the Y combinator. If they have no idea, no prob, but if they do, they can do clojure no prob.
Is it impolite for the Interviewer to tell the Interviewee: We are a Clojure shop. Since you are a "fast learner", can you learn Clojure on your own?
For the record, I've only used the Y once in my entire life and that's when I was trying to recur a lambda in erlang (since it can't call itself without a name)... and that was just a random fun thing I did on my own 😂
I didn't complete all of 4Clojure, jumped straight into CLJS and Om, more fun that way
I got a cljs job by showing clojure/clojurescript code I wrote, probably a good idea to request the interviewee to show code and explain it
Explaining the decisions behind the code and why it's structured the way it is structured sounds like a good idea
Given you can't make them at runtime (well, not w/o really weird herculean efforts), they probably shouldn't be considered first class things
so would you say classes in java are not first class then?
because clojure needs to do some pretty crazy stuff to make classes at runtime
"t treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures"
Is this all true in C?
Then they are first class
Although that's not probably what one wants to say when saying "first-class", maybe another term would be better
For example in php I can return "callables"
Yeah, C supports function-passing in the worst possible way
But....not the same as in JS or Scheme you know
I’m not saying C is so great - rather I’m saying that “first class functions” is a relatively low bar and what we really mean is different. For example late binding, and the fact that the runtime can extend the type system and compile new code.
Maybe anonymous functions would be better for this, since that's what allows the whole thing - making them at runtime, assigning them to vars, returning them from other functions..
Indeed anonymous functions allow functions to be values (not just references)
The last time I used C, I got the impression that you couldn't call a function pointer with arguments - it had to be a void function with no parameters, and if it needed state, it would capture globals you'd have to mutate
Is this not the case?
nah, you can call them just like any other function, just cast it to the correct type to get pass the compiler.
Hmmm. Is there some other reason that GLUT has such an awful API?
never written a line of GPU code in my life but I'd presume legacy and hardware limitations?
https://en.wikipedia.org/wiki/First-class_function#Language_support "Every language" supports first class functions
But anonymous functions...not so much
reminds me of the days of setting registers at hard-coded memory addresses and hoping for the best.... but then some JS APIs feels exactly like this.
@joelsanchez i don't agree with that article. by its reasoning even machine language has first-class functions. but that drains the meaning from "function" and "first class"
computationally a fn is a lambda abstraction. if your language lack a lambda op, it lacks first-class functions.
Yeah that's what I always thought, but there seems to be a lack of consensus around the term "first-class function"
It really depends on interpretation IMO.... arguably most languages' functions aren't even lambda abstractions (in the designer's mind) but subroutines.
Functions as independent values == first-class functions would be better
The closer they are to strings, the better
You can make arbitrary strings at runtime
Return them, etc
so haskell doesn’t have first class functions
in the mind of a purist, there's no such thing as a "pure function" because functions are by definition, pure.
so clojure doesn’t have functions
@joelsanchez the set of functions is closed upon compilation though, it can’t create new ones at runtime
That's a good point
Since every language puts different constraints around functions, there's a set of dichotomies around functions, and a given language may implement only a subset of those
For example, "can make them at runtime?"
"can take them as arguments?"
Kind of like that wikipedia article
well...... that's also quite a tough question... the C compiler is written in C so if your program has a compiler, what's runtime and compile time?
There's the runtime of the compiler, the runtime of your program, the runtime of the compiler inside your program...
but if your program has a C compiler, does that count as the C language being about to create functions at runtime?
fwiw i find it useful to think in terms of computational models. FP languages are based on the lambda calculus, whose central concept is "function". Languages like C are based on a different computational model, Turing or maybe von Neuman or something like that. Where the basic concept is "machine", or maybe "effective procedure". if course they're all equivalent, but the conceptual structure is very different.
I personally like to think of the computation models as mental models as you try to write code and different languages provide different levels of support for each mental model.
so FP languages like Haskell or Clojure "have" first-class fns, which really just means they provide the abstractions that help the peogrammer think in lambda terms, which makes reasoning more reliable. It takes a lot more work to do that in C or Assembler. Such languages force one to think first in machine terms - concrete procedures rather than lambda abstractions.
telling C or Java programmers new to FP that their languages already have first-class fns will only lead to confusion, imho.
(P.S. it is not true that "anonymous" fns have no names. They are names of the functions they denote.)
(fn [x] (+ 1 x))
is the name of the fn that increments its arg. inc
is just a different name for the same function.
@akiroz If it were an interpreter, maybe, but a compiler does not execute the program. Anyway, a Lisp interpreter written in C may be able to execute the program but the C part of it does not know about the functions on the Lisp program, only performs the computation. Being able to compute a result does not equate to creating a function, just because that computation was defined in a language that is being interpreted
A compiler doesn't execute, but you can just set the CPU's program counter to the address of the newly compiled code to run it in a C program.
@mobileink Well the problem is that in some languages (with no anonymous functions) you can't do that, you can only refer to the functions using a name that does not describe the function itself (like inc)
right. such languages do not support 1st-class functions, by definition. well, by my definition. 😉
@akiroz In a similar spirit to the interpreter remarks, that's "another program" so you aren't really creating new functions at your runtime
They are not functions to your program
i'm leaning toward the following simple definition: a language has 1st-class functions iff it has a lambda ("anonymous" function) operator. Everything else (passing and returning fn vals, etc.) follows from that.
As I see it, in the interpreter case, you execute computations but those computations are not functions in your program, but functions in the programs you are interpreting, and in the compiler case it's another program and nothing in that program is anything in your program
@mobileink That's very similar to the comment I made in this same thread, so I agree 🙂
"Maybe anonymous functions would be better for this, since that's what allows the whole thing - making them at runtime, assigning them to vars, returning them from other functions.. [7:50] Indeed anonymous functions allow functions to be values (not just references)"
but since the C compiler is basically written in C itself, you could copy & paste the sourse code of a C compiler into your code base so it's part of your program...
I think that the "compiler inside my program" case just makes new runtimes, or environments if you prefer
In the case of cljs, is js actually creating any clojure vars, clojure maps, etc.? No, just js objects who wrap values that js does not understand to be anything
Although those are different languages, but the point is similar I believe
How does having a compiler inside your program creates a new runtime...? It's the same process (OS-wise).
Conceptually
It would be like saying every 3rd party lib in your program creates a new runtime.....
Not process or thread or that stuff, just a conceptual runtime
Well the "world" for the program inside the compiler in your program looks really different than what it looks like to your program
A runtime results from executing a program that (in this case) a compiler generated
The child program does not have access to the compiler, for example
There is no child program, the compiler outputs machine code to a memory region in your program that you could tell the CPU to execute
you could embed a C compiler, written in Clojure, inside your Clojure application. but you could not run the code it compiles unless you also embed a C runtime, which is a different animal.
mobileink: are you suggesting there is a jvm that exists today that doesn’t include the c stdlib as a dependency already?
they are all written in c++
Indeed
And when you execute that C program you get a runtime, the fact that your program embeds a C runtime does not mean that your program can make C functions
unless you're doing very low-level embedded programming, no OS, no language runtime - but then you would never embed a compiler in an app.
picture this:
- your program calls a compile
function that takes a string (C code) as arg and returns machine code (array of bytes)
- you set the CPU's program counter to that array of bytes and it will execute.
Yes, but will it have access to the compile
function?
I think I'm not experienced enough in low level programming to refute this
as long as the compiled output knows the physical memory address of the compile
function, it can called
Well.... you could consider Clojure's case. It's also a compiled language and it could create new JVM byte code at runtime & execute those in the same runtime
for the JVM target, clojure's compile
function outputs .class
files and you can load them into your runtime via JVM's classloader
Yes, I guess...guess it counts as a really inconvenient way to "create new functions in my program at runtime"
It is like the Y combinator: in this case you are creating new functions at runtime for a language that does not support it, in the case of the Y combinator it is recursion without named functions
akiroz: howsabout TeX, the programming language, not the typesetting system? you wanna see something genuinely "insanely great" check out https://en.m.wikipedia.org/wiki/PGF/TikZ. the best vector graphics language in existence, written in TeX. I'm not making this up.
pretty much drew all the diagrams for my college assignments in TikZ.... and I have to say, I'm not a big fan of it.
akiroz: i didn't say "easiest". ;) but how 'bout all those crazy coordinate systems. geek love at first sight.
With the "it's a new runtime" point I was considering the case where you generate JVM bytecode and execute the program in a new JVM
But I see that was not your idea
Talking about Turing-complete things....
If you haven't heard of it already....
Yes, that's one of the things that blew my mind back in the day
The first one (related to FP) being Church numerals
(I was reading SICP and knew nothing about FP, you can imagine the shock)
Looking at you Category theory...
(Even though Haskell managed to make practical use of it)
I haven't fully read SICP, left half way through to learn (in a more practical spirit) Scheme, then Common Lisp, then Clojure...never returned to SICP, what a shameful human I am
That being said, I bought a physical copy, I like having it
I will read it on a flight I have in some hours, I recommend the version of that McCarthy paper that defined Lisp that includes comments by Paul Graham
Or something like that, it was amazing
Time to use my Google-fu
It is this one but it's in postscript http://www.paulgraham.com/rootsoflisp.html
they really should call it "schonfinkeling" instead of "currying". very tragic life. but you csn find his one paper online, it's totally brilliant.
akiroz: howsabout TeX, the programming language, not the typesetting system? you wanna see something genuinely "insanely great" check out https://en.m.wikipedia.org/wiki/PGF/TikZ. the best vector graphics language in existence, written in TeX. I'm not making this up.