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.
 
  • Post
  • Reply
Damiya
Jul 3, 2012

MononcQc posted:

:wink:
:wmwink:

If you had any idea how lovely I am at OOP you'd think differently. I just happened to be doing functional code for the last few years, and OO never really meshed with how I tend to think about things, so I'm always fumbling around in there.

Yea I mean I guess they really are different problem domains.

But your problem domain sounds way loving smarter than mine.

Adbot
ADBOT LOVES YOU

Cybernetic Vermin
Apr 18, 2005

i am rather enjoying the death of oo

lol if you didn't see it coming after the second patterns book

Shaggar
Apr 26, 2006
I decided I wanted to do a bunch of async crap in that Pandora client I was working on so its loads of delegates and I guess function pointers or something. idk. its way crazy overkill and looks really gross but it works.

that's my functional programming story

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Cybernetic Vermin posted:

i am rather enjoying the death of oo

countin chickens itt

MononcQc
May 29, 2007

The moment functional programming takes over is the moment it becomes all about logic programming.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
not that i know anything, but oo seems great at dealing with object-shaped problems. the problem is that the overwhelming majority of developers are comfortable with only OO, and so when they encounter a problem which doesn't have any clearly defined objects they try to smush it to fit in an object-shaped hole anyway

there's also a secondary problem which is that the power of OO is predicated on the human mind's innate ability to reason about interactions between objects. thing is, there're an awful lot of interactions that are beyond any individual's ability to reason effectively about, and in those cases it might be better to throw out intuitiveness in favour of rigour so that when you inevitably gently caress up at least the type system/static analysis/quickcheck/whatevs can catch you.

Notorious b.s.d.
Jan 25, 2003

by Reene
I am fond of grotesque hybrids like scala because I want both.

I want to have an OO type system I understand, and I *ALSO* want to have option types and either and map/filter/fold.

I can use each set of features on problems when it is intuitive to me, not along the boundaries that a theorist or a language designer pre-determined

MononcQc
May 29, 2007

Use Racket :smuggo:

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Cybernetic Vermin posted:

i am rather enjoying the death of oo

mega lol

gonadic io
Feb 16, 2011

>>=

MononcQc posted:

The moment functional programming takes over is the moment it becomes all about dependently typed programming.

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Notorious b.s.d. posted:

I want to have an OO type system I understand, and I *ALSO* want to have option types and either and map/filter/fold.

sounds like you need the power of PHP.

MeruFM
Jul 27, 2010
or just have a global "functions" singleton
:getin:

MononcQc
May 29, 2007


Sorry but Mercury already has something somewhat close to dependent types: http://dbpmail.net/essays/2011-09-03-mercury-tidbits.html it still is the future.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik
With javascript you have the power to do both functional and OO programming all half-assed.

double sulk
Jul 2, 2010

Tiny Bug Child posted:

sounds like you need the power of ruby 2.1.

distortion park
Apr 25, 2011


can anyone explain how Mathematica works? it feels pretty functional and i think there's a type system there somewhere but it seems very flexible.

Notorious b.s.d.
Jan 25, 2003

by Reene
my day job involves a great deal of ruby. i do not need to take that mess home with me to my hobby projects


edit: anyone who thinks ruby is an elegant language should consider two things

1. what is the difference between a bloc, a proc, and a lambda? when does this difference benefit you, the programmer? when does it benefit a naive C implementation of the language?

2. why are refinements scoped to a file on disk? same question as before: when does this scoping rule benefit you, the programmer, and when does it benefit a naive C implementor?

Notorious b.s.d. fucked around with this message at 19:58 on Feb 5, 2014

Notorious b.s.d.
Jan 25, 2003

by Reene

pointsofdata posted:

can anyone explain how Mathematica works? it feels pretty functional and i think there's a type system there somewhere but it seems very flexible.

it's powerpoint for math and it sorta incidentally includes a scripting language :q:

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

pointsofdata posted:

can anyone explain how Mathematica works? it feels pretty functional and i think there's a type system there somewhere but it seems very flexible.

it uses the same thought process as php: whatever argument is passed to a function, it should try its best to do something with.

coffeetable fucked around with this message at 20:06 on Feb 5, 2014

Deacon of Delicious
Aug 20, 2007

