[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: 21
File: animegirl.png (220 KB, 479x513) Image search: [Google]
animegirl.png
220 KB, 479x513
What are you working on, /g/?

Previous thread: >>51304261
>>
oop is actually pretty cool
>>
>>51307595
If your language doesn't have pointers
kill yourself
>>
>>51307609
you're*
>>
>>51307609
If your language requires header files, kill yourself.
>>
>>51307616
It doesn't
>>
>>51307609

Mine has pointers. :^)
>>
>>51307603
this t᠎bh f᠎am
>>
what is the advantage of a treeset over an array list. except for the treeset sorting the objects
>>
>>51307649
You have more time to think about how to improve your data structures while your code is running
>>
File: transp.jpg (178 KB, 980x735) Image search: [Google]
transp.jpg
178 KB, 980x735
nothing, because my head is damaged. Some time ago I finished my first transponder-prototype for a time-keeping appliance for motocross
>>
>>51307662
hmm. care to explain.

right now i have to program a system for a bar so that the barman can easily add orders to a table and pay orders. (college assignment)

in this use-case, is it still useful
>>
>>51307687
arrays gotta go fast
>>
>>51307702
?
>>
File: G70oT.png (186 KB, 984x964) Image search: [Google]
G70oT.png
186 KB, 984x964
>>51307687
Data structures aren't objectively better than other structures, they have their areas where they're better and areas where they aren't.
For example, a tree is better for large amounts of sorted data and searching for specific data where an array is better for looping through sorted/unsorted data.
>>
>>51307716
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>>
>>51307687
BST
>>
>>51307730
You forgot
>they have their areas where they're better and areas where they aren't.
>>
>>51307609
>>51307616
Go has pointers and doesn't have header files. do I win?
>>
>>51307826
It's just a meme
>>
>>51307716
>Data structures aren't objectively better than other structures

What does this even mean?
>>
>>51307716
A tree is a data structure you fucking dingaling
>>
>>51307834
ALL DATA STRUCTURES ARE BORN EQUAL
#linkedlivesmatter
>>
>>51307834
A tree isn't objectively better than a linked list.
A linked list isn't objectively better than an array.
They're used to fit the requirements of the current program.
What the fuck do you think it means?
>>
>>51307845
What "other structures" are there?

A tree is a data structure
A linked list is a data structure
>>
>>51307831
>lots of web/network services depend on Go software
>"It's just a meme"
/dpt/ - 2015
>>
>>51307845
Linked lists are always shit.
Name one scenario where a linked list is optimal.
>>
>>51307871
Insertion into large ordered structure
Because structure is ordered searching is faster too
>>
>>51307850
>Queue
>Stack
>Hashmap
>[custom made structure to fit your data requirements]

Are you just pretending to be retarded at this point?
>>
File: Backgrounds_26172.png (527 KB, 960x800) Image search: [Google]
Backgrounds_26172.png
527 KB, 960x800
Go and Rust are the future. Start getting good at them or get left in the dust
>>
>>51307881
Those are not "other structures"

Those are data structures

Did you mean to say "Certain data structures are not objectively better than other data structures?"

Back to English school kid
>>
>>51307834
>>51307850
Not the same guy, but I believe he means:
[any given] data structures aren't objectively better than other [data] structures.

That is to say:
for x in dataStructures[]{
for y in dataStructures[]{
dataStructures[x].objectiveValue = dataStructures[y].objectiveValue;
}
}
>>
>>51307880
>Because structure is ordered searching is faster too
Can't binary search a linked list.

>>51307871
Sorted data that gets data inserted often (easy sorting since insertion is just changing two nodes) and needs to be looped through.
>>
>>51307880
Tree
Vector of objects, vector of sorted indices
Vector of pointers to vectors
>>
>>51307903
>>
>>51307905

We need to get rid of linked fucking lists
>>
>>51307891
You're being fucking autistic. Data there was heavily implied with the term "other".
>>
>>51307905
Insertion is slower in all of those

>>51307903
>Can't binary search a linked list.

Nobody wants to
>>
>>51307901
>O(n^2)

Kill yourself
>>
>>51307919
Autism is one of the tenets of being a /g/entooman
>>
>>51307595
>What are you working on, /g/?
The official /dpt/ C toolkit. A general utility, state of art, library written by the community of /dpt/.

