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
Zombywuf
Mar 29, 2008

So the correct answer is Prolog, cool.

Adbot
ADBOT LOVES YOU

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Zombywuf posted:

So the correct answer is Prolog, cool.

clojure + core.logic

MeruFM
Jul 27, 2010
bash

tef
May 30, 2004

-> some l-system crap ->

Zombywuf posted:

So the correct answer is Prolog, cool.

if software = data structures + algorithms

algorithms = logic + control :v:

Meiwaku
Jan 10, 2011

Fun for the whole family!

trex eaterofcadrs posted:

clojure + core.logic

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance
mutability sucks and is stupid immutable structures go 4ever

Opinion Haver
Apr 9, 2007

MononcQc posted:

immutable data structures are pretty nice to have but also getting well-delimited mutability is a nice tool. I do prefer a clear delimitation between both modes than only mutable if available though.

IORef/State :colbert:

0xB16B00B5 posted:

look jsut loving decide what X is already stop changing your mind later int he program

i mean whatever it is we know it gon give it to ya

MononcQc
May 29, 2007


Monad stuff, independent data structure allowing modifications or not (what Schemes tend to do now, specifically Racket), clearly-defined semantics about mutability like what Clojure does, strict use of const stuff in Cs, uniqueness types, whatever.

I think (and have no data to back it up) that it's fairly important to make mutation very explicit when it happens, to have well-defined semantics between "this is safe" and "this isn't". If you can differentiate between state and identity the way Clojure does it then it's even better. I don't particularly care how it's done, as long as you can do it reliably.

It's nice to be able to have a reference to some data structure and know you can make idempotent operations on it, or that it's impossible and you should just not assume you can.

I'd generally go for immutable stuff by default and then get mutation or destructive updates when I actually have a real need to, either through performance requirements, or semantic ones. Then again, I work in systems and languages that give this to me by default, so that became my defacto thinking mode.

Sang-
Nov 2, 2007

Tiny Bug Child posted:

it is


where would the ability to perform this on types be useful

union types are really useful

