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
Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Dr Monkeysee posted:

easily but not elegantly. wrapping all your types in a struct is awkward and obscures your intent. like, size_t has deliberate semantics beyond "an unsigned integer of a certain size" and it's annoying that if i write a function that takes a size_t it'll also blindly accept a uint64_t or a long long or whatever (even aside from the fact that it'll accept *different* types on a different architecture).

if i say i take a size_t then i should *only* accept a size_t. and if you need to punch through the type system that's what casts are for.

Wrapping types doesn't have to be awkward unless it's stuff you need operators to work on, which is admittedly the case in your example. C++ obviously makes this easier. -Wconversion can also be nice but it's a bit impractical to introduce to a large existing project.

Adbot
ADBOT LOVES YOU

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!

tef posted:

btw python has a type checker now

it's pretty bad, though, especially w/ regards to forward references

Carthag Tuek
Oct 15, 2005

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



Zaxxon posted:

the best case I've ever found is when you want to describe a sequence of functions where they should have the type (whatever the previous one gave me)->(whatever the next one wants) discoverable at run time. I've written some data shoveling tools that dynamically spun up new processes to do ETLS based on watching zookeeper for job configs

I mean you could probably do that with a statically typed language too but it would likely be a pain in the rear end. because you would be looking at a list of unkonwn length where some combinations of functions are fine, but others aren't for example [read xml file, parse xml, save to database] would go fine but [read json file, parse xml, save to database] would not. Since you didn't know that you would be asked for those functions at compile time you would either have specify the type of the list so you could exclude some options or make all your function types generic enough to handle the cases at run time (basically type erasure.) Sure you could get run-time errors from choosing bad options in the list, but this code had to be built to withstand all sorts of run time errors since it was connecting to various different servers and doing various different error-prone things.

Whether this was a good idea or not I don't know as I left that job, but it worked pretty well while I was there.

we had a system that did stuff like that. my coworker made an Op interface that could be chained via input/output so every time we needed a new thing we wrote a new ParseXMLOp or ShitPantsOp or wahtever

i guess it wasnt really a list anymore

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Zaxxon posted:

the best case I've ever found is when you want to describe a sequence of functions where they should have the type (whatever the previous one gave me)->(whatever the next one wants) discoverable at run time. I've written some data shoveling tools that dynamically spun up new processes to do ETLS based on watching zookeeper for job configs

I mean you could probably do that with a statically typed language too but it would likely be a pain in the rear end. because you would be looking at a list of unkonwn length where some combinations of functions are fine, but others aren't for example [read xml file, parse xml, save to database] would go fine but [read json file, parse xml, save to database] would not. Since you didn't know that you would be asked for those functions at compile time you would either have specify the type of the list so you could exclude some options or make all your function types generic enough to handle the cases at run time (basically type erasure.) Sure you could get run-time errors from choosing bad options in the list, but this code had to be built to withstand all sorts of run time errors since it was connecting to various different servers and doing various different error-prone things.

Whether this was a good idea or not I don't know as I left that job, but it worked pretty well while I was there.

FWIW you can solve this sort of problem pretty satisfactorily with static types in modern C++ without too much effort or introducing excess dynamic checks, using the same kind of type erasure implementations of std::function do. You can see something very similar in the chaining support added by the current futures TS.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Ralith posted:

FWIW you can solve this sort of problem pretty satisfactorily with static types in modern C++ without too much effort or introducing excess dynamic checks, using the same kind of type erasure implementations of std::function do. You can see something very similar in the chaining support added by the current futures TS.

I wager you could even do it in Haskell or OCaml or something like that It would just be a pain.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Zaxxon posted:

I wager you could even do it in Haskell or OCaml or something like that It would just be a pain.

it's been done, it's called hlist and nobody really uses it cause there are usually better options

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
or dynamic in c#

MononcQc
May 29, 2007

tef posted:

btw python has a type checker now

no you see it's not the same because

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Zaxxon posted:

I wager you could even do it in Haskell or OCaml or something like that It would just be a pain.
In Haskell this sort of thing is really easy. The point was, as always, you don't actually need heterogeneous containers at all, just clever representations.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
if you cant nave heterogenous lists in your dynamic lang then what's the point even/?

VikingofRock
Aug 24, 2008




In a dynamic lang you might as well allow your lists to be heterogenous since it makes them more flexible and it's not like there's a compiler to catch type errors anyways.

MonocQc, I thought your posts over the last few pages were pretty interesting and even though I would rather use the giant ADT, I could understand why someone would prefer the big heterogenous list of options. Also the chained function thing was interesting, whoever posted that.

Shaggar
Apr 26, 2006

tef posted:

dynamic typing is great in the small, static typing is great in the large, what's the loving issue

dynamic typing is bad everywhere.

Bloody
Mar 3, 2013

the best part of static typing is it makes discovery trivial

Shaggar
Apr 26, 2006
the only defense of dynamic typing is morons still using text editors to write code complaining about keystrokes

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
what if you had something like unsafe in rust but for types

oh wait that would just be a go interface

Bloody
Mar 3, 2013

casting to object

Shaggar
Apr 26, 2006

MALE SHOEGAZE posted:

what if you had something like unsafe in rust but for types

oh wait that would just be a go interface

idk what that is cause I don't use bad languages, but in c# you can do ^^^^ and theres also a dynamic type. the only time its ever really used is in MVC examples of the viewbag and in SignalR for calling javascript methods from c#. imo they don't really need the dynamic stuff in signalr and it could be done better.

MononcQc
May 29, 2007

I don't know for you guys but my dynamic language of choice has a type checker that has parametric types and does inference and poo poo

JewKiller 3000
Nov 28, 2006

by Lowtax
in that case why don't you run the type checker before you run your program? then you don't have to call it a dynamic language anymore, and you'll benefit from better compiler performance and static correctness guarantees

Soricidus
Oct 21, 2010
freedom-hating statist shill
isn't the erlang thing more like a linter, it tells you where the types look wrong but you can still run the program and it might even work

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

JewKiller 3000 posted:

in that case why don't you run the type checker before you run your program? then you don't have to call it a dynamic language anymore, and you'll benefit from better compiler performance and static correctness guarantees
Presumably because it's bolted on after the fact and can't reliably reason about every bit of code. Still way better than nothing, of course.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

MononcQc posted:

I don't know for you guys but my dynamic language of choice has a type checker that has parametric types and does inference and poo poo



I like dialyzer and typescript

MononcQc
May 29, 2007

Soricidus posted:

isn't the erlang thing more like a linter, it tells you where the types look wrong but you can still run the program and it might even work

It's a full blown type checker, but instead of implementing Hindley-Milner or some other system like that, it does success types. Rather than doing an axiomatic analysis (start with the bottom type, allow things and expand it when you prove they work), it goes the other way around and starts with the 'term()' or 'any()' type and goes for subtypes of it as constraints are discovered in you program (i.e. if you are using additions, the inferred type is no longer allowing lists, tuples, binaries, etc., but only numeric types).

When it finds an error, it therefore knows for sure there is a problem. So rather than going "here are all the unprovable types", it goes "here are all the provably wrong types" which means you swap false positives and correctness for no false positive and possibly letting some errors through.

This was due to their objective:

quote:

Our main goal is to make uncover the implicit type information in Erlang code and make it explicitly available in programs. Because of the sizes of typical Erlang applications, the type inference should be completely automatic and faithfully respect the operational semantics of the language. Moreover, it should impose no code rewrites of any kind. The reason for this is simple. Rewriting, often safety critical, applications consisting of hundreds of thousand lines of code just to satisfy a type inferencer is not an option which will enjoy much success. However, large software applications have to be maintained, and often not by their original authors. By automatically revealing the type information that is already present, we provide automatic documentation that can evolve together with the program and will not rot. We also think that it is important to achieve a balance between precision and readability. Last but not least, the inferred typings should never be wrong.

Dialyzer is also able to do stuff like purity analysis (they haven't used it, but there's ideas around turning the type inference to be more stricter when a code subset is known to be pure for example), or race condition detection, and comes with a second tool (typer) which looks at code and generates type signatures for you.

I do believe some of that inference is used in HiPE to generate native code that optimizes code paths deemed safe.

E: an interesting bit in there is that the type checker finds more errors the larger the programs are; they do very little efficient work on small programs as there is little information to be used to refine types.

MononcQc fucked around with this message at 16:46 on Jun 10, 2016

suffix
Jul 27, 2013

Wheeee!
is there a hipster relational query language that is like sql but good?

i've been hitting cases of things that should be easy but turns out to require bolt-on-feature x that is only supported in some random 25% of sql servers

someone must have made something based more on relational algebra and less on cobol

Carthag Tuek
Oct 15, 2005

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



suffix posted:

is there a hipster relational query language that is like sql but good?

i've been hitting cases of things that should be easy but turns out to require bolt-on-feature x that is only supported in some random 25% of sql servers

someone must have made something based more on relational algebra and less on cobol

yea its here yo (20%)yo (73%) yo/74%)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
hipster database programming is just doing manual joins in ruby on a non-performant object store with no transactional guarantees

