Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Carbon dioxide posted:

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.

Twitter's Scala School was great but is now painfully out of date. I'm sure there's a tutorial somewhere that's reasonably current. Akka's docs are pretty good if you're want to sit down and read through them, although terrible if you want to google something.

Adbot
ADBOT LOVES YOU

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


Does Twitter use Scala anymore? IIRC they started moving away from it at some point.

Sedro
Dec 31, 2008

Beamed posted:

Does Twitter use Scala anymore? IIRC they started moving away from it at some point.

They're still using it

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.
Are they still on 2.8?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sedro posted:

They're still using it

But are they still making new things with it or just maintaining things they can't bear to replace

Hypnobeard
Sep 15, 2004

Obey the Beard



I'm trying to create a lexer using leex in Erlang 19/Elixir. I'm having problems matching angle brackets. The lexer compiles fine, but trying to let the string ">" results in an error:

No function clause matching in lists.sublist/2

The following arguments were given to lists.sublist/2:

#1
">"

#2
1

Pretty sure the angle bracket is screwing with the string formatting in Erlang. Anyone have an idea how to parse angle brackets? What am I screwing up?

MononcQc
May 29, 2007

Hypnobeard posted:

I'm trying to create a lexer using leex in Erlang 19/Elixir. I'm having problems matching angle brackets. The lexer compiles fine, but trying to let the string ">" results in an error:

No function clause matching in lists.sublist/2

The following arguments were given to lists.sublist/2:

#1
">"

#2
1

Pretty sure the angle bracket is screwing with the string formatting in Erlang. Anyone have an idea how to parse angle brackets? What am I screwing up?

That looks like Elixir syntax; Elixir strings are actually Erlang binaries by default, and are incompatible with the string module. Try binary:part/2 or one of the string module functions (starting OTP-20 the one in Erlang supports unicode properly)

Hypnobeard
Sep 15, 2004

Obey the Beard



MononcQc posted:

That looks like Elixir syntax; Elixir strings are actually Erlang binaries by default, and are incompatible with the string module. Try binary:part/2 or one of the string module functions (starting OTP-20 the one in Erlang supports unicode properly)

Yes, it is from Elixir, though I'm still calling the Erlang directly.

Ahhh.. durr, need to pass a char list in instead of an Elixir string. The simplest things...

timick
Apr 7, 2016


205b posted:

code:
leaves :: [Node]
leaves = concat leafPairs
    where
        valuePairs = chunksOf 2 [1..2^k]                   -- I can trace this
        parentValues = map sum valuePairs                  -- and this
        parents = getParents $ zip parentValues leafPairs  -- but not this
        leafPairs = zipWith build parents valuePairs       -- or this
        build parent [valueA, valueB] = [Node valueA r, Node valueB r]
            where r = Leaf $ Parent parent


-- We're down to one parent, so make it a root
getParents :: [(Integer, [Node])] -> [Node]
getParents [(value, [childA, childB])] = [Node value $ Root children]
    where children = Children childA childB
The problem is the the recursive definition of leafPairs, which depends on parents which depends on leafPairs and so on.

Workaday Wizard
Oct 23, 2009

by Pragmatica
can someone motivate me to learn clojure? what can it do better? a demonstration would be nice.

