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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 33

File: 1480590811928.png (389KB, 934x1000px) Image search: [Google]
1480590811928.png
389KB, 934x1000px
What are you working on, /g/?

Old thread: >>58160349
>>
File: .NET.png (5KB, 83x481px) Image search: [Google]
.NET.png
5KB, 83x481px
Why is she wearing the the hat on her knee?
>>
Functional programming thread:

>>58141396
>>
>>58168044

because she's a .NEET
>>
pls respond >>58167654
>>
File: 20161224_201954.jpg (2MB, 3264x1836px) Image search: [Google]
20161224_201954.jpg
2MB, 3264x1836px
Getting a sound stream to work in my decentralized streaming platform.

I'm going to run out to microcenter to pick up a cheap amp for some speakers, so I can plug a Raspberry Pi in and get a rag-tag surround sound system built from BasicTV.

Pic related are the speakers i'm going to use (big ones probably need a more powerful amp, three small ones are a good start). The small ones were $2 a pop and the pair of black ones ran me $5
>>
>>58168074
I'm working on Opus compression. I'm also going to make a macro system for different surround sound systems, so individual streams can be associated with different speakers (front left, front right, rear left, rear right, subwoofer, etc).

So how is your Christmas going /g/?
>>
>>58168047
>2 days old

Just let it die, lad. We don't need two separate programming threads.
>>
>>58168129
Cool. Who else /wasteTheirTime/ here? Who else /PissAwayThePreciousGiftOfLife/ here?
>>
>>58168172
Not me.
>>
>>58168158
Actually it's quite a nice thread
>>
File: scripting.png (98KB, 518x426px) Image search: [Google]
scripting.png
98KB, 518x426px
Ruby, I've found you a friend
>>58168012
>>58168032
>>58168177
>>
>>58168214

I've already got an entire thread full of horsefucker tripfags on another *chan to socialize with.
>>
Trying to create a simple .exe in C++ so I don't need to use .bat files and can use it in windows PATH.


Here's the code I'm using:

#include <stdio.h>
#include <stdlib.h>


int main ()
{
system("start \"C:\\streamlink\" \"C:\\streamlink\\python\\python.exe\" \"C:\\streamlink\\streamlink\\Streamlink.py\" --config=\"C:\\streamlink\\streamlinkrc\" %* best");
return 0;

}


the thing is that %* works in .bat files to pass along the arguments to streamlink.py but it doesn't in C++, how do I do this properly then?
>>
if I am dealing with float colors ( 0.0 - 1.0 float for each RGB channel) how would I properly "snap" the variable to simulate say 3-bits per channel?

round(Red * 8.0) / 8.0f?

this seems to get a just one more brighter color for some reason.
>>
>>58168567
Have you learned FP yet?
>>
>>58168588
isnt the %* a shell feature instead of being part of the command? Perhaps try passing this into a shell interpreter
>>
>>58168628
I think it's a cmd.exe feature but my understanding was that "system()" basically called cmd so it would work, I know fuck all about c++
>>
File: 1480383302510.jpg (19KB, 276x301px) Image search: [Google]
1480383302510.jpg
19KB, 276x301px
I just finished a beginner's C++ course. For a reference of where we ended the professor on the last day just briefly went over what objects/classes were.

Anyone have any recommendation for where to enhance my knowledge?
>>
Can you guys recommend some well-written Python programs to check out? Preferably an everyday ones.
>>
>>58168044
Perhaps she's wondering why someone would shoot a woman before throwing her out of a plane.
>>
>>58168759
Why would anyone shoot a woman at all?
>>
>>58168748
>Preferably an everyday ones.
What would that be?

If you want to learn python Pypy would probably be the best option.
>>
>>58168640
well, you could put all of that stuff in your .bat file and then use .exe to execute your bat file.
>>
>>58168779
It would be extremely painful
>>
>>58168710
Books.
>>
File: pep.png (147KB, 296x301px) Image search: [Google]
pep.png
147KB, 296x301px
>>58168791
>>
>>58168044
No one cared who she was until she put on the hat.
>>
>>58168783
PyPy seems too big, I've meant something like youtube-dl, ranger.
>>
>>58168806
(You)
(You)
(You)
(You)
>>
>>58168881
Start by implementing only a subset of the language.
>>
Write a program to print Merry Christmas in your favorite language
>>
>>58168826

Which books
>>
File: 1464763565326.png (56KB, 782x790px) Image search: [Google]
1464763565326.png
56KB, 782x790px
>>58168909
main = print "Merry Christmas!\nHappy birthday Jesus!"
>>
>>58168710

It seems you learned a lot of C. Maybe you should learn some C++ now.
>>
>>58168909
10 PRINT "MERRY CHRISTMAS!"
20 RUN
>>
>>58168920
whoops,
putStrLn
would be better than print

main = mapM_ putStrLn  ["Merry Christmas!", "Happy birthday Jesus!"]
>>
>>58168909
#include <cstdio>

int main()
{
::puts( "Merry Christmas!" );
return 0;
}
>>
>>58168923
Maybe not.

btw, you are not a girl and will never be
>>
>>58168952
It is well known that he is a hairy man and he has never stated otherwise
>>
>>58168989
Stop talking in third person.

But good, good. Let's try to forget your degenerate past.
>>
>>58168989
she*
>>
>>58168588
considering using powershell. it fixes lots of problems with batch. for example i was just trying to run a batch script someone else wrote from my batch script, and it would never fucking work no matter what I did. i just put script.bat in my powershell file and for some reason it worked. i don't fucking understand why batch is the way it is but PS has saved a lot of headache
>>
>>58169045
>>58169059
Not him desu
He posted a pic of himself before (or some anon did) and he had long gray beard and an ugly shirt
>>
>>58169077
I want it to be a .exe file so I can just add the damn folder to PATH and do "streamlink THING" from WinKey + R
>>
>>58169077

Batch scripts are okay for one line scripts. Powershell for anything complicated though.

>>58169095

I'm pretty sure you can run a batch script from win+r.
>>
I suppose it's not possible to create some OS for smartphones that wouldn't be slow?
What would be your ideal smartphone OS, though?
>>
File: Barnard_33.jpg (235KB, 1600x1573px) Image search: [Google]
Barnard_33.jpg
235KB, 1600x1573px
tis-100
>>
>>58169090
her*
>>
File: awdbawdbwa.jpg (25KB, 406x353px) Image search: [Google]
awdbawdbwa.jpg
25KB, 406x353px
>>58169342
>>
>>58168710
I was in the same boat. Basically you know some C and zero C++.

Check out templates and inheritance, that's where real C++ starts. Although you don't have to use inheritance in your programs.
>>
>>58169312

Making a smartphone OS that performs well is not really going to be much more difficult than making a desktop OS that performs well.

