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.
 
  • Locked thread
fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

fritz posted:

was Delphi like pascal where arrays of different lengths were different types

rust has this today

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

fart simpson posted:

rust has this today

are you serious

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

yes, but it also has "slices" into an array which are variadic size

Luigi Thirty
Apr 30, 2006

Emergency confection port.

quote:

My cohort Mike Mika and I were porting Klax, the arcade tile matching game, to Game Boy Color. It was a fun, intense, six-week project to bring one of our favorite games to the system.

We had the C source code (which was just Escape from the Planet of the Robot Monsters with a lot of robot monsters commented out and Klax put in), and we had chatted a lot with Dave Akers, the original arcade programmer, who had coded the prototype in Amiga BASIC over a weekend and ported it to C in something like one day.

Jesus

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

An array is a collection of objects of the same type T, stored in contiguous memory. Arrays are created using brackets [], and their size, which is known at compile time, is part of their type signature [T; size].

let xs: [i32; 5] = [1, 2, 3, 4, 5];
let ys: [i32; 6] = [1, 2, 3, 4, 5, 6];

these are different types

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

eschaton posted:

what design?

Borland cloned Delphi from object pascal before Anders was there from what I understand, he just tacked on some Common Lisp features (properties, aka slots) and OpenStep features (events, aka target/action)

and C# was just a clone of Java that to which he added those same Common Lisp and OpenStep features
In his defense, mechanically copying Common Lisp features makes you a smarter person than many language designers.

fart simpson posted:

An array is a collection of objects of the same type T, stored in contiguous memory. Arrays are created using brackets [], and their size, which is known at compile time, is part of their type signature [T; size].

let xs: [i32; 5] = [1, 2, 3, 4, 5];
let ys: [i32; 6] = [1, 2, 3, 4, 5, 6];

these are different types
See also vec, which is heap-allocated and has a dynamic length not specified in the type. It's basically the same deal as C: fixed-size arrays on the stack, dynamic whatever on the heap.

b0lt
Apr 29, 2005

fart simpson posted:

rust has this today

c++ does too, and so does c kind of, with weird syntax that no one uses (int foo(int bar[static 3])), except pointers just get coerced

zeekner
Jul 14, 2007

fart simpson posted:

An array is a collection of objects of the same type T, stored in contiguous memory. Arrays are created using brackets [], and their size, which is known at compile time, is part of their type signature [T; size].

let xs: [i32; 5] = [1, 2, 3, 4, 5];
let ys: [i32; 6] = [1, 2, 3, 4, 5, 6];

these are different types

yea, but you can interact with them via slices, which don't have a static length. the compiler is maintaining the real size of the array for safety reasons while still letting you access it in a more straightforward way in your type definitions.

a parameter type that can accept both of your example arrays is just &[i32] (or &mut [i32] for a mutable slice)
code:
fn array_thing(x: &[i32]) {
    println!("slice length: {}", x.len());
}

comedyblissoption
Mar 15, 2006

bobbilljim posted:

it is truly scary how many people are against const / final
I think Rich Hickey made a cool talk about why this is so
http://www.infoq.com/presentations/Simple-Made-Easy

Preferring mutability is a lot easier/more familiar to most people than the less complicated solution of preferring immutability

there's also the extreme inertia of mainstream practices to prefer mutability

I think it just takes time for these things to take hold

a lot of people like to point out that it took a generation of programmers before arguments over using JMP as a regular control flow construct were finished

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Uncomfortable Gaze posted:

yea, but you can interact with them via slices, which don't have a static length. the compiler is maintaining the real size of the array for safety reasons while still letting you access it in a more straightforward way in your type definitions.

a parameter type that can accept both of your example arrays is just &[i32] (or &mut [i32] for a mutable slice)
code:
fn array_thing(x: &[i32]) {
    println!("slice length: {}", x.len());
}

yeah

Vanadium
Jan 8, 2005

rust has a thing called dynamically-sized types where references to a lot of similar-ish concrete types can turn into fat references to a more generic type and the extra info from the type that got lost in the conversion

so &-references to [T; 1], [T; 42], [T; a million] can all be turned into &[T], which is basically a (ptr, length) tuple. this sorta makes intuitive sense to me since you can't have, like, a local variable of an array of a length that is only dynamically known, if it's not statically sized it has to live behind a pointer indirection.

it actually also works like that for functions and closures, where even among functions with the same signatures, every one is its own type. so when you pass a function to another function that's generic over the function type, the other function gets a shot at inlining your function into it since it's monomorphized knowing the exact function type and hence the exact function. and when you need to do stuff where you don't know statically what function you're looking at, you forget the type and use an actual function pointer (or for closures a fat pointer like (fnptr, closed-over-data-ptr))

remember that rust needs to appeal to C++ nerds who've been telling themselves that abstractions should be zero-cost for decades, so they basically need to be able to pretend that a sufficiently smart compiler can see through all the abstractions and generate optimal code since all the type info is still there!!

suffix posted:

did delphi ever get usable generics? i remember looking at a program to figure out why it loaded files so slowly, and it had like six copies of bubble sort for different array types.