i keep telling myself to learn it but i cant seem to find value in it :(

205b
Mar 25, 2007

timick posted:

The problem is the the recursive definition of leafPairs, which depends on parents which depends on leafPairs and so on.

Is it a problem specifically because I'm trying to pattern match in getParents? Otherwise, I thought mutually dependent declarations were ok.

Pollyanna
Mar 5, 2005

Milk's on them.


Shinku ABOOKEN posted:

can someone motivate me to learn clojure? what can it do better? a demonstration would be nice.

i keep telling myself to learn it but i cant seem to find value in it :(

The value I found in Clojure is 1. it looks cool and Lisp is cool 2. I wanted to get better at it. Other than that, you can pretty much say for 99% of everything "why would I want to do this when I can already do it with X?", so I can't really help you there cause I'm very similar to you in that regard :(

Trying to psyche myself up to try making Doom WADs in a very similar fashion, actually.

timick
Apr 7, 2016


205b posted:

Is it a problem specifically because I'm trying to pattern match in getParents? Otherwise, I thought mutually dependent declarations were ok.
It has to do with the way that you've defined your tree. To create the parent node you need two child nodes, to create a child node you need a root node. Evaluating the tree will loop forever. Keep in mind that the parent field in a node is not a pointer or a reference to the parent node, it is a new copy of the parent node (which in turn will have new copies of child nodes...).

I'm not sure what you're after but would it be enough to have a leaf that looks like this instead?
code:
Leaf Integer
Where Integer would be the Integer value from the parent node.

Votlook
Aug 20, 2005

Shinku ABOOKEN posted:

can someone motivate me to learn clojure? what can it do better? a demonstration would be nice.

i keep telling myself to learn it but i cant seem to find value in it :(

It will improve your Java stacktrace reading skills

Seriously though, my main reason for learning Clojure was the interactive development style it allows, with the REPL you
can inspect and incrementally change stuff in a running application, which is way more fun than the edit/compile/run cycle most languages offer.
It also has nice datastructures that can be read & printed easily, which is super nice for debugging.

The syntax is also awesome. The parentheses are weird at the beginning, some editors are capable of editing S-expressions directly, (im using Emacs with the paredit plugin) the learning curve is big, but once you get the hang of this, the parentheses are actually an advantage, as they give you a way to edit
based on the structure of the code. See a demo here: https://www.youtube.com/watch?v=D6h5dFyyUX0

205b
Mar 25, 2007

timick posted:

It has to do with the way that you've defined your tree. To create the parent node you need two child nodes, to create a child node you need a root node. Evaluating the tree will loop forever. Keep in mind that the parent field in a node is not a pointer or a reference to the parent node, it is a new copy of the parent node (which in turn will have new copies of child nodes...).

I'm not sure what you're after but would it be enough to have a leaf that looks like this instead?
code:
Leaf Integer
Where Integer would be the Integer value from the parent node.

I did need a distinct value for each node, but it turned out I could get away with a singly-linked tree, so I went with that. Just trying to wrap my head around what I did wrong. I think I get it now! What you're saying is that let x = 0:y; y = 1:x in x doesn't give you two nodes pointing at each other, but a chain of infinitely many nodes.

As a followup, how come length (let x = 0:y; y = 1:x in x) pegs my processor but my original example just sat there doing nothing?

dirby
Sep 21, 2004


Helping goons with math

205b posted:

I did need a distinct value for each node, but it turned out I could get away with a singly-linked tree, so I went with that. Just trying to wrap my head around what I did wrong. I think I get it now! What you're saying is that let x = 0:y; y = 1:x in x doesn't give you two nodes pointing at each other, but a chain of infinitely many nodes.

As a followup, how come length (let x = 0:y; y = 1:x in x) pegs my processor but my original example just sat there doing nothing?

Contrast the following two pieces of code.

x = 0:y; y = 1:x; main = print $ take 5 x outputs [0,1,0,1,0]. For the purpose of answering your question, you can safely pretend that it: looks at the first entry of x and sees it's known to be 0. Then it looks for the second entry of x, which is defined to be the first entry of y, which is known to be 1. Then it looks at the next entry of x, which is the second entry of y, which is the first entry of x, known to be 0...fourth must be 1...fifth must be 0, and we're done.

Since that doesn't ask the computer to do anything infinite, there's no problem with the theoretically-infinite definition of x.


But change main to print $ length x and it would have to do something along the lines of: Check if x has a first entry. It does, so the length is at least 1. The next entry, if any, would be the first entry of y, which exists (it's 1), so the length is at least 2. The next entry, if any would be the first element of x again (by the definition of y), so the length is at least 3...at least 4...5...6...7... and it would never stop.

timick
Apr 7, 2016


205b posted:

I did need a distinct value for each node, but it turned out I could get away with a singly-linked tree, so I went with that. Just trying to wrap my head around what I did wrong. I think I get it now! What you're saying is that let x = 0:y; y = 1:x in x doesn't give you two nodes pointing at each other, but a chain of infinitely many nodes.

As a followup, how come length (let x = 0:y; y = 1:x in x) pegs my processor but my original example just sat there doing nothing?

I hadn't noticed that it didn't consume any CPU in ghci, but I suspect it has to do with that the RTS can detect that something is wrong and stops executing. When I build and run your program it will fail with "project-exe: <<loop>>".

205b
Mar 25, 2007


Sure, got that part, I was just unclear on whether the recursive definition would result in a cyclical list or an infinite list. It sounds like it's the latter, which explains why my tree didn't work.

Thanks both for the help!

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

timick posted:

I'm not sure what you're after but would it be enough to have a leaf that looks like this instead?
code:
Leaf Integer
Where Integer would be the Integer value from the parent node.

Isn't that just CoFree?

SAVE-LISP-AND-DIE
Nov 4, 2010
I asked this in the general questions thread and was recommended to ask here:

In the year 2017, what are the compelling arguments to choose between Common Lisp, Scheme and Clojure for side project webdev?

Context:
I get the impression that CL spec is a touch outdated.

I like functional programming, pattern matching and algebraic data types are fantastic.

I write c#/js by day.

Oh great Lisp greybeards, lend me your knowledge!

Pollyanna
Mar 5, 2005

Milk's on them.


strange posted:

I asked this in the general questions thread and was recommended to ask here:

In the year 2017, what are the compelling arguments to choose between Common Lisp, Scheme and Clojure for side project webdev?

Context:
I get the impression that CL spec is a touch outdated.

I like functional programming, pattern matching and algebraic data types are fantastic.

I write c#/js by day.

Oh great Lisp greybeards, lend me your knowledge!

Side project web dev, specifically? Clojure by far. Clojure has a pretty robust selection of web development libraries ranging from basic HTTP handling, to SQL abstraction, to API management, and there's at least one legit web dev book to learn from.

Disclaimer: I am basically the opposite of a greybeard, so take my advice with a grain of salt. But, I have had good experiences doing web dev in Clojure!

spiritual bypass
Feb 19, 2008

Grimey Drawer
Clojure is the most convenient for web development because of its robust ecosystem, specifically the Luminus framework. It's more of a set of libraries with some basic scaffolding than anything Rails-like, which is why it's good. Programming in Clojure makes using Clojurescript more convenient, which is also a substantial benefit. The main downside of Clojure is that the error messages suck.

Common Lisp is good, too. SBCL can produce really fast binaries, there's a good webserver (woo), and plenty of other good tooling, including frameworks. The only downside I can think of is that reading the spec kinda sucks and that trying to figure out where your compiler diverges from the spec also sucks, but usually it's not a big deal in practice.

Every major Scheme implementation has at least a web server available for it, but I'm not aware of any that have a full-featured web stack with sessions, routing, and everything already well-considered the way Clojure has with Luminus. I'm on a personal crusade to make this happen for Racket, although Racket will be hampered by its execution speed for the forseeable future.

All of these languages have superb Emacs support, fwiw

xtal
Jan 9, 2011

by Fluffdaddy
Clojure is very nice but I'm going to recommend Racket as well. Those are probably your two best bets. SBCL is blazing-fast and battle-tested but shows its age, and Lisp-2 semantics were never not awful.

xtal
Jan 9, 2011

by Fluffdaddy

rt4 posted:

Clojure is the most convenient for web development because of its robust ecosystem, specifically the Luminus framework.

And the whole Java thing.

quote:

Racket will be hampered by its execution speed for the forseeable future.

Racket may be slower than Clojure but it's more than adequate when compared to the scripting languages that dominate web development. I would also say that, depending on the use-case, Clojure's boot time may make it a non-starter.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Racket is basically the best Lisp

AWWNAW
Dec 30, 2008

I've done several web apps with Clojure and Luminus and have no regrets.

Pollyanna
Mar 5, 2005

Milk's on them.


My one gripe with Clojure is the lack of an ORM, which is entirely because my SQL skills are relatively lacking. :negative:

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Pollyanna posted:

My one gripe with Clojure is the lack of an ORM, which is entirely because my SQL skills are relatively lacking. :negative:

Be the change you want to see in the world

Mr Shiny Pants
Nov 12, 2012

Pollyanna posted:

My one gripe with Clojure is the lack of an ORM, which is entirely because my SQL skills are relatively lacking. :negative:

Or write something like dapper for it. :) Good news: SQL skills are still relevant, even after all these years. And it does not seem to be going away anytime soon. So dig in!

bobthenameless
Jun 20, 2005

There is http://sqlkorma.com which is somewhat close but after looking is much closer to straight sql... The defentity macros seem to stray closer to orm style things though.

I've never actually used it so idk how ready it is to use for a real app, but I've had it in mind for whenever I wanna do a clojure app

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

I'm not a Clojure developer, but if I were to start a new database-backed project in Clojure I wouldn't skip the chance to use Datomic.

Pollyanna
Mar 5, 2005

Milk's on them.


True. Datomic is a better fit overall for Clojure, I just don't have a whole lot of familiarity with it. It makes sense to lean on it first, though.

xtal
Jan 9, 2011

by Fluffdaddy
The best ORM is no ORM

Pollyanna
Mar 5, 2005

Milk's on them.


xtal posted:

The best ORM is no ORM

Fair enough, and I do remember this sort of SQL templating happening when I made stuff with Luminus.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

xtal posted:

The best ORM is no ORM
Nice!

yesql posted:

Your database doesn't stick to the SQL standard - none of them do - but Yesql doesn't care.
:swoon:

SAVE-LISP-AND-DIE
Nov 4, 2010

Pollyanna posted:

Side project web dev, specifically? Clojure by far. Clojure has a pretty robust selection of web development libraries ranging from basic HTTP handling, to SQL abstraction, to API management, and there's at least one legit web dev book to learn from.

Disclaimer: I am basically the opposite of a greybeard, so take my advice with a grain of salt. But, I have had good experiences doing web dev in Clojure!


rt4 posted:

Clojure is the most convenient for web development because of its robust ecosystem, specifically the Luminus framework. It's more of a set of libraries with some basic scaffolding than anything Rails-like, which is why it's good. Programming in Clojure makes using Clojurescript more convenient, which is also a substantial benefit. The main downside of Clojure is that the error messages suck.

Common Lisp is good, too. SBCL can produce really fast binaries, there's a good webserver (woo), and plenty of other good tooling, including frameworks. The only downside I can think of is that reading the spec kinda sucks and that trying to figure out where your compiler diverges from the spec also sucks, but usually it's not a big deal in practice.

Every major Scheme implementation has at least a web server available for it, but I'm not aware of any that have a full-featured web stack with sessions, routing, and everything already well-considered the way Clojure has with Luminus. I'm on a personal crusade to make this happen for Racket, although Racket will be hampered by its execution speed for the forseeable future.

All of these languages have superb Emacs support, fwiw


xtal posted:

Clojure is very nice but I'm going to recommend Racket as well. Those are probably your two best bets. SBCL is blazing-fast and battle-tested but shows its age, and Lisp-2 semantics were never not awful.

Thanks for the replies. It sounds like Clojure is the quickest choice to go from zero to something working.

I'm interested in the recommendations for Racket. The official website plays up the DSL writing aspect, how much is that used in day-to-day coding?

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer
I'm halfway through Beautiful Racket, a guide to DSL writing, and it seems pretty cool and not that hard. I haven't done anything practical with it yet, but I plan to use it to build a Racket equivalent to Clojure's HugSQL. One DSL that Racket users will encounter frequently is Scribble, the Racket documentation generator. It's easy to work with and generates superb docs. When you build a package for the Racket package repository, the packaging system also builds and hosts your docs, so you'll definitely use it if you do any open source work in Racket.

One more Scheme I should've mentioned for web work is Chicken. I haven't used it myself, but it apparently has a following for its web capabilities. The website is nice and easy to navigate and it has its own package manager.

  • Locked thread