Problem is application programmers use better specs as an excuse to make shittier applications.
>>
File: masterpiece.jpg (109KB, 596x596px) Image search: [Google]
masterpiece.jpg
109KB, 596x596px
Are the pieces too bright?
>>
>>58169451
Maybe the background is too black?
jk, it looks okay. And I like darker bg since cobwebs.
>>
If I get an IBM Model M keyboard will I become a better programmer?
>>
>>58169399
>>58168710
Just write quality C code. C++ is a meme.
>>
>>58169473
No. Get knee socks.
>>
>>58169504
I know that it's a meme, I just want to be able to feed myself later in life too so I'll play along.

Can't really imagine being a 55 year old web dev. But in C++ coding that's like average senior professional age.
>>
File: ser.jpg (106KB, 607x557px) Image search: [Google]
ser.jpg
106KB, 607x557px
>>58169472
Worse?
>>
>>58169399

Inheritance is not really important¸ but useful from time to time for virtual method dispatch.

Templates are very useful, and very powerful, but most people won't end up abusing the fuck out of it. Standard template library covers a lot of use cases.

RAII is where C++ shines: automatic and deterministic resource management. Objects are self-contained state machines. When an object is created, its resources are allocated. When an object is destroyed, its resources are freed.

>>58169473
No. It will have no effect whatsoever.

>>58169513
This will also have no effect.
>>
>>58168909
(displayln "merry christmas")

(format t "merry christmas~%")

." merry christmas" cr

int main () {
std::cout << "merry christmas" << std::endl;
}


>>58169628
the most important part about RAII in C++ is learning not to how to write RAII constructors/destructors, but how to never write them, ever.
>>
>>58169628
>No. It will have no effect whatsoever

Do you tripfag just so people will know that you're wrong literally all the time?
>>
>>58169628
>Standard template library
That too is part of the ever expanding "C++ package" and learning that alone is probably harder than learning two simpler languages.
>>
>>58169753
>Do you tripfag just so people will know that you're wrong literally all the time?

No one cared who she was until she put on the trip.
>>
> nl2br() in global namespace

I hate php so much :(
>>
>>58169829
nl2br is the bread and butter of web dev
>>
>>58169853
This makes me want to die
>>
>>58169753

Most of the time spent programming is not spent typing up code. A keyboard that might marginally improve typing speed isn't going to improve your ability to write code that is performant and maintainable.

>>58169781

STL is mostly straightforward, Anon, and if you're going to use C++, you might as well use it. Because really, do you want to roll your own vectors? Do you want to use something like Klib that is really only somewhat decent and not maintained at all?

>>58169819

He, Anon. Say "He".
>>
>>58169910
>Most of the time spent programming is not spent typing up code. A keyboard that might marginally improve typing speed isn't going to improve your ability to write code that is performant and maintainable.
>most of the time spent on a mars expedition is travelling to mars
>it doesn't matter how fast you're able to decelerate upon reentry
>>
>>58169909
the end goal and output of web dev is generating html

so there's really nothing wrong with nl2br in global namespace, it's just convenient af
>>
File: IMAG1254.jpg (2MB, 1520x2688px) Image search: [Google]
IMAG1254.jpg
2MB, 1520x2688px
Just got this one. Good choice? What's the best IDE to go for?
>>
>>58169829
>>58169853
nl2br is the paratha and chutney of web dev
>>
>>58169781
>>58169910
Slightly off topic, but to me it seems like Rust's standard library is also incredibly dense and complicated, and is hugely vital to being able to write effective software in Rust.
Any language requires knowledge of the standard library, so what's really important is the available documentation.

>>58169956
That's a pretty bad argument, anon. And raw key press/release speed is not as important as
- ability to quickly come up with code to write
- ability to quickly find troublesome parts of code
- ability to refactor and rewrite code, or write code that doesn't need to be constantly refactored (thus saving time)

>>58169964
Have fun with your XSS vulnerabilities bub
>>
>>58169829
I start to cringe just by seeing that identifier.
>>
>>58169910
I know that STL is necessary... but it's very far from being consistent or complete (just compare string to mature libs in other languages) and yet the sheer size of it is massive somehow.
>>
>>58170007
>Slightly off topic, but to me it seems like Rust's standard library is also incredibly dense and complicated, and is hugely vital to being able to write effective software in Rust.
The main competitors are Java and C#. Rust will not enter the picture for years if ever.
>>
>>58169956

That's a bad analogy. Think about it like this: what is more important, spending more time designing a ship that can decelerate fast enough when you finally get there, or spending less time in transit to Mars? Typing up code is like the trip to Mars. It gets you to the destination, but it's not where the real work is done.

>>58170007

Plenty of languages have super huge standard libraries, not just C++. The STL is actually pretty small relative to say, the standard libraries in Java or .NET languages.

>what's really important is the available documentation
Yep!
>>
File: ..png (11KB, 806x212px) Image search: [Google]
..png
11KB, 806x212px
How come i can't call the method setText before i assign the TextView object to a variable?
>>
>>58170128
>Java or .NET
>defends the third world language in existence by saying it's no worse than the second and the first.

reported for violation of rule number 6
>>
>>58170159
third worst*
>>
>>58170146
Try wrapping that line in parentheses, like

((TextView)findViewById(R.id.myText)).setText();
>>
>>58169971
Just about everything you need to get started on game development is on MikeGeigTV. Assuming you already know a little C++
>>
>>58170159
Which languages do you have in mind?

BTW, Java and .NET libs are more usable.
>>
>>58170187
Thanks a lot kind anon.
>>
>>58170159
>>58170171

Using the report queue to try and get people banned for having unpopular opinions is actually a violation of global rule #7.

>>58170034

It is the nature of templates. They generate an entirely new class and a set of associated methods for each template instantiation. There is a potential for things to get huge.
>>
Hey guys, I posted last night but got no responses. My flight was cancelled so I'm all alone this Christmas. I've got >5 years ecommerce experience, primarily a C++ dev.

Anyone want to throw some ideas as to what I should do for the next 1-2 days?

Also, if you have questions about C++, I'd be happy to help.
>>
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

//given the sorted vector of ints "ivec", use std::find_if
//std::accumulate and a lambda to sum all the like numbers
//output should read 5, 10, 15, 20
int main()
{
std::vector<int> ivec{ 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3, 4,4,4,4,4 };

return 0;
}


Pop quiz, /dpt/.
>>
>>58170236
>C++
>1-2 days
is that like 1-2 hours in other languages?
>>
>>58170236

>ideas
Write a non-trivial program that will take a day to run.
>>
>>58170193
Since you are talking about C++, Java and .NET, I suppose you want a code monkey job.
Then go with clojure and scala, good languages that run on the jvm and can use java libraries.
>>
>>58170236
>Also, if you have questions about C++, I'd be happy to help.
Why the developer make it so shit? It actually had potential.
>>
>>58170256
I'm pretty fast at working with C++. With my own small git repo, I'm typically able to work as fast as my coworkers do in python. But I appreciate the joke nonetheless. =)

>>58170294
I do that at work, there's nothing fancy about that. =(