>>51307871
Real time systems. You don't want to have a few ms delay/pause because your vector is allocating/freeing/ when your plane is landing.
>>
>>51307919
Absolutely wasn't. Your English is fucking garbage mate.
>>
>>51307880
False. Even on garbage hardware vectors are much faster up to 500k elements.
>>
>>51307905
>tree
Enjoy sorting that every second when new data gets added.

>>51307920
Searching can't be faster if you can't do the faster searches.
>>
>>51307595
Reimplementing Wolfenstein 3D in Haskell.
>>
>>51307938
Searching is faster than an unordered array

Faster doesn't imply fastest

Linked lists are the ideal solutions for OS buffer caches because of fast insertion and fast enough searching
>>
>>51307934
>other
>as in something else of the same type
>if I have two int arrays and I have five others, I have seven int arrays (for god knows what reason)
Nah, you just have full blown autism.
>>
Attempting to figure out how to use std::atomic<T*>.
So far I have one as a member of a class uninitialized.
Then I run the std::atomic::exchange() function
And then I get a Access Violation writing location 0x00000000.
>>
>>51307949
>>other
>>as in something else of the same type

The type here being "structures".
>>
>>51307956
No, the type being data structures (the original type).
Structure was just used as a short method of referring to it.
>>
I'm new at GMP and have a question about big number arithmetic.

while(a != b)
{
if(a > b)
a = a - b;
else
b = b - a;
}
cout << "The GCD is " << a << endl;


This works fine when running normal numbers, but when I run HUGE numbers (like 100 digits big) it just stops and doesn't go through them all. My question is does GMP have a way to quickly do this that I'm not aware of? I declared a and b as
mpz_t a, b
and can add and subtract huge numbers fine. It's just looping loses me.
>>
>>51307949
Methinks the person you're arguing with only supports static typing.
>>
>>51307969
When you said "than other structures" the type "other" is referring to is "structures"

You don't get to make up new English rules

You should have said "than other data structures"
>>
>>51307862
Just a tiny fraction compared to PHP :)
>>
>>51307983
I genuinely think you have autism, you need to get yourself diagnosed by a doctor.
>>
>>51307977
I vaguely remember something about no being able to use normal operations with mpz_t variables. Something about the GMP compare function.
>>
>>51307983
To be fair, a data structure is a subtype of structure, but other subtypes of structure can't be objectively compared to data structures. If you parse the language correctly, you can unobfuscate implications and put that much together. This is a concept known to human beings as "common sense". To assume he's talking about structures that can't be compared to data structures when comparing them to data structures, is to assume he's trying to get you to throw an error, at which point, if you're right in that assumption, you gave him what he wants, whereas if you're mistaken, good job at bad parsing.
>>
https://news.ycombinator.com/item?id=10539328
>In a golang conference, the presenter talking about youtube's vitess said: "If vitess servers are down, then youtube is down. That's how golang is crucial for youtube"
also, cloudflare uses Go. need I say more?
>>
>>51308018
Human language is necessarily intricate and not resolvable to simple syntax rules.
>>
>>51308032
for >>51307995
>>
>>51308018
Now this is real autism.
>>
>>51308032
wow google uses their own product, how surprising
>>
C:
http://codepad.org/DrRDjhId

Got right up to line 143 when I realized I designed my program wrong.

A gradebook holds an array of students and num_students. A student looks like this:
struct student {
char name[MAXNAME + 1];
unsigned idno;
unsigned math;
unsigned reading;
unsigned science;
unsigned history;
unsigned computers;
};

I want to implement a function that allows me to choose a subject and print the top N students in that subject. That is, print_subject_top(3, gradebook, READING) prints the 3 students with the highest .reading grade.

However I realized this is quite difficult with my structure and that a subject enum with values like READING doesn't quite cut it for arbitrary subjects. Does anyone see a better way to implement this? Perhaps an array of grades instead, or some tricky macro?
>>
>data structures
IF YOU DON'T USE COMPRESSED SPARSE MATRICES FOR LITERALLY EVERYTHING THEN YOU LITERALLY DON'T CARE ABOUT PERFORMANCE
>>
>>51308067
unsigned subjects[NUM_SUBJECTS];

subject type becomes index
>>
>>51308034
English is a living language. Currently, people all over the world are speaking it differently. In the ghetto, they speak it in a way that you *must* look for context clues and process syntax, as words mean nothing.
You are thus implying that English is not a human language, as you claim human language is not resolvable to simple syntax rules.
Meanwhile, you can only understand a select few people, whereas I can process the speech of the most and least educated anglophones simply by resolving language to syntax rules. Can you guess who has more survival potential?
>>
>>51308087
but how much can you bench?
>>
>>51308053
and yet people keep asking if google uses Go, or if Go is even used in critical systems
>>
>>51308067
Codepad is acting weird.

