News for hackers. Stuff that matters.

Show HN: Hacker News Clone – Clojure, GraphQL Learning Project

I have ported "The Fullstack Tutorial for GraphQL" series, https://www.howtographql.com/, from Javascript to Clojure/script.

Blog post:

https://promesante.github.io/2019/08/14/clojure_graphql_full...

Source code GitHub repo:

https://github.com/promesante/hn-clj-pedestal-re-frame

Suggestions and corrections, more than welcome.

( 21 comments | 179 points | on HN )
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by cubix on Monday September 02, 2019 @09:27AM (#20858980)
I did a clone of HN in Clojure 10 years ago (wow, time flies), but it just wrote the state out to files: https://github.com/cubix/simplenews

No ClojureScript then, of course. I was planning something more sophisticated for persistence, but never got around to it.

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by sova on Monday September 02, 2019 @11:33AM (#20859707)
Neat, could you provide some annotations or a readme? I'm curious to see how you made this. Only if you have some extra time laying around of course
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by cubix on Monday September 02, 2019 @01:26PM (#20860556)
I might have some time to dust it off tonight.
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by jcadam on Monday September 02, 2019 @09:14AM (#20858915)
Cool! I'm currently working through the lacinia tutorial to learn GraphQL (I've invested a lot of time in getting good at designing RESTful APIs, so GraphQL definitely feels alien to me), making a few changes as I go (I prefer mount to component, for example).
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by Dowwie on Monday September 02, 2019 @09:11PM (#20862941)
And what are you discovering about GraphQL? What have you lost and gained in translation?
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by mckinney on Monday September 02, 2019 @10:27PM (#20863271)
Nice job!

On the whole the howtographql series is instructive but results in a ton of boilerplate code. The GraphQL framework[1] from the Manifold project avoids all of that with the "manifold" concept, which is similar to F#'s type providers.

Currently manifold targets Java exclusively, but the framework is designed to support other JVM languages. Perhaps clojure could be on the radar? Food for thought.

[1]: https://github.com/manifold-systems/manifold/tree/master/man...

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by simongray on Tuesday September 03, 2019 @06:45AM (#20865272)
No relation to Clojure's own manifold library, I guess? I was a bit confused when I visited that github repo you posted and saw a bunch of Java code :P

This is the one I thought of: https://github.com/ztellman/manifold

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by mckinney on Tuesday September 03, 2019 @03:10PM (#20870021)
Ah, no relation, but interesting library!
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by nickik on Monday September 02, 2019 @06:44AM (#20858171)
Interesting. I have wanted to get into GraphQL. As Clojure person I liked the idea but we had some similar stuff already.

I will defiantly look at that code later.

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by slifin on Monday September 02, 2019 @08:22AM (#20858626)
In Clojure we have walkable which can handle graphql and EQL, personally I found holes in the graphql type system that EQL wouldn't have had a problem with @see: Fulcro EQL walkable
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by beders on Monday September 02, 2019 @08:53AM (#20858801)
I like the idea of EQL, but I'm not sure I want to tie myself to Fulcro. Looking forward to more projects adopting EQL.

GraphQL definitely has a number of issues (type explosion being one) that can be avoided with EQL.

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by refset on Monday September 02, 2019 @10:04AM (#20859162)
EQL as a pull syntax for Crux is definitely interesting (and we're considering building something more official): https://github.com/souenzzo/graph-demo
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by masterjefferson on Monday September 02, 2019 @02:38PM (#20861000)
Been looking for a fun way to learn Clojure. Thanks!
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by thanatropism on Monday September 02, 2019 @09:13AM (#20858908)
I've been looking for a motivated tutorial to learn Clojure beyond the syntax and similar basics, thanks for sharing!
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by lucaspottersky on Monday September 02, 2019 @10:25AM (#20859275)
thats a lot of code
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by gryffin on Monday September 02, 2019 @09:24AM (#20858965)
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by sctb on Monday September 02, 2019 @11:34AM (#20859721)
Thanks! We've clickied the main ones.
Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by boarnoah on Monday September 02, 2019 @12:06PM (#20859922)
Not very exposed to Lisp style languages. So take this as you will.

But the actual clojure code looks weird? I get that its a different way of writing from the C like syntax, just that fro a quick glance it doesn't look very pleasant to read due to the how messy the brackets everywhere nature is.

I also feel like reasoning about CRUD problems is easier in a non functional way, but again no real experience with functional languages to say for sure.

EDIT: To illustrate with an example: In C# I can write LINQ using the lambda syntax for queries, however sometimes its useful to be able to break down complex queries into parts, step through with a debugger to follow the logic, don't see how the functional style of Lisp aids in doing any of that (at least not when writing it idiomatically).

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by snazz on Monday September 02, 2019 @12:13PM (#20859975)
Most people new to languages with Lisp syntax find it difficult to read at first. At some point, it becomes natural to read and write it that way. More importantly, it becomes obvious how useful having a consistent and extensible syntax is to writing all sorts of things.

Eventually the C-style syntax feels “messy” because the symbols are used less consistently. At the same time, Lisps like Dylan transitioned to a more conventional syntax and can still maintain lots of the power that they got with S-expressions.

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by dustingetz on Monday September 02, 2019 @12:35PM (#20860154)
Imperative code is structured with ; that terminate statements. var foo = 42;

Functional code is structured with () that composes function calls. foo(bar(42))

All else equal, composition has more interesting structure, which is very helpful for reasoning e.g. flow and dependency graph

Re:Show HN: Hacker News Clone – Clojure, GraphQL Learning Pr... by mbil on Monday September 02, 2019 @12:25PM (#20860071)
> its useful to be able to break down complex queries into parts, step through with a debugger to follow the logic, don't see how the functional style of Lisp aids in doing any of that

In Clojure normally rather than a step debugger one would use an editor with REPL integration to aid in exploring and developing program behavior. E.g. you may capture inputs to the function, and then quickly and iteratively decompose the function and evaluate the building blocks. This type of workflow is often called REPL-driven development.