code:
object Bar {
   def foo(xs: (String or Int)*) = xs foreach {
      case _: String => println("str")
      case _: Int => println("int")
   }
}
(note you can't do this in Scala)

tef
May 30, 2004

-> some l-system crap ->

Tiny Bug Child posted:

where would the ability to perform this on types be useful

ugh, academics, things are all the same type in a real programming language

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
in an ideal programming language, sure, but like an ideal gas no such thing truly exists

wins32767
Mar 16, 2007

Otto Skorzeny posted:

now you have 32767 problems

Nah, we cool

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

tef posted:

ugh, academics, things are all the same type in a real programming language

as a way of zeroing in on the perfect platonic ideal of a programming language, i've been kicking around this idea to help further remove the meaningless distinctions between "types": make everything an array. primitives as we currently know them are just arrays of length 1

MononcQc
May 29, 2007

should go back to bits and bytes instead. More general.

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
like if you try to do this:

$it = "string";
$it[] = "string2";

php bitches at you, when it should turn $it into array("string", "string2")

jooky
Jan 15, 2003

Tiny Bug Child posted:

like if you try to do this:

$it = "string";
$it[] = "string2";

php bitches at you, when it should turn $it into array("string", "string2")

*nods*

JawnV6
Jul 4, 2004

So hot ...
van der waals of abstraction

tef
May 30, 2004

-> some l-system crap ->

Tiny Bug Child posted:

as a way of zeroing in on the perfect platonic ideal of a programming language, i've been kicking around this idea to help further remove the meaningless distinctions between "types": make everything an array. primitives as we currently know them are just arrays of length 1

what about if you just made everything a function. so like primitives would just be a function that always returns the same value

:2bong:

tef
May 30, 2004

-> some l-system crap ->

Tiny Bug Child posted:

like if you try to do this:

$it = "string";
$it[] = "string2";

php bitches at you, when it should turn $it into array("string", "string2")

shouldn't it turn it into "stringstring2" :confused:

double sulk
Jul 2, 2010

tef posted:

shouldn't it turn it into "stringstring2" :confused:

php

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

tef posted:

shouldn't it turn it into "stringstring2" :confused:

nah that would be the . operator

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

JawnV6 posted:

van der waals of abstraction

this joke seems kind of forced.

milquetoast child
Jun 27, 2003

literally
I sort of want to learn python.

My "code" skills are ~1yr of SQL dba, and a few years of HTML. I took AP comp sci in high school 12 years ago in C++ and got a 3 on the exam, but I was written and I remember nothing.


Where do I start?

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

JosephStalinVEVO posted:

I sort of want to learn python.


Where do I start?

how about here:

http://www.learnpython.org/

homercles
Feb 14, 2010

Sang- posted:

union types are really useful

code:
object Bar {
   def foo(xs: (String or Int)*) = xs foreach {
      case _: String => println("str")
      case _: Int => println("int")
   }
}
(note you can't do this in Scala)
I thought this would be easily doable via implicit functions doing the mapping but the answers here do it through even nicer means.

http://stackoverflow.com/questions/3508077/does-scala-have-type-disjunction-union-types
http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/

this does a thing, somehow. really batshit crazy stuff i wish i understood

milquetoast child
Jun 27, 2003

literally

Ok but should I buy a new retina mbp so I can code right!?

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

JosephStalinVEVO posted:

Ok but should I buy a new retina mbp so I can code right!?

no, a thinkpad.

homercles
Feb 14, 2010

really like wtf i'm going to read more scala and come back to that crazy poo poo

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

homercles posted:

I thought this would be easily doable via implicit functions doing the mapping but the answers here do it through even nicer means.

http://stackoverflow.com/questions/3508077/does-scala-have-type-disjunction-union-types
http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/

this does a thing, somehow. really batshit crazy stuff i wish i understood

i dont think strong typing is worth the effort

homercles
Feb 14, 2010

maybe in 2.10 you could implement such a feature more explicitely with macros

it would still be butt ugly

Workaday Wizard
Oct 23, 2009

by Pragmatica

quote:


def size(x : Int ∨ String) = x match {
case i : Int => i
case s : String => s.length
}

zoom

quote:


def size(x : Int ∨ String) = x match {

enhance

quote:




:∨

Workaday Wizard
Oct 23, 2009

by Pragmatica
D34TH ∀

qntm
Jun 17, 2009

tef posted:

what about if you just made everything a function. so like primitives would just be a function that always returns the same function

jony neuemonic
Nov 13, 2009

JosephStalinVEVO posted:

I sort of want to learn python.

My "code" skills are ~1yr of SQL dba, and a few years of HTML. I took AP comp sci in high school 12 years ago in C++ and got a 3 on the exam, but I was written and I remember nothing.


Where do I start?

there's an mit course on itunes u that uses python. that seemed fine but it might be too intro-level for you.

double sulk
Jul 2, 2010

learn ruby instead

0xB16B00B5
Aug 24, 2006

by Y Kant Ozma Post
web "developer"status: sass owns so much porting everything over to it

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

tef posted:

what about if you just made everything a function. so like primitives would just be a function that always returns the same value

:2bong:

Isn't that what Lisp is like? Or OCaml or one of those functional things?


VVVV :saddowns:

prefect fucked around with this message at 14:33 on Dec 11, 2012

tef
May 30, 2004

-> some l-system crap ->
:thejoke:

MononcQc
May 29, 2007

unwarranted effort post:

Lisp and other similar languages are based on the idea of lambda calculus (the function-based everything), but for practical reasons, ditch a lot of "everything is a function" for efficiency reasons.

For example, by default, Scheme'S lists are the usual 'cons cell' data structure. You can think of it as a C struct with two pointers (current and next), which are pointers to the current value or the following one:

code:
> (cons 'a 'b)
'(a . b)
> (cons 'a '())
'(a)
> (cons 'a (cons 'b '()))
'(a b)
> (list 'a 'b)
'(a b)
> (car (cons 'a (cons 'b '())))
'a
> (cdr (cons 'a (cons 'b '())))
'(b)
A pointer to '() is similar to a pointer to NULL, pointing towards the end of the list. Now that's the practical implementation, but nothing keeps you from redefining lists as functions:

code:
> (define (cons x y) (lambda (f) (f x y)))
> (define (car l) (l (lambda (x y) x)))
> (define (cdr l) (l (lambda (x y) y)))
> (cons 'a 'b)
#<procedure>
> (cons 'a '())
#<procedure>
> (cons 'a (cons 'b '()))
#<procedure>
> (car (cons 'a (cons 'b '())))
'a
> (cdr (cons 'a (cons 'b '())))
#<procedure>
> (car (cdr (cons 'a (cons 'b '()))))
'b
So I'm able to replace language primitives with actual functions and reimplement list operations. Now what you've got to do is keep doing that everywhere, which takes long and will give you a very slow language.

Lambda calculus (untyped) works that way from the beginning, depending on if you allow the notation for anonymous functions to take more than one argument. If not, you need to work your way through currying to get something equivalent.

Languages in the ML family (ML, SML, OCaml, Haskell, etc.) instead base themselves on typed lambda calculus, which is significantly more complex, but allows the presence of type systems similar to what these languages have (they tend to pick Hindley-Milner).

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007

reimplementing lists as functions to talk about Schemes is my most common use of Schemes

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