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
comedyblissoption
Mar 15, 2006

here's what you should probably do to create an object of an implied type in regular old javascript so you don't end up killing yourself with stupid javascript bullshit:
code:
function createButt() {
  var self = {
    buttString: 'some butt string'
  };

  return {
    fart: fart,
    getButtString: getButtString
  };

  function fart() {
    console.log('fart with buttstring: ' + self.buttString);
  }

  function getButtString() {
    return self.buttString;
  }
}
although you should only probably do this as a module encapsulation thing b/c you should probably structure things as functions operating on data types and not data types with their own functions

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
stop fretting so much, there is no perfect language, newbies will be confused by everything anyways.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

and i bet jslint complains about all of these things too

MononcQc
May 29, 2007

I find I care less and less about typedness of languages (I do however enjoy optional typing because it's what feels the most like eating my cake and having it) as I work more and more with systems that are distributed.

I'm going to enjoy the local consistency of a code base, but this internal consistency won't be worth poo poo if it doesn't properly carry over to other parts of the system, how they fail, or given how much impedance mismatch you get across parts. The level at which the tricky lovely bugs show up end up being related to rules extremely hard to properly encode in a type system (you'd probably need idris or agda).

The simplest example is to think of ISO-8859-1 encoded data that is pretty much always readable as if it were utf-8, although the meaning changes and data gets subtly corrupted. You'll only find about it when data crosses many subsystems and reaches a human who goes "wait that's not right". Usually these tricky rear end bugs end up uncovering some very foundational or basic assumption you made when designing things, and that will need a lot of work to correct.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

comedyblissoption posted:

yeah but that's a strawman argument that no one who prefers large amounts of type inference is advocating

idk, while i've never heard anyone outright claim that you should never have to explicitly state what type something is except for when the language requires it, i think a lot of people go through a phase where they think that when first exposed to good type inference, until they've worked with it for a while and hit places where they wish some things had their types annotated for readability

VikingofRock
Aug 24, 2008




comedyblissoption posted:

i think python is great for teaching imperative programming

but the only problem is it is actively hostile toward functional programming concepts like recursion and folds so I feel like students will come out with using mostly for loops for iteration except for some of the python collection syntactic sugar

I haven't really looked into either recursion or folds in python, but what makes it particularly hostile towards them?

comedyblissoption
Mar 15, 2006

http://neopythonic.blogspot.co.uk/2009/04/tail-recursion-elimination.html

guido posted:

I recently posted an entry in my Python History blog on the origins of Python's functional features. A side remark about not supporting tail recursion elimination (TRE) immediately sparked several comments about what a pity it is that Python doesn't do this, including links to recent blog entries by others trying to "prove" that TRE can be added to Python easily. So let me defend my position (which is that I don't want TRE in the language). If you want a short answer, it's simply unpythonic.

http://www.artima.com/weblogs/viewpost.jsp?thread=98196

guido posted:

About 12 years ago, Python aquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches. But, despite of the PR value, I think these features should be cut from Python 3000.
...
I think dropping filter() and map() is pretty uncontroversial

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET

MononcQc posted:

The simplest example is to think of ISO-8859-1 encoded data that is pretty much always readable as if it were utf-8, although the meaning changes and data gets subtly corrupted. You'll only find about it when data crosses many subsystems and reaches a human who goes "wait that's not right". Usually these tricky rear end bugs end up uncovering some very foundational or basic assumption you made when designing things, and that will need a lot of work to correct.

I think you really have three kinds of bug -- shallow ones that any type system can catch ("you passed a function pointer, I wanted a double"), shallow ones no type system can catch for e.g. halting problem reasons (things like passing 'let x = x in x' to a function that's going to use its args in Haskell), and deep ones a type system could conceivably catch but that's not the point.

The last kind of bugs come from bad assumptions about the nature of the problem. When you go to the Idris website and see a perfectly-manicured rock paper scissors player or something that's provably going to follow the rules, that's easy to write because rock paper scissors is super well-defined. But you can write flawless rock paper scissors in almost any language assuming you're not a flake, because it's so well-defined. Compare that to a really hard problem like deciding whether an airplane reservation is valid for any airline in the world and you realize there's no math model that makes business rules not confusing.

So I think a lot of the people who think "we just need a type system strong enough to catch all the bugs" are putting the cart before the horse. The type-based representation of rock-paper-scissors isn't what makes their solution totally watertight -- it, like the watertight solution, is just an expression of how well they understand the problem.

I still think it's pretty important to catch the first kind of bugs though, and on a problem where everyone's vision of the problem is a little different it might be nice to have a type-based representation of the problem preventing clashing ideas from getting manifested in the program.

EDIT: lingua latina

Krotera fucked around with this message at 16:16 on Apr 13, 2015

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET
The airline reservation problem is fun, by the way, because it's anathema to abstraction. Any abstraction you make around airline reservations in general is wrong and any type-based representation has to encode all the requirements that makes them hard to represent in the first place -- so it's either demonstrably incorrect or it's probably bugged. Oy vey!

Workaday Wizard
Oct 23, 2009

by Pragmatica
at least a static type system will catch you adding currency to number of passengers or something like that

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET

Shinku ABOOKEN posted:

at least a static type system will catch you adding currency to number of passengers or something like that

Almost any static type system can do that, though: you can even do it in Java if you wrap your numeric types. That's not idiomatic, but doing it idiomatically in e.g. Haskell (a language with one of those type systems people like to wax poetic about) needs a language extension (GeneralizedNewTypeDeriving) or Java-equivalent boilerplate anyway.

EDIT: lingua latina

Krotera fucked around with this message at 16:15 on Apr 13, 2015

Soricidus
Oct 21, 2010
freedom-hating statist shill
please stop using ie when you mean eg, it's triggering me

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Krotera posted:

What advantages does that have over i.e. Java? Earnest question -- I'm not really a Pascal guy and don't see the appeal.

good introduction to C in my experience

MononcQc
May 29, 2007

Shinku ABOOKEN posted:

at least a static type system will catch you adding currency to number of passengers or something like that

Only if you had the discipline to distinguish these integer types in the first place.

gonadic io
Feb 16, 2011

>>=

MononcQc posted:

Only if you had the discipline to distinguish these integer types in the first place.

yeah i probably wouldn't have bothered, GeneralisedNewtypeDeriving or no. i tend to do it for units that are plausible to mix up, for example different coordinate systems or measurement units or escaped/unescaped text. Mayyyybe i would have done it for currency but no way wouldl i for number of passengers.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

Soricidus posted:

please stop using ie when you mean eg, it's triggering me

Chill Callahan
Nov 14, 2012

Soricidus posted:

please stop using ie when you mean eg, it's triggering me

also stop putting spaces before and after your em dashes thank,

Arcsech
Aug 5, 2008

Krotera posted:

Almost any static type system can do that, though: you can even do it in Java if you wrap your numeric types. That's not idiomatic, but doing it idiomatically in i.e. Haskell (a language with one of those type systems people like to wax poetic about) needs a language extension (GeneralizedNewTypeDerivnig) or Java-equivalent boilerplate anyway.

F# does this natively with very little syntax. It's called units of measure, specifically designed to make tagging primitive types with more type data easy.

If you use it for stuff like SI units it'll also simplify your units automatically when you do a bunch of arithmetic with tagged values

Notorious b.s.d.
Jan 25, 2003

by Reene

Arcsech posted:

F# does this natively with very little syntax. It's called units of measure, specifically designed to make tagging primitive types with more type data easy.

If you use it for stuff like SI units it'll also simplify your units automatically when you do a bunch of arithmetic with tagged values

wow that is rad

Notorious b.s.d.
Jan 25, 2003

by Reene
and fsharp is open source
and it has an emacs mode

i might just have to learn this poo poo, if only for the units of measure gimmick in interactive use

https://github.com/fsharp/

AWWNAW
Dec 30, 2008

yeah it's pretty sweet unfortunately the thought leaders on my team are way more into JavaScript

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET

Soricidus posted:

please stop using ie when you mean eg, it's triggering me

Do you have an authoritative source? Last guy I ran into said it was completely opposite way. (way I'm using now)

I think I'm going to just expand those acronyms from here on out.

Mr. Glass
May 1, 2009
e.g. == exempli gratia == "for example"

i.e. == id est == "that is"

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET

Mr. Glass posted:

e.g. == exempli gratia == "for example"

i.e. == id est == "that is"

Crud! Let me go back and fix all those posts.

EDIT: Fixed. Hope nobody went into a coma.

Krotera fucked around with this message at 16:24 on Apr 13, 2015

Sapozhnik
Jan 2, 2005

Nap Ghost
i wish ubungu wasn't the default linux for third-party development, it really is such a bad linux (but i repeat myself lol)

seeing this bizarro parallel universe microsoft developing a bunch of their core infrastructure as bona fide cross platform open source projects using git and stuff is just weird as hell

raminasi
Jan 25, 2005

a last drink with no ice

Notorious b.s.d. posted:

and fsharp is open source
and it has an emacs mode

i might just have to learn this poo poo, if only for the units of measure gimmick in interactive use

https://github.com/fsharp/

f# units of measure are sweet as hell but they make me wish the rest of the language was better so i could use it more

Arcsech
Aug 5, 2008

GrumpyDoctor posted:

f# units of measure are sweet as hell but they make me wish the rest of the language was better so i could use it more

what don't you like about f#? I'm honestly curious, I really like f# and sure it has some rough edges but it's probably my language of choice at the moment

raminasi
Jan 25, 2005

a last drink with no ice

Arcsech posted:

what don't you like about f#? I'm honestly curious, I really like f# and sure it has some rough edges but it's probably my language of choice at the moment

number one is the way you can't have cycles in your type dependency graph unless the types live in the same file

number two is how far its tooling is behind c#'s

i love the language as a language (it's easily my favorite on that level), but using it in a "real" project has always felt like more of a headache than it's worth

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Mr. Glass posted:

e.g. == exempli gratia == "for example"

i.e. == id est == "that is"

good mnemonic is e.g. = "example given" and i.e. = "in effect"

Krotera
Jun 16, 2013

I AM INTO MATHEMATICAL CALCULATIONS AND MANY METHODS USED IN THE STOCK MARKET

HappyHippo posted:

good mnemonic is e.g. = "example given" and i.e. = "in effect"

The guy I ran into last said "in example" and "oh, the other one."

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

in example? lol, sounds like he's misspelling "an example"

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Mr. Glass posted:

e.g. == exempli gratia == "for example"

i.e. == id est == "that is"

i am in favor of improved use of these terms :thumbsup:

Mr. Glass
May 1, 2009

HappyHippo posted:

good mnemonic is e.g. = "example given" and i.e. = "in effect"

good mnemonic is knowing latin :smug:

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Mr. Glass posted:

good mnemonic is knowing latin :smug:

i once convinced my friends that ibid was the name of a latin guy who wrote a ton of books

Soricidus
Oct 21, 2010
freedom-hating statist shill

Mr. Glass posted:

good mnemonic is knowing latin :smug:

sic

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

prefect posted:

i once convinced my friends that ibid was the name of a latin guy who wrote a ton of books

tolk aboot owned

MeruFM
Jul 27, 2010
I find I care more about static typing for personal projects. I like keeping them clean/maintainable and I read back to them later in life to see how much I improved. Python is still cool though.

otoh, dynamic typing at work because gently caress everything and spew code out like a broken fire hydrant. Not like anything I'm working on will be used 5 years later.

Soricidus
Oct 21, 2010
freedom-hating statist shill

MeruFM posted:

Not like anything I'm working on will be used 5 years later.

famous last words

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Soricidus posted:

famous last words

probably more like "not like i'll be here in 5 years"

Adbot
ADBOT LOVES YOU

Notorious b.s.d.
Jan 25, 2003

by Reene
writing a mess of p-lang spaghetti kinda makes the 5 years thing a self-fulfilling prophesy

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