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.
 
  • Locked thread
Nomnom Cookie
Aug 30, 2009



Soricidus posted:

if you need a tail-recursive map in ocaml, get extlib, which includes a drop-in tail-recursive replacement with no performance penalty.

(it avoids having to build the list backwards and reverse it by using a mutable data structure with the same memory representation as a list and then subverting the type system to turn it into one. don't try this at home.)

literally less type safety than java

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=

Kevin Mitnick P.E. posted:

literally less type safety than java

it's pretty common for libraries to cheat type systems for performance benefits.

i mean literally the entire purpose of ST in haskell is to formalise this

Soricidus
Oct 21, 2010
freedom-hating statist shill
ocaml trusts the programmer. its type system is a tool, not a cage.

(yes, this may be a reason to prefer java, which has more realistic expectations ...)

tef
May 30, 2004

-> some l-system crap ->

Symbolic Butt posted:

Raymond Hettinger is a huge proponent of for-else, I was thinking about it and there's this example in his slides:

https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1?slide=11

and you can still use a comprehension here instead of for-else, because comprehensions are loving awesome

code:
def find(seq, target):
    for i, value in enumerate(seq):
        if value == tgt:
            return i
    return -1
in many cases where you can use break, you can use a function, and return. ignore the weirdos who bang on about 'multiple points of return' as if it is a gospel truth.


code:
def find(seq, target):
    ret = -1
    for i, value in enumerate(seq):
        if value == tgt:
            ret = i
            break
    return ret
:q:


Zombywuf posted:

I like for else, it makes perfect sense to me.

the prosecution rests, no further questions.

JewKiller 3000
Nov 28, 2006

by Lowtax

Soricidus posted:

ocaml trusts the programmer. its type system is a tool, not a cage.

(yes, this may be a reason to prefer java, which has more realistic expectations ...)

the type cast you're talking about takes place outside the ocaml type system. it can only be done by calling an external C function and claiming that it has the type you need. that's not safe, but neither is any other C FFI that i know of... surely java has an equivalent construct in JNI?

Notorious b.s.d.
Jan 25, 2003

by Reene

JewKiller 3000 posted:

surely java has an equivalent construct in JNI?

not that I know of, but I am more familiar with C#. in C#'s FFI, you "marshal" data i.e. copy it onto the managed heap w/ strong type data attached at marshal-time, with the permissible marshal-ings defined by the language authors

you definitely don't just point at random unmanaged memory

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

tef posted:

in many cases where you can use break, you can use a function, and return. ignore the weirdos who bang on about 'multiple points of return' as if it is a gospel truth.

is this just a joke, or real advice? genuinely curious, as i tend to have multiple points of return and real programmers don't seem to do that

Bloody
Mar 3, 2013

Notorious b.s.d. posted:

not that I know of, but I am more familiar with C#. in C#'s FFI, you "marshal" data i.e. copy it onto the managed heap w/ strong type data attached at marshal-time, with the permissible marshal-ings defined by the language authors

you definitely don't just point at random unmanaged memory

iirc you can abuse c# into passing pointers around but you really shouldnt at it gets upset easily. like if you wanna pass a managed array into a c function that expects a pointer to an unmanaged array you can do that if you really really want to using fixed(){}

CPColin
Sep 9, 2003

Big ol' smile.

prefect posted:

is this just a joke, or real advice? genuinely curious, as i tend to have multiple points of return and real programmers don't seem to do that

it depends. just be consistent and don't mix styles in the same chunk of code.

Nomnom Cookie
Aug 30, 2009



JewKiller 3000 posted:

the type cast you're talking about takes place outside the ocaml type system. it can only be done by calling an external C function and claiming that it has the type you need. that's not safe, but neither is any other C FFI that i know of... surely java has an equivalent construct in JNI?

the jvm knows about classes. you could maybe alloc an object on the jvm heap and munge it to change its class, serialization and clone kinda do this. it would be really fragile though and also pointless

Notorious b.s.d.
Jan 25, 2003

by Reene
suffice to say, jni and marshalling are both designed to stop you from doing anything stupid, particularly by accident

Nomnom Cookie
Aug 30, 2009



it's not really the done thing in java to jump through hoops to preserve immutability. plus if you really care just make sure to expose only an immutable interface to clients

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Notorious b.s.d. posted:

suffice to say, jni and marshalling are both designed to stop you from doing anything stupid, particularly by accident

jni was "designed" to make it as annoying as possible to bridge into the jvm from native code to avoid dealing with subverting the safety guarantees

it succeeded wildly, with jni being entirely terrible

now there's rumbings of having a proper p/invoke style replacement

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

tef posted:

code:
def find(seq, target):
    for i, value in enumerate(seq):
        if value == tgt:
            return i
    return -1
in many cases where you can use break, you can use a function, and return. ignore the weirdos who bang on about 'multiple points of return' as if it is a gospel truth.

:doh:

CPColin
Sep 9, 2003

Big ol' smile.

hmm yes a well-reasoned point

tef
May 30, 2004

-> some l-system crap ->
i still hate for-else, mostly because of the name.

qntm
Jun 17, 2009

prefect posted:

is this just a joke, or real advice? genuinely curious, as i tend to have multiple points of return and real programmers don't seem to do that

real programmers also have laborious trace macros at the entry and exit points from every function. multiple points of return make it harder to mentally blot them out as boilerplate, and easier to accidentally omit them

Nomnom Cookie
Aug 30, 2009



qntm posted:

real programmers also have laborious trace macros at the entry and exit points from every function. multiple points of return make it harder to mentally blot them out as boilerplate, and easier to accidentally omit them

man if you're gonna do that then go ahead with the AOP

Zombywuf
Mar 29, 2008

qntm posted:

real programmers also have laborious trace macros at the entry and exit points from every function. multiple points of return make it harder to mentally blot them out as boilerplate, and easier to accidentally omit them

If you have multiple points of return then your exit traces should have different messages.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band
i should probably learn to read stack traces and run debuggers instead of just using print statements :saddowns:

Notorious b.s.d.
Jan 25, 2003

by Reene

prefect posted:

i should probably learn to read stack traces and run debuggers instead of just using print statements :saddowns:

debuggers are mostly a much, much faster version of your print statements

reading stack traces is loving essential, though. how the gently caress have you got this far w/out them

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Notorious b.s.d. posted:

debuggers are mostly a much, much faster version of your print statements

reading stack traces is loving essential, though. how the gently caress have you got this far w/out them

i can actually read them, up to a point. after the first few lines, it turns into white noise for my eyes

code:
12:20:42.535 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
12:20:42.535 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
12:20:42.535 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
12:20:42.536 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
12:20:42.536 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
12:20:42.537 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
12:20:42.537 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
12:20:42.537 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
12:20:42.556 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
12:20:42.556 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
12:20:42.557 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
12:20:42.557 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
12:20:42.558 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
it was mostly just me whining :blush: i can use a stack trace to figure out where to go poke around next, but i can't just look at them and know what the problem is, generally

Shaggar
Apr 26, 2006
when reading stack traces, first look to see if the message at the top of the stack makes sense. ex: couldn't read a file. if its something else like a runtime exception (ex: nullpointer) then find the first place in the stack trace that has your code in it and look at that line and find what you didn't check for null.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Shaggar posted:

when reading stack traces, first look to see if the message at the top of the stack makes sense. ex: couldn't read a file. if its something else like a runtime exception (ex: nullpointer) then find the first place in the stack trace that has your code in it and look at that line and find what you didn't check for null.

yeah, gradle stack traces generally seem to be three or four stack traces piled up in a row. so far, the first and the last ones have been most useful (the last one in this particular case, because i was trying to figure out why a third-party plugin was blowing up. they were trying to import a directory, thinking that it was an xml file)

Shaggar
Apr 26, 2006
yeah for hosting environments like tomcat or w/e gradle is theres gonna be a lot of stuff between the main thread and ur code. I wonder if theres a way to have logback ignore everything below a certain point in a stack trace for common frameworks/hosts. ex: ignore everything under the servlet on tomcat.

Zombywuf
Mar 29, 2008

prefect posted:

i can actually read them, up to a point. after the first few lines, it turns into white noise for my eyes

You are not at fault.

Java is at fault.

Sensible languages that encourage sensible practices have readable stack traces.


Although I'm now having flashbacks to the first time I saw a Gnome 2 stack trace.

Valeyard
Mar 30, 2012


Grimey Drawer
Java stack traces are fine, Javascript traces are useless

Javascript useless

pseudorandom name
May 6, 2007

juiceless

CPColin
Sep 9, 2003

Big ol' smile.
raise your hand if you love it when Eclipse hangs for several minutes when you ask it to refactor the name of a private static field!

zeekner
Jul 14, 2007

CPColin posted:

raise your hand if you love it when Eclipse hangs for several minutes when you ask it to refactor the name of a private static field!

get intellij and never look back

FamDav
Mar 29, 2008
my only issue with intellij is it doesnt have eclim

i like eclim

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Uncomfortable Gaze posted:

get intellij and never look back

i think this was with the previous version of intellij, but when i would try to load the source for gradle as a project, it would practically hang my work computer for an extended period

zeekner
Jul 14, 2007

prefect posted:

i think this was with the previous version of intellij, but when i would try to load the source for gradle as a project, it would practically hang my work computer for an extended period

was the gradle project a gradle project? i know gradle support wasn't very good until they improved it for android support

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Uncomfortable Gaze posted:

was the gradle project a gradle project? i know gradle support wasn't very good until they improved it for android support

yes, the gradle source was a gradle project. their gradle support has gotten better, but it still doesn't hold a candle to their maven support (which makes sense, since maven's all xml, et cetera)

Nomnom Cookie
Aug 30, 2009



also maven is used by grownups who've graduated from college so maven support is more relevant to jetbrains' customer base

Nomnom Cookie
Aug 30, 2009



i used sbt and liked it. its probably a bad tool but writing scala code is more fun than editing poms

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
nuget is pisstrash and is v slow ;_;

i used f# 2day and it wasn't all that much better than c# for dicking with azure blobs

Valeyard
Mar 30, 2012


Grimey Drawer

Kevin Mitnick P.E. posted:

also maven is used by grownups who've graduated from college so maven support is more relevant to jetbrains' customer base

we used maven in one of our lovely classes this year!!!

Bloody
Mar 3, 2013

Malcolm XML posted:

nuget is pisstrash and is v slow ;_;

i used f# 2day and it wasn't all that much better than c# for dicking with azure blobs

nuget is crippled by corporate firewalls/proxies lol

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

Kevin Mitnick P.E. posted:

its probably a bad tool but writing scala code is more fun than editing poms
and we wonder why all software is terrible

when asked why the bridge collapsed killing hundreds, the structural engineer explained that while it was probably a bad tool, playing pontifex was more fun than analysing nonlinear stress.

  • Locked thread