http://pastie.org/private/y8zpg3muiu6cifvuwobi2g
>>
File: Untitled.png (112 KB, 1158x883) Image search: [Google]
Untitled.png
112 KB, 1158x883
the fuck is this shit
I'm like, 99% sure that my code has nothing wrong with it.
Especially since std::atomic has such shit documentation
>>
>>51308101
That depends. We taking social engineering botnets into account? Cause my monkeysphere is full of people who hit the gym way too often to try to drown their depression in sore muscles.
>>
>>51308034
Do you even lojban?
>>
>>51308124
Should I just tell atomic<T*> to fuck off and just use shared_ptr<T>s?
I hear shared ptrs have atomicity
>>
>>51308178
>If multiple threads of execution access the same shared_ptr without synchronization and any of those accesses uses a non-const member function of shared_ptr then a data race will occur;
>>
>>51307845
An array is objectively better than a linked list.
>>
>>51308087
>not resolvable to simple syntax
>NO SYNTAX WHATSOEVER?!?!?!??!?!?!?!?!?!?!?!?!?!?!?!?!?!??!?!?!?!?!?!?!?!?!?!?!?
>must write autistic reply
>>
>>51308235
But that's wrong.
>>
>>51308235
enjoy your no concept of lazy evaluation
>>
>>51308235
Why?
>>
>>51308249
You can't get any simpler syntax than English. It's the most mind numbing language on the planet.
>>
>>51308235
it's faster to insert in the middle of a list
it's faster to delete from a list
it's MUCH faster to delete all references to an object instance in any intrusive list from that object's destructor, which is the main motivation for lists in high-performance stuff
>>
>>51308295
please write a simple program that can understand what is being said in English 99.9% of the time while only knowing simple syntax rules
>>
>>51307932
Is there a online repo?
>>
TEПEPЬ ЭTO PУCCКИЙ ЧAT
MAКC PEПOCT
>>
>>51308326
I don't write language parsers. I write games. R&D would take longer than this thread will live.
>>
>>51308446
You can't write language parsers and you don't write games, at best you program them if not a small part of them.

Language parsers don't just rely on syntax rules, they need to be artificially intelligent and capable of learning.
>>
>>51308371
no.
>>
>use Visual Studio
>work on Web project on PC1
>solution builds without any errors
>use git to transfer the Web project to Laptop1
>over 30 errors, including missing NuGet packages
>everything is there, I manually checked

Any ideas guys ? The errors make no sense at all, I get errors at my Razorview, ViewBag etc.
>>
>Want to make a large program of mine multi threaded
>Check tutorials
>Have it all done within 30 minutes

I love you Java!!!
>>
>>51308717

Run tests. Your program is incorrect.
>>
>>51308711
Tried clean + rebuild?
>>
>>51308711
you might not have committed everything necessary
use github's VisualStudio.gitignore, and do a git add -A.
>>
>>51308741
All of the threads are working with with separate structures and results. Anyway I checked the new stuff against previously known results and it's all good.
>>
>>51308741
It's in Java, why would he need to test?
Of course it's broken
>>
File: 8nSiShx.png (1 MB, 1920x1080) Image search: [Google]
8nSiShx.png
1 MB, 1920x1080
i have an array list where you have the length: the number of elements, and the capacity: the number of allocated slots. i have a operation trimCapacity(ArrayList a) which adjusts the capacity to the length. now, i want an operation that would raise the capacity to N. how would you name it ?
>>
>>51308772
What's the difference between an array and an array list?
>>
>>51308782
Arrays are fixed size arraylist isn't

Prob some other nerdy language specific differences too
>>
>>51308772
rename trimCapacity to truncate and give it an additional, optional int n parameter.
If given, truncate to n, deleting elements if necessary, else resize to the number of allocated slots.
>>
File: 1444700676915.jpg (823 KB, 1920x1080) Image search: [Google]
1444700676915.jpg
823 KB, 1920x1080
>>51308782
array list is an implementation of the abstract type list where the elements are stored in an array, it's what c++ calls a vector (which is wrong). other implementations are linked list, double linked list, ...
>>
>>51308772
shrink
expand
>>
>>51308742
Yes, I'm getting the same errors.
>>51308752
I pulled the same Web Project on my Computer1 and there it's working fine.
>>
>>51308809
why is this wrong
are they stored contiguously
>>
>>51307647
What the fuck? were the word filters rmoved?
desu senpai baka
>>
>>51308825
same visual studio?
completely updated to latest version?
>including missing NuGet packages
have you tried opening the nuget window and clicking Restore?
>>
>>51308833
because a vector is not a list but more like a tuple.