yeah but the version we use doesn't. everything even slightly abstracted is either stringly-typed (TStringList as a list of "key=value" strings) or dynamically-typed (apparently there's Variant types which can be most of the types you'd find in an sql thing, and conveniently anything even slightly non-trivial we do seems to invole a lot of juggling sql-derived data). i wrote (copied from wikipedia) a quicksort the other day because there didn't seem to be a reasonable general sort function (not even something like qsort in C's stdlib), but got to throw it away when it turned out i could just dump all my data in a thing for representing sql query results and tell it to sort it instead.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
c terrible programmer s: finally got my c++ port of the deep dream technique working.

was bashing my head against it for a while and then started a snack overflow post, halfway through the post i knew where to look to find the problem

rubber duck debugging works yo

oh no blimp issue
Feb 23, 2011

my boss/professor is making our 16 year old intern use R, i have no experience with R but i assume this is a bad idea

Vanadium
Jan 8, 2005

Dessert Rose posted:

c terrible programmer s: finally got my c++ port of the deep dream technique working.

was bashing my head against it for a while and then started a snack overflow post, halfway through the post i knew where to look to find the problem

rubber duck debugging works yo

rubber ducks are the best and stackoverflow is pretty great for inducing the rubber duck experience, because you just know if you don't spell out your problem precisely enough, some shitlord there is gonna try to get your question closed or w/e

oh no blimp issue
Feb 23, 2011

i opened a question on stack overflow sometime asking about a recursive permutation algorithm and it was just full of people going "i dont understand", "what does the swap function do?"

Soricidus
Oct 21, 2010
freedom-hating statist shill

Awia posted:

my boss/professor is making our 16 year old intern use R, i have no experience with R but i assume this is a bad idea

the one good thing I can say about R is that at least it isn't matlab

VikingofRock
Aug 24, 2008




Dessert Rose posted:

snack overflow

ConanTheLibrarian
Aug 13, 2004


dis buch is late
Fallen Rib

comedyblissoption posted:

I think Rich Hickey made a cool talk about why this is so
http://www.infoq.com/presentations/Simple-Made-Easy

Preferring mutability is a lot easier/more familiar to most people than the less complicated solution of preferring immutability

there's also the extreme inertia of mainstream practices to prefer mutability

I think it just takes time for these things to take hold

a lot of people like to point out that it took a generation of programmers before arguments over using JMP as a regular control flow construct were finished

im sorry but mutability is key to getting maximum performance out of my perl scripts

Soricidus
Oct 21, 2010
freedom-hating statist shill

ConanTheLibrarian posted:

im sorry but mutability is key to getting maximum performance out of my perl scripts

i would like to recommend that you make use of this forum's mutable posts instead of allocating new ones all the time

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Soricidus posted:

the one good thing I can say about R is that at least it isn't matlab

i kinda like r

Bloody
Mar 3, 2013

R sure is a thing that exists

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Bloody posted:

R sure is a thing that exists

imo the best thing you can do for an intern is to make them work on terrible/legacy code.

R might not be a bad choice.

KOTEX GOD OF BLOOD
Jul 7, 2012

i loved this poo poo in middle school

Bloody
Mar 3, 2013

MALE SHOEGAZE posted:

imo the best thing you can do for an intern is to make them work on terrible/legacy code.

R might not be a bad choice.

ugh no they ask so many questions. why are they so helpless and useless. why can't they just Google poo poo. gently caress

Bloody
Mar 3, 2013

fresh hires, too. asking so many dumb rear end questions. when I say I don't know what I'm really saying is just figure it out yourself, it's not complicated, put in some effort, stop bothering me

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Bloody posted:

fresh hires, too. asking so many dumb rear end questions. when I say I don't know what I'm really saying is just figure it out yourself, it's not complicated, put in some effort, stop bothering me

those people really piss me off

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Awia posted:

my boss/professor is making our 16 year old intern use R, i have no experience with R but i assume this is a bad idea
there is no good reason to use R over python for a new project

RangerAce
Feb 25, 2014

Bloody posted:

fresh hires, too. asking so many dumb rear end questions. when I say I don't know what I'm really saying is just figure it out yourself, it's not complicated, put in some effort, stop bothering me

I politely nod and reply, "I've got a link I can send you."

Then I email them lmgtfy.com links.

oh no blimp issue
Feb 23, 2011

coffeetable posted:

there is no good reason to use R over python for a new project

i said that, but they've switched to python now anyway

oh no blimp issue
Feb 23, 2011

is it possible to sniff data off bluetooth connections without pairing? ive got like one of those fitness bands that i wanna get the stuff off without using the normal app

alternatively could i just sit a sniffer near it during a normal pair and collect everything?

Bloody
Mar 3, 2013

yes*

fritz
Jul 26, 2003

coffeetable posted:

there is no good reason to use R over python for a new project

except if there's r packages that do the analyses you need but you'd have to write the python yourself

Shaggar
Apr 26, 2006

Bloody posted:

fresh hires, too. asking so many dumb rear end questions. when I say I don't know what I'm really saying is just figure it out yourself, it's not complicated, put in some effort, stop bothering me

actually the worst is when you give them the answer and tell them why its the answer and then they don't do it like you said because it would take them 10 extra minutes

fritz
Jul 26, 2003

fritz posted:

except if there's r packages that do the analyses you need but you'd have to write the python yourself

also ggplot is reason enough to go with r

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

r has easier to use plotting stuff built into it than matplotlib

oh no blimp issue
Feb 23, 2011


hit me with the footnote

Vanadium
Jan 8, 2005

is this safe space accepting of indentation style discussions

Share Bear
Apr 27, 2004

Bloody posted:

fresh hires, too. asking so many dumb rear end questions. when I say I don't know what I'm really saying is just figure it out yourself, it's not complicated, put in some effort, stop bothering me

i wish i had better mentoring, because they're all like this, because the definition of what is simple is relative

i try not to do it as much, but if it's like "what does group by do in sql" i get annoyed

Share Bear
Apr 27, 2004

Vanadium posted:

is this safe space accepting of indentation style discussions

no

do what your team lead does

if you dont have a spec make one and then make whatever bullshit decision you want because theyre all wrong

Adbot
ADBOT LOVES YOU

oh no blimp issue
Feb 23, 2011

Vanadium posted:

is this safe space accepting of indentation style discussions

hard tabs or gtfo

  • Locked thread