This is code from an episode of Fun Fun Function: https://youtu.be/6sQDTgOqh-I
| machine: | |
| services: | |
| - docker | |
| dependencies: | |
| override: | |
| - docker info | |
| - docker build --tag='test_image' --file=Dockerfile.ci ..: | |
| pwd: | |
| backend |
| const fetch = require('node-fetch') | |
| const Bacon = require('baconjs') | |
| function getInPortuguese(word) { | |
| // Google Translate API is a paid (but dirt cheap) service. This is my key | |
| // and will be disabled by the time the video is out. To generate your own, | |
| // go here: https://cloud.google.com/translate/v2/getting_started | |
| const apiKey = | |
| 'AIzaSyB4DyRHIsNhogQXmH16YKbZfR-lTXrQpq0' | |
| const url = |
I'm mpj, and this is funfunfunction.
Let's say that you have a food type, and you want to make lots of different instances of that food, such as waffles, and I don't know why you'd want any other food than waffles, but maybe you like carrots or something. In that context, food is the prototype of waffles and carrots.
Some of you will be thinking - that reminds me of classes! You'd be right, but they are not the same thing, so try to put classes aside and think of prototypes as something completely new - if you try to shove prototypes into the same place in your brain where you keep classes you'll be very unhappy.
When you work as a programmer, it’s only a small percentage of your time that is spent on writing code. The vast majority of your time is spent trying to understand code that is already written. Either code of others, or code that you yourself wrote a last year.
It’s especially tricky to get into a completely new codebase. You might when you start a new job or perhaps your team takes ownership of a new system.
I have done this a couple of times now, and I have a process for it now, and I figure that it might be interesting to some people to hear about it, and that is what we are going to explore today.
In case you’re new - this is FunFunFunction, a weekly show where we try to become more confident and excited about programming by exploring old wisdom, wild ideas and having fun. At the end of this episode, I’m going to ask to subscribe.
Welcome to funfunfunction!
Today, we’re talking about Clojure, more specifically the syntax of Clojure. I’m doing this episode bit hung over because yesterday was Halloween. I was at a party with scary tales theme. This is my costume, it’s the three bears from goldilocks.
So why look at other languages? We mostly use JavaScript in this show, because it’s the lingua franca of the internet, but we really don’t want to learn JavaScript, we want to learn programming, and to do that we need to expand our horizons.
Clojure is cool because it has almost no syntax at all. Clojure really is to programming languages what the Star Wars lightsaber is to weapons. Let’s compare Clojure to JavaScript:
1 + 2 + 3;if(true) {
console.log("You can have delicious soup.");
console.log("… and a puppy!");
}(if true
(do| var bridge = require('spotify-bridge-request'); | |
| bridge.request('cosmos_request_create', [ | |
| 12871287128327, | |
| { | |
| "action": "GET", | |
| "uri": "sp:\/\/core-collection\/unstable\/@\/list\/tracks\/all?decorate=false&sort=addTime DESC,discNumber,trackNumber&", | |
| "headers": { | |
| }, | |
| "body": "{\"policy\":{\"list\":{\"link\":true}}}" |
| const customerRevenueNode = (store) => { | |
| return createNode({ | |
| accessMemory: { | |
| 'orderCancelled': (order) => | |
| _store.GetByOrderId(order.orderId) | |
| .then((snapshot) => { | |
| snapshot, | |
| save: (nextState) => _store.save(nextState) |