suffix
Jul 27, 2013

Wheeee!
apparently it's called tutorial d, or maybe business system 12 if you want to go retro

kind of interesting but probably completely pointless since nothing supports it

http://c2.com/cgi/wiki?QueryLanguageComparison

http://dcs.warwick.ac.uk/~hugh/TTM/Importance-of-Column-Names.pdf is basically a critique of sql
i can agree with some of it, but lol at advocating natural joins, and double lol at doing it on the same page you're using 'E#' as a column name
how much of an academic do you have to be to not anticipate the accidental name collisions from that

Cybernetic Vermin
Apr 18, 2005

datalog should come back

Grim Up North
Dec 12, 2011

in the same vein there's andl

quote:

Andl is a New Database Language designed to replace SQL and then go beyond.

Andl is a full programming language with an advanced type system; it is relationally complete and has higher order queries; and it has platform independent interfacing. So Andl does two things well: perform advanced relational queries and build an application data model for any platform.

First, Andl can perform relational queries at or beyond the capabilities of any SQL dialect. It can do all the ordinary things like select, where and join but it can also do generative queries, self-joins, complex aggregations, subtotals and running totals (a bit like SQL recursive common table expressions and windowing).

it being written in C# and not being ported to ms mono, and also forbidding commercial use has stymied my plans to rely on a project developed by one .NET graybeard.

