|
But... what's the different between 'extending the language' and building an API/library then? I've read McCarthy's paper and I realize the whole thing is built from a fairly basic foundation, which is cool in itself, but I keep getting hung up about that particular choice of words, especially when multiple authors use it to refer to defining functions. I can kind of seeing it make sense when talking about macros. Maybe I just haven't reached lisp nirvana yet.
Colonel Taint fucked around with this message at 23:01 on May 3, 2017 |
# ? May 3, 2017 22:57 |
|
|
# ? May 28, 2024 14:17 |
|
Colonel Taint posted:But... what's the different between 'extending the language' and building an API/library then? I've read McCarthy's paper and I realize the whole thing is built from a fairly basic foundation, which is cool in itself, but I keep getting hung up about that particular choice of words, especially when multiple authors use it to refer to defining functions. I can kind of seeing it make sense when talking about macros. Maybe I just haven't reached lisp nirvana yet. I mean, that's basically the point: Adding new syntax is as simple as adding a library. Consider Clojure's arrow macro: code:
code:
Another good example is Clojure's core.async, which implements a concurrency model similar to Go, but with no need for language support: It's just a library. And you can do this all pretty easily and safely, because the language is written in the same data structures you use for "normal" data. So yes, it's "just" macros, but it's really, really drat good macros.
|
# ? May 4, 2017 00:10 |
|
core.async and core.typed are my favourite examples here. Goroutines and the type system are libraries not language
|
# ? May 4, 2017 01:08 |
|
Colonel Taint posted:what's the different between 'extending the language' and building an API/library then? There's a lot of bullshit around the phrase. My phd is on language extension, and at one point I quote someone from the 70s talking about how the "class" keyword extends the language with new types in this newfangled Simula language! Assume the phrase means nothing, along with other phrases like "strong/weak typing". Look at what they're actually doing instead. SICP was originally authored in 79, it could well be "marvel at functions, you GOSUB BASIC-plebs!" crazypenguin fucked around with this message at 16:52 on May 6, 2017 |
# ? May 6, 2017 16:50 |
|
I just kinda assume that any of the magical stuff that Lisp does was subsumed into modern languages long ago, so none of it is impressive or out of the ordinary for those of us using anything newer than COBOL.
|
# ? May 6, 2017 21:56 |
|
Pollyanna posted:I just kinda assume that any of the magical stuff that Lisp does was subsumed into modern languages long ago, so none of it is impressive or out of the ordinary for those of us using anything newer than COBOL. I think a lot of that stuff has finally been making it into more 'modern' languages only very recently, and each language seems to take different parts. That's why things like Greenspun's 10th rule exist: a lot of complicated software (including other programming languages, IMO), poorly reimplement parts of Common Lisp.
|
# ? May 7, 2017 00:42 |
|
The key thing with Lisp is that the data structure for a function is also exactly the same data structure as anything else. Imagine your language of choice, being able to treat a function as an object (if you're not already able to), but then also being able to map and index on it as if it was an array.
|
# ? May 7, 2017 01:18 |
|
Roadie posted:Imagine your language of choice, being able to treat a function as an object (if you're not already able to), but then also being able to map and index on it as if it was an array. That's JavaScript.
|
# ? May 7, 2017 05:12 |
|
Doc Hawkins posted:That's JavaScript. Interestingly, what became JavaScript was originally supposed to be Scheme, until Netscape decided that their scripting language had to look like Java. Basically JavaScript is what you get if you take Scheme and gently caress it up horribly by trying to squeeze it into a Java suit over the course of 10 days Arcsech fucked around with this message at 05:51 on May 7, 2017 |
# ? May 7, 2017 05:47 |
|
This may not be exactly what's being discussed, but lisp macros always seemed like some sort of arcane lost magic to me until I read this (lengthy) Common Lisp tutorial that walks through building a simple database with functions and then finally uses macros to make an SQL-ish language for writing queries to the database. I found the article so interesting that I briefly tried learning Common Lisp before realizing it's kind of ancient. I ended up trying Racket instead, which I enjoyed but had no real use for.
|
# ? May 7, 2017 06:52 |
|
Clojure is the most modern of the mature lisps, I think.
|
# ? May 7, 2017 07:55 |
|
Doc Hawkins posted:That's JavaScript. In JS, I can treat a function as an object, but I can't go in and muck around with the AST of that function as a normal part of the language.
|
# ? May 7, 2017 19:38 |
|
Roadie posted:In JS, I can treat a function as an object, but I can't go in and muck around with the AST of that function as a normal part of the language. You also cannot do that in any recent version of Lisp. You can get access to the syntax tree at compile-time via macros, but you can't inspect function objects at runtime (unless you made sure to squirrel away their definition somewhere yourself).
|
# ? May 7, 2017 22:24 |
|
I will admit that I have trouble understanding the advantage of having direct access to the AST of a function.
|
# ? May 7, 2017 22:39 |
|
Pollyanna posted:I will admit that I have trouble understanding the advantage of having direct access to the AST of a function. At runtime, there isn't much. At compile-time, being able to emit functions programmatically is a very powerful form of metaprogramming.
|
# ? May 7, 2017 22:45 |
|
A lot of the appeal is that the core language is based around list manipulation and the core data structures are all list based. The entire AST is not only representable as lists but it's most obvious form is those same list structures, so it makes manipulating it straightforward and more "natural" than in any other language.
|
# ? May 8, 2017 18:17 |
|
Hm, I think the idea is starting to set in. It's pretty cool to think of writing programs in that way. Like pure lisp basically - to use a loaded word - transcends other languages in its directness of interpretation. Like it's something of a polar opposite of - but at the same time analogous to - assembly language. On a side note, going through SICP and doing all the little number theory exercises has been good fun. It's been pretty gentle so far so I'm hoping I can keep up with the rest as I go.
|
# ? May 9, 2017 02:41 |
|
Has anyone used Finch? How was it? How does it compare to AkkaHttp or http4s?
|
# ? May 20, 2017 01:05 |
|
While playing around with generic execution models I ran into the following, a typeclass with a function that returns another instance of that typeclass:code:
|
# ? May 20, 2017 12:33 |
|
loose-fish posted:While playing around with generic execution models I ran into the following, a typeclass with a function that returns another instance of that typeclass: The way you've written Processor is requiring that a Processor can be turned into any other instance of Processor by calling process on it, i.e. the return type of process needs to be polymorphic, but when you wrote the instance for P, you fixed the return type as P. You can fix this by requiring Processors to provide you with a generic constructor function: code:
code:
code:
fomo sacer fucked around with this message at 00:57 on May 21, 2017 |
# ? May 20, 2017 16:06 |
|
Thanks for clearing that up! I had a fundamental misconception of type classes, guess the 'forall' should've tipped me off... I'm trying to find a solution for processors with arbitrary local state, and a function to apply an event to the global state according to the current processor. (I say 'State' but I don't care if it's in the State Monad, it's just what I'm using here). This is the best I've come up with so far: code:
code:
|
# ? May 21, 2017 11:53 |
|
How do I install Scheme on Windows? I trying to go through SICP.
Guacamayo fucked around with this message at 05:34 on Jun 2, 2017 |
# ? Jun 2, 2017 05:26 |
|
Guacamayo posted:How do I install Schemeon Windows? I trying to go through SICP. You might try Racket, which can be configured to use R6RS or other Scheme dialects rather than its own custom dialect.
|
# ? Jun 2, 2017 05:30 |
|
Bongo Bill posted:You might try Racket, which can be configured to use R6RS or other Scheme dialects rather than its own custom dialect. Cool Im gonna try that out
|
# ? Jun 2, 2017 05:43 |
|
FWIW, I found SICP to be wildly overrated, but I'm not good with math, and most of the early examples at least involve math stuff. You might want to look at How to Design Programs for a more updated textbook, if you are trying to learn functional programming in general and not Scheme in particular.
|
# ? Jun 2, 2017 08:03 |
|
I've been going through SICP over the past month or two using DrRacket and it's pretty good. I'm currently up to section 2.2. Along with scheme R6RS, you can grab the sicp language pack - using this became especially useful when list structures were introduced. Also I don't know what version of the text you're reading, but there's a pretty good HTML version available on github: https://sarabander.github.io/sicp/html/ e: Trees constructed from lists are the devil Colonel Taint fucked around with this message at 19:50 on Jun 2, 2017 |
# ? Jun 2, 2017 15:33 |
|
Haskell question for you guys - I'm trying to build a cyclic data structure by "tying the knot", and my code compiles but then just hangs when I try to run it. First, some context. I'm trying to build a doubly-linked binary tree. Each node in the tree references a state of a hash function, and non-root nodes include a block of input bytes such that hashing the input (starting from the node's state) yields the parent node's state. It doesn't matter what the actual hash states are, only that this relationship between states holds. As a result, it's much easier to build the tree from the leaves up than from the root down. (Given two states, we can search for inputs that will produce a collision on any parent state, but if we start from the root, we have to search for states and inputs that yield the parent state.) Here's the code: (edit: more concise example below) Sorry for the messiness! I'm still picking up the language and I think I'm probably overdoing it on pattern matching. 205b fucked around with this message at 23:03 on Jun 5, 2017 |
# ? Jun 5, 2017 10:12 |
|
Your pattern matching is mostly fine, although honestly given that the chunksOf 2 is hard-coded to be 2 I recommend getting it to just return a pair. Lists with statically-known lengths are a code smell. In terms of your problem it's pretty difficult to know exactly where the problem is, could you post a smaller snippet that still demonstrates the bug please? Also the Debug.Trace module is handy for this kind of thing, although you might have to be careful that you don't fully evaluate the entire tree when printing at each step, or you'll just move your problem to there.
|
# ? Jun 5, 2017 21:28 |
|
gonadic io posted:although honestly given that the chunksOf 2 is hard-coded to be 2 I recommend getting it to just return a pair. Lists with statically-known lengths are a code smell. chunksOf 2 returns a list of lists of length 2 except maybe there could be a list of length 1 at the end if you didn't statically know that the argument had even length. Therefore, the best you could do is make it into a function that returns a list of pairs and does something counterintuitive at the end for odd-length inputs.
|
# ? Jun 5, 2017 22:03 |
|
dirby posted:chunksOf 2 returns a list of lists of length 2 except maybe there could be a list of length 1 at the end if you didn't statically know that the argument had even length. Therefore, the best you could do is make it into a function that returns a list of pairs and does something counterintuitive at the end for odd-length inputs. Right, if I run out of elements I get a final list of length 1 and then pattern matching fails at runtime. Even if chunksOf gave me tuples, the compiler wouldn't be able to guarantee me an input list of even length. I couldn't think of an unobtrusive way around that. gonadic io posted:Your pattern matching is mostly fine, although honestly given that the chunksOf 2 is hard-coded to be 2 I recommend getting it to just return a pair. Lists with statically-known lengths are a code smell. That's already a huge help because I didn't know about Debug.Trace - I'd been putting conditional error calls in for debugging I cut out all the hash stuff, so now nodes just have an integer value, and parent values are the sum of child values. I also cut the number of leaves to two, so it should be a three-node tree. code:
|
# ? Jun 5, 2017 22:27 |
|
I'm starting to write some small DSLs for work (and well, for fun. It's really fun). I'm building interpreters with Scala and the atto parser combinator library (https://github.com/tpolecat/atto), which is amazing. The DSLs aren't meant to be used from within Scala, it's just that the interpreter / compiler is implemented in that language. My DSLs are declarative but have features like variable dereferencing, function application, native lists, some basic typechecking, etc. I think I did an okay job implementing them, but I was wondering if anyone can point me to some modern literature on compiler and interpreter implementation. I'm aware of some of the papers on Free and extensible effects, but I am not using those techniques here.
|
# ? Jun 15, 2017 02:47 |
|
Typing the Technical Interviewquote:Haskell is a dynamically-typed, interpreted language.
|
# ? Jun 16, 2017 21:58 |
|
That entire series of posts is gold
|
# ? Jun 16, 2017 23:13 |
|
What's the most efficient way in Scala to do pass a String through a number of possible regex pattern and match based on which pattern is matched?code:
|
# ? Jun 19, 2017 19:08 |
|
I'm working through a compiler book with Racket and I'm liking it a lot.
|
# ? Jul 11, 2017 19:32 |
|
emoji posted:I'm working through a compiler book with Racket and I'm liking it a lot. What book?
|
# ? Jul 11, 2017 21:08 |
|
The Elements of Computing Systems and the companion site http://www.nand2tetris.org which works through building a general purpose computer. The hardware is built with an HDL from nand gates and simulated which interprets a machine code, on top of which you write an assembler, vm, compiler, os, etc. Afterwards I'll probably try a more focused compiler text.
|
# ? Jul 12, 2017 00:22 |
|
Hey folks, I'm currently familiar with Java 8's support for functional programming with some basic knowledge of rx Java. I'm moving to a job where I will spend a lot of time in Scala, with Akka. Can anyone suggest any good tutorials to get started with that? Thanks.
|
# ? Jul 15, 2017 08:33 |
|
Any recommended F# blogs and tutorial videos? I tried to wrap my head around FP using Haskell and it just wasn't taking, so I figure I'll give F# a whirl.
|
# ? Jul 15, 2017 20:22 |
|
|
# ? May 28, 2024 14:17 |
|
F# for fun and profit is always the go-to - it has a basic tutorial path but there's a ton of content in there
|
# ? Jul 15, 2017 20:47 |