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
gonadic io
Feb 16, 2011

>>=

CRIP EATIN BREAD posted:

so I decided playing with rust again recently, and discovered this sort of behavior:

code:
let addr = "127.0.0.1:12345".parse().unwrap();
let listener = TcpListener::bind(&addr);
...
Now since TcpListener::bind takes a SocketAddr as a parameter, the compiler knows to check for a FromStr trait implementation for SocketAddr, and infer it, even though it happens further in the execution.

This is really cool. Are there other langs that support this sort of type inference?

haskell (with no extensions),
f# (without subtyping)
scala 3 (dotty) without subtyping
ocaml
rust uses a variant
mercury

agda, idris et al have a more powerful version

basically any statically typed functional lang uses it or at least uses it as a starting point before bolting their own stuff on top of it (rust's lifetimes, the dependent typed stuff, any oo stuff, etc).

it doesn't work great with oo inheritance so scala and f#'s version is less useful when that stuff comes into play (also gently caress scala implicits)

e: see https://www.quora.com/What-are-all-the-programming-languages-that-have-type-inference

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
if oo subtyping is too confusing for your type inferences it's too confusing for you

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

DONT THREAD ON ME posted:

if oo subtyping is too confusing for your type inferences it's too confusing for you

to be more specific I think it's an inherent limitation of dynamic dispatch

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
With functional langs, it makes sense to me to have that type inference. Like inferring:

code:
foo("abc".parse())
is a pattern I've seen all the time.

I guess I just haven't seen too many non-functional langs do that sort of thing.

gonadic io
Feb 16, 2011

>>=
go, c++, c#, java all have limited type inference using var/auto but the key difference (and the entire thing that makes HM worth using) is that HM basically builds up a collection of constraints on a generic type, and then only tries to work out the actual type after it's seen all its usages and it keeps it as generic as possible.

those non HM langs generally look forward for 1 usage and then pick that as the inferred type going forwards or worse only look at the exact concrete type on the right hand of an assignment.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

CRIP EATIN BREAD posted:

With functional langs, it makes sense to me to have that type inference. Like inferring:

code:
foo("abc".parse())
is a pattern I've seen all the time.

I guess I just haven't seen too many non-functional langs do that sort of thing.

it's really not *that* different from using auto in c++ or var c# although i'm sure both are more limited, like i dont think you could do:
code:
var s  = "abc".parse()
foo(s)
because it wouldn't know what to infer for `parse()`

e: oh yeah as gonadic io says in other langs it feels like the inference only goes one or two steps ahead wheras with HM it's "solving" for your type.

DONT THREAD ON ME fucked around with this message at 23:25 on Feb 20, 2019

Carthag Tuek
Oct 15, 2005

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



swift can do the object instantiation if you conform to any of the ExpressibleBy[...]Literal protocols

https://developer.apple.com/documentation/swift/swift_standard_library/initialization_with_literals

Zlodo
Nov 25, 2006

DONT THREAD ON ME posted:

IIRC Rust uses Hindley–Milner (or something close) for type inference, so other langs using that. Haskell I think.

but yeah it's great.

never got to use such a language but the idea that poo poo i write later in the code specifies the type of poo poo i wrote earlier feels weird and counter-intuitive

maybe its just great in practice though, i dunno

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

DONT THREAD ON ME posted:

it's really not *that* different from using auto in c++ or var c# although i'm sure both are more limited, like i dont think you could do:
code:
var s  = "abc".parse()
foo(s)
because it wouldn't know what to infer for `parse()`

yeah it makes sense. it's not like it can propagate down really far, i'm just not used to seeing that work correctly in an imperative setting

gonadic io
Feb 16, 2011

>>=

Zlodo posted:

never got to use such a language but the idea that poo poo i write later in the code specifies the type of poo poo i wrote earlier feels weird and counter-intuitive

maybe its just great in practice though, i dunno

you can always choose to specify the type. in haskell all top level items (i.e. functions, constants, etc) should have explicit type params and it's a warning for them not to, so the uncertainty/unspecifiedness you talk about only exists inside a function block.

in f# it's common to leave them all off entirely even for exported types and i don't like it at all

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Zlodo posted:

never got to use such a language but the idea that poo poo i write later in the code specifies the type of poo poo i wrote earlier feels weird and counter-intuitive

maybe its just great in practice though, i dunno

a lot of functional programming features can be like that at first, but they are fairly neat in practice

have a look at Prolog for even weirder (but related) programming paradigms

e:
here's a quick c/p from wikipedia:

quote:

In Prolog, program logic is expressed in terms of relations, and a computation is initiated by running a query over these relations. Relations and queries are constructed using Prolog's single data type, the term. Relations are defined by clauses. Given a query, the Prolog engine attempts to find a resolution refutation of the negated query. If the negated query can be refuted, i.e., an instantiation for all free variables is found that makes the union of clauses and the singleton set consisting of the negated query false, it follows that the original query, with the found instantiation applied, is a logical consequence of the program. This makes Prolog (and other logic programming languages) particularly useful for database, symbolic mathematics, and language parsing applications. Because Prolog allows impure predicates, checking the truth value of certain special predicates may have some deliberate side effect, such as printing a value to the screen. Because of this, the programmer is permitted to use some amount of conventional imperative programming when the logical paradigm is inconvenient. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features.

Private Speech fucked around with this message at 00:31 on Feb 21, 2019

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Krankenstyle posted:

lmao i just force pushed 3 times because i kept finding more elegant ways of writing various things

sounds like my feature branches tbh. when I finally finish this loving thing I've been doing it's gonna be a huuuuuge pack of changes for merging

shame we have zero regression tests to validate I didn't gently caress something up 2 months ago and forget about it!

AggressivelyStupid
Jan 9, 2012

Private Speech posted:

a lot of functional programming features can be like that at first, but they are fairly neat in practice

have a look at Prolog for even weirder (but related) programming paradigms

e:
here's a quick c/p from wikipedia:

now imagine prolog but with lisplike syntax


now you have microprolog and by extension Fril :shepface:

Soricidus
Oct 21, 2010
freedom-hating statist shill

Symbolic Butt posted:

oh there's a 'trick' here, you probably should check it with lua_type like
code:
lua_type(L, -1) == LUA_TNUMBER
edit: (unless I'm not getting your problem)

yeah, that's what i ended up doing. just registering my horror at having a function called lua_isstring that doesn't test whether the thing is a string or not.

i mean i can see what they were going for, it's not so much "is it a string" as "will lua_tostring return a non-null result" and i guess that's reasonable? but then lua_tostring is also badly designed (let's convert numbers to strings, but not anything else even if it has a __tostring metamethod. and if we convert a number to a string, let's also modify the original number on the stack, loving up anything that was relying on it staying a number, because ... reasons? idk why anyone would ever want this.)

lua is so bad and it's past midnight again and i'm still obsessively integrating it into my dumb hoby project. i think this might be a cry for help

Arcsech
Aug 5, 2008

Powerful Two-Hander posted:

shame we have zero regression tests to validate I didn't gently caress something up 2 months ago and forget about it!

it’s ok, you probably did

but if you codebase has no automated tests it’s not your fault for breaking something, unless you are the one responsible for there being zero tests

VikingofRock
Aug 24, 2008




Okay, which goon wrote the Google python style guide?

Section 2.1.4 posted:

Make sure you run pylint on your code.

Suppress warnings if they are inappropriate so that other issues are not hidden. To suppress warnings, you can set a line-level comment:
Python code:
dict = 'something awful'  # Bad Idea... pylint: disable=redefined-builtin
pylint warnings are each identified by symbolic name (empty-docstring) Google-specific warnings start with g-.

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


AggressivelyStupid posted:

now imagine prolog but with lisplike syntax


now you have microprolog and by extension Fril :shepface:

I'm thinking I'll write something with SWI-Prolog for my last week at work

they screwed me out of vacation and have me working overtime a lot

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:
I nearly hulked out on a sales rep today.

A junior dev on my team sent this sales rep an email asking about how he wanted some malformed data from an ETL process to actually look. The sales rep proceeded to hit "reply all", blast the junior dev on my team for running a lovely ETL process that loads malformed data into a new application he's trying to sell, and added add his boss, the product owner, another sales region manager, another software team's manager, and the direct manager of the junior dev in said reply.






The junior dev inherited this ETL process 2 months ago from this sales rep because the contractors he had actually doing the work kept shoving malformed data into the system and then decided to not renew their contracts.

The "ETL process" is really just a terrifying monolithic SQL script that lived in a shared network drive until the last contractor finally put it in source control about 4 months ago before he left.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

redleader posted:

seems unlikely, but only because that would have to be one heck of a mega db. my guess is that they have a small number of mega dbs

Its this

Plus 1.5 nines of uptime

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Private Speech posted:

I'm thinking I'll write something with SWI-Prolog for my last week at work

they screwed me out of vacation and have me working overtime a lot

if it's your last week, why the heck are you working overtime?

redleader
Aug 18, 2005

Engage according to operational parameters

ThePeavstenator posted:

I nearly hulked out on a sales rep today.

A junior dev on my team sent this sales rep an email asking about how he wanted some malformed data from an ETL process to actually look. The sales rep proceeded to hit "reply all", blast the junior dev on my team for running a lovely ETL process that loads malformed data into a new application he's trying to sell, and added add his boss, the product owner, another sales region manager, another software team's manager, and the direct manager of the junior dev in said reply.






The junior dev inherited this ETL process 2 months ago from this sales rep because the contractors he had actually doing the work kept shoving malformed data into the system and then decided to not renew their contracts.

The "ETL process" is really just a terrifying monolithic SQL script that lived in a shared network drive until the last contractor finally put it in source control about 4 months ago before he left.

hulk out

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
yes just reply all and explain how the junior dev is trying to clear up sales rep's mess

if your organization does not understand that, then sever

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Jabor posted:

if it's your last week, why the heck are you working overtime?

I'm not anymore, that's a big part of why I'm leaving

I won't actually do it but I'd probably get away with it

Soricidus
Oct 21, 2010
freedom-hating statist shill
I have now taken the day off work and am seriously considering writing my own lua interpreter. i think lua has given me brain damage. just say no y'all, not even once

Carthag Tuek
Oct 15, 2005

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



why are you doing this to yourself?

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Arcsech posted:

it’s ok, you probably did

but if you codebase has no automated tests it’s not your fault for breaking something, unless you are the one responsible for there being zero tests

good news: I wrote the original feature so if I did gently caress it up I can un-gently caress it and it's actually reasonably well architected and resilient to regression gently caress ups (most likely ones are creating an inconsistency between the db procedures and the models)

bad news: I am the reason there are no tests on it. though I'm not the reason there are zero tests on the entire application.

doing something about this is on my list once our source code and library migrations are finally done

Chalks
Sep 30, 2009

having zero tests in the entire application is always a team effort

Soricidus
Oct 21, 2010
freedom-hating statist shill

Krankenstyle posted:

why are you doing this to yourself?

I don’t know! it is just happening and now i am trapped in lua hell like a lobster in a pot, but without the claws or exoskeleton

maybe I can trick myself into writing a scheme interpreter instead

gimmicks aside, the real reason is autism

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
make your own lua

Carthag Tuek
Oct 15, 2005

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



Soricidus posted:

I don’t know! it is just happening and now i am trapped in lua hell like a lobster in a pot, but without the claws or exoskeleton

maybe I can trick myself into writing a scheme interpreter instead

gimmicks aside, the real reason is autism

tbf i might do similar self-damage for reasons of desperate procrastination or just plain donkeybrains

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:

Sagacity posted:

yes just reply all and explain how the junior dev is trying to clear up sales rep's mess

if your organization does not understand that, then sever

I'm sort of doing this by taking to each person.

After that response I did stop what I was doing and paired with the junior dev for the rest of the day. I was able to help him prove that all the poo poo he just got blasted for has actually always been a problem and we found a few more issues that just haven't been noticed by anyone yet as well. The validation for this ETL process is just this sales guy going into the application after the data is moved and clicking around until he shrugs his shoulders and says it looks good.

Zlodo
Nov 25, 2006

Soricidus posted:

I don’t know! it is just happening and now i am trapped in lua hell like a lobster in a pot, but without the claws or exoskeleton

maybe I can trick myself into writing a scheme interpreter instead

gimmicks aside, the real reason is autism

just build your own language, you'll probably have more fun

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Soricidus posted:

I have now taken the day off work and am seriously considering writing my own lua interpreter. i think lua has given me brain damage. just say no y'all, not even once

rewrite luajit to support the latest poo poo, thanks in advance

Aramoro
Jun 1, 2012




Chalks posted:

having zero tests in the entire application is always a team effort

By far the easiest way to green line your app.

Carthag Tuek
Oct 15, 2005

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



lol just wrote a pair of de/serializers for my custom objects, ran a big test that failed, then realized that i hadnt actually used them but still used the built-in ones

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Chalks posted:

having zero tests in the entire application is always a team effort

putting this on my annual review under the "teamwork" goal

elite_garbage_man
Apr 3, 2010
I THINK THAT "PRIMA DONNA" IS "PRE-MADONNA". I MAY BE ILLITERATE.
roll your own crypto.

Carthag Tuek
Oct 15, 2005

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



Krankenstyle posted:

lol just wrote a pair of de/serializers for my custom objects, ran a big test that failed, then realized that i hadnt actually used them but still used the built-in ones

turns out they worked perfectly in teh first go when i actually used them. nice.

raminasi
Jan 25, 2005

a last drink with no ice
what's the least poo poo document db. there's no common data model to normalize to because the only people capable of coming up with one think that just taking the union of every property they could ever conceivably care about constitutes data modeling. i have been fighting this fight for a year, i'm giving up. so what's the least poo poo document db.

e: wait i can just dump garbage into a sql server column, maybe that's the least bad option

raminasi fucked around with this message at 20:19 on Feb 21, 2019

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


postgres has json and jsonb data types

jsonb can be indexed

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