http://stackoverflow.com/a/758548
https://en.wikipedia.org/wiki/Vector_%28mathematics_and_physics%29
https://en.wikipedia.org/wiki/Tuple
>>
>>51308859
vector in C is different to the mathematical definition
>>
>>51308772
trimCapacity -> shrink_to_fit
resize
>>
>>51308852
Yes everything is the same. Updated etc.
I've tried that and it did restore some things but again it says that I'm missing Microsoft.Compiler which is there (both in the NuGet package window and on my Laptop).
>>
File: umarusfs.jpg (115 KB, 1280x720) Image search: [Google]
umarusfs.jpg
115 KB, 1280x720
>>51308870
resize is problematic because i have an operation size(ArrayList a) that returns the memory size (in bytes) while length(ArrayList a) returns the size in elements.
>>
>>51308886
>problematic
Triggered.
>>
>>51308885
a quick idea, try creating the web project on laptop, then commit that project to git, and see if it compiles on your desktop...
if it does...well, I'd just manually copy and paste everything over...
>>
>>51308772
Extend
>>
>>51308124
Oh my god it's so hard to find an up-to-date compiler that doesn't have a broken std::atomics implementation
>>
>>51308913
is extend relative or absolute ? extend(5) implies capacity + 5 or capacity = 5 ?
>>
>>51308911
That I haven't tried but it is a good idea.
At least to find out what is causing the problem.
>>
I'm procrastinating studying for my crypto class whilst learning Golang. Also reading interview prep.
>>
>>51308989
>learning golang
>>
how do i fill an array of semen
>>
>>51309044
Open up your buttcheecks.
>>
File: Happiness 0.60229.png (416 KB, 1435x587) Image search: [Google]
Happiness 0.60229.png
416 KB, 1435x587
Messed up a screening interview question today, /g/.

The problem is:
There's a frog at one bank of a river that needs to get to the other side, which is X distance away. The frog can only jump D distance in a single bound. Every second, a leaf falls on the river. Given an array A where A[n] is the position a leaf falls at at the nth second, determine the second at which the frog is able to hop across the river. The algorithm's complexity has to be linear with the number of seconds in A.

Now, if it weren't for the runtime requirement, it would be pretty simple: at each second, add the new position to a sorted list of positions (least-first). Remove all positions from the list that are at or behind the frog's current position. Then, while there are positions that are within jumping distance of the frog's current position, set the frog's current position to the new position and remove the position from the list.

Problem is that the insertions are going to be O(log n) no matter what, and since n of them occur, the overall runtime will be O(n log n). I can't seem to find a way of solving this problem that doesn't involve sorting of the leaf positions to make the runtime linear.

Anyone have any ideas? Am I coming at this totally wrong?
>>
>>51309056
Oh, I should have added: after the leaf-traversal part of each iteration, if the bank is within jumping distance of the frog, then the current second should be returned. And if all the seconds are accounted for and the frog still hasn't reached the bank, then an error should be returned.
>>
java's method to raise the capacity of an array list to N is is ensureCapacity(N), what you guys think about this nomenclature ?
>>
>>51309023
It takes maybe 30 minutes and then you can add it to your resume.
>>
>>51309109
Verbose and ugly, like everything in Java.
>>
>>51309115
Are you Indian by any chance? Only these smelly fucks would consider putting a language on their resume after a day of reading about it.
>>
>>51309146
>Only these smelly fucks would consider putting a language on their resume after a day of reading about it.

ITT we've never applied for jobs

Most people here put languages on their resume before they've even started them

Get called in for an interview? Learn the language in the days before the interview
>>
>>51309146
No, I've just done a few projects with Go and know how simple the language is.
>>
>>51309152
>The reason fizzbuzz why exists: The post
>>
>>51309167
If you can't do fizzbuzz after learning a language for 5 minutes, never mind a few days, I think it's time for a different hobby
>>
>>51307935
>up to 500k elements.
>implying any number matters
>>
>>51308859
. . .
>>
>>51308809
>(which is wrong)
>not understanding cpu architectures
>>
>>51309307
what ?
>>
>>51309377
>he doesn't know what a vector is
>laughing SIMD and MIMD architectures
>>
Since there's a UDL:
template <char ... str>
inline auto constexpr operator ""suffix();

