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
jony neuemonic
Nov 13, 2009

VikingofRock posted:

I'd guess the shaggarpinion is that C# is the better language and that Java has better tooling, but we'll have to wait for The Shaggar Themself to come by and give the appropriate biblical analogy for the relevant langs.

i mean, this is the correct opinion.

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015

hackbunny posted:

no, I'm not using python 3
no, I'm not using mypy and I don't even know what it is

issues with python so far: passed the wrong variable or used the wrong method a couple times, because dynamic typing; have to google everything because dynamic typing; have been bitten by the infamous accidental singleton gotcha, except default object field value instead of default function argument. still like it. haven't written any new generators because the problem I'm solving is hostile to map reduce. finished analyzing data, found that some of it doesn't make sense and it doesn't include what I was interested in anyway. ah well. I probably won't get to do any automated reverse engineering after all

MyPy is optional typing thing for Python. You can get it to work with Python 2.7, but it becomes larger PITA to use in doing so (your type annotations and assertions become comments instead of part of the language...).

comedyblissoption
Mar 15, 2006

Symbolic Butt posted:

I don't like chaining too many functions/methods, they get hard to understand fast. even C# linq people try not to get too crazy and break chains into smaller steps and give names to them.

comedyblissoption wants a functional programming language to satisfy his functional programming lust and I respect that. I'm just saying those are not relevant to judge python as a BAD LANGUAGE because python has very little pretense of following this paradigm.

like I agree, python is a lousy funclang. python's lambda is kind of bad and broken outside of the most straightforward usage. is it relevant though? not really because python promotes using stuff like functools/operator modules instead of lambda.

someone make a car analogy here
sorry, but python lacking these extraordinarily useful features is why it is a lovely language.

C# and Java let you chain higher order functions together in a use-able way and actively encourage it. they do not bill themselves as funclangs. they just recognize that this functionality is absurdly practical and useful.

comedyblissoption
Mar 15, 2006

even stupid plang javascript is trying to push you toward this idiom
https://www.airpair.com/javascript/posts/mastering-es6-higher-order-functions-for-arrays

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

comedyblissoption posted:

sorry, but python lacking these extraordinarily useful features is why it is a lovely language.

C# and Java let you chain higher order functions together in a use-able way and actively encourage it. they do not bill themselves as funclangs. they just recognize that this functionality is absurdly practical and useful.

I have no idea what you're talking about, working with java 8's functions is an exercise in boilerplate and frustration

but sure having andThen method is so much better because oh my god I don't want to write f(g(h(x))), that's barbaric

comedyblissoption
Mar 15, 2006

f(a, g(b, h(c, x))) is less readable than:
c#-ish/javascript-ish:
code:
x.h(c)
  .g(b)
  .f(a)
haskell-ish:
code:
f a . g b . h c $ x
f#-ish:
code:
h c x |> g b |> f a

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
you can do x.h(c).g(b).f(a) in python, you just have to include \ if you're breaking lines because of semantic whitespace (like Asymmetrikon said)

but insinuating that python DOESN'T SUPPORT IT is disingenuous

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
the thing with python not having a funclang-like syntax for function composition is because there's an active effort on not making things too smart, one way of doing obvious basic stuff etc.

it'd just turn into one of those features that people use to show off, to refactor perfectly fine procedural code into more ~elegant~ code. and that probably would slow down the resulting bytecode because surprise surprise python wasn't originally designed with those features in mind

(as you can see I have a slight beef with generators...)

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

im the guy writing python when im concerned about speed enough to avoid generators

jony neuemonic
Nov 13, 2009

Symbolic Butt posted:

perfectly fine procedural code

hmmm.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

fart simpson posted:

im the guy writing python when im concerned about speed enough to avoid generators

I don't avoid generators, I just don't like when people try too hard into refactoring code to use them everywhere

comedyblissoption
Mar 15, 2006

Symbolic Butt posted:

you can do x.h(c).g(b).f(a) in python
are there standard and widely used collection libraries that do this

if not, it's really a moot point

mystes
May 31, 2006

comedyblissoption posted:

haskell-ish:
code:
composelists x y = foldr (.) id (map (uncurry ($)) $ zip x y)
composelists [h, g, f] [c, b, a] $ x
Edit: Oh this isn't the terrible programmer thread.

mystes fucked around with this message at 02:06 on Oct 28, 2016

Shaggar
Apr 26, 2006

VikingofRock posted:

I'd guess the shaggarpinion is that C# is the better language and that Java has better tooling, but we'll have to wait for The Shaggar Themself to come by and give the appropriate biblical analogy for the relevant langs.

c# is mostly a better language, but java does some things better (enums, exceptions) and java has maven which is the best thing ever. C# has better web frameworks (asp.net mvc/webapi/signalr) java has better data libraries (mybatis/mybatis-spring).