>>58170318
I like it. Different strokes for different folks.
>>
>>58170299
What is not code monkey then? All the more efficient "intellectual", innovative or sciency software is being written in those three basically.
>>
>>58170239
>stdafx.h
>>
>>58170357
Microsoft is the best...Problem?
>>
>>58170341
>What is not code monkey then?
Clojure, Scala, C, Ruby, Python
Plenty of science and production code been written in those.

But for real, choosing a good language will only make you job easier. If you are good mathematician or engineer companies will find a way to integrate your code in other languages or will give you training.

(I will not say haskell and other lisp dialects because I don't want to get memed)
>>
>>58170341
And with all due respect for its efficiency, pure C with it's tiny set of capabilities and tricks will not stimulate your intellect after a while, like at all.
>>
>>58170336
Me, ctd, didn't see >>58170239

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

void do_thing(const std::vector<int>& v) {
auto trailing_ptr = v.begin();
while (trailing_ptr != v.end()) {
const auto leading_ptr = std::find_if(
trailing_ptr, v.end(), [&](const int i) { return i != *trailing_ptr; });
std::cout << std::accumulate(trailing_ptr, leading_ptr, 0);
std::cout << (leading_ptr == v.end() ? "" : ", ");
trailing_ptr = leading_ptr;
}
}

int main() {
std::vector<int> ivec{ 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3, 4,4,4,4,4 };
do_thing(ivec);
}
>>
>>58170392
> not code monkey
>Ruby, Python
kek
>>
>>58170381
What's the point in having that if you're not going to include all the STL headers in there?
>>
>>58170396
Yeah, yeah, shut the fuck up code monkey.
Writing code doesn't stimulate intellect in any language. Solving actual problems do.

No one gets a boner for *typing* a book.
>>
>>58170406
>capture all by reference
>>
>>58170410
Those are not. They both are well designed languages.
Python is VERY used in science and data mining.

The fact that they have a low entry barrier and hipsters like them doesn't make them bad.
>>
>>58170432

https://google.github.io/styleguide/cppguide.html#Lambda_expressions

>Use default capture by reference ([&]) only when the lifetime of the lambda is obviously shorter than any potential captures.

=)
>>
>>58170428
>Writing code doesn't stimulate intellect in any language.
Bullshit, try to learn a modern language like C++14. You'll learn that software design is very fucking difficult even for pros.
>>
>>58170444
>Python is VERY used in science and data mining.
Well, it's used to call functions written in C++ mostly. "Coding" on that level is not the difficult part of data mining.
>>
>>58170239

I'd say it looks like homework, but then I remembered it's Christmas.

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

int main()
{
std::vector<int> ivec { 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3, 4,4,4,4,4 };
auto it = ivec.begin();
while (it != ivec.end()) {
auto next = std::find_if(it, ivec.end(), [=](int x) {
return x != *it;
});
auto sum = std::accumulate(it, next, 0);
std::cout << sum << std::endl;
it = next;
}

return 0;
}
>>
>>58170465
>Bullshit, try to learn a modern language like C++14. You'll learn that software design is very fucking difficult even for pros.

That's not hard, that is just gigantic.

I'm not the one to blame if you are not a clever person.
>>
>>58170521
>That's not hard, that is just gigantic.
Same thing. You wrestle with bigger complexity, more options, more interactions to consider. That's what's stimulating even longer term.

The barrier for entry for professional C++ is too high for most programmers though.
>>
>>58170501
>output should read 5, 10, 15, 20
>>
>>58170236
Still looking for ideas (or questions to answer). =)
>>
>>58170565

rubyist@Overmind:~/scratch$ g++ --std=c++14 test.cpp
rubyist@Overmind:~/scratch$ ./a.out
5
10
15
20


Your point? I arrive at the correct answers, do I not?
>>
>>58170580
Where does C++ start and what differentiates it from C+objects in real life?
>>58169399
>>58169628
>>
>>58170608
What is "real life"?
>>
>>58170608
Well, in the work I do, I typically don't use too many objects, except when the concept in question is a tightly coupled set of things, and there are many operations that need to act on them together.

Most of my coworkers and I tend to write as much "pure" (but not really, we pass in pointers to classes / structs we need to modify, rather than return a new class / struct) functions as we can to achieve our goals efficiently. Objects sometimes leave you asking "what if we call X then Y" and this combinatorial explosion of program state required to understand is a lot tougher than understanding the effect of free standing functions.

A great mastery of std::algorithm and when to use it is really powerful. Like knowing that std::nth element also partitions your vector can give you some pretty fast solutions to problems that would otherwise be significantly slower in practice.

For reference, I'm this guy >>58170236 and most of my work is in distributed systems / ecommerce.
>>
>>58170646
>What is "real life"?
Not college assignments or book examples but real industry experience.
>>
>>58170547
>Same thing
No.
Most C++ features are useless and no one ever uses them.

>That's what's stimulating even longer term
That's a disgrace and leads to unreadable and unmaintainable code.

>The barrier for entry for professional C++ is too high for most programmers though.
Most programmers are stupid.
Stop thinking so highly of this piece of shit.
>>
>>58170547
Also, if writing code is more stimulating than the problem you have to solve, you are a code monkey.
>>
http://en.cppreference.com/w/cpp/experimental/fs
>it's taking them this long to MAYBE implement a native filesystem library that
Dear lord what are the stdlib developers wasting their time on?
>>
>>58170714
>>58170691
>Also, if writing code is more stimulating than the problem you have to solve, you are a code monkey.
You solve problems with code, you must always consider the facilities and restrictions that your language of choice provides for that.

Most C++ features (especially the ones added recently) must be used by competent programmers as they greatly improve efficiency and productivity.
>>
>>58169971
Text editor + gcc
>>
>>58170691
Most stupid things are actually complicated. If not all of them.
>>
>>58169971
Emacs + GCC
>>
>>58170691
>Most programmers are stupid.
>Stop thinking so highly of this piece of shit.
I have several fancy pieces of paper and awards proving that I'm not stupid and yet C++ is kicking my ass.
>>
>>58170239
#include <stdio.h>
#include <stdlib.h>

int main()
{
int v[] = {1,1,1,1,1, 2,2,2,2,2, 3,3,3,3,3, 4,4,4,4,4};

int i, j, sum;
for (i = 0; i < sizeof(v) / sizeof(int); i = j) {
sum = 0;
for (j = i; v[i] == v[j]; j++) {
sum += v[j];
}
printf("%d\n", sum);
}

return 0;
}


FUCK C++
>>
>>58170766
>You solve problems with code
No. You solve problems by using, old or new, algorithms that are put together.
Writing code is trivial. Stating otherwise is saying that the job of, idk huxley, typer's is somehow challenging compared to his. It's not, it's just writing the sentences someone dictates to you.

