[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 26
File: hime c.png (1 MB, 1280x720) Image search: [Google]
hime c.png
1 MB, 1280x720
old thread: >>54037315

You have been visited by the 3 star programmer of Shimoshina Academy!

Good performance, triple indirection, and tail call optimization will come to you, but only if you post "Keep overflowing the stack, Hime!".

Also, what are you working on, /g/?
>>
>>54042677
fuck
>>
Genuine question here
Is it really a good idea to cast the return value of malloc()?
>>
Would you attend her coding class?

Full tuition + tip
>>
File: 1452861416362.png (132 KB, 507x325) Image search: [Google]
1452861416362.png
132 KB, 507x325
FUCKING RETARDS.
GET YOUR FUCKING SHIT TOGETHER FOR FUCK SAKE.
>>
I'm trying to compile some firmware following this tutorial

https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141386

and I'm getting the error message as in
>>54042311

Please send help, I have no idea what I'm doing. I don't know jack shit about coding.

>>54042672
Thanks, but I'm just getting a different error message now.
>>
>>54042703
You should ask if it's a good idea to still code in C when C++11/14 exists
>>
>>54042703

It will have no impact on the generated code whatsoever, but some people may think it'll look shitty. On the other hand, if you're using malloc in C++ (for whatever reason), you HAVE to cast the result.
>>
>>54042677
keep overflowing the stack hime!
>>
>>54042753
Jesus christ those cheekbones.
>>
>>54042753
i'll give her just the tip.
>>
use this thread. fucking trap cancer in here >>54037326
>>
>>54042677
Why is she casting return value of malloc()? Is she using C++?
>>
>>54042753
I'd probably go into the class, talk shit for 5 minutes and get asked to leave
>>
File: Untitled-123.png (696 KB, 3320x1920) Image search: [Google]
Untitled-123.png
696 KB, 3320x1920
Mocking up my app in Photoshop because I want to know what the UI will look like before making it. Lay out the features and such.
It will fetch a JSON from UPCItemDB (based on the search query) and display the results, as shown on pic related.
>>
>>54042857
m8, nobody cares
>>
>>54042677
Keep overflowing the stack, Hime!

Also still porting this MATLAB shit. I'm 99% sure the sequence I'm searching is hidden in a fig file.
I don't understand why or how but I can't find it anywhere else. And I can't view the fig file, MATLAB freezes when I want to.
>>
>>54042877
looks neat anon
>>
>>54042867
>she
>>
File: clipscreen-BK33.png (45 KB, 343x547) Image search: [Google]
clipscreen-BK33.png
45 KB, 343x547
>>54042937
Yes, she, you foul newfag.
>>
>>54043015
The only newfag here is you.
Hime is a boy, you fucking retard, did you even watch the anime?
>>
>>54043038
No. Sorry oldfag-kun. Which anime? Let us be nice.
>>
File: i am dead inside.gif (420 KB, 500x282) Image search: [Google]
i am dead inside.gif
420 KB, 500x282
Can anyone stop an error in this query?

http://pastebin.com/nNHzDfYL


The
LastPostIndexed
seems to be fine but
LastPostIndexedAuthor
is always wrong
>>
This might be off topic, but I truly trust you homosexuals to know this: is there such a thing as a hardware volume equalizer? I'm in dire need of one.
>>
>>54042757
Malloc exists in C++ too.
>>
>>54043038
If she's a boy, why doesn't she look like a boy?
>>
>>54043610
You must be new to anime.
most boys in anime can easily look exactly like girls if they only put on a wig and wear girl clothes.
>>
>>54043510
Kill yourself.
>>
>>54042753
Is that you delores?
>>
>>54043653

Very rude, family.
>>
>>54042857
Did you notice the trap image features something relating to programming? Did you notice that image does not?
>>
>>54043564
and it is always wrong to use malloc in C++
>>
>>54043803
Then why is it included?
>>
>>54043814
because C++ has to be a superset of C
>>
>>54042677
I've been curious for a while but what kind of programming challenges do they tackle in that show?
>>
>>54043510
Fucking Google it, you lazy asshole.
>>
>>54043826
Then by definition, if there is an appropriate use for malloc in C, then there must be an appropriate use for it in C++. Because almost every C program is also a C++ program.
>>
>>54043852

Couldn't find anything.
>>
what is c# used for? can you get jobs for it?
>>
So this is sort of an abstract question.

But whats the sort of algorithm to detect how many new results on a page.

My thoughts are as follows:

Original Follow on Page saves the original timestamp and original title of the most recent result.

Then update checks if the first result's timestamp is the same as the cached one, and if so it returns 0 results.

If the first result is not the same timestamp then it checks title, if that is not the same then it checks the second result, adding 1 to a counter, and so on until the cached on. Then it does in reverse the amount of the counter and prints the list of new updates.

I just feel as if this could be made easier though.

Anyone have any comments on this?
>>
>>54043991
Web development and enterprise shit primary. Yes, there's shitloads of jobs for it.
>>
>>54043991
C# is pretty much Java, only better (and little less cross-platform)
>>
>>54043873
You are so fucking retarded.
>>
>>54044022
fuck off microshit shill
>>
>>54044161
fuck off oracle cuck
>>
>>54042677

rate my fizzbuzz

String out;
for(int i = 1; i<=100;i++){
out="";
if(i%3==0)out+="fizz";
if(i%5==0)out+="buzz";
if(out.length()==0)out+=i;
System.out.println(out);
}
>>
GTP btfo of pol
another day in the life of GTP
>>
In java I originally had:
function scr_EntityUpdate ( ID ) 
if entity[ID] ~=nil and entity[ID].ID == ID then
if entity[ID].upd then
entity[ID]:upd()
end
else
print( "ENT: unable to update entity ", ID )
end
end

Now I have:
void ent_UpdateAll ( void ) 
{
unsigned int i;
for ( i=0; i<G_ent->length; i++ )
{
/* grab the entity table */
lua_getglobal( gVM, "entity" );

/* grab the array that correlates to the G_ent's ID no. */
EntArr *e = array_get ( G_ent, i );
lua_rawgeti( gVM, -1, e->ID );

/* grab the update (upd) function and call it */
lua_getfield( gVM, -1, "upd" );
if ( lua_isfunction(gVM, -1) ) {
lua_pushvalue(gVM, -2); /* so the self variable works */
if( lua_pcall ( gVM, 1, 0, 0 ) != 0 )
lua_error( gVM );
}
}
}

Which runs alot better and uses less memory I might add (as far as I know).

I'm trying to internalize this:
function EntityAdd ( objtype, ID, x, y ) 
if _G[objtype] then
if entity[ID] == nil then
entity[ID] = entityMT:import( objtype )

entity[ID].ID = ID

if entity[ID].new then
entity[ID]:new()
end

entity[ID].offset.x = x
entity[ID].offset.y = y

print( "ENT: added entity at ", ID )
else
print( "ENT: unable to add entity ", ID )
end
else
print( "ENT: unable to find objtype: ", objtype )
end
end


but i'm having a hard time, given I have to call a metatable function. Any ideas?
>>
>>54044278
>java
lol it autocorrected to java from lua
>>
>>54044246

I didn't get blown out anywhere. The thread is still alive.
>>
>>54044292
back to /o/ turd
>>
I was watching house MD and there was this patient with aphasia(you can't spell or write the correct words that come to your mind, you just say and write gibberish) but he could answer with a yes or no when asked such a question. What would be the most efficient algorithm if you tried to build words letter by letter to understand him? Worst I can think of is a linear algorithm(the trivial is it a, is it b etc solution), the best I can think of is a binary search algorithm that runs at O(log(N)). Is there any faster one?
>>
>>54043510

a hardware volume equalizer is usually either a graphic equalizer or a parametric equalizer

or do you mean something just to turn down the volume?

google rackmount passive attenuator
>>
>>54044511

I think this is where the rub lies, I guess I'm looking for a volume normalizer, rather than an equalizer. I need loudness equalization.
>>
File: allheads.png (28 KB, 486x316) Image search: [Google]
allheads.png
28 KB, 486x316
what's a good way to scale a random number distribution?
>inb4 mod

Also xorshift generators are generally the fastest right?
>>
Reading a book on C# right now. I'm a little confused about enums. Is the primary benefit that they're basically limited versions of Python's dictionary? That is, it's a way of accessing a member that has a value by name instead of using an array and getting values by numbers which aren't very descriptive of the content?
>>
>>54044292
Kek
>>
>>54044427
give him a pen and paper and get him to draw what he wants to say instead?
>>
>>54044278
this isn't how you're supposed to use embedded scripting languages
you need simple, clear boundaries between your engine and your scripts
if you're in the position where you're rewriting script functions in your engine, you're wasting time and effort and haven't drawn the boundaries between script and engine in the right place
>>
>>54044674

I can't believe you ruined it. You son of a bitch.
>>
>>54044685
He can't draw, that's how aphasia works.
>>
>>54044427

This is actually something people have already worked on. The general idea is that you start with the most frequently used letters and move to the least frequently used ones.

You could also use a row column situation where you say "Is it a letter in row A? Is it a letter in row E?" etc. using vowels to split it into 5 rows. You can see an example of this in Breaking Bad when the nurse is helping Hector Salamanca write out what he wants to say. He indicates his choice by ringing a bell.
>>
>>54044699
I plan to leave the entity calling functions non-user changeable, with free range on being able to do whatever (within engine boundaries) for the entity
>>
>>54044528
As an audio engineer I think you're just saying words that sound like audio terms. Loudness has to do with dynamic range, which is controlled with a compressor or limiter. Equalization refers to controlling the volumes at different frequencies. Buying a USB eq (if that exists lol) would do what you want. If you just want a hardware volume knob, just get a rotary encoder and hook it to Window's volume knob through USB or whatever.
>>
>>54044731
euthanasia then
>>
>>54044752
It's usually not a permanent condition you thick fuck.
>>
>>54044759
then wait it out m8
>>
>>54044745
are your entities lua side objects or engine side objects? because they appear to be lua-side objects yet you're rewriting the functions for them in the engine. this defeats the point of using a scripting language in the first place. if you need more performance, make your entities engine-side objects. Writing engine-side functions that manipulate script-side objects defeats the point and should be done sparingly
>>
>>54044750
>As an audio engineer I think you're just saying words that sound like audio terms.

It's called 'loudness equalization' in pretty much every audio card driver I can think of. I just need a hardware version of it. The reason I can't google it that I don't know what the hardware equivalent is ACTUALLY called.

Please use your audio engineering mastery to redirect me to a piece of affordable consumer equipment that will make low volume scenes louder, and high volume scenes quieter.

All the best,
GTP.
>>
>>54044828
im not rewriting the entities functions, just internalizing the function that calls the entities function (in other words, removing the middle man).

internally just the ID no. is stored, but the rest of the object is/should be external
>>
>>54044628

Enums are not hash tables. They do not map keys to values. They simply are a set of typed integer constants. That their name is stored in assembly information does not really effect runtime performance, as the symbols should be resolved at compile time.
>>
awfully cheeky for someone who is looking for help.
>>
>>54044832
The problem with getting a piece of hardware is the need for a proper interface and a mixing board to get it working... which is expensive. The advantage of compressors is with consumer audio, they just torque the ratio really high (hence limiter) and leave the threshold engaged. My suggestion, get something like AULab and get a VST limiter. A lot of engineers use software over hardware because software is actually surpassing the feasibility of hardware. There's this big bullshit debate, but I won't go into it. In short, go with a VST limiter that can apply to your computer's audio output, set the threshold to where the signal is hitting it, and let it be. I don't know why you need it, but this is the best solution.
>>
>>54044427
>build words letter by letter
Is that one of the requirements, or would an auto-complete style approach also be acceptable? If so, there are tables that have the most used words, and it wouldn't be hard to adapt that into a sort of smart auto-complete.

Also...
>Is there any faster one?
Honestly? The algorithm efficiency doesn't matter too much, only the interface convenience. Comparing the time it takes a modern machine to do a linear search across 26 letters vs the time it takes to press a button or say yes or no, the application would spend almost all of its time waiting.
>>
encapsulation is a meme
pretty much every other OOP rule is valid, except for this one
inb4 CS graduate
prove me wrong
>>
File: 4.jpg (13 KB, 175x230) Image search: [Google]
4.jpg
13 KB, 175x230
>Here you can insert any custom CSS to the theme using the ACE Editor, which offers the ability to edit back-end
>CSS
>BACK END
>>
>>54044950
functional programming is a meme
pretty much every other functional rule is valid, except for this one
inb4 NEET
prove me wrong
>>
Hello /g/
first time posting here. I have an MD but after a while in general practice i decided this is not for me. I wanted to learn some programming, didnt actually know anything about it. So i started with what i found was the easiest language to learn (html and css). But my real goal is to make videogames, so i recently started learning python, its actually a lot of fun.

The question that brings me here is this, what language should i learn to start making my own game? also, i tried to find a site like code academy that teaches me c language, but haven't been able to find anything similar.
Please excuse me if my english is not perfect.
>>
>>54044917
Obviously there could be an auto-complete approach but I'm trying to make this as simple as possible.

The algorithm efficiency matters because the person with aphasia has to answer less yes or no questions with a more efficient algorithm.
>>
>>54044911

I need to be used with an otherwise analog system, though. It's part of my home theater setup.
>>
>>54044848
writing engine functions that deal entirely with script objects just because they run faster negates all the ease-of-use benefits you get from using scripts in the first place. if you're having performance problems, move the entity system entirely to the engine side. but it looks like you're just doing premature optimization so you should probably put the script functions where they belong, on the script side
>>
>>54042677
Implementing linked lists on c++ how do i do it?
How does it work
>>
>>54044986
C#
>>
>>54044999
Oh ok. You'd need to intercept the output of your amplifier, which can be tricky because consumer amps use banana plugs while hardware studio gear use TRS or XLR. You can get a converter cable I guess. So, onto a cheap compressor. I don't know the price range or whatever but, take a look http://www.sweetwater.com/c790--Compressors_Limiters

Keep in mind, Behringer isn't terrible at the price point, but it's pretty shit compared to anything else. Any compressors at a lower price point are going to be unreliable poo-in-loo noise bags.
>>
>>54045052
template <typename T>
struct LLNode {
T value;
LLNode<T>* next;
}
>>
>>54045070
How and why does it work? I'm googling but i'm finding old stuff, did you type this just now? where can i read more about it
>>
>>54045095
think of a box. The top of the box stores your school notes, the bottom of the box points to another box that holds more of your school notes. The "advantage" of this is it allows a data structure to exist without the data having to be right next to each other like in an array. This makes it easy to slip in data where ever you want without a huge hassle of shifting everything out of the way. It's retarded to do in actual practice, Stroustrup rightly points out it's retardedness.
>>
>>54045069

I've actually got all the audio running over TRS. Did that early on since I had some things going optical->analog
>>
>>54045152
he was probably asking what the template did, not the general theory of linked lists
>>
Does anyone have an example of two equivalent programs, one object-oriented and the other functional, on hand? I have serious trouble "rethinking" OOP code for anything non-trivial.
>>
>>54045184
Ah that's pretty good. A lot of gear nowadays use a XLR/TRS combo jack so you should be fine there. Do you have a price range in mind?
>>
>>54045202
Oh well theory behind a template is pretty simple.
template<typename T>


This tells the struct that there is a type named T now. This type is variable based on how it's defined in a struct declaration. For example,
LLNode<int> blah;


This tells the newly declared struct that all the times it sees T, it means int. Your struct will become

struct LLNode{
int value;
LLNode<int>* next;
}


You can use any type at any time. I don't think I need to explain the usefulness of this.
>>
File: CPP functional 2.png (12 KB, 454x286) Image search: [Google]
CPP functional 2.png
12 KB, 454x286
>>54045209
Currying and composition
>>
>>54045217

I was hoping to spend around $100, but it looks like that's right out.
>>
>>54042677
How important is discrete math? My final exam is in 7 days, and my pre-exam mark is 55%. How much is this going to hurt my chances of getting a job after graduation? I have like a B average otherwise.
>>
Apparently the Really Nice Compressor by FMR is a favored consumer device. It's also rather small, which is nice.
>>
>>54045277
Closest you can get is a Behringer, check this video out

https://www.youtube.com/watch?v=Ps8cjK72a1M?t=4m15s
>>
>>54043873
No

malloc and free have been replaced in C++ by other tools, such as new and delete. Smart pointers in C++11 can even give you reference-counted pointers that automatically free when no longer needed. Using malloc in idiomatic C++ would be fucking retarded and completely counterproductive. The only exception is when you're writing C style code and using C++ for a few useful features
>>
Friendly reminder that there is nothing wrong with linked list stacks.
struct _llist_node {
unsigned data;
struct _llist_node *next;
};

struct _llist_head {
struct _llist_node *head;
unsigned size;
};

typedef _llist_node lnode_t;
typedef _llist_head llist_t;

llist_t stack;
llist_init(&stack);
llist_push(&stack, data);
unsigned *val = llist_pop(&stack);
llist_destroy(&stack);
>>
>>54045302
That doesn't look too bad actually. It uses DSP but that's not necessarily a bad thing.
>>
>>54045378
For fuck sake why would you use a linked list stack if you're just going to do LIFO operations, it makes no sense.
>>
>>54045395
what if it's FIFO?

void llist_push(llist_t *stack, unsigned data)
{
lnode_t *node = (lnode_t *) malloc(sizeof(lnode_t));
node->data = data;
node->next = stack->head;
stack->head = node;
}
>>
>>54045378
Literally why would you not just use a ringbuffered array

ringbuffers are the most efficient solution for a finite stack and you're retarded for doing anything else unless you REALLY need theoretical infinity
>>
>>54044614
mod
>>
>>54045414
Then it would a queue. There a data structure for that too.
>>
>>54044614
div

/ (max / n)
>>
>>54045458
in my design you can only pop values in the reverse order that you pushed them.
that's a stack
>>
>>54044614
how is it distributed? there's usually a scale parameter in your typical distribution...
>>
>>54045469
that's [0, n] btw where % is [0, n)
>>
>>54045472
Then that would be LIFO you retard.
>>
>>54045503
I'd LIFO you too, if you catch my drift. ;)
>>
>>54045482
[0, 2^32) or [0, 2^64), uniformly

it'd be something like this (nicked from wikipedia)
#include <stdint.h>

uint64_t x; /* The state must be seeded with a nonzero value. */

uint64_t xorshift64star(void) {
x ^= x >> 12; // a
x ^= x << 25; // b
x ^= x >> 27; // c
return x * UINT64_C(2685821657736338717);
}

I wouldn't want to touch that big constant
it looks important
>>
File: stoolworthblessed.jpg (1 MB, 1688x2535) Image search: [Google]
stoolworthblessed.jpg
1 MB, 1688x2535
>daily reminder that the Son will not restore our souls to Heaven until we program away the evils of this world
>>
>>54045565
>jesus
>libcuck

I saw that one coming
>>
>>54045296
If you don't know or practice what you learned in school, first it's an utter waste of time, second you'll be unhirable. For your test in 7 days get into damage control mode and study now. Get the fuck off of this site.
>>
>>54045587
>If you don't know or practice what you learned in school, first it's an utter waste of time, second you'll be unhirable.

This makes no sense. I thought it was kind of implied that I was doing a CS degree.
>>
>>54045581
if the Son of God was Jesus he wouldn't have died. The Son is yet to come, but only after we've made a world where he can survive.

Stallman indeed does God's work and if we were all more like him the world would be a much better place, overly strict free doctrine or not.
>>
>>54045608
I got asked if I know any discrete math in a sophomore internship interview and didn't get the position when I said I didn't, so I guess it's important.
>>
>>54045623
Yeah but I would be able to answer yes to that question.
>>
is the C++ programming language 4th edition pdf actually badly formatted? Code samples are blue in color and typesetting in general looks shit

Or is it because it is a pirated copy, dl'd like 4 different versions and all the same

anybody have a legit one to compare? Or the hardcopy
>>
>>54045608
Yeah, and we know your kind.
>"i wanna get a job in computers"
>doesn't program outside of class
>doesn't have any drive to write software outside of class or outside of the language he learned in class
>act confused and glare at people who actually like programming as a hobby because "wow who the fuck actually likes this shit???"
>go on /g/ and make a shitfit about being "forced" to have an open source portfolio
>>
>>54045633
Ok then don't worry about it
>>
>>54045640
I have projects and a GitHub profile where I have my own stuff from outside of class, and no I'm not posting it here.
>>
>>54045659
ok so what's your question
>>
>>54045548
sorry I don't know what the fuck that function does. I never use XOR operators and I don't know how the >> and << works with it.

why not just use rand()?
>>
>>54045670
this
>>54045296
>>
>>54045296
you have 7 days. that's 28 hours of study time at a completely reasonable rate. go read your fucking book and work through problems. math is not hard and we don't need more ignorant tards in the working world.
>>
>>54045678
rand() is actually really fucking slow
you're better off scrambling your own numbers with something less random if it means less processor cycles per call

if you're working with multiple threads, don't even try to use rand() because they will all grab identical random values unless you use rand_r
>>
how do I get a 4chan post ip address?
>>
>>54045764
you have to be a janitor like me for those privileges.
>>
>>54045827
Check your privilege you cis scum.
>>
>>54042677
I really want to learn Perl or Python. What are the best resources available at the current time?
>>
>>54045827
can you give me an ip adress?

I need to bully an /int/ mexican piece of shit who is shittalking me since weeks ago.
>>
>>54045836
I do my janitor work in my dress like a dirty polish maid.
>>
>>54045865
I too, also do my programming work in skirt. :3
>>
>>54045864
not sure if retarded or retarded
>>
>>54045861
Google
>>
>>54045678
>why not just use rand()?
you're a python programmer, aren't you?
>>
>>54046050
I need to know his city so I can mock the faggot.
>>
File: maki.jpg (590 KB, 1240x1550) Image search: [Google]
maki.jpg
590 KB, 1240x1550
what programming language should i learn for maki?
>>
>>54046073
F# for Machi
>>
>>54045861

It depends on how you learn. Pluralsight and Team Treehouse are both good if you like videos. Learn Python the Hard Way, Think Python, Learning Python and Real Python are all good books (with very different styles and tones that may suit you).

It might be worth looking through a few of them and finding out which one speaks to you the most. They'll all be excellent choices for a beginner and none of them should really lead you astray (except Learn Python The Hard Way does have a big bias against Python 3 which isn't really deserved).

Also check out /r/learnpython. They'll be helpful and nice to you.
>>
>>54046073
i don't even like idol anime but maki fills me with warm happiness every time I look at her

you should learn javascript
>>
Will someone explain the controversy around linked lists to me? I've seen people say (with experiments to prove it) both that linked lists are far faster and far slower than arrays.
>>
>>54046434
linked lists usually work best in conjunction with other data structures

since they require no additional work to resize them, they're great for vector implementations

they're also good for handling hash collisions in hashmap implementations
instead of worrying about allocating more space for a collision, the colliding element just gets added as a node to the hash bucket
>>
File: 1410846695838.jpg (396 KB, 849x1200) Image search: [Google]
1410846695838.jpg
396 KB, 849x1200
>>54046073
Python. Maybe you can satisfy her with it.
>>
>>54046434
In C/C++? Yes. In higher level languages? You can't tell unless you know the implementation. Some just put your "linked list" into a large dynamic array.
Reason that linked lists are so slow is because operating systems allocate memory where it is optimal for the OS to not run out of usable memory. That leads to the allocated memory usually landing in different memory pages which you can only hold a certain amount of in the CPU for fast access. So with large linked lists (that are not actually arrays in the background) there's a good chance that a lot of the list elements are all over the god damn place and you constantly have to wait for page-swapping. Of course arrays can get so big that they don't fit in a single page, but the pages-per-element ratio is a lot higher.
>>
>>54046531
>pages-per-element ratio
I obviously meant the "elements-per-page ratio". Fuck.
>>
>>54046434

Someone earlier made the analogy that a linked list is like a set of numbered boxes with labels telling you which box to pick next, while arrays would be contiguous boxes.

The theory goes like this:
You've got 4 boxes. If you're using a linked list, all you need to do is change two labels - the box before the target position (to the new box), and the new box's label (to the box after the target position). If you've got an array, you need to move at least two boxes out of the way to make room for the next one - if there isn't room on the line, you need to move all of them to somewhere with room.

In practice, because of the relative speed of cache and memory, and because of things like prefetching, parellisation and prediction, it's more like this:
The boxes in the linked list version are all in different buildings.
>>
>>54045711
>rand() is actually really fucking slow

Isn't it more or less:
int rand()
{
static unsigned int seed = 1;

seed = (seed * 1103515245) + 12345;
return (seed >> 16) % 32768;
>>
>>54046073
>>54046527
>satisfy
D
>>
>>54046531
Additionally, arrays are extremely cheap to copy as they're a continuous range of memory. So even inserting data into an array can be faster than using a linked list, depending on a variety of factors (list/array length, position where the element is being inserted into, ...).
>>
>>54046583
srand() sets the random seed value, so it must static global variable inside rand.c
>>
File: TheProdigy.jpg (236 KB, 1737x662) Image search: [Google]
TheProdigy.jpg
236 KB, 1737x662
>"You're a mug, that's why I had to cut you down. You run with the wolves while I hunt like a hound." - Santiago Gonzalez, 2015
What did he mean by this?
>>
>>54046666
wow
puberty hit him like a ton of bricks
>>
>>54046434

Advantages of a linked list:
1. O(1) insertion at center when one has an iterator to do so (otherwise it's O(n) to seek to the center).
2. O(1) insertion at front or end. While this may not seem particularly special, given that a vector can do at least the latter in O(1) amortized time, there is an advantage here in that linked lists will never invalidate pointers when doing so. This makes them more suitable for functional languages that need a good, immutable data type.

Disadvantages:
1. O(n) random access. This hurts a lot for most practical use cases.
2. Requires an allocation on the heap for each node. By comparison, only log(n) allocations are used in a vector, less if you can get at least a ballpark estimate of how much memory you'll need from the start. Although the vector does require everything be moved over when you make a new allocation.
3. No guarantee of nodes being in contiguous memory, and many implementations, this is highly unlikely to occur. Most CPUs are optimized for accessing memory addresses in sequential order. Using a load or store operation on some address n tends to get n+1, n+2, n+3... up to the size of a cache line. Accessing elements by dereferencing pointers to completely different sections of memory is likely to generate a lot of cache misses, which are not cheap. For some datasets that are not particularly large, the O(n) cost of inserting at the middle of a vector may beat out the cost of the cache misses in a linked list.

Linked lists should be used where appropriate, but one should recognize that they do have some rather real flaws that make them not really the best choice for everyday data structures.
>>
Just finished converting dlink pin generator from python to android.
>>
>>54046628
Well, yeah; does that somehow slow it down?
>>
>>54046768
no, your example runs pretty fast

glibc's rand() is supposedly more "random" because it scrambles your number much further than necessary, but this kills performance, especially if you're calling it 3 million times per second
>>
Every single programmer should be required to understand low level concepts.
>>
>>54046820
what are low level concepts to you?
and please don't say C.
>>
>>54046826
You should be able to write a program to run on bare metal, without an underlying kernel.
C is not low level.
>>
>>54046860
news flash grampa, compilers write better assembler than you ever will

write C and port it to any architecture
it'll run plenty fast
>>
>>54046887
When the fuck did I say to write only in assembler?
All I said was that C is not low level, because it's true, that doesn't mean not to use it in a kernel, of course you can, and should.
but assembler is unavoidable, if you plan on writing your own bootloader (which you should be able to do) or install interrupt handlers, you don't really have a choice but to write them in x86 assembly.
The point is that you SHOULD be able to write a program, in any language (provided it has no runtime), that runs on bare metal without a kernel.
If you can't, then you should learn to do it, otherwise, you're not a programmer, and you should refrain from writing any more code.
>>
>>54046962
t. unemployed neet
>>
>>54046983
Good rebuttal.
>>
>>54046962

> you don't really have a choice but to write them in x86 assembly.
x86 is not the only ISA on the block, and given how cheap ARM computers are (and how they don't have a billion different gotchas like the fucking A20 line), it would be better for a beginner to develop an ARM kernel than an x86 kernel.
>>
>>54046962
>he point is that you SHOULD be able to write a program, in any language (provided it has no runtime), that runs on bare metal without a kernel.
If you can't, then you should learn to do it, otherwise, you're not a programmer, and you should refrain from writing any more code.

>You SHOULD be able to play Bach's Fugas, on any instrument (provided it has no electronic parts) that has keys or at least strings. If you can't, then you should learn to do it, otherwise, you're not a musician, and you should refrain from playing any more music.
>>
>>54047071
Sure, x86 was just an example, whatever arch you develop for doesn't have to be an intel arch.
>>
>>54047081
Fuck off retard, music is not in any way comparable to programming.
>>
// example about structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

struct movies_t {
string title;
int year;
} mine, yours;

void printmovie (movies_t movie);

int main ()
{
string mystr;

mine.title = "2001 A Space Odyssey";
mine.year = 1968;

cout << "Enter title: ";
getline (cin,yours.title);
cout << "Enter year: ";
getline (cin,mystr);
stringstream(mystr) >> yours.year;

cout << "My favorite movie is:\n ";
printmovie (mine);
cout << "And yours is:\n ";
printmovie (yours);
return 0;
}

void printmovie (movies_t movie)
{
cout << movie.title;
cout << " (" << movie.year << ")\n";
}


Going over some basic coding stuff, had a quick question about
void printmovie (movies_t movie)

Why is "movie" in there? I don't understand what it's referring to. Why wouldn't you just do void printmovie (movies_t) ?
>>
>>54047107
don't deprecate music senpai
>>
>>54047133
Do you even know what deprecate means?
>>
>>54047144
Yeah, it means shit on it

like when a cow deprecates in a field
>>
>>54047116
>Why wouldn't you just do void printmovie (movies_t) ?
Read chapter 1 again.
>>
>>54047116
in the forward declaration
readability
>>
>>54047157
Oh, I understand now. The movies_t is the type.

thanks anon
>>
>>54047116
I don't really do C++ but it looks like movie is the variable you're passing in referring to the specific movie, whereas the movies_t is telling it that movies isa movies_t structure. Since a structure is essentially defining a new type, you're letting the function know what the type of the variable is.

I dunno though I do lisp lol. Also I'm bad at explaining shit.
>>
>>54047182
why do you use a deprecated language family, family?
>>
>>54047246
cause lisp is the balls famalam
>>
>>54047178
Just for fun, that could have been "movies_t asblarghfarg" and the code would run fine. Variable names in function prototypes are for clarity and nothing else.
>>
>>54047289
why do you suck balls anon
>>
>>54047116
It's good practice to make your code as readable by others as possible. If someone is just glancing over your header, it'd make more sense seeing something like

int foo(int input, int output);


instead of this
void bar(int, int);
>>
What's the easiest way to implement an inline assembler on Windows?
>>
I got a phone interview for a coop job in San Jose (I'm from Canada). It is for a job called "embedded system software, integration and hardware intern" where I'm supposed to do stuff with FPGAs. I'm in second year and I put C and verilog on my resume which is what they were looking for, but I am a little rusty on both since I learned them last semester. My interview is next Tuesday. What should I do? What should I expect? Are they gonna grill my ass
>>
>>54042677
I don't know any C++ but am forced to use it for school, thus I write C, cast my mallocs, and change the file extension.
>>
>>54047434
bullshit. A class doing something with C++ doesn't touch the memory with malloc.
>>
>>54047417
C/C++ have inline asm

Call a C/C++ compiler
>>
File: scumbag-security.jpg (174 KB, 500x503) Image search: [Google]
scumbag-security.jpg
174 KB, 500x503
The big theme for this year at my job is security. A security team was formed and they started talking away access to a lot of things.

Developers who need to fix production issues are now locked out of production. Instead, they setup a special production support team. The problem is that production support is made up of interns and contractors. They're mostly black or Indian women and they've never used a command line shell in their lives. Nearly all the bugs they report are actually typos they made trying to run a command.

One of the dumbest things that happened recently though is that the security team wants me to have read-only access to the database in DEV! So not only do I get blamed for production issues that I'm no longer able to solve or even diagnose, but I can't freaking modify anything in DEV? Meanwhile single-mom Shaniqua and barely speaks English Sanji Patel are able to fuck around in Prod.
>>
>>54047634
That's probably a good sign to start looking for a new job.
>>
>>54047422
yes
expect embedded questions obviously
and maybe bit shit and what not
>>
>>54047422
If you have a phone interview with one of their engineers, then you're fucked. They love dick slapping you with their knowledge. Very easy to feel intimidated. If you can withstand that you're good. Study the fuck up on FPGAs and C.
>>
Hey guys, I am looking for a solution on something, Sometimes while I am coding at home, I have some free time in between my college classes, and sometimes I would like to test out some code on existing project. But don't have access to it, anyone use anything cloud base to sync between desktop, and laptop?

I was thinking of using google drive to achieve that, any other suggestions?
>>
>>54047871
what is this even
setup a git repo with bitbucket then work like, with copies on your laptop and desktop and pushing/fetching changes
or if you mean to ssh in your desktop with your laptop
>>
>>54045355
>replaced in C++
you don't know what you're talking about
>>
>>54047996
replaced for adoption yes, but not underlying obviously
>>
>>54048009
>backpedaling
classic
>>
>>54047328
tell that to openbsd
>>
Can anyone help me out?
I am trying to compile OpenSSL on windows with perl, native c++(visual studio 2008) and nmake. It finishes fine but is reliant on the MSVC90.dll which I do not like. Is there any way to bypass that dependency?
>>
>>54046887
>plenty
that's not fast enough
>>
>>54048103
/MT
>>
>>54048124
yeah I guessed so much, but in which step should I insert that?
>>
>>54048128
it's a compiler switch, so, the compilation step?
>>
>>54048150
that's not helping at all but i might have found its place in the makefile so... thx i guess
>>
>>54048048
it is replaced
they just can't remove it due to old codebases
>>
>>54045384
>>54045302

they're mono, though, he needs stereo. you can link two RNCs but it may be a bit fiddly for a home stereo system.

actually what he wants is a _limiter_

look for stereo limiters where the channels can be linked and which have 1/4" io

dbx 1066 for instance
>>
>>54047871
Bittorrent sync
>>
what makes a good programmer?

how do i transition from being an alright programmer to being a good programmer?
>>
>>54048297
fizzbuzz
>>
>>54048222
No it isn't, it's stereo. http://www.fmraudio.com/rnc.html

The ratio goes up to 25:1 which is above what is considered a limiter (20:1)
>>
>>54048297
Why would you want that? Being alright programmer is enough to get you paid, being a good programmer is overrated.
>>
>>54048297
Recursive Fibonacci sequences
>>
How do I want to do things? I never feel like doing anything and it makes work and fun hard.
>>
>>54048297
write reusable and well structured code
knowing a bunch of algorithms doesn't make you a good programmer
>>
>>54043814
Its not included. It comes from C. Probably lays in <cstdlib>. As printf does in <cstdio>.
>>
>>54043826
But C++ isn't a superset of C.
>>
>>54048547
>Its not included
anon...
>>
>>54048297

read and try to fix shitty code

read and fix good code

study what makes the good code good

takes time
>>
Suggest to me a smallish sized project as well as a language to complete it in.
>>
File: Untitled.png (36 KB, 1024x768) Image search: [Google]
Untitled.png
36 KB, 1024x768
Finally got my old shit compiling and running on old shit. :o
>>
>>54048745
Holy shit, is that Ubuntu 16? It looks fantastic
>>
>>54048829
It's actually ReactOS.
>>
>>54048740
Space invaders

JavaScript/canvas

OR

C/SDL
>>
>>54048745
>Icons from 9x
>Task Manager from XP
What is this abomination? NT 4.0?
>>
>>54048844
NT 4.0 m8.
>>54048863
Totally, I just used it to test compatibility since I couldn't find a way to virtualize a 95 machine and have OpenGL 1.2 support. Funny thing is that's it running in 32-bit color yet a ton of icons are still using low color mode.
>>
fizzbuzz took me about 3 minutes

am i a genius?
>>
>>54048892
Yes, that is really impressive.
>>
>>54048892
You probably did it wrong.
>>
>>54048892
post proof
>>
>>54043244
Post expected results and what you're getting now.
>>
Does someone have the picture with the D FizzBuzz snippet and the incredible smug Walter (or Andrei)?
>>
>>54048944
//current time: 6:21AM
static void FuzzBizz(int max) { int l = 1, i, O = 1; string c = "zz", a = "fi", b = "bu"; l += 2; i = l; i += 2; for (; O < max + 1; O++) WriteLine(((O % l) > 0 && 1 > (O % i)) ? a + c : (1 > (O % l) && (O % i) > 0) ? b + c : (1 > (O % l) && 1 > (O % i)) ? a + c + b + c : O + ""); }
//current time: 6:24AM
>>
>tfw high digit ratio
>tfw doomed to suck at programming
>>
>>54049001
>9001
ebin
>>
>>54049069
>69
ebin
>>
>>54049110
>110
YOU BLEW IT
>>
File: shocking_trick.jpg (14 KB, 480x360) Image search: [Google]
shocking_trick.jpg
14 KB, 480x360
>>
>>54049193
HackThePlanet();
>>
>universities in my country teaches Computer Engineering but not CS
why
i dont want tolearn physics and mechanics, i want to program
>>
How do I make java hang for a few seconds rather than immediately moving on to the next statement
>>
>>54049296
>want to program
>go to college instead of programming
>>
>>54049322
im writing this from my dev computer at work, i already know HOW to program
i want a masters degree to make applying for international jobs easier, and figured i might as well learn something i WANT to learn
>>
>>54049320
>>54049320
for (int i = 1; i < 8000000; i++)
{
int ayy = 0;
}
>>
>>54049358
For undergrad, do a business degree related to tech, like MIS or Supply Chain.

Get your master's in something specific to what you want to work in.

Boom, hirable as fuck.
>>
In the GL shading language, what happens if you add a float to a vec3?

float f = 0.1;
vec3 v1 = vec3(1.0, 1.0, 1.0);
vec3 v2 = f + v1;


Does the float add to all components of the vector?
>>
>>54048962
Expected results is LastPostIndexedAuthor being correct instead of being the date of the author post
>>
>>54049742
https://www.opengl.org/registry/doc/GLSLangSpec.3.30.6.pdf

>One operand is a scalar, and the other is a vector or matrix. In this case, the scalar operation is applied independently to each component of the vector or matrix, resulting in the same size vector or matrix.
>>
>>54049896
Your query as written won't return a date as LastPostIndexedAuthor unless your tables are fucked up.

The only possible values in that field are UName and p.PAuthorId.
>>
>>54049928
What I'm trying to do is get the last post
max(PDate)
and then query forum_database_users with PAuthorId comparing it to UId to get the UName

LastPostIndexedAuthor is supposed to be the nickname of the last post inside the thread
>>
>>54049956
All those
ifnull()
are making me die inside. It just screams horrible table design.

Interestingly enough, some DBMS wouldn't even let you use that query as-is.

You're performing aggregates within coalesces and only grouping by one field, where other fields are available, which leads to arbitrary selection in your case, I guess.

It's pretty difficult to help you out given the clusterfuck of a database design you're working with and a lack of example tables for me to test on locally.
>>
>>54042867
malloc is from C.
It's a good practice and makes the code readable also it suppress some warnings if im not mistaken.
>>
File: 1454356009160.jpg (69 KB, 500x669) Image search: [Google]
1454356009160.jpg
69 KB, 500x669
>>54050042
All the
iffnull(
is because I'm indexing shit, not an actual forum so sometimes I won't have data for a user yet.

Here's the structure
http://pastebin.com/3R30mnPL
>>
>>54047116
so you have a variable to refer to
makes it easier to understand than perl and shit
>>
File: umaruic.webm (1 MB, 640x360) Image search: [Google]
umaruic.webm
1 MB, 640x360
Ask your much beloved programming literate anything (IAMA)

>>54049742

"""
One operand is a scalar, and the other is a vector or matrix. In this case, the scalar operation is
applied independently to each component of the vector or matrix, resulting in the same size vector
or matrix.
"""

>>54049910
>3.30
>2010

4.50 now
https://www.opengl.org/registry/doc/GLSLangSpec.4.50.pdf

>>54049320

https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#sleep-long-

>>54043826

http://www.stroustrup.com/bs_faq.html#C-is-subset

>>54042867

maybe it's a function pointer.

>>54042703

no except if it's a function pointer.

>>54050100
>malloc is from C.
malloc is a procedure that is part of both c and c++ standards.
>>
>>54050132
>4.50 now
I'm pretty sure that the statement still holds true though.
>>
Red pill me on the Android NDK.
Thread replies: 255
Thread images: 26

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.