View clojure-spec-plumatic-schema-comparison.clj
(ns versioned.crud-api-attributes
(:require [versioned.model-support :as model-support]
[versioned.model-spec :as model-spec :refer [Model]]
[versioned.json-api :as json-api]
[versioned.model-attributes :refer [api-writable-attributes api-readable-attributes]]
[versioned.crud-api-audit :refer [updated-by created-by save-changelog]]
[versioned.crud-api-types :refer [coerce-attribute-types]]
[clojure.spec :as s]
[schema.core :as schema]))
View java_vs_clojure_immutable.md

Java

We are using the Builder pattern here. Notice how each field is duplicated about five times and how we need to implement equals and hashCode manually (left as an exercise for the reader):

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@JsonDeserialize(builder = User.Builder.class)
View clojure_vs_java_8.md

Java:

public Optional<String> getType() {
    return this.types.isEmpty() ?
        Optional.empty() :
        Optional.of(String.join(",", (Iterable)this.types.stream().map(Enum::name).collect(Collectors.toList())));
}
View synchronized_function.js
'use strict';
// NOTE: this in memory locking approach will only work with a single process
// You might use something like Redis och memcachached for storing the lock if you need to lock
// across several processes.
var synchronizedFunction = function(lockIdFn, fn) {
var locks = {};
var synchronized = function() {
var args = Array.prototype.slice.call(arguments),
lockId = lockIdFn.apply(null, args);
View clojure-derive-multimethods-example.clj
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BASE CLASS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; public class ContentItem {
; public String foobar() {
; return "content_item";
; }
; }
View gist:b07ed9377153c5ced7e6
'use strict';
var R = require('ramda');
var CATEGORIES = [
{category_type: 'cuisine', id: 1, name: 'French', type: 'categroy'},
{category_type: 'diets', id: 2, name: 'Vegetarian', type: 'category'}
];
var children = {
View gist:496e99b118e7688e2cab
'use strict';
var R = require('ramda');
var blank = function(value) {
return value == null || (typeof value === 'string' && value.trim().length === 0);
};
var present = function(value) {
return !blank(value);
View gist:75aa6cf67f370b5bae4e
// BEFORE REFACTORING (IMPERATIVE)
var filteredLinks = [];
var weekdayCounts = {};
// Limit to 4 links per weekday.
// Loop through all links and keep track of
// how many are in each weekday.
widget.links.forEach(function(link) {
var weekday = link.group;
if (weekdayCounts[weekday] === undefined) {
weekdayCounts[weekday] = 0;
View es6-uncensored.js
// 1. Swith two variables
// ES5
var temp = a;
a = b;
b = temp;
// ES6 - destructuring assignment
[b, a] = [a, b];
View programming-languages.md

Programming Languages

Lisp (1958)

Interpreted, dynamic typing, functional

C (1972)

Compiled, static typing, imperative (procedural)