>Most C++ features
Most C++ features are intended to make incompetent people productive and garbage code tolerable.
None of them is remotely complex, they are just meant for extremely specific situations. So any code monkey can be productive in any area where computers are necessary.

Prime example: game dev
>>
>>58170580
Still here, will be cooking in a bit =)
>>
>>58170341
Ada Spark 2014 (Ravenscar Profile)
Coq
Idris
>>
>>58170831
I'm not saying you are stupid, just don't think those things attest anything but the fact that you might have had good opportunities and is probably a dedicated person.

>I have several fancy pieces of paper and awards proving that I'm not stupid and yet C++ is kicking my ass.
The difficulties you are having probably arise from:

>Not a very good mathematical/cs background.

>The fact that most C++ features are intended to make incompetent people productive and garbage code tolerable.
None of them is remotely complex, they are just meant for extremely specific situations. So any code monkey can be productive in any area where computers are necessary.

Seriously, if you have to use C++, don't learn more than the core language(barely more than C). You will only need the rest to read some stupid crypto code an incompetent person wrote, even then you can consult a book or manual.
>>
>>58170874
>No. You solve problems by using, old or new, algorithms that are put together.
That's math. Non-trivial programming is and will always be different from doing theoretical mathematics.
>>
What do you guys program outside of a job or something? How do you think of things to make?
>>
>>58170874
Not him, but not all problems are simply finding an answer to a question or something like that. Sometimes a problem is related to how you can make something more efficient or how to make something more reusable.
>>
software design > actual programming
>>
>>58170239
import Data.List (group)

sumGroups :: (Eq a, Num a) => [a] -> [a]
sumGroups = fmap sum . group

main :: IO ()
main = print . sumGroups $ [1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4]
>>
>>58171013
The funny part is that it quickly gets so fucking complex that you can't design purely in theory. That's why google wrote mock objects.
>>
>>58171013
software design == actual programming
:^))
>>
>>58170236
Make a minimal online commerce game/simulator with Elo instead of capitalism and tell me if this works.

>>58170943
Just think about something you wish existed

>>58171013
Math > Design > Engineering
>>
>>58170874
>>58170958
>inb4 algorithmic growth
On real hardware, a theoretically worse algorithm can outperform a theoretically better one due to realities like cache.
>>
>>58170937
>theoretical
I suspect you don't know what this word means.
In mathematics everything is a theorem, i.e. a theory. No theoretical mathematics is wrong or is just an axiom.

>That's math.
Programming is math. What is vulgarly thought of as 'math' are problems of the kind 'what is' and 'how do they relate', while what is vulgarly though as programming is 'how to'. The later is just a specific case of the first, in which you relate objects(states) through well defined relations(iteration, recursion and operations). Which can also be thought as an algorithm, that is mathematics.

Once will have the algorithm, the implementation is trivial, if the implementation is not trivial then the algorithm is not optimized.

Writing code is literally the same as simply typing in any other language.
>>
>>58171026
>import essay
>>
>>58171056
It's all theoretical until you must tell a multi-core CPU via a programming language made with trade-offs and peculiar design choices what to do. Then your theoretical mathematical solution can go fuck itself in practice.
>>
>>58171026
Print /@ Times @@@ Tally[{1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4}]
>>
>>58171043
You are stupid. Then your algorithm is simply inadequate and probably was developed with other purposes(being 'pure', easily understandable, short, whatever), not fast on your hardware.

There is no difference between "theoretical" and "practical" in mathematics. Practical is just carrying out what you thought of, if it doesn't work, you didn't think well.

>>58170958
Yes they are.
>how you can make something more efficient or how to make something more reusable
Then that's your problem. If you want to write the procedures for finding the roots of a quadratic equation in the most readable and generic way, then your problem is to write the procedures for finding the roots of a quadratic equation in the most readable and generic way, NOT how to find them. And you solve those problems with the same "theoretical" tools you used for the problem of how to find the roots. If you are using some kind of heuristics to solve that problem, you are doing it wrong, and you are just a code monkey.
>>
>>58171108
Then your theory doesn't fit the constraints of the problem. It's inadequate and the fact that you are using some kind of heuristics to make it fit for the said constraints just shows that you incompetent and a code monkey.
>>
>>58171152
>And you solve those problems with the same "theoretical" tools you used for the problem of how to find the roots. If you are using some kind of heuristics to solve that problem, you are doing it wrong, and you are just a code monkey.
You see, the issue is that CPUs are so damn complicated with their reordering and deep pipelines and whatnot that you often simply cannot guarantee theoretically that something will be faster than another thing. You have to do profiling.

I mean, you don't need to profile and use trial and error to know that an array will be traversed faster than a linked list, but that's hardly a question of algorithmic design.
>>
>>58171026

Are we code golfing with different languages now?

[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4].group_by {|x|x}.each {|k,v|p k*v.size}


80 characters even.
>>
>>58171176
>theoretically
I think it's important to make clear the difference between a theory and a hypothesis.

>the issue is that CPUs are so damn complicated with their reordering and deep pipelines and whatnot
That's is simply another constraint to the problem.

>theoretically that something will be faster than another thing
Yes you can, if you can't, they you don't know the problem well enough.
If you find hard to deduce from axioms what the behavior would be, just "profile" it. The conclusions you take from your experiment are now new constraints to the problem.

The original statement being disputed was that "writing code is hard or C++ is hard or C++ is stimulating". What I'm saying is:
>it's not
>if it is the language is shit
The problem always boils down to creating an algorithm. Implementing it is trivial. If it's not trivial, the language is shit or the algorithm doesn't take some constraints into account(multicore for example) and is unfit.
You should get back to those "theoretical" tools and adjust the algorithm.
>>
>>58171214
this is my python solution, but i can't write it as one liner

def sum_(lst):
for i in list(set(lst)):
print sum(filter(lambda z: z==i,lst))

sum_(lst)


i tried this but doesn't work
sum_ = lambda x: sum(filter(lambda z: z==i for i in list(set(x)),x))
>>
>>58171214
main = mapM_ print$sum<$>group [1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4]
>>
>>58171281
I think the issue is that you are drawing the line between algorithm and program closer to the metal than most do. A misunderstanding is all.

Now that guy talking about how it takes skill to work around bad languages can fuck off.
>>
>>58171283

72 chars. I'm beat, I guess. Ruby lacks a single purpose group function, but group_by generally does the trick most of the time.

>>58171282

Python lambdas are shit. One of the main reasons I prefer Ruby. Blocks just... make everything better.
>>
>>58171297
Probably. The discussion got kinda off topic, originally I was just telling a C++ shill to fuck off.
>>
>>58171041
>Make a minimal online commerce game/simulator with Elo instead of capitalism and tell me if this works.

Huh?

Also, please no more ecommerce. That's my living, not my passion.
>>
>>58170943
>do you guys program outside of a job or something?
yes
>How do you think of things to make?
I try and make software that's cool enough that everybody can use it (i'm >>58168074 ).