I bet the twist ending is Dracula's dick-babies

pointsofdata posted:

can anyone explain how Mathematica works? it feels pretty functional and i think there's a type system there somewhere but it seems very flexible.

you press = twice and do everything as a wolfram alpha query

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Notorious b.s.d. posted:

I am fond of grotesque hybrids like scala because I want both.

I want to have an OO type system I understand, and I *ALSO* want to have option types and either and map/filter/fold.

I can use each set of features on problems when it is intuitive to me, not along the boundaries that a theorist or a language designer pre-determined

is there anything in scala (or another multiparadigm language) that allows you to declare a fragment of the program as entirely functional, and forbids side effects/mutability/etc? cause the problem with letting the programmer do whatever they want is that programmers do whatever they want :suicide:.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

MononcQc posted:

The moment functional programming takes over is the moment it becomes all about logic programming.

Dependent types now!

MononcQc posted:

Sorry but Mercury already has something somewhat close to dependent types: http://dbpmail.net/essays/2011-09-03-mercury-tidbits.html it still is the future.

ehhh i like having my logic programming hived away. Slap the unifier as a lib i guess.

distortion park
Apr 25, 2011


Notorious b.s.d. posted:

it's powerpoint for math and it sorta incidentally includes a scripting language :q:

cool that's how i've been using it. good to know i shouldn't be trying to do any more with it

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

pointsofdata posted:

can anyone explain how Mathematica works? it feels pretty functional and i think there's a type system there somewhere but it seems very flexible.

The Wolfram Language is a highly developed knowledge-based language that unifies a broad range of programming paradigms and uses its unique concept of symbolic programming to add a new level of flexibility to the very concept of programming.

from https://reference.wolfram.com/language/guide/LanguageOverview.html


to think that years ago I had only a vague impression that wolfram was full of poo poo

distortion park
Apr 25, 2011


Symbolic Butt posted:

The Wolfram Language is a highly developed knowledge-based language that unifies a broad range of programming paradigms and uses its unique concept of symbolic programming to add a new level of flexibility to the very concept of programming.

from https://reference.wolfram.com/language/guide/LanguageOverview.html


to think that years ago I had only a vague impression that wolfram was full of poo poo

yeah i found that before i asked the question but it didn't really help.

Notorious b.s.d.
Jan 25, 2003

by Reene

pointsofdata posted:

yeah i found that before i asked the question but it didn't really help.

it wasn't written to be helpful

Damiya
Jul 3, 2012

Notorious b.s.d. posted:

I am fond of grotesque hybrids like scala because I want both.

I want to have an OO type system I understand, and I *ALSO* want to have option types and either and map/filter/fold.

I can use each set of features on problems when it is intuitive to me, not along the boundaries that a theorist or a language designer pre-determined

Scala owns :3

Sapozhnik
Jan 2, 2005

Nap Ghost
wtf are call/cc and delimited continuations, and what are they good for? wikipedia's explanations of both concepts are your typical legendarily bad wikipedia explanations with no motivating context.

if you want a generator or something then can't you just construct a closure and call it from time to time?

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED

Mr Dog posted:

wtf are call/cc and delimited continuations, and what are they good for? wikipedia's explanations of both concepts are your typical legendarily bad wikipedia explanations with no motivating context.

if you want a generator or something then can't you just construct a closure and call it from time to time?

continuations are an abstract representation of control state. a continuation represents a context from which program execution can continue, once a value is known. so continuations are really just a representation of "what still needs to be computed."

call/cc just takes the current continuation (i.e. everything that still needs to be computed from that point on) and passes it to a function. the function can then call the continuation it gets whenever it wants to "resume" execution from the point where call/cc was called.

continuations are cool because they let you implement a lot of control flow mechanisms. for example, here is how you can write exceptions using continuations

code:
failIfZero :: Int -> Continuation -> Continuation
failIfZero i errHandler = callCC $ \success -> do          -- calling success returns a top-level value
     theError <- callCC $ \fail -> do                      -- calling fail populates theError w/ an error
          when (foo i == 0) $ fail "it's zero"
          success (bar i)
     errHandler theError
the outer call to call/cc calls the first line anonymous function with the continuation representing the top level of the function. so if you call success with a value, execution resumes from the outer level, i.e. callCC "returns" whatever was passed in to success.

