|
If you think the web is good enough I don't even know where to begin with that.
|
# ? Jan 20, 2017 18:35 |
|
|
# ? May 30, 2024 13:27 |
|
I'm going through old problems that were a breeze in OOP and taking ages to work out how to even approach them functionally. It's tremendous fun though, I'm being pushed hard to work out how to do things from scratch again.
|
# ? Jan 20, 2017 19:02 |
|
the talent deficit posted:i think it's only a matter of time before you see clients that effectively just make rpc calls to a backend service. whether this is negotiated via an sdk that uses graphql/rest or just uses something like gRPC or thrift over http2 i think application developers will stop having to care about the details of how their app talks to the server Unless I'm missing something, isn't this just J2EE thick clients from 2 decades ago?
|
# ? Jan 20, 2017 19:05 |
|
xtal posted:If you think the web is good enough I don't even know where to begin with that. If you're doing something a browser can't do well enough for 99% of users then yeah sure it's real bad. Otherwise, it's a featureful, near-universal UI toolkit that, like any other complicated thing, happens to have some sharp edges and only runs a janky-assed language under the hood that you never have to write a line of if you don't want to. Also many people misuse the poo poo out of it in various terrible ways, so there's that.
|
# ? Jan 20, 2017 19:13 |
|
EmmyOk posted:I'm going through old problems that were a breeze in OOP and taking ages to work out how to even approach them functionally. It's tremendous fun though, I'm being pushed hard to work out how to do things from scratch again. Get ready, it's gonna ruin Java for you! If you haven't seen it already you should take a look at F# for fun and profit, it's really comprehensive - and a lot of the examples give you an imperative approach in C#, then the F# equivalent, and then refine it into a more natural F# approach. You can pick up a lot from that kind of thing
|
# ? Jan 20, 2017 19:48 |
|
baka kaba posted:Get ready, it's gonna ruin Java for you! I've been bouncing around between it, my book, and googling particular things. I tend to end up on the site a lot though because it's such a great resource, for example it's the first place that went through what function signatures actually mean. At the moment it's really weird getting my head around using recursion to replace loops. Or I'll see a short code segment and spend a few hours trying to work out how it actually works.
|
# ? Jan 20, 2017 19:55 |
|
Yeah my issue is knowing how compact functions can be once you combine the right ones to process your data, and then you end up thinking about your data structures much more abstractly. So then you end up trying to mentally juggle this idea of working on lists of lists of tuples or whatever, and my brain isn't ready for that. Good exercise though, I get there eventually You're using something that annotates your function signatures as you work on them, right? That's a huge help for checking what it knows you're putting in and what it spits out, you can make changes and see the result immediately in your editor Good for tweaking things until you actually get what you wanted But yeah there's a few people in here who know F# on some level if you want to throw anything out there!
|
# ? Jan 20, 2017 20:33 |
|
Ok where do I get all of your neat editor things in VS2015? ^^^ those are some hot digraphs F# for Fun and Profit is a great resource. The author of it somehow knows exactly what he can assume I already know, and then also what I want to know about F# as it relates to what I need to know .. if that was understandable ... he's good at instructional writing is what I mean. EmmyOk posted:At the moment it's really weird getting my head around using recursion to replace loops. Or I'll see a short code segment and spend a few hours trying to work out how it actually works. I've written forth for a few things, and I feel like I became an able F# programmer once I realized that I am more or less writing backwards forth. When I think about looping in a functional language, I think about lists. When I want a loop in an imperative program, I'm trying to apply a function or repeat a procedure until some condition breaks the loop. In F# this is usually just the end of the list you're working on. I haven't had really any guidelines to go by. I don't know if I'm right or standard about anything, criticism is welcome, but with F# I take this approach: - Arrange data into one or more fancy union type trees. - Get my data into lists of whatever type. - Parse the list using the hella sweet list matching, and maybe have some side-effects. - Repeat ad absurdum. Maybe it was because I learned F# to parse things (fparsec is soo good uuh), but I feel that with F#, with thanks to the type system and matching, everything can be approached as a parsing problem w/ side effects (is this what haskell users have been doing? wow whoa). I never use the built-in list operators in lieu of using recursive matching, because it's always clear to me what is going on in my program that way. I can break down every god drat branch my program makes if I please. My F# programs are all a series of 'type', 'let'/'let rec', 'and', 'do', with the occasional lazy keyword. When you use recursion, you are literally creating a list; This is either as a transform of the list/tree of data you're working on, or you are generating a new list. Each called function appends its context or value after the callee's context, more or less. When the last call hits the condition that "breaks the loop", you have the choice of returning some aggregate value, or unrolling that chain of calls and returning a list. I'm not much of a Java programmer, I think IIterable is the name of the interface in Java, but it's nearly the same (I don't think it's evaluated the same) approach as using C# IEnumerable, the Enumerable class methods, and the yield keyword, if that is helpful. And of course, since lists and functions are first-class types, which can hold types of themselves as values, the purpose of your program is to cull the state of these things into a self-parsing well-trimmed n-ary tree that has the function you wanted. I think that the 'trick', so to speak, is to treat your program like a stack of typed values/functions/lists, and to operate on that stack like you're making a little stack machine. By Currying, the only operation of this machine is to create one big function that will eventually be evaluated when you ask it nicely and feed it some data in the right order. So really, instead of trying to cram all that typing info into your face, and remembering what level of indirection you've stumbled into, you only focus on the immediate area. The words, "I saw the angel in the marble and carved until I set him free" come to mind. Your job as an F# programmer is to cull state. In this awfully melodramatic analogy, the data is the marble and F# is your chisel. You just gotta chisel that data bit by bit until a statue comes out. I'm not the best functional programmer; I'm going to have to be buried with a C compiler if my brain hasn't turned into one by then, but I've done some fancy low-level research/work on the topic ... I can go on but I'm a really terrible technical writer I think, and I'm not sure what I can speak openly about, but I think I can try to help fellow newbie F# programmers ... dougdrums fucked around with this message at 22:54 on Jan 20, 2017 |
# ? Jan 20, 2017 22:49 |
|
On the topic of f# and monads (this being the FP thread) I stumbled on this tutorial for working with monads in f#.
|
# ? Jan 20, 2017 23:44 |
|
dougdrums posted:Ok where do I get all of your neat editor things in VS2015? ^^^ those are some hot digraphs Oh yeah, totally forgot about that - it's just the Fira Code font, it has nice ligatures. I use VS Code with the Ionide plugins mostly, it's nice for quick scripting - plus I feel like I'm learning more of the nuts and bolts of working with . NET projects than with VS 2015 Ochowie posted:On the topic of f# and monads (this being the FP thread) I stumbled on this tutorial for working with monads in f#. If you're interested there's one here too https://fsharpforfunandprofit.com/posts/computation-expressions-intro/ It's more of a series so it's a bit longer, but it feels more like a general introduction to the concepts and why you'd use them. I'm a nublet so I need the hand-holding baka kaba fucked around with this message at 00:10 on Jan 21, 2017 |
# ? Jan 20, 2017 23:46 |
|
dougdrums posted:Snip
|
# ? Jan 21, 2017 00:23 |
|
baka kaba posted:Oh yeah, totally forgot about that - it's just the Fira Code font, it has nice ligatures. I use VS Code with the Ionide plugins mostly, it's nice for quick scripting - plus I feel like I'm learning more of the nuts and bolts of working with . NET projects than with VS 2015 The code lens (automatic type annotations) in Ionide is amazing. I think it's the first feature it offers that simply can't be found in Visual Studio, and makes it a legit alternative even if you're running on Windows. I still went back to VS because managing project files by hand (or with Forge's extremely limited commands) is godawful, and the .NET Standard thing has only made targeting even more of a clusterfuck. I do use VS Code for writing .fsx scripts, though. I made a batteries-included folder that contains FSI.exe and all its required libraries, so I can just give scripts to colleagues without needing them to have anything installed. NihilCredo fucked around with this message at 10:24 on Jan 21, 2017 |
# ? Jan 21, 2017 10:20 |
|
This actually helps quite a bit! The first problem I looked at was the first Project Euler question (sum of 3s and 5s below 1000) and at first I was thinking of how to start at 1000 and step back in steps of 5 and 3. After a few minutes I realised I was thinking about it all wrong and just filled a list and filtered it followed by sum. The bit of code I am failing to understand currently is the following code:
|
# ? Jan 21, 2017 15:18 |
|
It picks out the head, which is a list, and glues that onto the result of recursing on the tail of the list of lists. You basically end up with code:
|
# ? Jan 21, 2017 15:28 |
|
Su-Su-Sudoko posted:It picks out the head, which is a list, and glues that onto the result of recursing on the tail of the list of lists. Oh my god I am so dumb it just clicked. Shameful.
|
# ? Jan 21, 2017 15:32 |
|
Hehe I think it's a pretty common problem! I certainly struggled with it when I was learning this stuff
|
# ? Jan 21, 2017 15:46 |
|
NihilCredo posted:The code lens (automatic type annotations) in Ionide is amazing. I think it's the first feature it offers that simply can't be found in Visual Studio, and makes it a legit alternative even if you're running on Windows. I find codelens to be annoying in VS (only because it messes up the spacing), but I do find myself hovering my mouse over definitions quite often ... dougdrums fucked around with this message at 16:21 on Jan 21, 2017 |
# ? Jan 21, 2017 16:19 |
|
dougdrums posted:All of the digraphs don't show up in VS2015, or I least I couldn't get them to ... in Code they work great though! I've been using Code on my linux laptop, for working on the run or when I'm waiting somewhere. It makes good use of screen space when I don't need a debugger or I am content with using gdb manually. Someone I work with made a more-or-less makefile using a fsx script, including building C libraries. It worked well and I thought it was a pretty good idea. The ligatures involving a hyphen "-" (which unfortunately is most of them) don't work in Visual Studio due to some issue with its codebase, and I don't expect it to be fixed either; others do work, but since those ligatures are Fira Code's entire selling point, I just use a different font for VS (Office Code Pro Medium, if you're curious).
|
# ? Jan 21, 2017 17:00 |
|
I just realised the -> ligature isn't working in VS Code for F#, but it was before and it works fine if the language mode is set to Plain Text weird So it's called a code lens huh. I thought there was something similar in F# Power Tools, but I guess not! Anyway it's rad as hell, the spacing bothered me at first and then I realised I didn't really care. A toggle would be cool though EmmyOk posted:
This is just One Weird Trick, but when your function (concatList) has one parameter and you jump straight into pattern matching on it, you can rewrite it as code:
And if that's confusing then don't worry about it right now!
|
# ? Jan 21, 2017 17:57 |
|
Reading on in the book they are dealing with for loops and sequences but I'm planning to avoid for loops of any description because they're not functional right? And that does help, baka!
|
# ? Jan 23, 2017 18:20 |
|
EmmyOk posted:Reading on in the book they are dealing with for loops and sequences but I'm planning to avoid for loops of any description because they're not functional right? And that does help, baka! Meh, if it works it works. Don't get hung up on it, if it easier to understand use it.
|
# ? Jan 23, 2017 18:52 |
|
This is sort of the problem I have with it - there's like (broadly) OOP, imperative programming and functional programming, and you can mix and match to achieve the same ends in different ways, and a lot of books and tutorials dive into everything instead of deciding on one best practice and showing you how to work within that paradigm. F# especially seems to encourage this because it sits in a weird place between pure functional languages and the rest of .NET, which it can interoperate with. I mean look at this: https://fsharpforfunandprofit.com/posts/13-ways-of-looking-at-a-turtle/ Some of that is different approaches to designing the system, but others are like 'here you can use classes' or 'here you can use record types'. You have a lot of freedom, and it can make it easier to learn when some of it is familiar OOP style, but it can make it hard to learn to make the right decisions when you want to tackle a problem in a certain way, you can end up straying in the wrong direction Anyway yeah it's sort of an imperative vs declarative thing, the idea is that functional languages (and stuff like LINQ in C#) allow you to describe what you want to happen to the data, instead of doing all the manipulation by hand, possibly using mutable state while you juggle things and build a result. Functions like map and fold can transform data and produce a final result just by describing what you want to happen. Getting familiar with that stuff will make it easier to work with, and you'll be able to create and compose complicated workflows with not a lot of code This stuff might help! Yes that site again
|
# ? Jan 23, 2017 19:10 |
|
Mr Shiny Pants posted:Of the top of my head, the guy was talking about how you would implement a webserver in Erlang and instead of one process that handles the connections and kicks of threads you would have a process for every connection coming into the server. Joe Armstrong wrote a thing at one point? http://joearms.github.io/2016/03/13/Managing-two-million-webservers.html
|
# ? Jan 25, 2017 01:14 |
|
I realize this is pretty vague but for those who use Haskell, what type of projects have you used it for? I'm making another try at wrapping my head around functional programming with Haskell and looking for inspiration on some projects that people have use the language for. Outside of large, enterprise-size applications.
|
# ? Feb 2, 2017 01:22 |
|
My two most recent Haskell projects were a geospatial webapp for a hackathon at work, and little GUI utility to implement the Schulze voting method (lesson learned: never, ever try to write a portable GUI by using GTK in any language).
|
# ? Feb 2, 2017 01:32 |
|
I am writing Diplomacy (the board game) as a REST service which I will turn into a Slack bot. I've used it for a few other random small services. I have no loving clue what Australia uses it for, but here's the job post: https://jobs.csiro.au/job/Brisbane%2C-QLD-Functional-Programming-Engineers/385668100/ Galois in Portland, Oregon, US uses it for space stuff. Or maybe crypto stuff. Or maybe crypto in space stuff. https://galois.com/careers/software-engineer/ Its ecosystem is good enough to use it as a general purpose programming language, but for some applications it is pretty obtuse. sink fucked around with this message at 04:42 on Feb 2, 2017 |
# ? Feb 2, 2017 04:40 |
|
Facebook uses it in production but I don't know to do what specifically.
|
# ? Feb 2, 2017 04:48 |
|
They wrote Haxl, a library for remote data retrieval (like SQL, I suppose?) Haskell is pretty good for server-side web-based stuff like APIs. Also parsing and language design.
|
# ? Feb 2, 2017 04:51 |
|
FB also uses it for spam, and hired Brian O'Sullivan and some other big-name Haskell people. Many talks online about Haskell at Facebook and how to train an engineering team in FP. As a side note, they also use OCaml and built a new and somewhat disappointing-looking language on top of it.
|
# ? Feb 2, 2017 06:10 |
|
Hughmoris posted:I realize this is pretty vague but for those who use Haskell, what type of projects have you used it for? I'm making another try at wrapping my head around functional programming with Haskell and looking for inspiration on some projects that people have use the language for. Outside of large, enterprise-size applications. i wrote an interpreter for a dumb programming language i invented
|
# ? Feb 2, 2017 06:56 |
|
the talent deficit posted:i wrote an interpreter for a dumb programming language i invented Including coursework, I've written a compiler, a physics engine, a program to generate a depth map from stereoscopic images, and then a bunch of algo stuff and puzzles. Never done any web/networking stuff myself in it.
|
# ? Feb 2, 2017 10:06 |
|
I'm looking at Idris. Can anyone shed some light on what's going on here: code:
|
# ? Feb 4, 2017 19:31 |
|
Ploft-shell crab posted:I'm looking at Idris. Do you notice a similarity between that type and the linked list? It's numbers represented at the type level by recursion. A function like 'length' on link lists could convert this type to an integer.
|
# ? Feb 4, 2017 19:48 |
|
Fin n represents a finite set of size n (where n is greater than 0) - so like the natural numbers, but bounded by n. FZ is the zero element, which is a member of all finite sets. You can think of its constructor as "for all natural numbers n, FZ is a member of Fin n iff n is greater than zero". FS is the successor function; pretty much the same as the Nat successor. Probably a point of confusion is that FZ and FS can inhabit multiple different types. FZ is a member of Fin 1, Fin 2, and so on. The finite sets are generated inductively, so Fin (S n) contains all of the elements of Fin n, plus FS applied on the greatest element. If we look at the members of each of the Fin instances, we see: Fin 0 {} Fin 1 {FZ} Fin 2 {FZ, FS FZ} Fin 3 {FZ, FS FZ, FS FS FZ} ... So (FS FS FS FZ) is a member of Fins 4+.
|
# ? Feb 4, 2017 19:50 |
|
Ploft-shell crab posted:I'm looking at Idris.
|
# ? Feb 4, 2017 20:59 |
|
I want to look into erlang or elixir for web development, after having a lot of experience with Python. My main usage will be building stuff bigger than the stuff I use Django for, so essentially I want to figure out the OTP stuff so I can make good use of the hardware I have with at least security in the knowledge that scaling won't be so bad as splitting up a monolith. What's best in breed in the ecosystem according to people who actually use erlang/elixir? What am I losing if I use elixir? All the frameworks out there market themselves exactly the same way saying they have a great dev experience or fault tolerant or whatever, all products of the language largely, so it's hard to tell where's the best place to invest my time in first.
|
# ? Feb 4, 2017 21:38 |
|
Maluco Marinero posted:I want to look into erlang or elixir for web development, after having a lot of experience with Python. My main usage will be building stuff bigger than the stuff I use Django for, so essentially I want to figure out the OTP stuff so I can make good use of the hardware I have with at least security in the knowledge that scaling won't be so bad as splitting up a monolith. If you want to do web dev in the Erlang ecosystem, Elixir + Phoenix is almost certainly what you want, especially coming from Python. Phoenix is very user-friendly, and it's far and away got the most users and the largest community of anything on the BEAM (Erlang VM). Programming Elixir and Programming Phoenix are both pretty good books to get started with Elixir. The downsides of using Elixir rather than Erlang:
|
# ? Feb 4, 2017 23:40 |
|
Already looking through Monoqnc's book on erlang, so no doubt I'll be getting used to both syntaxes while I work through it, just not the type of person with the time or inclination to slowly work through an entire book, I'd rather be applying the knowledge to a project and jumping back and forth between learning and doing. I guess Phoenix is where to carry on with that.
|
# ? Feb 4, 2017 23:45 |
|
Ralith posted:Remember that k : Nat is implicitly universally quantified, because it's lower case. Read the constructors as "for all Nats k, FZ inhabits Fin (S k)" and "for all Nats k, applying FS to a Fin k produces a Fin (S k)" Asymmetrikon posted:Fin n represents a finite set of size n (where n is greater than 0) - so like the natural numbers, but bounded by n. xtal posted:Do you notice a similarity between that type and the linked list? It's numbers represented at the type level by recursion. A function like 'length' on link lists could convert this type to an integer. These were all pretty insightful, thanks!
|
# ? Feb 5, 2017 00:24 |
|
|
# ? May 30, 2024 13:27 |
|
I've been asked to give a talk introducing Haskell and functional programming to a group of fairly experienced C++ developers. I can go through a pretty standard introduction covering the various languages out there, the way expressions are evaluated model, the idea of formal semantics, and the major language features, but I'm wondering if there's anything that's specifically helpful for people whose primary experience is a with a low-level stateful imperative language. I've found the Haskell Tutorial for C Programmers and I'm going to read through that, but I'd really appreciate anything else that might be helpful.
|
# ? Feb 5, 2017 00:38 |