[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
SICP/Lisp Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 44
Thread images: 12
File: cover.jpg (51 KB, 400x579) Image search: [Google]
cover.jpg
51 KB, 400x579
So I always figured this book was a meme pushed by /dpt/ as a way to feel special about their secret hipster language that went out of date thirty years ago

Fuck me sideways was I wrong, LISP is fucking amazing and any /gentoo/men who haven't read this thing yet get on it

Lisp Thread fagots, show me dem parentheses
>>
>>54291335
It is fun and a good learning book, but LIPS seems like the least useful language possible.
>>
File: Paulgraham_240x320.jpg (12 KB, 240x320) Image search: [Google]
Paulgraham_240x320.jpg
12 KB, 240x320
>>54292045
>seems like the least useful language possible.
read Paul Graham.

No seriously we should argue here. The defining trait of a Lisp (it's an entire family of PLs) is its simple, uniform or almost uniform syntax. By contrast, other languages tend to have special case, complex constructs, and operator precedence rules. I don't think there's any programming task that can't fundamentally be accomplished by any Lisp whatsoever (Turing-completeness, yadi yada), which would make Lisps inherently useless, but feel free to disagree.

With that out of the way, this naturally spawns the long-lasting debate of simple vs complex notation rules, not only Lisp vs others, but also Polish notation vs mainstream notation, and so on. I'm a RPNfag myself (also TIL that my favorite calculator won't be allowed at exam, FML) and a Lisper, but all tastes can be found in nature, so let's also put personal preference aside.

I would argue that, while special cases in syntax (how our widespread algebra operator precedence is adjusted in order to express polynoms without parenthesis, for example) can appeal to intuition - that's what we often hear, be it true or false: infix notation is supposedly more intuitive - it gets stuck very quickly in its own bias, with people unlikely to want to use some constructs, or think some ideas, because they appear ugly in this context (Saphir-Wolff if you hear me). Esthetics and intuition is not what should be used in programming (sorry girls), what we want is intelligence: the ability to explore concepts and their relations. This requires being able to express findings clearly in an unbiaised lang. Lisps do very well because they can be extended with macros, to the point of eager versus lazy evaluation, go do that in Java or Haskell.
>>
File: fourfourtyfour.png (17 KB, 1000x500) Image search: [Google]
fourfourtyfour.png
17 KB, 1000x500
>>54291335
>show me dem parentheses
Here's some Clojure code. Once upon a time, an anon on /dpt/ had a self refering definition (electrical nodes pointing to each other) and wanted a way to "modify" it afterwards and "update" other nodes accordingly. I suggested doing a fixpoint function instead.
(defn gates [self]
{"third" 1,
"second" 1,
"first" (delay (+ @(get @self "second") @(get @self "third")))})
(defn gates2 [self]
(assoc (gates self) "second" 0))

(defn fix&force [f]
(let [self (promise)]
(deliver self (f self))
(into {} (for [[k v] @self] [k @v]))))

(println (fix&force gates))
(println (fix&force gates2))

Then I abstracted the pattern into a "fix" macro. Very convenient
>>
File: clojure.png (36 KB, 500x500) Image search: [Google]
clojure.png
36 KB, 500x500
>>54292470
Here's the whole thing, rate!
(defn source-substitution [form orig rep]
(letfn [(rec [x]
(cond
(seq? x) (map rec x)
(vector? x) (mapv rec x)
(set? x) (into #{} (map rec x))
(map? x) (into {} (for [[k v] x] [(rec k) (rec v)]))
(= x orig) rep
true x))]
(rec form)))

(defn eager-deref [p]
(assert (realized? p) "premature access to fixpoint")
@p)

(defmacro fix [[arg] & body]
`(let [~arg (promise)]
(deliver ~arg (do ~@(for [form body] (source-substitution form arg `(eager-deref ~arg)))))
(deref ~arg)))

(deftype LazyHash [impl] ; omg dependency injection!!!!!
clojure.lang.IPersistentMap
(assoc [this key val] (LazyHash. (.assoc impl key val)))
(cons [this o] (LazyHash. (.cons impl o)))
(containsKey [this key] (.containsKey impl key))
(count [this] (.count impl))
(empty [this] (LazyHash. (.empty impl)))
(entryAt [this key] (let [[k v] (.entryAt impl key)] (clojure.lang.MapEntry. k (force v))))
(equiv [this o] (.equiv impl o))
(seq [this] (for [[k v] (.seq impl)] (clojure.lang.MapEntry. k (force v))))
(valAt [this key] (force (.valAt impl key)))
(valAt [this key notFound] (let [uq (gensym)
res (.valAt impl key uq)]
(if (= uq res) notFound (force res))))
(without [this key] (LazyHash. (.without impl key)))
clojure.lang.IFn
(invoke [this key] (.valAt this key))
(invoke [this key notFound] (.valAt this key notFound))
clojure.lang.IDeref
(deref [this] (into (.empty impl) (for [[k v] impl] [k (force v)]))))

