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
Sagebrush
Feb 26, 2012

ERM... Actually I have stellar scores on the surveys, and every year students tell me that my classes are the best ones they’ve ever taken.
if ( (input == 0) || (input == null) || (input == int('0')) || (input == false) || (input == "") || (input == " ") ) {

Adbot
ADBOT LOVES YOU

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Sagebrush posted:

if ( (input == 0) || (input == null) || (input == int('0')) || (input == false) || (input == "") || (input == " ") ) {

yes, exactly. this is what you have to do in bad languages with bad type systems, instead of just being able to say "if (!$input)".

JewKiller 3000
Nov 28, 2006

by Lowtax

Tiny Bug Child posted:

the proper way to do things is to write your code so that it means the same thing whether something is null or false or "" or "0" or 0, and then just go "if ($butt)" or "if (!$butt)"

in some people's jobs which don't involve making porn sites, the distinction between "0" and "" may be quite important

distinguishing the others should be taken care of for you automatically by the type system, of course

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
for sure. that's when you gotta special case it. save_butt($butt === '' ? null : $butt). spergequals is always there for when you actually need to care about the difference, you just have to be able to be able to recognize those situations. ppl who use strongly typed languages aren't smart enough to do that so they have to have a compiler to hold their hand.

nrook
Jun 25, 2009

Just let yourself become a worthless person!
tbc was right, you want very broad booleans in a dynamically typed language

code:
if not some_list:
instead of
code:
if len(some_list) == 0:
weirded me out when I first started coding python, but I've grown to appreciate it

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

FamDav posted:

its good for dumb langs that do it but the problem is nullable should never be the default.

what's weird is that well-written c++ actually does this p well with references and such, you can take an object reference as one of your parameters and it's impossible for it to refer to null

this feels extremely strange to me, being used to stuff like c# where nearly everything is a reference and can be null

i kind of like it, though

you know, in among the "your code doesn't compile? sprinkle some &s and std::move()s around until everything works" :bang:ing

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
i think i'm starting to acquire stackholm syndrome, someone help me

Sapozhnik
Jan 2, 2005

Nap Ghost
yeah of all things loving Vala gets nullability right

you get string? vs string where the latter is never-null and it's enforced by the type system.

(well and of course every pattern-matching lang with Maybe and Just but nobody uses those)

JewKiller 3000
Nov 28, 2006

by Lowtax
http://en.wikipedia.org/wiki/Cyclone_%28programming_language%29

Nomnom Cookie
Aug 30, 2009



i like Maybe, its a good monad. maybe the only good one

Tavistock
Oct 30, 2010



lol whats more important than porn.
(I heard porn killed it during the storms)
please stop arguing about how languages pass nulls and learn your language instead and talk about the merits of higher level stuff. I'm trying to learn. I'd like a tef post tbh he gets you guys going in the right direction

Innocent Bystander
May 8, 2007
Born in the LOLbarn.

Tavistock posted:

lol whats more important than porn.
(I heard porn killed it during the storms)
please stop arguing about how languages pass nulls and learn your language instead and talk about the merits of higher level stuff. I'm trying to learn. I'd like a tef post tbh he gets you guys going in the right direction

Just curious why you would want nulls? Either you want your objects to have some object defined zero value, and I'm using zero loosely here as I know we don't always work with numbers. But this object you're working with, does it belong to some mathematical group? Can you think of a way it should? Can you make it belong to some analogous group, like an additive or multiplicative group? If you can force this constraint null values really don't make any sense at all and only force more type checking which is pretty loller.

Deus Rex
Mar 5, 2005

Nomnom Cookie posted:

i like Maybe, its a good monad. maybe the only good one

yeah lists are freakin' stupid

Tavistock
Oct 30, 2010




Sorry, I didn't mean to stoke the fire further. I'm just back seat modding.

I'd like to learn more about why the object paradigm is so bad. I've heard a lot about the greatness about functional languages without side-effects(idk what a side-effect is) as being good, but why cant functional and oop exists together (are they opposed)? does it have to do with typing (non-keyboard)?

sorry if that's too much and not yospos'y nuff

friday night biiiches

MeruFM
Jul 27, 2010
fuzzy booleans are poo poo

is it that hard to type equal signs and a keyword?

FamDav
Mar 29, 2008

Tavistock posted:

Sorry, I didn't mean to stoke the fire further. I'm just back seat modding.

I'd like to learn more about why the object paradigm is so bad. I've heard a lot about the greatness about functional languages without side-effects(idk what a side-effect is) as being good, but why cant functional and oop exists together (are they opposed)? does it have to do with typing (non-keyboard)?

sorry if that's too much and not yospos'y nuff

friday night biiiches

they arent oppose my brudda

an object is just data plus functions that act upon them

functional programming is arguably mostly about no side eeffects

a side effect s like you get the output of a unctiuon but the function actually did something you didnt know about so when you call the function somethng else changes? another example is that when you do io the result is always different because people are capricious and suck.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I think the best way to learn what's the deal with side effects is to just try to do anything in some functional language.

I mean really, try doing something silly like a counter function.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
layout-wise fp and oop are kind of opposite when you look at the decomposition in a table

if you organize your program into functions doing operations you'll get one function per column

if you break your program into classes dictating behavior you'll get one class per row

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
closure objects are the poor man's object closures etc etc

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
functional programming seems pretty useless. "side effects" are the actual useful things a computer does. woo i can push numbers around how exciting

FamDav
Mar 29, 2008

Tiny Bug Child posted:

functional programming seems pretty useless. "side effects" are the actual useful things a computer does. woo i can push numbers around how exciting

cept it turns out that most things arent side effecting fagggot

Arcsech
Aug 5, 2008

Tiny Bug Child posted:

functional programming seems pretty useless. "side effects" are the actual useful things a computer does. woo i can push numbers around how exciting

side effects as in showing things on the screen or w/e are good and useful

side effects as in randomyl making GBS threads global state all over the place and then depending on that exact configuration of poo poo to work consistently is not

the second one is what functional languages attempt to prevent, sometimes this makes the first one a little harder

Arcsech
Aug 5, 2008

Tiny Bug Child posted:

woo i can push numbers around how exciting

also this is literally all computers ever do so

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
tbc do you work with other ppls code or is it all yr own

coffeetable fucked around with this message at 10:31 on Jan 25, 2014

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Arcsech posted:

side effects as in showing things on the screen or w/e are good and useful

side effects as in randomyl making GBS threads global state all over the place and then depending on that exact configuration of poo poo to work consistently is not

the second one is what functional languages attempt to prevent, sometimes this makes the first one a little harder

Yeah FP means you have to think a lot harder about where you have state in your program, but it makes it an awful lot easier to maintain the functional parts once they're done. You get the knowledge that values go in and results come out, and manage to rule out a bunch of possible errors in the process.

gonadic io
Feb 16, 2011

>>=

Tavistock posted:

Sorry, I didn't mean to stoke the fire further. I'm just back seat modding.

I'd like to learn more about why the object paradigm is so bad. I've heard a lot about the greatness about functional languages without side-effects(idk what a side-effect is) as being good, but why cant functional and oop exists together (are they opposed)? does it have to do with typing (non-keyboard)?

sorry if that's too much and not yospos'y nuff

friday night biiiches

F#, C# with LINQ, clojure, scala are all oop langs that are pretty functional.

Sapozhnik
Jan 2, 2005

Nap Ghost
Haskell sounds cool, lemme go develop some web apps in it

*puts "Expert Loli developer" on his resume*

seriously who comes up with this poo poo, the same people who decided to call a Photoshop clone "the GIMP"?

Stringent
Dec 22, 2004


image text goes here
haskell is basically just something programmers came up with so they wouldn't have to use the software they're writing

Deus Rex
Mar 5, 2005

http://www.haskell.org/haskellwiki/What_a_Monad_is_not

quote:

This shouldn't be too surprising, though, as >> isn't the binary operation of some monoid: the algebraic properties of join are very close to those of + and incidentally, join is also the operation true category theorists tend to work with. They also know of bind, but don't use it a lot because, unlike programmers, they don't do any actual productive work.

Sapozhnik
Jan 2, 2005

Nap Ghost
i could maybe deal with c++11 as a language to program in but is there any part of the standard library that is not utterly terrible?

:byodood: DON'T WRITE YOUR OWN STRING CLASS YOU IDIOT STD::STRING WAS IMPLEMENTED BY SOMEBODY MUCH SMARTER THAN YOU

even then std::exception is still baked into the language because std::bad_cast is baked into the language

Nomnom Cookie
Aug 30, 2009



Deus Rex posted:

yeah lists are freakin' stupid

list monad is. so are linked lists

gonadic io
Feb 16, 2011

>>=
You know what my least favourite monad is?

((->) a)

so many dumb and unintelligible hacks because of that one. hey i can save 3 characters and force somebody to spend 5 minutes figuring out what this line does?? :smuggo:

e: i guess this is what all of haskell is like to tbc

gonadic io fucked around with this message at 16:20 on Jan 25, 2014

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





the difference between functional and object oriented languages is that in oo langs you do

code:
PileOfData.method(params...) 

and in functional languages you do

code:
method(PileOfData, params...) 

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

AlsoD posted:

You know what my least favourite monad is?

((->) a)

so many dumb and unintelligible hacks because of that one. hey i can save 3 characters and force somebody to spend 5 minutes figuring out what this line does?? :smuggo:

e: i guess this is what all of haskell is like to tbc

reader monad is super lol

Sapozhnik
Jan 2, 2005

Nap Ghost
"OOP" is wishy washy grab bag of fashionable programming language features that doesn't have a well-defined meaning beyond "the word 'object' is used to refer to at least some things that would otherwise be called 'values'".

PL features that do have well-defined meanings include subtyping, dynamic dispatch, overloading, coercion, strong/dynamic/weak typing, access control, and operator overloading. Any given PL may have any combination of these features, some of which might be considered to be "object-oriented".

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

yes, stromg/weak typing. the most well-defined of terms

Sapozhnik
Jan 2, 2005

Nap Ghost
actually yeah I suppose you're right

still better defined than "OOP" though.

Sapozhnik
Jan 2, 2005

Nap Ghost
Strong typing: References are typed (but values can coerce a bit?)
Dynamic typing: References have no type, values can coerce a bit but only between numeric types.
Weak typing: References are untyped, Strings coerce to and from things on the numeric tower and ah who the gently caress cares just make semantics up as you go along.

...except by that logic C++ is both strongly and weakly typed, since I can declare a FuckedString class that has an operator int, a FuckedString(int) ctor, and a FuckedString operator+(int rhs)

so yeah you're right strong/weak typing isn't particularly well defined.

gonadic io
Feb 16, 2011

>>=
strong/weak is unrelated to static/dynamic

static/dynamic is whether or not the types are checked/discarded at compile time or kept at runtime (also tends to be compiled vs interpreted but this obviously isn't true all the time)

weak/strong is generally whether or you can implicitly coerce things or if you're forced to do any coercions explicitly

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

Mr Dog posted:

i could maybe deal with c++11 as a language to program in but is there any part of the standard library that is not utterly terrible?

:byodood: DON'T WRITE YOUR OWN STRING CLASS YOU IDIOT STD::STRING WAS IMPLEMENTED BY SOMEBODY MUCH SMARTER THAN YOU

even then std::exception is still baked into the language because std::bad_cast is baked into the language

i don't ever want to have to write another stack/queue/map/etcetcetc again

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