Tavistock
Oct 30, 2010



Cybernetic Vermin posted:

datalog should come back

Datomic is sorta datalog and fully sick, http://www.datomic.com

To bad it's expensive and not open source

Gul Banana
Nov 28, 2003

don' t try and write database-agnostic SQL

like, T-SQL and PL/SQL and pgSQL are all fine. they're also similar ENOUGH that an ORM can generate code for them like dialects. but 'ANSI SQL' is essentially a nonsense

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Gul Banana posted:

don' t try and write database-agnostic SQL

like, T-SQL and PL/SQL and pgSQL are all fine. they're also similar ENOUGH that an ORM can generate code for them like dialects. but 'ANSI SQL' is essentially a nonsense

just order an ansi standard za

brap
Aug 23, 2004

Grimey Drawer
SQL is not a language but rather a big pile of special cases

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i enjoy writing sql

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





MALE SHOEGAZE posted:

i enjoy writing sql

me too. it is a sickness

the day i learned about CTE's in postgres was legitimately a highlight of my professional career

AWWNAW
Dec 30, 2008

MALE SHOEGAZE posted:

i enjoy writing sql

Bloody
Mar 3, 2013

the talent deficit posted:

me too. it is a sickness

the day i learned about CTE's in postgres was legitimately a highlight of my professional career

i dont doubt that postgres contains chronic traumatic encephalopathy

Cybernetic Vermin
Apr 18, 2005

sql is poo poo and old-school databases are poo poo but databases in general and query languages with some sound logical basis are good fun to work with

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Bloody posted:

i dont doubt that postgres contains chronic traumatic encephalopathy

Adbot
ADBOT LOVES YOU

compuserved
Mar 20, 2006

Nap Ghost
SQL is cool and good

reminder: https://wiki.postgresql.org/wiki/Mandelbrot_set

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