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
Brain Candy
May 18, 2006

hackbunny posted:

like, a compile-time ast api

boost sprint

now i am forever sullied

Adbot
ADBOT LOVES YOU

b0lt
Apr 29, 2005

hackbunny posted:

like, a compile-time ast api

have you heard of our lord and savior, martin odersky?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Brain Candy posted:

boost sprint

now i am forever sullied

spirit?

Brain Candy
May 18, 2006

those would be the right letters

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

bobbilljim posted:

where are your stored / parametrized queries???

I use x-macros to build the static parts, ie the list of columns, the list of parameter placeholders, and the list of binding parameters themselves. the schema is stupid simple and I would have been happy with the babbiest of babby orms but bb10 doesn't have even that, so half-handwritten half-autogenerated queries it is. I paste together some string literals, some x-macros expanding to other string literals, and I get queries that might be handwritten clean as they are

so goddamn happy to be finally using c++ at work

objective c is alright, java is fine and groovy is tolerable, but man. c++ in production eternal job security :woop:

Brain Candy posted:

boost sprint

I mean an api into the compiler's ast, to generate code at compile time in a type-safe way. type-safe macros. using (x-)macros makes you write code like this:

C++ code:
#define DEFINE_SETTER_(Type_, Ref_, name_, Name_) \
	void FartBoner::set##Name_(Ref_ new##Name_) { \
		m_##name_ = new##Name_; \
	}

FARTBONER_ENUM_PROPERTIES(DEFINE_SETTER_)

#undef DEFINE_SETTER_
yeah it works, not to mention the only way to achieve this result, but it's super-gross


and every time I bring up type-safe macros/compile time data this is what they tell me

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
to be actually useful, there should be another api that works at the semantic level, where you can query symbol tables, type definitions etc.

it will never ever happen

e: I did see a proposal for a low-level reflection primitive in c++ that was basically compile-time introspection

hackbunny fucked around with this message at 01:21 on Mar 10, 2015

Brain Candy
May 18, 2006

boost proto :colbert:

somebody tried it http://icai.ektf.hu/pdf/ICAI2010-vol2-pp383-390.pdf

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
it just lacks the analog warmness of token-pasting

MrMoo
Sep 14, 2000

bobbilljim posted:

where are your stored / parametrized queries???

Use MemSQL, no support for stored proc or prepared statements, but parameterized queries are there. In MemSQL queries are translated into source code and fed into GCC.

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
cutesy sql wrappers including orms tend to get useless when you need nested queries or grouped queries, god help you if you need both

the most important query in our model (fills the data in the very first page of the UI) is

SQL code:
SELECT fartboner1.timestamp AS timestamp, fartboner1.key AS key, fartboner1.fart AS fart, fartboner1.boner AS boner,
	(SELECT COUNT(*) FROM fartboner
		WHERE key = fartboner1.key
			AND NOT acknowledged) AS unacknowledged_entries
	FROM fartboner AS fartboner1
	LEFT OUTER JOIN fartboner AS fartboner2
		ON fartboner1.key = fartboner2.key
			AND fartboner1.timestamp < fartboner2.timestamp
	WHERE fartboner2.key IS NULL
	ORDER BY fartboner.timestamp DESC
on iOS with Core"don't call me an orm"Data I had to break it down into three queries, one of which repeated for each row

(rereading it now it seems it could return more than one result for each unique key, if they have identical timestamps. goddamn)

MrMoo posted:

Use MemSQL, no support for stored proc or prepared statements, but parameterized queries are there. In MemSQL queries are translated into source code and fed into GCC.

sure, let's add a caboose to the qcc mantrain

Shaggar
Apr 26, 2006
please use stored procs

Bloody
Mar 3, 2013

hackbunny posted:

cutesy sql wrappers including orms tend to get useless when you need nested queries or grouped queries, god help you if you need both

the most important query in our model (fills the data in the very first page of the UI) is

SQL code:
SELECT fartboner1.timestamp AS timestamp, fartboner1.key AS key, fartboner1.fart AS fart, fartboner1.boner AS boner,
	(SELECT COUNT(*) FROM fartboner
		WHERE key = fartboner1.key
			AND NOT acknowledged) AS unacknowledged_entries
	FROM fartboner AS fartboner1
	LEFT OUTER JOIN fartboner AS fartboner2
		ON fartboner1.key = fartboner2.key
			AND fartboner1.timestamp < fartboner2.timestamp
	WHERE fartboner2.key IS NULL
	ORDER BY fartboner.timestamp DESC
on iOS with Core"don't call me an orm"Data I had to break it down into three queries, one of which repeated for each row

(rereading it now it seems it could return more than one result for each unique key, if they have identical timestamps. goddamn)


sure, let's add a caboose to the qcc mantrain

i hope the fartboners are a direct copy and paste

Notorious b.s.d.
Jan 25, 2003

by Reene

gonadic io posted:

reminder: 90% of these are a normal haskell function with:
- possibly '<' in front of it (returns the value before applying the function)
- the infix function name itself
- possibly '@' (indexed)
- then either ~ (is a normal function lens) or = (is a lens affecting the state) after it

sure <<>~ looks like a tampon but <> is great.

how is this really that different from all of printf's operators? "%+-6.6f\n" is fine right you just have to know the spec or have it in front of you

resurrecting this bad post from page 3 to remind you that printf is loving terrible and should die

Notorious b.s.d.
Jan 25, 2003

by Reene

hackbunny posted:

cutesy sql wrappers including orms tend to get useless when you need nested queries or grouped queries, god help you if you need both

the most important query in our model (fills the data in the very first page of the UI) is

SQL code:
SELECT fartboner1.timestamp AS timestamp, fartboner1.key AS key, fartboner1.fart AS fart, fartboner1.boner AS boner,
	(SELECT COUNT(*) FROM fartboner
		WHERE key = fartboner1.key
			AND NOT acknowledged) AS unacknowledged_entries
	FROM fartboner AS fartboner1
	LEFT OUTER JOIN fartboner AS fartboner2
		ON fartboner1.key = fartboner2.key
			AND fartboner1.timestamp < fartboner2.timestamp
	WHERE fartboner2.key IS NULL
	ORDER BY fartboner.timestamp DESC
on iOS with Core"don't call me an orm"Data I had to break it down into three queries, one of which repeated for each row

(rereading it now it seems it could return more than one result for each unique key, if they have identical timestamps. goddamn)


sure, let's add a caboose to the qcc mantrain

this query would be easy to do in hibernate, and probably more readable. bad ORMs exist but not all ORMs are bad because you touched activerecord once

MeruFM
Jul 27, 2010

Notorious b.s.d. posted:

this query would be easy to do in hibernate, and probably more readable. bad ORMs exist but not all ORMs are bad because you touched activerecord once

what was hibernate's reasoning for making a query language almost like sql but not really?

just to gently caress with everyone who first thought they could write straight sql?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Notorious b.s.d. posted:

resurrecting this bad post from page 3 to remind you that printf is loving terrible and should die

reminder that nbsd's proposed replacement was c++ iostreams but without the operator overloads, because localisation doesn't matter I guess

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Notorious b.s.d. posted:

this query would be easy to do in hibernate, and probably more readable. bad ORMs exist but not all ORMs are bad because you touched activerecord once

more like activerecord touched me

Shaggar
Apr 26, 2006
all orms are bad use statement mappers and procs

leftist heap
Feb 28, 2013

Fun Shoe
iBatis was and is pretty simple to use and useful which explains why it never really took off. people just love loving around with poo poo like hibernate endlessly instead of just using something simpler and moving on with their lives.

Notorious b.s.d.
Jan 25, 2003

by Reene

MeruFM posted:

what was hibernate's reasoning for making a query language almost like sql but not really?

just to gently caress with everyone who first thought they could write straight sql?

hibernate tried to be all things to all people, and some people are stupid.

i always preferred the criteria interface

Java code:
 List cats = session.createCriteria(Cat.class)
     .add( Restrictions.like("name", "Iz%") )
     .add( Restrictions.gt( "weight", new Float(minWeight) ) )
     .addOrder( Order.asc("age") )
     .list();	

Notorious b.s.d.
Jan 25, 2003

by Reene

Soricidus posted:

reminder that nbsd's proposed replacement was c++ iostreams but without the operator overloads, because localisation doesn't matter I guess

you could keep the string templating for localization purposes, but abandon the dumb and totally un-type-checked dsl for formatting

the bits inside the template would just be names for the parameters, and you could have type safety on the named arguments. so the compiler can know if the thing about to be formatted as a float actually is a float

Notorious b.s.d. fucked around with this message at 20:04 on Mar 10, 2015

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Notorious b.s.d. posted:

you could keep the string templating for localization purposes, but abandon the dumb and totally un-type-checked dsl for formatting

the bits inside the template would just be names for the parameters, and you could have type safety on the named arguments. so the compiler can know if the thing about to be formatted as a float actually is a float

cool, and how exactly do i set the number of significant digits on that float

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Notorious b.s.d. posted:

you could keep the string templating for localization purposes, but abandon the dumb and totally un-type-checked dsl for formattin

this is pretty disingenuous btw, every c compiler for a thousand ages has given warnings if the types in your format string don't match the types of the actual arguments provided

Notorious b.s.d.
Jan 25, 2003

by Reene

Dessert Rose posted:

cool, and how exactly do i set the number of significant digits on that float

with a typechecked class or function whose sole purpose is to format floats, instead of bashing it into a mega-subroutine like printf

Notorious b.s.d. fucked around with this message at 21:19 on Mar 10, 2015

Notorious b.s.d.
Jan 25, 2003

by Reene

Blotto Skorzany posted:

this is pretty disingenuous btw, every c compiler for a thousand ages has given warnings if the types in your format string don't match the types of the actual arguments provided

so you are telling me bugs relating to the lack of typechecking in printf are so common and troublesome that compilers have special handling specifically for printf?

great language design there, guys

Bhodi
Dec 9, 2007

Oh, it's just a cat.
Pillbug
Wasn't someone suggesting printf strings were the only reasonable way of sending data to logger because otherwise you have to perform an operation per variable to concatenate it?

nm it was shaggar http://forums.somethingawful.com/showthread.php?threadid=3548182&pagenumber=322&perpage=40#post442140978

Bloody
Mar 3, 2013

c# string formatting is different from c printf

Soricidus
Oct 21, 2010
freedom-hating statist shill
fwiw i quite agree that the printf we have today is deeply flawed. but the basic concept of string templates using a dsl to specify formats is good and convenient and likely to be more readable than any alternative, and in languages that are insufficently powerful to handle typechecking that in a library, it is sensible for the compiler to special-case that typechecking.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

compiler should see into the logging code and sink the computation of the logging string below the is-enabled test :colbert:

Notorious b.s.d.
Jan 25, 2003

by Reene

Soricidus posted:

fwiw i quite agree that the printf we have today is deeply flawed. but the basic concept of string templates using a dsl to specify formats is good and convenient and likely to be more readable than any alternative, and in languages that are insufficently powerful to handle typechecking that in a library, it is sensible for the compiler to special-case that typechecking.

yeah i guess this is where we disagree. i find the dsl for formatting to be really, really terrible. it's so hard to remember, i have to look up the specific format every time. if i wrote format strings all day every day, that would probably stop. but i don't. it's optimizing for the wrong case. code should be easy to read, being easy to write is totally optional

the lack of typechecking and lovely compiler warnings are just consequences of the bad design

Soricidus
Oct 21, 2010
freedom-hating statist shill

Notorious b.s.d. posted:

yeah i guess this is where we disagree. i find the dsl for formatting to be really, really terrible. it's so hard to remember, i have to look up the specific format every time. if i wrote format strings all day every day, that would probably stop. but i don't. it's optimizing for the wrong case. code should be easy to read, being easy to write is totally optional

the lack of typechecking and lovely compiler warnings are just consequences of the bad design

i'm not even sure we disagree all that much. depends whether you mean the printf dsl specifically, or all dsls period. the printf dsl is bad.

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

Subjunctive posted:

compiler should see into the logging code and sink the computation of the logging string below the is-enabled test :colbert:

macros, my friend. macros

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

Notorious b.s.d. posted:

it's so hard to remember, i have to look up the specific format every time. if i wrote format strings all day every day, that would probably stop. but i don't.

if you write C or C++ code every day, you'll use printf format strings every day. or you are a bad programmer and have no/bad logging in your code

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
if you have a specific suggestion for how to do it better without losing templating, that would be cool. it is not a coincidence that most languages tend to recreate printf at some point, dynamic unsafety and all

if you had dynamic type information, you could avoid some of the %f/%g crap, i guess? but now you've introduced dynamic type metadata into the language, good luck with designing that tiny little feature

feel free to say "you should completely abandon some basic goals of your language in order to make printf better", but maybe you should recognize that's what you're saying

Sapozhnik
Jan 2, 2005

Nap Ghost
uuh just make it a variadic template and don't encode the type information in the format string? C++11 can do this now, all that's really needed is some sort of std::to_string() convention.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
ah yes, C++-style variadic templates, a small feature that could have been painlessly added to c in 1980

Soricidus
Oct 21, 2010
freedom-hating statist shill

Mr Dog posted:

uuh just make it a variadic template and don't encode the type information in the format string? C++11 can do this now, all that's really needed is some sort of std::to_string() convention.

this is the kind of thing people tend to come up with, yes.

then they realise that you can't simply say "convert all these objects to strings please" because you also need to handle different bases for numbers, different precisions and rounding modes and scientific notation, content-aware padding that might care about lining up things like decimal points, etc etc ... and the formats become more complex, and if you're not careful you're back at printf except instead of a bad syntax that only a few people know, you have a bad syntax that nobody knows.

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
I'm rather fond of Boost.Format but internally it's based on iostreams and that's eugh

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

Notorious b.s.d. posted:

this query would be easy to do in hibernate, and probably more readable. bad ORMs exist but not all ORMs are bad because you touched activerecord once

you're confusing me with shaggar I think

I have used GORM (Grails) and CoreData. CoreData in particular makes complex queries nearly impossible, but then CoreData "is not an ORM". GORM's most common API, the criteria builder DSL, doesn't support subqueries and the alternatives (detached criteria) are horribly documented and poorly integrated. which is par for the course for Grails, visible plumbing and nested layers of dynamic dispatch everywhere

Adbot
ADBOT LOVES YOU

VikingofRock
Aug 24, 2008




I don't really understand all the hate for C++'s streams. Is it just that they are not typechecked or is there more?

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