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
Zlodo
Nov 25, 2006

prefect posted:

i've heard that linq can be punishing performance-wise because sometimes you'll wind up calling methods way more than you would have if you'd just used a plain old loop

that's because j-languages only way to do polymorphism is at runtime with interfaces and poo poo which is completely ridiculous for things like linq

a c++ implementation of linq would own, except that everyone is too lazy to do it

Adbot
ADBOT LOVES YOU

Zlodo
Nov 25, 2006

Nomnom Cookie posted:

i used c++ in college and then got a java job. now i'm using c++ again after abt 5 years and it seems p nice using boost.asio, shared_ptr, etc. its almost as convenient as java. is this going to bite me in the rear end? tia

damnit don't shed your c++ hater label your making me all confused and scared

but yeah c++11 is p good and have managed to smooth out many things but still have some rough spots

c++03 is a pita to use in comparison. I use it at work and god how im missing lambdas and auto

Zlodo
Nov 25, 2006

Otto Skorzeny posted:

i think gcc and clang and msvc mostly supported auto (and decltype? maybe?) before the standard was even finished

yeah, vc2010 supports quite a few c++11 goodies
unfortunately we use 2008 at work

Zlodo
Nov 25, 2006

MrMoo posted:

Using GCC 4.8.1 on RHEL 5, the C++ error messages have really improved quite nicely.

yeah, thats thanks to the competition from clang
its funny how even in open sores people aren't willing to get off their rear end and improve things until a competitor shows up that does things better

Zlodo
Nov 25, 2006
yeah i looked into it sometimes and ugh

reminder: it was originally written by rms and even though they prolly threw away most of his code over the year im sure his ~spirit~ still permeates the code base

Zlodo
Nov 25, 2006

prefect posted:

if you had been a c programmer in 1980, i bet you would have murdered bjarne stroustrup

when I was writing assembly i was like "lol c is piss easy poo poo for dumbasses"
then i switched to c and i was lke "lol c++ is a dumb loving mess of things that some dumb academic bolted onto c bc he prolly feels like its ~theoretical nicer~ this way, then i read stroustrup's faq about c++ and it was approaching all those things from a practical angle so i trhough well maybe ill try to use c++ right and see how it goes"
now i use c++ and im like "lol wasteful bytecode interpreted java/c# shaggar PoS" but its been like 10 years and my mind isnt remotely about to change this time until a better natively compiled language than c++ comes along

Zlodo
Nov 25, 2006

Nomnom Cookie posted:

i wish c++ had sane and convenient features rather than a horrifyingly complicated and lovely compile-time environmemt for computation of types.

yeah that's basically what i dislike with c++. you can do all kind of neat compile time stuff but you are forced to use functional kinda programming with a very awkward syntax just because the entire thing grew out of a system that was originally only made to do generic containers

thing is there's no good alternative mature language with good metaprogramming facilities that compiles to native code

rust is promising but looks still quite some way from being a production quality language

Zlodo
Nov 25, 2006

unixbeard posted:

jit compilation is better anyway cause it can make the most of whatever the current cpu supports

everything has p much the same cpus nowadays
desktop: core I whatever
mobile: some arm w/ neon

I thought the standard fantasy that jit is better than offline compilation was that it could detect hot code paths dynamically

Zlodo
Nov 25, 2006

prefect posted:

is there a language where a nice pile of regex isn't going to look like that, though?

regex are gross and only useful to sift through the dejections of another program to find some data

if you need to write regex you are doing a job so unimportant that no one bothered to output the data you need in an usable format

Zlodo
Nov 25, 2006

:barf:

Zlodo
Nov 25, 2006

MononcQc posted:

Schemes and Lisp often toyed with the idea of alternative function-based approaches to regular expressions. One of them (SRE) had the POSIX regex:

code:
"[[:<:]]([b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z])+[[:>]]"
Be represented in Scheme as:

code:
(w/nocase (word+ (~ ("aeiou"))))
Where a sequence of functions would just build a matching expression. The interesting thing you could do with these is that you can define matches as functions and compose them:

code:
(define ws (rx (+ whitespace))) ; Seq of whitespace

(define date (rx (: (| "Jan" "Feb" "Mar" ...) ; A month/day date.
                    ,ws
                    (| ("123456789")          ; 1-9
                       (: ("12") digit)	      ; 10-29
                       "30" "31")))))
In that case we're defining two expression: ws, for whitespace, and date, for a month followed by whitespace and the numbers 1-31. Later on, I can define and compose regular expressions by doing:

code:
(rx ... ,date ... (* ... ,date ...)	    
          ... .... ,date))
This is all macro-time poo poo, but there was run-time stuff prepared for it with a different function (use csl instead of rx)

It's an interesting approach that ultimately seems to have never caught on (much like Scheme itself), and can be somewhat obtained by concatenating strings (although groups of backreferences and poo poo are not safe to merge all willy-nilly)

well basically this is what happens when you want to make regex not poo poo: you turn it into an actual parser with multiple independently defined grammar rules that can be reused, and with the right language / library writing such rules can be made really nice and easy so why even bother with regex

this is typically the type of things that ~the power of C++~ is very good at. using templates and operators overloading you can have something very similar to that scheme thing above that let you define and compose parsing grammar rules like this:

code:
    auto slsl = Term( '/' ) & Term( '/' );
    auto slst = Term( '/' ) & Term( '*' );
    auto stsl = Term( '*' ) & Term( '/' );

    auto NewLine = Term( '\n' ) >> [&]( const range_t& r ){ ++lineNum; lineStart = r.begin() - source.begin(); };

    auto Comment = slsl & Until( Any(), End() | NewLine );
    auto CommentBlock = slst & Until( NewLine | Any(), stsl );
    auto Blank = InString( " \t\r" ) | NewLine;
    auto Space = +( Blank | Comment | CommentBlock );
then it all compiles down into the bunch of function you'd write for each of those rules to implement that grammar as a recursive descent parser
boost::spirit offers just such a parsing library

Zlodo
Nov 25, 2006

Tiny Bug Child posted:

if you never need to write regex your job is so boring that someone has already gotten to the data you need and carefully digested + regurgitated it so your babby self can handle it

my job is not boring BC I'm not a web dev who have nothing else to do than data janitoring

Zlodo
Nov 25, 2006
the main rationale behind "exceptions should be used only for truly exceptional cases" is pretty simple: exception handling is slow.

I dunno how they are implemented in java but in c++ the way they work on a decent compiler (ie not vc++) is that when the exception is thrown a bunch of lookup tables are used to unwind the call stack and find out which objects need to be destructed until a suitable handler is found to catch the exception.

(vc++ just pushes and pop exception handlers on the stack during the normal execution flow so it slows you down even when you don't throw. Good job by microsoft as always)

so basically if you are at least slightly concerned about performance you shouldn't use exceptions for things that are expected to happen during a normal execution of your program

for instance imagine you can load config files or plugins from multiple location, like you try the current dir first, then a user specific location, then a system location. you try loading your thing from all these places and a lot of failures are expected. if you use exceptions for that you'll have a bunch of them thrown every time although nothing bad is actually happening that justifies using such a costly mechanism

Zlodo
Nov 25, 2006

tef posted:

this sorta dogma ridden hand writing over a confused language feature is possibly why go didn't include them

According to their FAQ it seems to me that the reason they don't like exceptions is the same reason as most people who don't like exceptions:

quote:

Why does Go not have exceptions?
We believe that coupling exceptions to a control structure, as in the try-catch-finally idiom, results in convoluted code. It also tends to encourage programmers to label too many ordinary errors, such as failing to open a file, as exceptional.

Zlodo
Nov 25, 2006

Posting Principle posted:

can text editors be our new argument tia

on what planet text editors arguments can possibly be new

Zlodo
Nov 25, 2006

Max Facetime posted:

quick, who of those discussing the slowness of exceptions has benchmarked exceptions recently?



well, no need to scamper to your compilers to whip up some microbenchmarks because I already did that, and the results are:

pre:
100_000_000 repeats of trivial work done, 50% errors:

method 1, boolean return          took  667 ms,  result was 3
method 4, reused flow exception   took  752 ms,  result was 3

a mere 10% slowdown for the privilege of using some dodgy flow control as part of the normal execution path

lol java programmers

also

quote:

method 3, option type wrapper took 910 ms, result was 3
there should be no reason for an option type to be significantly slower than returning a value + a bool indicating if its valid. java is awful

Zlodo
Nov 25, 2006

b0lt posted:

memory allocation/deallocation is free and instantaneous

allocating memory on the stack (which is how value types too large to fit into registers are returned in c++) pretty much is: it is literally nothing more than an addition

Zlodo
Nov 25, 2006
pointer to members are v useful to do things like serialization, scripting language bindings, using methods as callbacks for listeners and such

Zlodo
Nov 25, 2006

Notorious b.s.d. posted:

trigger warning: this is worse than c++

well duh

Zlodo
Nov 25, 2006

Tiny Bug Child posted:

it's php in 95% of cases. i've been using python lately for some stuff php isn't fast enough for and it's also adequate, so if you like dumb formatting rules you can use that too.

lol at python being faster than php
PL special olympics

Zlodo
Nov 25, 2006

spongeh posted:

http://peterevjan.com/posts/we-should-all-just-decide-on-javascript-and-solve-the-interesting-problems-instead/

let's all just abandon every language and use javascript!!!!!

also re: all the above if i'm able to understand what tef is saying y'all are dumb and tef is right when dealing with protocols. for a bunch of posters who go on and on about MAKING IT SIMPLE FOR THE USER!!! there sure is a lot of point missing going on here. not hardcoding urls is better. let the programmer deal with the complexity of determining what's supported. the end user doesn't care and just wants the best/fastest.

"lets make it simple to the user by making him supply the url"

lol

Zlodo
Nov 25, 2006

spongeh posted:

yea just like you supply the url to http://forums.somethingawful.com instead of going to http1.1://forums.somethingawful.com/v2/ because i'm using a web browser that supports http 1.1 and because i'm familiar with my client enough that i know i can use some arbitrarily named v2 of the website.

everything is a web app that runs through a web browser

Zlodo
Nov 25, 2006

Malcolm XML posted:

Didn't you get the headers, they negotiated a new version of posting but kept the names the same

Zlodo
Nov 25, 2006

lol

Zlodo
Nov 25, 2006
more like cripple optional types because our language sucks and have to store everything as a pointer to a thing allocated separately on the heap but now for some reason we actually do care about cache efficiency

jdk8 more like jok8

Zlodo
Nov 25, 2006

Tiny Bug Child posted:

yes, exactly. my point was that autoloading is just how you do it in PHP. he was drawing a parallel between autoloading and eval like autoloading was as gross as using eval, but they aren't comparable at all

the various shades of gross in PHP are hard to discern for normal people

Zlodo fucked around with this message at 19:41 on Sep 18, 2013

Zlodo
Nov 25, 2006
best 30$ i spent in a while

Zlodo
Nov 25, 2006

im the unticked_statement
no wait im the expr_without_variable

Zlodo
Nov 25, 2006

Notorious b.s.d. posted:

perl regex is turing complete and can be used to write a complete parser no problem

it's just that most people don't bother

because being turing complete doesnt mean its not an horrible pile of trash

you could write a complete parser in brainfuck

Zlodo
Nov 25, 2006
xml does something that everyone needs it and it doesnt really do it well but not badly enough that people bother using something better

if you do small poo poo like some configuration files or serializing a few things its ok. if xml is used for instance as a file format to describe (during development) all the objects making up a large video game's open world and perforce takes one hour to get the latest version of the data and the game take 5 minutes to load you kind of wish a less wasteful format like json had been used

re: schemas you can do schemas in json too

in fact, plot twist: you can even do schema validation on plain text. it's called a "parser" and the schema is called a "grammar". thats another thing with xml, people seem to literally believe that you can't do cool data manipulation on structured data represented in any other way than tags in angle brackets

Zlodo
Nov 25, 2006

Notorious b.s.d. posted:

having a well-specified standard means that when i want to interoperate with a french mainframe, an american minicomputer from the 1970s, and a warehouse running Windows, i'm gonna use xml

ah yeah clearly a typical day-to-day use case for most people

Zlodo
Nov 25, 2006

Shaggar posted:

yeah that's kind of the whole point of serialization.

yeah you clearly never need serialization in a context that doesnt involve heterogenous systems

Zlodo
Nov 25, 2006

Notorious b.s.d. posted:

yes it is a completely typical day-to-day use case

or have you never shopped in a retail store
or driven a car
or used a product manufactured in a country other than the u.s.

most code in the world isn't consumer-facing webapps written by startup wunderkinds. it's awful vile data processing to manage business processes

i don't remember having to personally deal with data serialization and validation last time I shopped at a store, drove my car or used a product??? I think you might be doing those things wrong

Zlodo
Nov 25, 2006

Shaggar posted:

in that case a custom binary format would be faster

shaggertef was right

Zlodo
Nov 25, 2006
re: config files, unironically just write a parser

you can define a grammar + parse a file using it in a few lines of code in c++ with a good parsing library

Zlodo
Nov 25, 2006

unixbeard posted:

C++ is probably pretty cool if you've never used anything but C++

I used basic assembler c c++ c# lua and javascript and i think c++ owns hth

Zlodo
Nov 25, 2006
oh I also used python but its so awful that I'm unconsciously blocking those memories apparently

Zlodo
Nov 25, 2006

Shaggar posted:

use wpf for apps

no use qt

Zlodo
Nov 25, 2006

Pollyanna posted:

but im on osx :(

use qt wpf is bad anyway

Adbot
ADBOT LOVES YOU

Zlodo
Nov 25, 2006

double riveting posted:

the reason plang people hate xml:

design goal: xml does everything
design outcome: xml does everything badly

it is the php of data serialization.

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