I also wanted a whole house surround sound system for a while, and I already laid down some of the BasicTV code when I got some speakers. All I need now are some amps and I should be set.

I also think that cable TV is absolutely terrible, and a DRM free, decentralized, and superior format can work out fine (especially if it acts as a relay for current content).
>>
>>58171374
Make a multidimensional Conway's Game of Life with random seeds, find any unusual or interesting shapes through a little algorithm, record them, and publish them.

The rules might want to be redefined so it doesn't do anything boring, but I like the idea.
>>
stumped on euler.
>>
>>58171432
Which problem?
>>
>>58171436
355
>>
>>58171448
my first suggestion: create a sieve of euler's totient function
i haven't solved this problem, however, so this is only a suggestion
>>
>>58171478
haha kill me i forgot the definition of the function when i posted that and that actually makes no sense after i looked it up again
>>
>>58171407
I did that lots in college, when learning graphics programming (boxes are easy, then I wrote rules to combine the boxes if they're close, and connect them in different ways with splines...)

Anyways, I've already done that! What are the odds. :)
>>
File: 3019d614f07ec15d8377d04efb4e30f1.jpg (964KB, 880x1245px) Image search: [Google]
3019d614f07ec15d8377d04efb4e30f1.jpg
964KB, 880x1245px
>>58171407
Don't listen to this crazy man

>>58171374
Make a botnet deeply engraved into the code of Elon's first mars colony to have total control over their life support and kill those spatial hipsters at will. Then force them to do some real life hunger games/king games.
>>
>>58171520
Did you find anything interesting in higher than three dimensions?
>>
>>58171432
>>58171448
this is what i meant to suggest if you haven't done it already:
https://en.wikipedia.org/wiki/Coprime_integers#Generating_all_coprime_pairs
>>
>>58171526

A botnet on a machine sent to Mars would not be an easy one to control. Depending on the position of Earth and Mars around the Sun, it would take anywhere from 3 to 22 minutes for a UDP packet to reach there, IF it reached there. It could take upwards of an hour to do a single TCP handshake.
>>
>>58171627
>It could take upwards of an hour to do a single TCP handshake.
i like it
>>
>>58171627
>>58171526
>not going up there and patching your version of the life support system
It's like you don't want to watch the hunger games live
>>
>>58171547

No, but I had trouble creating rules that didn't suck for 5+ dimensions.
>>
>>58171687
(And by this I mean, rules that didn't make anything special or interesting when compared with the 3-D or 2-D counterpart.)
>>
>>58171687
I'm still going to try this out some day
>>
>>58171724
Do it! My means of displaying the info was either a trivial projection into 3-D space (AKA, pick elements {X_i, X_j, X_k}) or something dumb. So I bet there could be something interesting I didn't touch.
>>
File: 1482268990896.jpg (24KB, 640x480px) Image search: [Google]
1482268990896.jpg
24KB, 640x480px
Anons l know im a big dum dum for this question but l'm totally new to C# and l don't really know where to start, l'm fluent in java, and l thought l'd switch to C# for some reason and now l'm stuck, what do people use to code in C#, unity ?
Sorry if it sounds dumb l made the decision today and l have nowhere else to ask, also merry christmas
>>
>>58171753
Making the repo and doing some math on paper now
>>
I'm very close to finishing a project, how do I focus?
>>
>>58171655

>Wanting to be stuck on a shitty red planet with no life just to watch a few people go crazy

Anon, just go to Africa, take over a small country no one cares about, and institute your hunger games there. It would be much easier. And when you get bored, you can change your identity and retire on Earth.
>>
>>58171766
Take a break!

No, for realsies. Step away from your computer and do something relaxing, like read a book or listen to some music. It doesn't have to be for long. 10 or 15 minutes would be just fine.
>>
http://nbviewer.jupyter.org/url/norvig.com/ipython/Advent%20of%20Code.ipynb

>norvig still has passion
>>
>>58171766
Do what rich and succesful people do : instead of doing things you like you should force yourself to do things that will make your life better in the future

People who make it in the world don't make it because of luck, they make it because they force themselves to do it every single day, instead of playing vidya they do the things that lead to a succesful life while other people don't

Oh and you should take a nap whenever things get tiring, naps are very nice
>>
>>58171831
Okay I'll start once for all tomorrow
>>
File: j33vesu.jpg (19KB, 217x320px) Image search: [Google]
j33vesu.jpg
19KB, 217x320px
>>58168017
>mfw spending 4 hours non stop on string manipulation in c
>>
File: IMG_20161225_122237193.jpg (3MB, 2340x4160px) Image search: [Google]
IMG_20161225_122237193.jpg
3MB, 2340x4160px
>Understanding the Linux Kernel
THICC
>>
>>58171883
Smug > K-on > Feels > Frogs > this.jpg
>>
>>58171883
what string(s) are you manipulating, benito?
>>
>>58171906
>understanding the kernel on your own

kek, time will be wasted for nothing.
i'm studying it in UNI, you need a teacher to understand it.
>>
I'm writing a function in C which checks if the given file path is a regular file (i.e. not a symlink, not a directory, etc). A .jpg should be a regular file.

Here it is:

#include <sys/stat.h>

bool is_file(char *fpath) {
struct stat path_stat;
stat(fpath, &path_stat);
return S_ISREG(path_stat.st_mode);
}


However this is giving the wrong answer on .jpg files. Am I using stat.h incorrectly?
>>
>>58171923
stdin input then TCP socket streams, ... just fuck my shit up senapi
>>
>>58171831
>>58171808
I don't think C++ syntax is helping me much either.
>>
>>58171934

teachers are a huge meme, silly anon
>>
>>58171934
Not if I channel my inner autism
I think half the things I've learned about computers have been self-taught anyway
>>
>>58171941
Ah actually I've just realised my mistake. The working directory isn't the same as the one in which the .jpgs reside. The problem is that S_ISREG is returning -1 in this case to signify "file does not exist". The solution is to chdir into the directory first, and also to add an extra check to distinguish between non-zeroes for non-existent files, and non-zeroes for files which actually do exist.
>>
>>58171843
You should do the things that annoy you the most whenever you really don't feel like doing them to build character anon, start whenever you can
>>
>>58171962
not the kernel brah, it needs a teacher, i don't want to disappoint you just warning you.
>>
File: Screenshot_2016-12-25_22-16-22.png (111KB, 822x913px) Image search: [Google]
Screenshot_2016-12-25_22-16-22.png
111KB, 822x913px
>>58171955
And it works! I think.
>>
>>58171946
good luck senpai

>>58171941
check that the bool cast isn't fucking anything up
this can happen if sizeof(bool) < sizeof(S_ISREG(m)) = sizeof(S_IFMT)

>>58171978
you made this post while i was responding
glad you fixed it :^)
>>
File: 1457319649861.gif (2MB, 480x270px) Image search: [Google]
1457319649861.gif
2MB, 480x270px
send help plz

i got "/tmp" in argv[2]
and a str[100]="DOWNLOAD filename";

i have to open a file that's named : "/tmp/filename"

what should i do ?

been trying with sprintf and strtok, and getting segmentation faults.
>>
>>58172108
Post code
>>
Why do they always insist on making beginner C programmers do lots of text manipulation when C is absolutely atrocious for text manipulation? Why not give them a simple library for e.g. graphics, or numbers, or something?
None of the way you manipulate strings in C is going to carry into other languages, and nobody writes code that uses a lot of strings in C these days anymore, especially not using strtok, strcat and the other absolutely garbage C stdlib functions.
>>
File: browser #113.png (2MB, 1920x1080px) Image search: [Google]
browser #113.png
2MB, 1920x1080px
got adjustable overlay layers working!
fuck year! didn't think I'd be able to figure it out.
>>
>>58172108
apply
char * strcat ( char * destination, const char * source );
char * strcpy ( char * destination, const char * source );

as follows
char file_path[100];
strcpy(file_path, argv[2]);

int length = strlen(file_path);
file_path[length] = '/';
file_path[length + 1] = '\0';

strcat(file_path, str + 9 * sizeof(char));

9 is a magic number that is the count of character in the string "DOWNLOAD "

i do wish some of the string functions would return the strlen(dest) instead of dest
>>
>>58172186
Because C handles text the same way a machine would.
>>
>>58172197
i also have UPLOAD
download was an example
>>
>>58172253
strcat(file_path, strchr(str, ' ') + 1);

i hope the syntax of str is fixed lol
>>
>>58172186

>None of the way you manipulate strings in C is going to carry into other languages
Point is to show people how those other languages are working under the hood.
>>
>>58172360
Most languages don't necessarily use null terminated C-strings. Most languages have utf-8 support, why don't we see how that works under the hood in C?
>>
>>58172275
i have to use strtok.

char* tok=strtok(str," "); is ok
then
tok = strtok(NULL," ");
is causing the segmentation fault
>>
>>58172436
i mean when i try to printf tok the second time. it fails
>>
>>58171990
Does your program support group chats? Maybe some of us would join it?
>>
>>58172456
char *token = strtok(str, " ");
char *next_token = strtok(token, " ");


btw, is this like an assignment requirement that you use strtok bc strchr is slightly advantageous

>>58172456
i don't totally understand what you mean by that but the above code may help
>>
>>58172456
>>58172436

ok, my socket is fucked up, i only got DOWNLOAD not DOWNLOAD filename
>>
>>58172494
yeah some null pointer checks will help with that
the code i wrote does absolutely none :P
>>
>>58172513
i understand that yours will work.

finally i got the problem,
fucking strtok(src," ") modifies the src after the first space, i didn't know that.

i got this.
>>
import random 

class monster:
def __init__(self):
self.health = 100
self.defense = 20

goblin = monster()
while True:
attack = random.randint(10, 30)
if attack < goblin.defense:
print('too strong')
goblin.health -= attack
print(goblin.health)
if goblin.health <= 0:
print('dead')
break


messing around with oop. does anyone have any cool computer/programming documentaries?
>>
>>58172556
I read this post as satire
>>
>>58172568
what why?
>>
>>58172568
We were all noobs once
>>
>>58171934
You are retarded.
>>
>>58172537
>i got this.
word, i'll be here for a while in case you run into more issues
>>
>>58172556
i like it
>>
hey /dpt/, do you wrap lines of your codes?
what length do you use?
>>
>>58168017

Looking for some general design advice (disclaimer, I am a hardware engineer hacking this together to help automate some shit at my job) for a python program i'm working on. I've written this shit in like a day or two.

I'm taking an XML file and parsing out the data I need. I then store the data in a 'hierarchy' of objects.

Essentially, I have an object A() which has some basic attributes, and also stores a list of object B(). Object B() has some basic attributes and also stores a list of Object C(). So each instance of A() has multiple B(), which each have multiple C().

My problem is I only need to run this script once to get the XML, parse it, and store the data I need, so I'd like the Object data to persist somehow. I'm looking at the pickle library in python to write the object data to a file and unpickle it whenever I need to access it.

Am I a retard for storing this data in 3 separate classes and having them linked to each other? Is there some other way I should be approaching this problem?

Any help or shit-flinging is appreciated.
>>
>>58172637
80
>>
>>58172648
for what language do you use that? I don't think it will look nice on a verbose language like Java
>>
>>58172675
C++
It works pretty well when you start to use a lot of quirky indentation rules
>>
I'm wanting to create a browser based 2d game.
Is the best way to do this pure JS or should I use some library?

I plan on handling all the game logic server side and just display the animations and get user input on frontend. Just not sure where to start.
>>
>>58172481
Well yes, that's what it is. It's basically a slightly modernized IRC with voice.
>>
>>58172788
Can you make a room for us to join?
>>
>>58172856
Yes, though not right this second.
>>
>>58172902
well, tell us when you do
>>
is there any 'cheat sheets' out there for programming languages? I learned python many years ago and I need to brush up on the ins-and-outs of it . Just something with the important syntax/semantics will do.
>>
>>58172696

>Is the best way to do this pure JS or should I use some library?
Use libraries where applicable. Avoid large frameworks that will make the browser lag to shit. Some of us have 20+ tabs open.

>I plan on handling all the game logic server side
Is this going to be multiplayer, or with some sort of persistent user data? Why can it not be handled on the client side?

>Just not sure where to start.
I would start with figuring out everything you want to be in your game before you start writing up actual code. Otherwise, rewriting a lot of shit is going to be a pain.
>>
>>58168017
Maybe in the future I'll learn a different tech just to have a side skill (I mainly use wpf things) I'm considering asp.net or xamarin? Any good resources in these? (bls good books).
>>58172917
They exists, but probably each for every programming language since they're tend to be different in many main aspects. For example, for C, I probably want a cheat sheet about pointers notation.
You can probably make your own general sheet tho, wrapping all the core concepts of programming, that being: statements, keywords, and functions.
>>
>>58172902
Does it have a TCP fallback so I can use it over Tor? I don't want some /g/ haxxor messing with me
>>
l1 = ["a","b","c","d","e"]

for a in l1:
for b in l1:
for c in l1:
for d in l1:
for e in l1:
print(a+b+c+d+e)


For a non-repetitive permutation over n symbols (5 in this example), how would I code this without writing all the loops?
>>
>>58172961
It uses tcp because of some technical limitations.
>>
>>58172973
>implying TCP isn't superior
>>
>>58172969
recursion
>>
>>58172969
itertools.permutations

http://stackoverflow.com/questions/104420/how-to-generate-all-permutations-of-a-list-in-python
>>
>>58172969
Your code prints permutations with repetitions.

import itertools as it
for a, b, c, d, e in it.permutations(l1, r=5):
print(a, b, c, d, e)
>>
>>58173014
Apologies, I perhaps mean no-repetitions with reference to the produced strings and not the symbols themselves

e.g.

aba
aca is fine

abc
abc is bad


Thank you all for your answers.
>>
>>58168017
Daily reminder that wearing a skirt makes you a better programmer
>>
started programming, trying to learn how to use github/seemethere/nba_py
to scrape nba data. have used python and sql before, but have no idea how to use this/pandas/requests
>>
Is it possible to set up an effective dev environment in which you never have to touch a mouse?
>>
>>58173088
ya if you use the bci or some sort of voice to text software.
>>
>>58173053

why?
>>
>>58173088
i3 + emacs/vim + compiler = yes
>>
File: SDL.png (22KB, 1089x432px) Image search: [Google]
SDL.png
22KB, 1089x432px
I just got started with this SDL stuff, but I don't see any sort of output when using printf, I hear that I'm supposed to get a txt file with the output but I can't find it. Where did it go?
>>
File: 1473615656699.jpg (31KB, 720x960px) Image search: [Google]
1473615656699.jpg
31KB, 720x960px
>>58173097
but i already bought an i7
>>
>>58172973
what technical limitations
>>
>>58173127
Shit out of luck then
(i3 is a window manager if you're memeing me)
>>
>>58173102
>I hear that I'm supposed to get a txt file with the output
Close but you actually get a letter in the mail. Remember that C was designed in the 1880s before there were txt files.
>>
>>58172989
Thanks, this is what I came up with
a = []
def p(s, d=''):
if len(d) == 4:
a.append(d)
else:
for c in s:
p(s, d+c)

p("abc")
print(a)
>>
>>58173142
It runs over WAMP, which only supports TCP, websocket, and http transports.
>>
>>58173102
Unless you have stderr or stdout redirected, it should output to the console like it would by default in any program. What happens if you put a printf statement before the call to SDL_Init?
>>
>>58172937
The figuring out everything is definitely the best thing to do. And I've got most of the concepts and classes that I'll need to build laid out.
And it is going to be multiplayer so that's why the backend needs to handle the logic as well as persistent user data.
>>
>>58173175
looking good!
one critique: you should put the list as a function argument for better usability like

>>
>>58173204
i don't know what just happened but i hit some keys wrong and it actually posted with no valid captcha...umm

>>58173175
anyway this is what i meant to post
def p(s, d='', L=None):
if L == None:
L = []

...p(s, d + c, L)...
return L
>>
File: 1437399019248.jpg (74KB, 750x422px) Image search: [Google]
1437399019248.jpg
74KB, 750x422px
>>58172603
done

an FTP server+client
doing LIST,DOWNLOAD,UPLOAD via tcp sockets

8 hours of work, most of it spent on str* shit.
>>
>>58168017
writing a compiler for my own dialect of C
>>
""""physically based rendering"""" is flawed shit isn't it?

https://en.wikipedia.org/wiki/Diffuse_sky_radiation
>When the sun is at the zenith in a cloudless sky, with 1367 W/m2 above the atmosphere, direct sunlight is about 1050 W/m2, and total insolation about 1120 W/m2.[1] This implies that under these conditions the diffuse radiation is only about 70 W/m2 out of the original 1367 W/m2.

i'm expected to believe that the ambient term in this scenario would be 0.0625. but the shadows in real life don't look that dark to the human eye. you would have to tone-map this somehow. but PBR doesn't have the answer.
>>
>>58173398

How does it compare to Holy C?
>>
>>58173175
It's a nice exercise to implement that with recursion, but you can just use itertools.product:
import itertools

print [''.join(p) for p in itertools.product('abc', repeat=4)]


https://docs.python.org/2/library/itertools.html#itertools.product
>>
File: Screenshot_2016-12-25_23-39-53.png (647KB, 1053x517px) Image search: [Google]
Screenshot_2016-12-25_23-39-53.png
647KB, 1053x517px
http://pastebin.com/3jJtEQtt

My VM is coming along quite swimmingly. I need to make an assembly language for it soon because writing in hexadecimal is simultaneously fun and a major pain in the ass
>>
File: buster.jpg (33KB, 620x374px) Image search: [Google]
buster.jpg
33KB, 620x374px
I'm a CS student. What's the best way to hone my skills over the holidays so I don't end up just jacking off and generally being a lazy cunt?
>>
>>58173516
so you took my advice of yesterday with the divide by zero and overflow detectors, nice. You may want to write an exception system to let the applications know what has occured.
>>
>>58173181
Still doesn't work no matter where I put it.
>>
>>58173485
not too good, its basically C but without retarded GCC inline assembly. for example, to set the AL register to 'a', you would do:
AL = 'a';

instead of something like
asm("mov 'a', %al");

i'm making it for OS Development, so it will have function modifiers for interrupts and such.
>>
>>58173546
The checkedint module came in real handy
https://dlang.org/phobos/core_checkedint.html
>You may want to write an exception system to let the applications know what has occured
Could you expand on what you mean by this? Like moving an error code into a certain register?
>>
>>58173563

I always find inline assembly to be a bit awkward. When I want to use assembly code with C, I'll write a whole function in assembly and link it in.
>>
>>58173563
>function modifiers for interrupts
That's really ugly. Overhaul the signal library to handle interrupts.
>>
>>58173595
it could be a specific location in memory to read the error code, or a special register, ARM64 for example has a special exception register that has a numeric value which tells you what's the exception
>>
File: Extra4.jpg (45KB, 650x698px) Image search: [Google]
Extra4.jpg
45KB, 650x698px
>>58173659
A dedicated register sounds like the best idea, also makes a lot more sense than printing a message (since a real CPU wouldn't actually do that).
Thanks anon
>>
>>58173709
you're welcome anon-chan :3
>>
>>58173595
The other common implementation is a position in memory corresponding to a handler for that exception type.

Ideally, your VM will have a process frame register and a exception handler for that process can be held in memory at a known offset. Also in the process frame could be saved registers for context switches and other process info. Also maybe the stack for that process. Finally, add in some memory mapping so you can use a memcpy to switch processes.
>>
>>58173727
>The other common implementation is a position in memory corresponding to a handler for that exception type
I know Intel CPUs do that, I could add another array to my VM to hold all those handlers and index with another set of enums
>Ideally, your VM will have a process frame register
Never heard of a process frame register, is there another term for that?

The rest, with implementing multitasking would be fun, but I think that'll come much later down the road.
>>
>>58173829
>The rest, with implementing multitasking would be fun, but I think that'll come much later down the road.
Don't code yourself into a corner. Implement thing you might not even think you need and trim them later. Better to have and not need, than need and not have. I think that's enough analogies to get my point across.

>The rest, with implementing multitasking would be fun, but I think that'll come much later down the road.
No. And currently, no architecture supports such a thing. Just like a stack frame register holds a pointer to the beginning of the currently executing subroutine, the process frame register would hold a pointer to the beginning of the currently executing process. Process information would reside there. The purpose is to make processes first-class, as well as to prime the caches (TLB, and L1, depending upon how deep the current stack for that process is and how complex the prefetching is, by doing the initial context switch, because data is spatially local).

The reason no architecture has such as thing, is that it would impose a certain process scheme on the OS. A tightly-coupled design would benefit performance, however.
>>
Can I expect arduinos to be as reliable as a cheap PLC? Say I want to automate something basic like plant watering and want to never have to interact with it, can I expect months of reliable use?
>>
>>58173996
Yeah. Reliable power source is your only concern.
>>
>>58173915
>Implement thing you might not even think you need and trim them later.
I suppose I can start thinking about that once I get jump and comparison instructions completed. Figuring out how to do it is going to be quite the challenge though.
>Just like a stack frame register holds a pointer to the beginning of the currently executing subroutine, the process frame register would hold a pointer to the beginning of the currently executing process.
I see, so instead of having the OS save the execution state within a struct, that functionality would be baked straight into the hardware (well, "hardware" since this is a VM)?
>>
New /fpt/:

>>58174033
>>
File: wew.png (188KB, 640x1136px) Image search: [Google]
wew.png
188KB, 640x1136px
>>58168017
Do you even Swift, /g/?
Making shitty space shooter for iOS
>>
>>58174017
Comparison is pretty simple. Subtract and compare with respect to zero. That's how most microprocessors do it. Jumping might be difficult if you don't have a proper program counter set up.

>so instead of having the OS save the execution state within a struct, that functionality would be baked straight into the hardware.
Exactly. It's something I've had to think about recently. I'm helping develop a hardware OS. Tight coupling between the processor and the OS. Are necessary, not just as an optimization.
>>
>>58174041
This is irrelevant to /dpt/.
>>
>>58174087
It's very relevant
>>
>>58174087
why do you think I care?
>>
>>58174046
Neat! Repo? webm? I love shmups, if that is one.
>>
File: Sif.gif (35KB, 230x200px) Image search: [Google]
Sif.gif
35KB, 230x200px
>>58174067
>Comparison is pretty simple. Subtract and compare with respect to zero
Yeah, that's the plan
>Jumping might be difficult if you don't have a proper program counter set up.
I have a separate array for the code section and a code_ptr variable that servers as the instruction pointer, so that won't be a problem

Having the hardware save the process context is a neat idea though, thanks senpai.

I'd like to hear more about the hardware OS, it sounds like an interesting project.
>>
am I allowed to post noobshit in this thread?
>>
>>58174154
yes
>>
>>58174154
Yes
>>
File: Capture.png (43KB, 1024x657px) Image search: [Google]
Capture.png
43KB, 1024x657px
>>58174157
>>58174161


>Write a program that asks for an integer and then prints all the integers from (and including) that value up to (and including) a value larger by 10.

What have I done wrong? pls no bully xddd
>>
>>58174185
int i;
for (i = 0; i < num + 10; ++i)
printf("%d\n", i);



in Haskell
readLn >>= (\x -> print [x .. x + 10])
>>
>>58174213
haskell
readLn >>= print . (enumFromTo <*> (+10))
>>
>>58174213
Well the book hasn't taught me about for yet so there must be another way to do it.
>>
>>58174185
>What have I done wrong?

used c
>>
>>58174225
it's a shit book then
>>
>>58174213
int i = num
while(i <= num + 10)
{
printf("%d\n", i);
++i;
}

>>58174185
You don't need the h in the scanf statement
>>
>>58174241
printf("%d\n", i++);
>>
>>58174238
literal nigger spotted
>>
>binary grows from 1.4MB to 2MB
Is there a tool or some way to see what's causing muh bloat?
>>
>>58174261
What language?
>>
>>58174261
>muh
yeah it's on the website you came from.
>>
File: Capture.png (20KB, 312x735px) Image search: [Google]
Capture.png
20KB, 312x735px
>>58174241
it works bro. So I need to have two variables to do this program instead of one. Interesting
>>
>>58174185
The semicolon immediately after the while loop is fucking everything up. That line repeats with no output until the condition is met.

The other issue is that theoretically num++ would continue to be less than num + 10 forever. What's happening here is something called integer rollover. The maximum value that you can store in a signed 32 bit integer is 2147483647. If you increment that number by 1, it rolls over to -2147483648. So the loop continues until num is 9 less than the maximum integer value. At that time, num+10 evalueates to -2147483648 which is less than num since num is positive, but num+10 rolls over to a negative. The loop terminates and THEN executes the printf statement.
>>
>>58174279
What's your book?
>>
>>58174274
C++. It's so bizzare though since it's not like I added any templates.
>>
>>58174299
C Primer Plus 6th Edition Stephen Prata
>>
I CURSE this thread
>>
>>58174320
>>
>>58174133
Well it's late. But the gist is to move the scheduler to hardware and implement this on a network-on-chip style architecture. This would allow fine-grained task allocation between all the processors on the chip, and allow most work and communication between nodes to happen deterministicly. We are chasing deterministic asynchronous task farming. Being able to provide bounds on utilization and task completion time.
>>
>>58174278
>yeah it's on the website you came from.
The text boards were on the same site as the imageboards, anon.
>>
New thread:

>>58174411
>>58174411
>>58174411
>>
>>58171026
If you can use different languages, then here's Java:

Counter<Integer> counter = new Counter();
for(int i : ivec) {
counter.add(i);
}
for(Tally t : counter.tallies()) {
System.out.println(t);
}


It's not as short as Haskell is, but it's still pretty good.
>>
>>58174627
>
Counter<Integer> counter = new Counter();

is this a real java class? i mean in the standard library
>>
>>58172360
But other languages don't work the same way.
Haskell implements strings using linked lists.

Common Lisp uses a vector (which unless you specify otherwise, is non-growable and one dimensional. If you need to write multidimensional text strings... gods have mercy on you.), Java uses an array, Microsoft C uses 255 long strings as standard, it seems, and Prolog doesn't really have strings. Just lists of integers that can be interpreted as strings.

C is a very good way of learning how a PDP-11 really works, but I'm beginning to question the utility of that information.
>>
>>58172644
There's an eXtensible Markup Language that may be of help anon.
>>
>>58173088
Yes, depending on your language.
Use Emacs or Vim as your editor, integrate your development environment with those and you're mouse-free.

Works surprisingly well with most languages. Some setup-time required though.
>>
>>58174632
No, it's from a separate util library.
It's really fucking useful when you need to count things, and saves me typing.

It is, as you might guess, a wrapper over java.util.HashMap, and Tally is just a pair.
>>
>>58170501
As a long time C# dev, overtime I'm more and more interested in C++, especially the joy of templates and freedom of choosing how to allocate shit.

The only thing that is keeping me from switching over, is the lack of extension methods, and the verbose lambda syntax ;(
>>
>>58173541
code things
>>
>>58174296
In C signed integer overflow is undefined.
Thread posts: 320
Thread images: 33


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.