is it technically now the case that ANYTHING is potentially valid C++, string escaping aside?
>>
>>51309460
(I mention that UDL because it allows you to /statically/ interpret whatever you like, presumably allowing arbitrary return types)
>>
>>51309452
wtf, c++ vector and simd vector are two different things.

http://en.cppreference.com/w/cpp/container/vector
>>
>>51309056
> Every second, a leaf falls on the river. Given an array A where A[n] is the position a leaf falls at at the nth second, determine the second at which the frog is able to hop across the river. The algorithm's complexity has to be linear with the number of seconds in A.
> Anyone have any ideas? Am I coming at this totally wrong?
Do the leaves remain on the river indefinitely? If they only remain for a fixed amount of time, then a linear solution should be clear.

Otherwise ... it's possible that an algorithm which appears to be O(n^2) is actually O(m*n) where m is proportional to X/D.

Consider: find the first i where A[i]>=X-D. Clearly, the frog can't reach the other side before that i. Now the question is finding the least j where A[j]>=A[i]-D. And so on. Each of those steps is O(n), but the question is whether the number of steps is O(1).
>>
>>51307716
Shit diagram. Just use vectors. Even the guy that invented the STL says so:

“Use vectors whenever you can. If you cannot use vectors, redesign your solution so that you can use vectors". -Alex Stepanov
>>
any bounded set where the maximum and minimum values are known can be sorted in O(n) time.

;^)
>>
>>51307932
>written by the community of /dpt/
m8
it's literally just you, and you said you wouldn't even post the source anywhere
>>
>>51307932
>written by the community of /dpt/
>no repo
Sounds like shit already.
>>
>>51308001
l2into english fgt
>>
>>51308045
>I'm dumb as balls
>>
>>51307932
You realize that not a single person will use your library because all of C programmers suffer from NIH syndrome and they'd rather reinvent the wheel on their own? Case in point: your code, you're doing something that's been done numerous times.
>>
>>51308309
>faster to delete from a list
false
>lists in high-performance stuff
top cuk
>>
>>51310081
Happiness is a journey, not a destination; happiness is to be found along the way not at the end of the road, for then the journey is over and it's too late. The time for happiness is today not tomorrow.
>>
>>51310095
>sucking dick with such enthusiasm
>>
>>51307886
go and rust are competitors. rust is superior anyway
>>
>>51310179
>rust
>superior
he fell for the rc<>arc<>unwrap meme
>>
>>51310205
are you serious? rust doesn't even do reference counting at runtime. you've either got it confused with swift, or are just trolling
>>
>>51310205
>go
>superior