(defn lazy-hash
([impl] (LazyHash. impl))
([k v & kvs] (LazyHash. (apply hash-map k v kvs))))

(defn gates [amend]
@(fix [%]
(amend
(lazy-hash "third" 1,
"second" 1,
"first" (delay (+ (% "third") (% "second")))))))

(prn (gates #(assoc % "second" 0)))
>>
>>54292457
>read Paul Graham.
Maybe later. Now I will use my time on something more productive.
I can read all about theory, cs problems and why I should use this language and algorithm over this one, but I would rather spend my time on something more pragmatically productive on my spare time.
Also getting a bit tired of all those parentages after half a year with this book. Really fun though, but I need to take a break from this before I pick it up again later.
>>
>>54292532
Unmaintainable crap/10.
>>
>>54292470
Clojure is awesome.

A couple of buddies and I are trying to start a small business. I've been working on the backend of our site with Clojure (using Compojure and Carmine for Redis). Without any optimization on my part, siege was getting just over 200,000 requests/second on a crappy VM I'm developing on.

I hardly doubt we'll ever need more than that. If we do, I can easily fire up more instances of the application. We're already using nginx as a proxy and to handle SSL, so we can just make it load balance across additional instances if necessary. After a couple of those I can shard Redis trivially.

Scalability has never been simpler.
>>
I tried lisp when I tried to extend GNU Emacs and it was fun. Seems like a comfy language with probably the best syntax I've ever seen.
>>
File: 1457029773526.jpg (742 KB, 2272x1704) Image search: [Google]
1457029773526.jpg
742 KB, 2272x1704
>>54292818
Right, it was my second PL, and now it is my everyday tool, as well as my religion. There is something special about Emacs and the way things were done in the golden age, something that can't be told, or so I guess...

Also muh Practical Software Freedom, come and tell me how awful it goes in a non-Lisp PL
>>
lisp syntax seriously pisses me off

it's not clear at all
>>
File: 1456133419115.png (135 KB, 600x551) Image search: [Google]
1456133419115.png
135 KB, 600x551
>>54294024
Pic related
>>
There's a reason why C syntax became the dominant syntax that 90% of languages were based on.

It's easy for a programmer to read, even if they don't know C.
Lisps and other functional langs are literal idioglossia in comparison.
>>
Scheme is not a Lisp.
>>
>>54294079
C is just very clear to read, you know where things begin and end.

Lisp just kind of blends together.
>>
>>54294082
Yes it is.
>>
>>54294082
Why not?
>>
File: 1456339111292.jpg (298 KB, 800x650) Image search: [Google]
1456339111292.jpg
298 KB, 800x650
>>54294100
>It's easy for a semitrained codemonkey to read, even if they don't know C.
Repeating myself Here but intuitiveness is not required for a programming language or calculator input mode. Maybe it's effective at getting you in at first because it is easy, but it's actually an arbitrary clusterfuck loosely that you have to workaround if you want to think in depth. Maybe you can Kode(tm) using that, but us male-minded people would rather use reason over feelings when we program.
>>
>>54294245
-loosely
>>
>>54292649
You're probably just retarded if you're having problems with something this pure and simple.
>>
>>54294245
why is every lisp programmer so pretentious
>>
>>54294319
Don't get butthurt Klossy, I'm not attacking you, I'm using the stereotypical way in which most women think to contrast a point. I'm a feminist: I want equality, but this means that I encourage both men and women to think my way in the same fashion. Likewise, individuals of both sexes are free to disagree, but I will hold their counter-arguments to the same standard. Let me ask you again: do you think that intuitiveness preempts profoundness and versatility? If not, do you disagree with me on infix notation with millions of special cases being shallow and specific?

Be a man and answer the point. see pic related, you and I deserve a debate higher on this scale.
>>
>>54294509
>everyone that doesn't suck Lisp's dick is karlie kloss
loling irl
>>
File: emacslogo.png (32 KB, 302x260) Image search: [Google]
emacslogo.png
32 KB, 302x260
>>54294525
I'm not claiming this you fuckwith, this is both an example of such a person and a response to a response to tone. Now grow a brain.
>>
>>54292762
that's not clojure but jvm being awesome.
>>
File: tip.jpg (44 KB, 469x463) Image search: [Google]
tip.jpg
44 KB, 469x463
>>54294245
>>54294509
>this is what lisp users are like
ometedou dude
>>
I was in the middle of teaching myself Ruby and Ruby on Rails, but somehow ended up reading about Common Lisp.
Is this a good starting point?
http://www.gigamonkeys.com/book/
>>
>>54294940
Hate to say this to you but you're low on the Graham Pyramid, as well as on the irony detecting scale. Pretty autistic if you ask me.
>>
>>54294577
combination of both, really.
Mainly it's immutability guarantee and the STM from Clojure which lets the JVM avoid being retarded when it matters.
>>
File: 1421969834243.png (76 KB, 560x399) Image search: [Google]
1421969834243.png
76 KB, 560x399
Common Lisp is Jewish

If you use Common Lisp, you reject Jesus and go to hell
>>
>>54294082
What are the properties of a Lisp?
>>
>>54295145
But isn't Jesus the king of the Jews?
>>
>>54293998
>weirdest cat ever
>>
>>54292762
I myself started a company where the product is the site, and did it in ASP.NET out of convenience. Quite a lot of code and classes and ORM and other dumb bullshit. It was huge and hard to keep upright with two people, but we finished it and it worked.

Then we decided to re-do the site verbatim in Clojure. I'm continually shocked by how goddamn small and easy-to-navigate our codebase is, and how fucking ridiculously fast the web serving is. The heaviest logic organizes data for pages, and those sorts of functions never exceed 10-15 lines.

I think one page which previously took a couple hundred lines of C# to get shaped up took 13 lines of Clojure. Fucking insanity.

Does anyone have any experience with core.typed? Or using defrecord? Thinking of making our DB entries (which we pass around as maps) more performant and checkable statically.
>>
I'm confused as to which dialect of lisp I should start out on. Should I use emacs and learn with it in parallel with a lisp?

I've given some thought to trying out Scheme and even have a copy of The Little Schemer, but I get lost in it.
>>
File: sicpthankyou1427512241060.png (752 KB, 707x898) Image search: [Google]
sicpthankyou1427512241060.png
752 KB, 707x898
>>54291335
we tried to tell you OP
you watched the lectures too right?
https://archive.org/details/MIT_Structure_of_Computer_Programs_1986/
>>
>>54294082
are you retarded?
it's like, the quintessential lisp
the beautiful minimal straightforward core of lisp
>>
>>54297159
do you know some good resources to learn Clojure and preferably functional programming at the same time? I found such book for Scala:
http://www.amazon.com/Functional-Programming-Scala-Paul-Chiusano/dp/1617290653
I read 2 chapters, but I realized I absolutely hate Scala syntax and could get myself to finish it.
>>
>>54297642
Clojure for the Brave and True. The web site is free.

I also learned a good bit of functional programming on the F# for Fun and Profit site, it's got some pretty good explanations of immutable data and how to model computations with functions and values.
>>
>>54294509
using yellow font color should be the lowest tier in this pyramid
>>
>>54297857
thanks!
>>
So let me save you guys years of your life:
Scheme is awesome as fuck, but none of the implementations are compatible with each other, and none fully implement standards. They also have vastly different performance and the best performing ones are the least compatible. They each have their own implementation of features any language needs, because the scheme standards are TOO lean. Common Lisp lacks these problems for the most part (most implementations are fast, support the majority of the language, and code 95% of the time works between different implementations), but the language sucks compared to Scheme. It probably won't be apparant at first that it sucks, but it does. You will agree most likely. If the scheme people made a standard that eliminates the need for implementors to 'roll their own' features, all would be good. The only option is to pick one and stick with it's drawbacks. I guess most people choose PLT scheme, which is far from lean, and kind of sucks, but there you have it. I guess it;'s not too bad if you're into having too many options and a giant monster of an environment.. I'ts worth playing with to learn about amazing shit like the Y combinator, combinatory logic, and other stuff that haskell, javascript, python, etc. completely ripped off and did poorly at.
>>
>>54298115
I am hoping r7rs little and big are successful at that.
>>
>>54292457
>I don't think there's any programming task that can't fundamentally be accomplished by any Lisp whatsoever
you can say that about INTERCAL
Thread replies: 44
Thread images: 12

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.