I prefer working in c# cause of the work I'm doing now but I wouldn't mind doing java at all.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

comedyblissoption posted:

are there standard and widely used collection libraries that do this

if not, it's really a moot point

you mean doing something like this?

Python code:
>>> 'a,a'.replace('a', 'b').upper().split(',')
['B', 'B']
sure, that's common but it depends on the nature of the objects

another example

Python code:
relevant_fart_data = openpyxl.load_workbook('butt.xlsx').get_sheet_by_name('Sheet1').sheet['B1':'B6']
but it does feel like a little too much for one line in this case so a more meticulous way to do this imo is:

Python code:
butt_workbook = openpyxl.load_workbook('butt.xlsx')
farts_sheet = butt_workbook.get_sheet_by_name('Sheet1')
relevant_fart_data = farts_sheet['B1:'B6']

comedyblissoption
Mar 15, 2006

what's the equivalent of this pseudocode in python

code:
[1, 2, 3, 4, 5].map(x => x * 100).filter(x => x < 300).reduce(*, 1)

VikingofRock
Aug 24, 2008




comedyblissoption posted:

what's the equivalent of this pseudocode in python

code:
[1, 2, 3, 4, 5].map(x => x * 100).filter(x => x < 300).reduce(*, 1)

Python code:
reduce(lambda x, y: x*y, filter(lambda x: x<300, map(lambda x: x * 100, [1,2,3,4,5])), 1)

VikingofRock
Aug 24, 2008




Probably you would just write it as a for loop though.

Python code:
result = 1
for x in [1, 2, 3, 4, 5]:
    big_x = x * 100
    if big_x >= 300:
        continue
    result *= big_x

hobbesmaster
Jan 28, 2008

VikingofRock posted:

Probably you would just write it as a for loop though.

Python code:
result = 1
for x in [1, 2, 3, 4, 5]:
    big_x = x * 100
    if big_x >= 300:
        continue
    result *= big_x

but that isn't functional

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

VikingofRock posted:

Probably you would just write it as a for loop though.

Python code:
result = 1
for x in [1, 2, 3, 4, 5]:
    big_x = x * 100
    if big_x >= 300:
        continue
    result *= big_x

yeah, this is what I meant by "perfectly fine procedural code"

anyone who mastered the accumulator loop pattern pretty much got 70% of real world programming skills

comedyblissoption
Mar 15, 2006

the main issue with the procedural style is when you start adding more complexity the obfuscation factor starts increasing rapidly

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

yeah i think the idea that functional style method chaining is more complex or harder to read than procedural loops is completely backwards

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Symbolic Butt posted:

yeah, this is what I meant by "perfectly fine procedural code"

anyone who mastered the accumulator loop pattern pretty much got 70% of real world programming skills

my programming languages have mastered the accumulator loop pattern with a function called "reduce" or "fold"

Communist Pie
Mar 11, 2007

...Robot!

comedyblissoption posted:

what's the equivalent of this pseudocode in python

code:
[1, 2, 3, 4, 5].map(x => x * 100).filter(x => x < 300).reduce(*, 1)

from functools import reduce
from operator import mul

reduce(mul, [x*100 for x in [1, 2, 3, 4, 5] if x*100 < 300])

distortion park
Apr 25, 2011


Communist Pie posted:

from functools import reduce
from operator import mul

reduce(mul, [x*100 for x in [1, 2, 3, 4, 5] if x*100 < 300])

lol

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Are we just ignoring that:

code:
result = (
  'a,a'.replace('a', 'b')
       .upper()
       .split(',')
)
is valid code? Like, I know it's annoying to have the extra parentheses, but chaining is just not that hard to do if the object supports it

gonadic io
Feb 16, 2011

>>=

mystes posted:

Edit: Oh this isn't the terrible programmer thread.

just zipWith

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Maluco Marinero posted:

Are we just ignoring that:

code:
result = (
  'a,a'.replace('a', 'b')
       .upper()
       .split(',')
)
is valid code? Like, I know it's annoying to have the extra parentheses, but chaining is just not that hard to do if the object supports it

Yeah this is a really silly argument. Python "supports" functional composition to the same degree that C# does. To whit: neither of them support it as a language feature* but their standard libraries have types that return composable results (e.g. functools vs the extension methods in LINQ). It's not like it's a hard pattern to implement.

If you use libraries that are built around functional composition surprise surprise you have functional composition. While there's nothing in Python's core lib that looks as nice as, say, Haskell you dip into data processing packages like pyspark and your code looks nearly identical to comedyblissoption's pseudo code.


* ignoring linq expressions which were there only to introduce the idea of functional composition to fussy .NET devs afraid of change

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

fart simpson posted:

yeah i think the idea that functional style method chaining is more complex or harder to read than procedural loops is completely backwards

I didn't say either of those things dumbass, my argument is that python was not designed to be a functional language and it's silly to shoehorn these things just to conform with comedyblissoption's standards of what makes a Not Bad programming language.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

fart simpson posted:

my programming languages have mastered the accumulator loop pattern with a function called "reduce" or "fold"

functional programming is neat and I'm glad newer programming languages have been moving towards it

Volte
Oct 4, 2004

woosh woosh
guido and acolytes' claim that a procedural accumulator loop is clearer than a functional pattern is plain false. a map or a reduce is a very specific pattern with no room for ambiguity, while a general loop can capture pretty much any computation you can think of. personal preference is one thing, but one pattern captures objectively more semantic information than the other one. reminds me of arguments like "why would I ever use meters when I can visualize what a yard looks like?"

that said, I do prefer the loop style in python, but only because they purposely butchered functional programming to make it less pleasant to use

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Volte posted:

guido and acolytes' claim that a procedural accumulator loop is clearer than a functional pattern is plain false.

I disagree, it's definitely clearer for most working programmers for sure. but that's just a matter of social circumstances, the vast majority of people learn to code with ifs and loops and not maps and filters.

I can't fault python's conservative attitude here, it's not in their best interests to risk alienating people in order to push features that doesn't even bode well with the language.

comedyblissoption
Mar 15, 2006

Dr Monkeysee posted:

While there's nothing in Python's core lib that looks as nice as, say, Haskell you dip into data processing packages like pyspark and your code looks nearly identical to comedyblissoption's pseudo code.
this is what i'm asking for as a counterexample to the claim that python poorly supports higher order functions

chaining a bunch of functions together that are just taking in non-functions isn't a counterexample to my claim that python poorly supports chaining higher order functions. a higher order function is a function that takes a function as a parameter and this style is often used in transforming data of collections.

the pyspark et al libraries are the counterexample and it looks like something you'd do in C#:
http://standarderror.github.io/notes/Data-munging-cheat-sheet/

unfortunately the python community is such that if you collaborate with others they might pitchfork you if you use such libraries, but I take back my claim that python is awfully bad.

it's now a reasonable dynamically typed language (which still makes it bad much like linted javascript)

comedyblissoption
Mar 15, 2006

Symbolic Butt posted:

I disagree, it's definitely clearer for most working programmers for sure. but that's just a matter of social circumstances, the vast majority of people learn to code with ifs and loops and not maps and filters.

I can't fault python's conservative attitude here, it's not in their best interests to risk alienating people in order to push features that doesn't even bode well with the language.
guido is absolutely right w/ his position to get broad appeal of the language to already indoctrinated imperative programmers. you can still provide support of it though while also supporting better idioms on the side.

the familiarity of a language to common idioms and pushing common idioms over superior alternatives can be bad though. rich hickey (the clojure guy) makes a compelling case of why catering to the industry norm of imperative style is disastrous: https://www.infoq.com/presentations/Simple-Made-Easy

comedyblissoption
Mar 15, 2006

also I think the reason fold is shunned by a lot of "working" programmers is because of pedagogy and the way it's taught as some complicated recursive thing.

the best way to teach it is that fold is an encapsulation of the following pattern:

a0 f a1 f a2 f a3

where f is an infix operator

it's really simpler than the equivalent for loop and any programmer that can understand that can understand fold if it's properly taught

Cybernetic Vermin
Apr 18, 2005

the python3000 debacle goes a pretty long ways towards my distrust of the stewards of the language, i am not sure why it is so hard for platform maintainers have such a hard time grasping that the software written in/on/against the platform will always be vastly more valuable than the platform itself if it is even moderately successful

java people gets it. microsoft built an empire on knowing it but appears to have since forgotten. the most no-effort profitable parts of ibm are still based on having a basic level of respect for others investment into your stuff

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news
at least its not swift lol

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Mr SuperAwesome posted:

at least its not swift lol

whatw wrong with swift, i like it

Smoke_Max
Sep 7, 2011


One of the few presentations I actually managed to watch in its entirety, it's very good.

Adbot
ADBOT LOVES YOU

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
:argh: why does this class layout make no loving sense, why is the base class in the right place but the base's base at the rear end end of the class :argh: why doesn't it show in the debug symbols :argh:

*notices "virtual public" thinks nothing of it*
*notices typecasts access memory*
*resolves symbol for memory*
*"vbtable" :confused:*
*remembers about "virtual public"
*googles virtual inheritance*

-> :stare:

god drat when you think you know a language. c++ can still surprise me sometimes

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