he fell for the
if err != nil {

meme
>>
What's the quickest way (in terms of processor time) to implement fizzbuzz?
I'm talking, maximum autism
bonus points for making it look pretty
>>
File: 1394031748708.jpg (27 KB, 215x296) Image search: [Google]
1394031748708.jpg
27 KB, 215x296
>writing C code with ed without indenting
>run `indent mymain.c main.c`
>>
>>51310231
can you even into ia32e m8?
>>
>>51310223
I just cannot understand what Go is meant to be used for. Unless it's for an incredibly narrow use case of when you want better performance than something like C#, but want a more productive language than C/C++. And you don't mind that both those languages have incredibly large and mature library ecosystems, tool chains and labour pools and Go is relatively shit.

I find it hard to picture a large project that's going to turn out better in Go than one of the other options there.
>>
>>51310262
Systems programming, m8!
>>
>>51310231
local t = {1, 2, "Buzz", 4, "Buzz", "Buzz", 7, 8, "Buzz", "Buzz", 11, "Buzz", 13, 14, "FizzBuzz", 16, 17, "Buzz", 19, "Buzz", "Buzz", 22, 23, "Buzz", "Buzz", 26, "Buzz", 28, 29, "FizzBuzz", 31, 32, "Buzz", 34, "Buzz", "Buzz", 37, 38, "Buzz", "Buzz", 41, "Buzz", 43, 44, "FizzBuzz", 46, 47, "Buzz", 49, "Buzz", "Buzz", 52, 53, "Buzz", "Buzz", 56, "Buzz", 58, 59, "FizzBuzz", 61, 62, "Buzz", 64, "Buzz", "Buzz", 67, 68, "Buzz", "Buzz", 71, "Buzz", 73, 74, "FizzBuzz", 76, 77, "Buzz", 79, "Buzz", "Buzz", 82, 83, "Buzz", "Buzz", 86, "Buzz", 88, 89, "FizzBuzz", 91, 92, "Buzz", 94, "Buzz", "Buzz", 97, 98, "Buzz", "Buzz"}

for i = 1, #t do
print(t[i])
end
>>
>>51310231
    #include <iostream>
#include <cstdlib>

struct Matcher {
int multiple;
const int factor;
const char * const noise;
inline Matcher (int n, const char * s) : multiple (n), factor (n), noise (s) { }
inline void operator () (int n, bool &toSetIfMatched) {
if (n > multiple)
multiple += factor;
else if (n == multiple)
toSetIfMatched = true, std::cout << noise;
}
};

int
main (int ac, char **av)
{
int upTo = ac > 1 ? atoi (av[1]) : 100;

Matcher threes { 3, "Fizz" };
Matcher fives { 5, "Buzz" };

for (int n = 1; n <= upTo; ++n) {
bool matched = false;
threes (n, matched);
fives (n, matched);
if (!matched)
std::cout << n;
std::cout << '\n';
}
return EXIT_SUCCESS;
}
>>
>>51310231
>what is haskell
>what is clojure
>what is meme language november 2015 edition
>>
>>51310231
for (uint i = 1; i < 101; puts(""),++i)
{
if (i%3==0)
{
printf("Fizz");
if (i%5==0)
goto buzz;
continue;
}
if (i%5==0)
{
buzz:
printf("Buzz");
continue;
}
printf("%u", i);
}
>>
>>51310271
>garbage collected systems
k
>>
>>51310278
I can't stop laughing
>>
>>51310285
>std::cout
>performance
u for real mate?
>>
>>51310288
>puts
>printf
>performance
into the trash it goes!
>>
>>51310301
for some reason the universal meme symbol disappeared after I posted
>>
>>51310315
those are implementation defined, you can't say anything about their performances by just looking at this code.
>>
Daily reminder that Go is for keks.
>>
>>51308741
it's actually really simple. he just needs synchronized(lock) blocks and he's golden. then for other things like with volatile and atomics he should read more about it before he thinks he's done
>>
File: Capture.png (477 B, 32x30) Image search: [Google]
Capture.png
477 B, 32x30
>>51310327
fuck me why can't I post these anymore?
>>
>>51310205
Is garbage collection better?
>>
>>51310336
>can't say anything about their performances by just looking at this code
confirmed amateur with no knowledge of performance programming
>>
>>51310359
always
>>
>>51310336
>those are implementation defined to be slow
ftfy
>>
On my way to work. Hopefully I can shut my brain up a bit and get some work done.
>>
>>51310401
>shut my brain up a bit
schizo?
>>
>>51310336
wew lad
>>
>>51310451
Feeling kinda meh about the job is all, not sure if I want to try getting a remote job or move someplace else. I've been living here since I was born and haven't lived anywhere else and would like to live somewhere outside of my region(southeast) for once.
>>
>>51310231
public final class FizzBuzz {

public static void main(final String[] args) {
System.out.print("1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n16\n17\nfizz\n19\nbuzz\nfizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizzbuzz\n31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz\n41\nfizz\n43\n44\nfizzbuzz\n46\n47\nfizz\n49\nbuzz\nfizz\n52\n53\nfizz\nbuzz\n56\nfizz\n58\n59\nfizzbuzz\n61\n62\nfizz\n64\nbuzz\nfizz\n67\n68\nfizz\nbuzz\n71\nfizz\n73\n74\nfizzbuzz\n76\n77\nfizz\n79\nbuzz\nfizz\n82\n83\nfizz\nbuzz\n86\nfizz\n88\n89\nfizzbuzz\n91\n92\nfizz\n94\nbuzz\nfizz\n97\n98\nfizz\nbuzz\n");
}

}
>>
>>51307611
>If you are language
Top Kik
>>
>>51310653
kill you'reself t᠎bh f᠎am s᠎mh
>>
Are pointers just numbers in C?
>>
>>51310642
This, assuming the fizzbuzz is exactly 100.

I guess you could write code to generate a file and run that.
>>
File: 1424817651119.jpg (37 KB, 604x340) Image search: [Google]
1424817651119.jpg
37 KB, 604x340
>>51310736
>>
>>51310747
yes and no

void *v = 0;
int *i = v;
v += 1;
i += 1;
v != i
>>
>>51310769
>java
>performance
TOP CUK!
>>
>>51310747
> Are pointers just numbers in C?
Everything on a computer is just numbers.
>>
>>51310790
>yes and no
>and
anon...
>>
>>51310803
i have a coffee cup *on* my computer, is that a number too?
>>
>>51310792
Well, that's pretty much the most performant way to do it in Java, at least.

I'm not saying that Java has good performance.
>>
>>51310231
>maximum autism
does compile time function execution count?
>>
>>51310921
bjarne pls go
>>
>>51310943
>bjarne pls go
>what are lisp macros
k tard
>>
>>51310954
>lisp
>performance
wew lad
>>
>>51310251
>using ed
fuckin' lol
although the text file on the gnu site was pretty funny.
>>
>>51307595


public static void main(String[] args) {

List<Integer> lista=new ArrayList<Integer>();//skapar lista

for(int i=0;i<1000;i++)
lista.add((int)(Math.random()*6)+1);//ger slumpvärden

System.out.println(antalSexor(lista));//Skriver ut räknat värde
}

public static int antalSexor(List l){//metod som räknar
int a=0;
for(int i=0;i<l.size();i++)
if(l.get(i).equals(6))
a++;
return a;
}


Could anybody help me change this program so that instead of using a list it uses a regular vector(in the method too) and so that the method counts all values less than three?
Please
>>
>>51310817
No, but you are, and son.. Your number is up.
*tip*
>>
How do I improve my code the fastest? How do you guys go about learning/improving?
>>
>>51311048
package skrap;

public class test {

public static void main(String[] args) {
int lista[] = new int[1000];

for(int i=0; i<lista.length; i++) {
lista[i] = (int) (Math.random()*6+1);
}
System.out.println(sixes(lista));
}
public static int sixes(int n[]) {
int a = 0;
for(int i:n) {
if(i == 6) {
a++;
}
}
return a;
}
}


quick and messy but should work, you could easily shorten it by yourself.
>>
>>51311364
There is no "fast" way, you only need to put time and dedication to it, solve problems(even if it ends up messy). Learn from what you done, repeat problem and solve it again with another approach(more refined one).
>>
what idiot thought it was a good idea to make C++ standard time durations such as std::chrono::milliseconds and std::chrono::seconds incompatible with each other?
yes i mad
>>
>>51311412
>2015
>using c++ unironically
ishiggydiggy m8
>>
>>51311412
whats the problem
>>
>>51311393
How do you walk the fine line of getting help/doing things by yourself?
>>
What's the correct way to express templated types in llvm via the C++ API (or IR I guess, I can translate)? That is,
template<typename T>
T(*)(T, int)

for instance. Is the only option to make a tagged void*?
>>
>>51311364
Use a systems programming language, like Go.
>>
>>51311451
You get a code buddy(which is hard) or you just google the shit of the stuff and learn from it. Get an account at stackoverflow or somewhere else and post random questions or look at other peoples questions(that might be related to your problem). Good luck and have fun.
>>
>>51311473
>You get a code buddy and you suck the knowledge out of his dick.
ftfy
>>
>>51311445
im creating a class that uses an internal clock to keep track of some things and would like for said class to be constructed with a specific time delay passed into the constructor
problem is there is no "generic" time duration so i have to either force my users into always writing the time in milliseconds, create a shitload of constructors for every type, or use template shenanigans
>>
>>51311528
or you could stop being a retard
>>
>>51311549
quality post friend
>>
>>51311528
git gut you shitter
template <class R, class P>
void function(const std::chrono::duration<R, P> &duration)
{
// whatever
}

auto main(int, const char **)
{
function(100ms);
function(10s);
function(20ns);

return 0;
}
>>
>>51311567
>meme
>>
>tfw no python library is safe from my big C# dick
>>
>>51311473
>not using this shit hole as your own personal code buddy
>>
>>51311615
You again. How many times I need to tell you, we could have done that in C++ thousands of years ago
>>
>>51311707
You said since 2005, it's been available in C# since 2006.

It's just highly exciting to me and I feel erect when I think about language interop.
>>
>>51310217
WTF m8 ? Look it up fool, rust has an rc class that you can use when your allocation model implies shared ownership (and the arc class is atomic i. e. threadsafe) save yourself looking like a complete idiot, don't assume something is impossible, just look for someone who's already done it (the standard library ffs)
>>
>>51311728
Thousands
Of
Years
Ago
>>
File: example.png (90 KB, 1600x900) Image search: [Google]
example.png
90 KB, 1600x900
How would we display the seating prices entered into display ticket prices.
>left side

the right side is just a seating chart of open seats. But when a seat is purchased then the purchased seat must be changed from '#' to '*'.

Any help is appreciated
>>
>>51307595

>tfw learning java to become the ultimate neckbeard programmer

And when I've made something I'll shitpost
>>
>>51311843
I assume your seats are stored in a 2d array, yeah?
When the user purchases a seat, check if it's already sold and if not change the array to either * or 1 depending on how you're storing the information in your array
seat[row][col] = 1;
>>
>>51311934
Ya it is a 2d array.
We got it to display the rows and prices just now. Just have to make it look neat.
and thank you as well anon
>>
>>51311902
>java
>ultimate neckbeard programmer
not even close
>>
why?
>>
>>51312561
because
>>
I'm fairly new to programming and was wondering if for my first real project in C#, a calculator would be too challenging or not too challenging?
>>
>>51312578
What do you mean a calculator? One without a GUI, then sure, you could knock that out real quick. If you want to use a GUI, I'd wait until later desu. You should learn to program before learning a library imo.
>>
>>51312578
C# winforms programs have a drag & drop GUI builder.
>>
>>51312659
>>51312632
Yeah, meant with visual studio, it's fairly simple to create a gui, not sure how complex it would need to be to actually program one, that's why I'm asking.
>>
>>51312578
I think it's fine to start with a GUI.

The calculator will be as good as you can make it, and you'll start finding all these little issues and annoyances as you develop it.

Use Visual Studio and do a WinForm project.

Don't do WPF for now, as it will just confuse the shit out of you.
>>
>>51312729
it's a waste of time if you're new to programming
learn
actual
programming
first
>>
>>51312806
Such as? I'm pretty sure everyone defines that differently, what would you say actual programming is?
>>
>>51312806
But doing a calculator with a GUI, rather than just a command line app, helps you build more skills.

It also gives the user more visual feedback on their inputs, outputs, and actions.

The big thing is that it's more interesting and fun, which can promote actually learning the stuff and seeing it through.
>>
trying to install a crosscompiler mingw32 I screwed everything. Now I cant' even compile the most simple c file. I should have never used "sudo make install" with the default install path.

Is there something like "make uninstall"? I cant' believe I have to install linux all over again.
>>
>>51312856
>he fell for the linux meme
>>
>>51312856
Just force install the package to have it override the files.

On Arch that would be:
pacman -S --force mingw32
>>
>>51312923
can i do that with apt-get?
>>
>>51312856
what distro? what error messages do you get?

>I cant' believe I have to install linux all over again.
you don't, ever, need to do this. if you really do this... you are the problem.
>>
>>51312941
Try:
apt-get -o Dpkg::Options::="--force-overwrite" install mingw32
>>
>>51312966
It's linux mint 64bit.
It seems the make install replaced files from /usr/include and usr/bin and now if I try compiling some c it uses the mingw-headers instead of i686.

>>51312975
Thanks. I'll try that.
>>
>tfw your spaghetti function crashes the program
>>
>>51313041

Use a debugger.
>>
>>51313061
sudo apt-get purge tripfag
>>
>>51313076

I'm a windowsfag, please use OneGet. Thanks.
>>
>>51312966
>you don't, ever, need to do this. if you really do this... you are the problem.
there are plenty of situations when it's preferable to just create a new virtual disk and start anew.
>>
>>51313094
why would you use a poor copy of any linux package manager?
>>
>>51313124
>virtual
key word
>>
>>51313124
learn how to use your package managers. even if you, say, removed your own kernel, you would be able to install it either from the running system (if you hadn't rebooted), or from a live system (livecd/usb, whatever)
remember: linux is not windows.
>>
>>51313176
of course is not. Linux is for virtual machines.
>>
>>51313198
This.

Windows for main OS, Linux as VM. Always.
>>
>>51307886
Go in the streets, Rust in the sheets
>>
>>51313214
if you play games, yeah
If you browse the internet and program, no windows necessary
>>
>>51313230
>if you play games, yeah

Who doesn't? "Videogames are for manchildren!" is a tired old meme.
>>
>>51313214
more like

>Linux for main OS
>Windows as VM for when you port your programs
>>
>>51313230
Why would you never ever play a video game?

Linux performs fine in a VM. Vidya in a VM not so much.
>>
>>51313284
Can I not play games on my computer without being labelled as one of those faggots? I don't have a problem with games, I just don't play any.
Thread replies: 255
Thread images: 21

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.