the inner call/cc is similar, if you call fail the execution resumes at the point of that call/cc. so fail "it's zero" makes the inner call/cc return "it's zero" (binding it to theError) and then you just pass it off to your error handler.

delimited continuations are similar, except instead of representing the rest of the execution, they represent the rest of the execution up to a certain point. this can be useful for example if you are building an interactive loop in scheme - you don't want your continuation to capture the loop itself, just everything up to the point of returning control back to the loop (for output/input). one neat thing about delimited continuations are that they're able to be composed, since they are kinda like functions.

continuations are more powerful than generators in the sense that they can be used to implement more control flow structures. a lot of people (rightly so) don't like continuations, because they can be confusing to reason about and provide power that no one really needs.

Pie Colony fucked around with this message at 21:51 on Feb 5, 2014

Cybernetic Vermin
Apr 18, 2005

one fun thing to now and then ponder about oo is whether clos was ridiculously insightful or if it missed the point entirely

don't entirely know how to feel

raminasi
Jan 25, 2005

a last drink with no ice

coffeetable posted:

is there anything in scala (or another multiparadigm language) that allows you to declare a fragment of the program as entirely functional, and forbids side effects/mutability/etc? cause the problem with letting the programmer do whatever they want is that programmers do whatever they want :suicide:.

d's got pure but it's d

double sulk
Jul 2, 2010

probably gonna pick up one of scala or clojure at some point in the future. i guess i'd be dehumanizing myself pretty hard for the latter though.

Arcsech
Aug 5, 2008

what programming language feature wont d poorly implement

FamDav
Mar 29, 2008
is double sulk actual sulk or somebody else

because if so get the gently caress out sulk

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


coffeetable posted:

is there anything in scala (or another multiparadigm language) that allows you to declare a fragment of the program as entirely functional, and forbids side effects/mutability/etc? cause the problem with letting the programmer do whatever they want is that programmers do whatever they want :suicide:.

there's an effect typing plugin for the scala compiler that kind of does that with annotations.

code:
def fib(x: Int): Int @pure = x match {
  case 0 | 1 => x
  case _ => fib(x - 1) + fib(x - 2)
}
stuff like that basically

Deus Rex
Mar 5, 2005

Notorious b.s.d. posted:

2. why are refinements scoped to a file on disk? same question as before: when does this scoping rule benefit you, the programmer, and when does it benefit a naive C implementor?

maybe I'm misunderstanding you, but I believe this has changed in 2.1. refinement imports can be scoped to a module and methods of that module relying on that refinement can be used from another file:

Ruby code:
# a.rb

class Widget
end

module Foo
  refine Widget do
    def foo
      :foo
    end
  end
end

module Bar
  using Foo

  def do_bar
    w = Widget.new
    puts "do_bar #{w.foo.inspect}"
  end
end

# b.rb

require_relative './a'

include Bar
do_bar

begin
  puts "Widget.new.foo, before using Foo"
  puts Widget.new.foo.inspect
rescue NoMethodError => e
  puts "no method found #{e}"
end

puts "Widget.new.foo, after using Foo"

using Foo
puts Widget.new.foo.inspect
code:
$ ruby b.rb
do_bar :foo
Widget.new.foo, before using
no method found undefined method `foo' for #<Widget:0x007ffd699e65d8>
Widget.new.foo, after using
:foo

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

FamDav posted:

is double sulk actual sulk or somebody else

because if so get the gently caress out sulk

yes he's sulk

tef
May 30, 2004

-> some l-system crap ->

MononcQc posted:

The moment functional programming takes over is the moment it becomes all about logic programming.

one day

hepatizon
Oct 27, 2010

Deus Rex posted:

maybe I'm misunderstanding you, but I believe this has changed in 2.1. refinement imports can be scoped to a module and methods of that module relying on that refinement can be used from another file:

it's still kinda wack that the method lookup depends on the lexical context of the call, and not just on the object the method is being called on. that said, i appreciate the demo and might have a use for it

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

hepatizon posted:

it's still kinda wack that the method lookup depends on the lexical context of the call, and not just on the object the method is being called on. that said, i appreciate the demo and might have a use for it

it kind of has to, though, right? like if you don't include the module that the code is in, you can't call the code. seems pretty logical to me.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply