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
Notorious b.s.d.
Jan 25, 2003

by Reene

Posting Principle posted:

should i actually make an effort to learn scala

if you expect to work in a java shop ever again, yeah probably worth it

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006
people don't use scala irl. java shops use java or c#

Posting Principle
Dec 10, 2011

by Ralp
i'm not sure i want to work in a java shop

Notorious b.s.d.
Jan 25, 2003

by Reene

Tiny Bug Child posted:

someone posted this a couple pages back, it is hilarious and taught me as much about scala as i will ever need to know

i just don't really agree with him about most of his points, he's a disingenuous trollin' motherfucker, but now that three people have posted the link i guess i gotta address them

  • His workers can't understand what a scala.collection.Traversable interface is for? are they loving illiterate? I just don't believe this one.

  • "So this one guy says the only way to do this is with a bijective map on a semi-algebra, whatever the hell that is" -- nobody talks like this.

    The scala community basically exiled the FP spergs, they went off and created the scalaz library. If you want to get crazy functional, you can, and you can do it over there, not in the core language.

    Did he accidentally post to an academic mailing list? Or was he making poo poo up because you are trying to troll HN? (I think I know which one it is.)

  • For-loop crap: that hasn't been true for a really long time. Longer than I've been using the language. I don't think it was true when he wrote the memo two years ago.

  • Performance complaints about specific types in the collections library makes no sense. Different collections classes exist specifically to provide different semantics and performance tradeoffs. I just don't understand why he's mad that a Set is sometimes faster than other structures.

lastly, all his complaints about sbt are true, and then some. sbt is a hopeless, indefensible crock of poo poo and it never fails to anger me

Notorious b.s.d. fucked around with this message at 22:17 on Oct 9, 2013

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

Pie Colony posted:

code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

my intuition says it shouldn't compile, or barring that should return -1. python agrees with the latter.

funy code.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Bloody posted:

cool 14 page """standard"""

utf-8 is like 12, and it p much is the best

Notorious b.s.d.
Jan 25, 2003

by Reene

trex eaterofcadrs posted:

utf-8 is like 12, and it p much is the best

the unicode standard is 692 pages

utf-8 can be simple/concise specifically because the foundational material is longwinded/careful/explicit

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Notorious b.s.d. posted:

the unicode standard is 692 pages

utf-8 can be simple/concise specifically because the foundational material is longwinded/careful/explicit

well it's kind of similar

json based on the ecmascript spec, at 243 pages

Notorious b.s.d.
Jan 25, 2003

by Reene

trex eaterofcadrs posted:

well it's kind of similar

json based on the ecmascript spec, at 243 pages

json is a bad spec

i assume ecmascript is badly specified too, because ecma are a rubber stamp who will ratify anything you want as a standard

this is why c#/cil is an ecma standard and not iso or ietf. iso would actually require the standard to make sense. ietf would require interoperable implementations and permit revisions/additions by other vendors

X-BUM-RAIDER-X
May 7, 2008
fuckin love my pretend standards (rfc)

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Notorious b.s.d. posted:

json is a bad spec

i assume ecmascript is badly specified too, because ecma are a rubber stamp who will ratify anything you want as a standard

this is why c#/cil is an ecma standard and not iso or ietf. iso would actually require the standard to make sense. ietf would require interoperable implementations and permit revisions/additions by other vendors

might be true but "it works"

Nomnom Cookie
Aug 30, 2009



MononcQc posted:

New JSON standard is out.
They still went with the railroad diagrams. I hoped they'd at least specify that object names need to be unique
and if there are duplicates whether you drop them, accept the first one or the last one, or deny all input. This poo poo is still unspecified and implementation-dependent.

if it was well-specified then it would be "too big"

Nomnom Cookie
Aug 30, 2009



Pie Colony posted:

code:

       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	

what should this code do?

murder whoever wrote it

FamDav
Mar 29, 2008

Pie Colony posted:

code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

this makes me think of throwing an exception in a destructor

fritz
Jul 26, 2003

Notorious b.s.d. posted:

hate to break it to you: python is one of the slowest languages ever

cython takes care of some of that, i got a 10x improvement on a thing a while ago just by changing py to pyx and importing the thing a little differently

Max Facetime
Apr 18, 2009

Pie Colony posted:

code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

Issue a warning, before anything else

Nomnom Cookie
Aug 30, 2009



prematurely exiting a finally block is heinous abuse of a language and should be illegal

My Ideal Programming Language would disallow exits from finally and also disallow catch blocks. this is what rust and go do iirc

Tokamak
Dec 22, 2004

Pie Colony posted:

code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

Use c++ with RAII and smugly goad others over the terseness of c++.

PrBacterio
Jul 19, 2000
nope, sorry, this is never right
I don't even need to read the rest of your sentence

fritz
Jul 26, 2003

Pie Colony posted:

code:
       for(;;) {       	   
           try {
      	       return 1;
           } finally {
               break;	   
           }		   
       }		   
       return -1;	
what should this code do?

make the author feel ashamed

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
it should crash. "for (;;)" should never be valid

PrBacterio
Jul 19, 2000

Tiny Bug Child posted:

it should crash. "for (;;)" should never be valid
huh what the hell why not, thats the most comfortable idiom for an endless loop in c(++) so why shouldnt I use it (except because no one should ever use c++ at all, but thats a topic of its own)

b0lt
Apr 29, 2005

Tiny Bug Child posted:

it should crash. "for (;;)" should never be valid

http://ideone.com/uzXv8r

uG
Apr 23, 2003

by Ralp

PrBacterio posted:

huh what the hell why not, thats the most comfortable idiom for an endless loop in c(++) so why shouldnt I use it (except because no one should ever use c++ at all, but thats a topic of its own)

goto LABEL if you want to be smug otherwise yeah for(;;) is the norm for C

Tokamak
Dec 22, 2004

PrBacterio posted:

huh what the hell why not, thats the most comfortable idiom for an endless loop in c(++) so why shouldnt I use it (except because no one should ever use c++ at all, but thats a topic of its own)

ever heard of syntactic sugar, its what those cool haskeller kids are always going on about. no point putting conditions in your for-loop, if you don't want them to ever be satisfied. same goes with c++'s powerful operator overloading feature

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





MononcQc posted:

New JSON standard is out.
They still went with the railroad diagrams. I hoped they'd at least specify that object names need to be unique
and if there are duplicates whether you drop them, accept the first one or the last one, or deny all input. This poo poo is still unspecified and implementation-dependent.

wtf? the json standard was supposed to be fixed. i maintain three and a half different json parsers i don't have time to fix them

horse_ebookmarklet
Oct 6, 2003

can I play too?
a little late but

Socracheese posted:

i have a dumb programming question. has anyone messed with neural network things before?

why are people using linked hardware to try to simulate, why cant u just abstract the neurons with C++ objects or something on one computer with a shitton of ram
Neural networks are really a math problem, not a software design problem.

You could implement a simple single layer perceptron network. Perceptrons have well documented problems (they're p bad), but are an approachable place to start.
In this case you could:
  • Define (and allocate a handful) of objects containing weight, bias, and links to other nodes. Give the objects logic to run and update the network
  • Allocate two vectors, weight and bias, then use a loop to run and update the network

Check out this case where two dudes attempt to solve sudoku. One guy attempts to solve it using "agile" methods and gets bogged down in how to represent the data and writing tests. The other guy (Norvig :swoon:) just writes some constraints and a solver.

Zlodo
Nov 25, 2006

Notorious b.s.d. posted:

no one can craft correct programs in c++

c++ devs imagine they can
the rest of us already know that's not true

and since every other language is directly or indirectly implemented in c++ (or c) it means that no language implementation is correct, and therefore that no program in any language is correct

Vanadium
Jan 8, 2005

still no trailing commas allowed in json, trash standard

X-BUM-RAIDER-X
May 7, 2008

PrBacterio posted:

(except because no one should ever use c++ at all, but thats a topic of its own)

elaborate

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

this is how you sort in c++ and c++ people think that this is worth showing off:

shrughes posted:

clock() returns approximate processor time used by the program, not waiting time. And you didn't even count transfer times. Also, my CPUs are faster than your GPU.

code:
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <thread>
#include <vector>

template <class T>
void find_mids(T first1, T last1, T first2, T last2,
               T *mid1_out, T *mid2_out) {
    size_t n = ((last1 - first1) + (last2 - first2)) / 2;

    T w1 = first1;
    T w2 = first2;

    while (n != 0) {
        size_t m = n - n / 2;
        if (m > last1 - w1) {
            w2 += m;
        } else if (m > last2 - w2) {
            w1 += m;
        } else {
            if (*(w1 + (m - 1)) < *(w2 + (m - 1))) {
                w1 += m;
            } else {
                w2 += m;
            }
        }
        n -= m;
    }
    *mid1_out = w1;
    *mid2_out = w2;
}

template <class T, class U>
void recombine(T first1, T last1, T first2, T last2,
               U dest_first, int levels) {
    T mid1, mid2;
    find_mids(first1, last1, first2, last2, &mid1, &mid2);

    auto first_part_size = (mid1 - first1) + (mid2 - first2);

    if (levels == 1) {
        std::thread t(std::merge<T, T, U>,
                      first1, mid1, first2, mid2,
                      dest_first);
        std::merge(mid1, last1, mid2, last2,
                   dest_first + first_part_size);
        t.join();
    } else {
        std::thread t(recombine<T, U>, first1, mid1,
                      first2, mid2,
                      dest_first, levels - 1);
        recombine(mid1, last1, mid2, last2,
                  dest_first + first_part_size,
                  levels - 1);
        t.join();
    }
}

template <class T, class U>
void do_fastsort(T first, T last,
                 U aux_first, U aux_last,
                 int levels) {
    if (levels == 0) {
        std::sort(first, last);
    } else {
        T mid = first + (last - first) / 2;
        U aux_mid = aux_first
            + (aux_last - aux_first) / 2;
        std::thread t(&do_fastsort<T, U>,
                      first, mid, aux_first, aux_mid,
                      levels - 1);
        do_fastsort(mid, last, aux_mid, aux_last,
                    levels - 1);
        t.join();

        if (levels % 2 == 1) {
            recombine(first, mid, mid, last,
                      aux_first, levels);
        } else {
            recombine(aux_first, aux_mid, aux_mid,
                      aux_last, first, levels);
        }
    }
}

template <class T>
void fastsort(T first, T last) {
    using V = typename T::value_type;
    std::unique_ptr<V[]> aux(new V[last - first]);

    do_fastsort(first, last,
                aux.get(), aux.get() + (last - first), 6);
}

double clock_secs() {
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    return ts.tv_sec
        + static_cast<double>(ts.tv_nsec) / 1000000000;
}

int main() {
    srand(time(NULL));
    puts("Generating randoms...");
    std::vector<int> vec(pow(2, 26));

    for (int& x : vec) {
        x = rand();
    }

    puts("Sorting...");
    double start = clock_secs();
    fastsort(vec.begin(), vec.end());
    double duration = clock_secs() - start;

    if (!std::is_sorted(vec.begin(), vec.end())) {
        printf("Oops, not sorted!\n");
    } else {
        printf("Sort runtime: %f\n", duration);
    }
}
Sort runtime: 0.422622

Nomnom Cookie
Aug 30, 2009



isn't timsort in c++ stdlib? it is in java. ofc if you took out the reinvented wheels 90% of c++ code would cease to exist

X-BUM-RAIDER-X
May 7, 2008
who cares

X-BUM-RAIDER-X
May 7, 2008
oh no people writing code in a good language, how awful

Zlodo
Nov 25, 2006

Cocoa Crispies posted:

this is how you sort in c++ and c++ people think that this is worth showing off:

no it isn't

std::sort is how you sort in c++

Nomnom Cookie
Aug 30, 2009



i would like to do something meaningful with my waking life and not spend half of it recreating algorithms already better implemented by my betters. these libraries work well enough for my purposes and i don't need to flip out about the few percentage points i could gain by tripling this project's maintenance burden
-- idk but definitely not a c++ programmer

Zlodo
Nov 25, 2006

Nomnom Cookie posted:

i would like to do something meaningful with my waking life and not spend half of it recreating algorithms already better implemented by my betters. these libraries work well enough for my purposes and i don't need to flip out about the few percentage points i could gain by tripling this project's maintenance burden
-- idk but definitely not a c++ programmer

i havent met any single c++ programmer arguing against using the stl in ages

Nomnom Cookie
Aug 30, 2009



Zlodo posted:

i havent met any single c++ programmer arguing against using the stl in ages

thats because experienced c++ programmers have a personal library of hacked up containers they c+p into every project

Adbot
ADBOT LOVES YOU

Nomnom Cookie
Aug 30, 2009



its better because it doesn't copy. just dont use the value after adding it ez pz

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