Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 242 KB, 775x845, 1504559735686.jpg [View same] [iqdb] [saucenao] [google] [report]
62363622 No.62363622 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Old thread: >>62356950

>> No.62363673
File: 140 KB, 720x494, Untitled.jpg [View same] [iqdb] [saucenao] [google] [report]
62363673

Just finished my C assignment and moving onto microprocessor stuff
enjoying it a lot

>> No.62363686

whats something challenging you should be able to program before you can even think of calling yourself a programmer

>inb4 fizzbuzz

>> No.62363687

>>62363622
Daily reminder that D was made by a gypsy romanian, therfore it's shit by definition

>> No.62363700

>>62363686
Yoz have to kode with Karlie

>> No.62363708

>>62363687
people don't use sepples when a GC is acceptable, so a sepples replacement with a GC is as terrible an idea as sepples was in the first place

>> No.62363710

>>62363686
An optimizing compiler for your own high-level programming language.

>> No.62363713

@62363687
>falseflagging this much
I see you're getting creative with shilling, Andrei.

>> No.62363717

How do you design a database schema?

>> No.62363727

>>62363717
With pencil and paper

>> No.62363754

>>62363717
a series of wooden blocks and straws

>> No.62363786

>>62363717
put everything into 1 table like a pajeet
extra points for redundant columns

>> No.62363800

Learning C++
Confused with opOverloading
#include <iostream>
using namespace std;

class Point {
private:
int i{0}, j{0}, k{0};

public:
Point(int x = 0, int y = 0, int z = 0) : i{x}, j{y}, k{z} {
cout << "Creating " << *this
<< "\n"; // haven't overriden << yet but still works
}
void operator-() { // This is not a friend! How can main see this?
--(this->i);
--(this->j);
--(this->k);
}

friend ostream& operator<<(ostream& outstream, const Point& p) {
outstream << "(" << p.i << "," << p.j << "," << p.k << ")";
return outstream;
}

friend istream& operator>>(istream& instream, Point& p) {
char l_paren, f_comma, s_comma, r_paren;
int temp_i, temp_j, temp_k;
instream >> l_paren >> temp_i >> f_comma >> temp_j >> s_comma >> temp_k >>
r_paren;
p = Point(temp_i, temp_j, temp_k);
}
};

int main() {
Point p;
cin >> p;
-p;
cout << p << "\n"; // works
// cout << -p << "\n"; //won't
}

>> No.62363813

>>62362745 #
>employed where

>> No.62363819

>>62363800
>opOverloading
Its not something you should be using anyway

>> No.62363843

>>62363819
>Its not something you should be using anyway
Found the Java brainlet. Good boy. You should stick to "never do this, always do that" mantras if you're incapable of good judgment.

>> No.62363844

>>62363819
It's very convinient. I have to master it

>> No.62363846

>>62363819
Why? In certain cases it's an amazing tool to improve code readability. C++ streams use it really well.

>> No.62363847

>>62363800
>// This is not a friend! How can main see this?
It's public.

Anyway, operator- should not mutate the current object. It should return a temporary object. Do something like this instead.
Point operator-() const {
return Point(-this->x, -this->y, -this->z);
}

>> No.62363850
File: 44 KB, 254x252, 1482910622003.png [View same] [iqdb] [saucenao] [google] [report]
62363850

why the fuck do matlab arrays start at 1

>> No.62363857

>>62363846
C++ streams are a crap example of operator overloading.
Anon's using a Point class. That's arithmetic, so operator overloading is sensible and appropriate.

>> No.62363873

>>62363847
Well, I am doing this because unary -- is not allowed afaik

>> No.62363880

>>62363847
>It's public.
Oh thanks

>> No.62363892

>>62363800
cout << p << "\n";
(cout << p) //returns an ostream& so it basically does
(ostream&) << p << "\n";
(ostream&) << "\n";
(ostream&);


cout << -p << "\n"; //becomes
(cout << void) << "\n" //because your - operator doesnt return anything

>> No.62363908

>>62363850
mathfags dont like 1 indexing

>> No.62363915

>>62363908
*0-indexing
fugg

>> No.62363923

>>62363915
I'm a mathfag. It's not about "liking" what I choose to like, it's math.

That being said, 0-indexing is correct.

>> No.62363950

>>62363892
Hmm, I get it
Thanks. Can you explain this?
friend istream& operator>>(istream& instream, Point& p) {
char l_paren, f_comma, s_comma, r_paren;
int temp_i, temp_j, temp_k;
instream >> l_paren >> temp_i >> f_comma >> temp_j >> s_comma >> temp_k >>
r_paren;
p = Point(temp_i, temp_j, temp_k);
// p here is a reference variable
// It points to a locally created instance of a class
// p should be refering to the local object, which gets destroyed
// Why isn't p invalid?
}

>> No.62363975

>>62363950
p continues to refer to the remote object. The Point is a local, temporary object.
p = Point(temp_i, temp_j, temp_k);
This line is equivalent to this.
p.operator=(Point(temp_i, temp_j, temp_k);
The compiler automatically generates this function if you don't specify it yourself or delete it.
The function copies the values of all the members of the temporary object onto p.

>> No.62363984

What's the difference between an object and an instance of a class?

>> No.62363993

>>62363984
They are the same.

>> No.62364002

>>62363975
Alright. Thanks anon. :)

>> No.62364022 [DELETED] 

>>62363923
0-indexing came about because its easily translatable to a pointer + offset
ptr + index*sizeof(element) [code]If index is 0 its just becomes ptr.

Mathfags do not care about this at all so I always see math oriented stuff starting with 1.

>>62363950
Said it better than I could have but if you're using c++1x I believe its calling the
operator=(Point&&)
Look up rule of 5 .[/code]

>> No.62364024

>>62363984
>What's the difference between an object and an instance of a class?
All instances of a class are objects but not all objects are instances of a class. Class-based OOP is a meme and there are superior alternatives.

>> No.62364037

>>62364022
>0-indexing came about because its easily translatable to a pointer + offset
Exactly.

Even when you are trying to specify a point in the axis, you really are specifying the distance from 0.

int* array0;

>> No.62364051

>>62364022
>Look up rule of 5
Thanks for that

>> No.62364101

>>62363727
But how do you ensure it's optimized then?

>> No.62364172

struct Butts{
int data;
};

void init(Butts* b){
b->data = 100;
}


class Butts{
int data;
Butts(){
data = 100;
}

Is there a difference?

>> No.62364183

Help needed.

sigprocmask(2)
>The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3).
>Each of the threads in a process has its own signal mask.
>A child created via fork(2) inherits a copy of its parent's signal mask; the signal mask is preserved across execve(2).

pthread_sigmask(3)
>A new thread inherits a copy of its creator's signal mask.

So if I call sigprocmask on one of the threads in a multithreaded process, the behaviour is unspecified but if I call sigprocmask on a single threaded process and then run new threads, it's not? Is thread's signal mask inherited from the parent thread or does it get a new one?

>> No.62364205

>>62364172
>You have to call a constructor on a class, you may not init a struct
>You can return an error value from an init function, you can only throw an exception or set an internal flag from a constructor

>> No.62364218

>>62364172
One has a public constructor, the other doesn't

>> No.62364226

>>62364172
data is default public in structs and private in classes

>> No.62364280

>>62363713
I unironicaly hate romanians tho

>> No.62364357

I'm trying to self teach myself programming. It's not easy. I'm following cs50 on some freeshit site. It's nice, but no one wants to learn C. Are there any self taught programmers lurking? How did you learn? I find it interesting if you're just naturally talented.

>> No.62364416

>>62364357
I learnt programming from very 0 by myself back in school days(got my CS degree later). I don't know whether it's the best way but I just picked a programming language and read a book(it was Java one, a regrettable choice). I just don't like any any online courses. If I could back in time I'd tell myself to start from SICP or K&R C programming language

>> No.62364421

>>62364357
>no one wants to learn C
I did.

>How did you learn?
Books, tutorials, asking for help on forums as a last resort. Nothing special or surprising. The trick is staying motivated, and what did it for me is always trying to apply a newly acquired piece of knowledge to write a program that does something that interests me. I started making little game-ish programs early on using only colored ASCII characters. That was always fun.

>> No.62364524

>>62364357
Reading and rereading books that my brainlet brain couldnt understand the first time, taking that cs50 harvard class, taking a few other free courseware classes, falling for the sicp meme, watching both the old sicp lectures and the one by brian harvey, many small toy programs, many college courses but I was already self taught in most of what matters, now it's just drudging through UML Software Process memes.
Went from using Visual studio to writing makefiles(Cmakelists) in vim.

Gotta learn pointers and recursion my man, learn C or at least C++.
Go find out why some cases of recursion don't blow the stack.
Learn about referential transparency.

>> No.62364573
File: 103 KB, 1280x720, maxresdefault.jpg [View same] [iqdb] [saucenao] [google] [report]
62364573

So, is this shit any good for learning?

>> No.62364613

>>62363923
0-indexing is useful if we assume that index means memory offset. Otherwise, why would we use it?
>have N elements
>can't have Nth element

>> No.62364634

>>62364524
>C
But there's no TCO

>> No.62364643

>>62364357
>google cs50
>harvard webite
>click syllabus
>they literally have a tl;dr written with big red letters
The current state of CS. No wonder why we're ridiculed.
I thought Harvard was a good university, at least good enough for me to hear about it, being a non-American. wtf is this shit?

>How did you learn?
I played Roblox, so my first language was Lua. Then I played with some meme framework for GTA:SA modding in Lua/C#.
Then we had some "C++" in high school, or as I've recently taken to calling it, C plus iostreams. There was a student circle where we "learned" Java but it was just that we asked the teacher how to write something and the next day he would print us some code in Java and tell to rewrite it in an IDE and compile without any explanation.
At that time a friend showed me GNU±Linux, so I learned very little of Bash on my own.
Then I took the university that first taught me C on the first semester and then x86 assembly and Java on the second and I think this is an optimal start. You learn how shit really works. C teaches you the very basics, assembly shows you how shit really works and Java teaches you about abstracting that shit to make it easier to comprehend and how not to do this. Then you can pick up an interpreted language like Python or Lua.
You might want to try functional programming too. We started with SML but I can't tell if it's good cause the professor didn't give a single flying fuck about us and he just let everybody pass almost unconditionally. If somebody can confirm it's good to start with SML please do. Otherwise I would recommend Haskell. At least it seems more useful than SML in real world.

>> No.62364672

>>62364357
>>62364643

>I find it interesting if you're just naturally talented.
Talent is a meme; there's no such thing. It's just a matter of how well you understand the subject (how much you are willing to understand it), and the time and attention spent on it. You only need to practice. Start from a small project like a calculator app and slowly build up even to stuff like a simple 3D game engine or a compiler for your own language, whatever you fancy.

I'd recommend to learn software design and have a solid background in maths.

>> No.62364687

>>62364226
Can you make private data in struct?

>> No.62364701

>>62364687
Yes, use
private:

Just as you'd use public

>> No.62364714

>>62364183
bump

>> No.62364731

>>62364687
private keyword works fine.
Structs and classes are exactly the same thing in C++, the only difference is that structs are implicitly public and classes implicitly private.

>> No.62364741

>>62364701
But how would you put data or initialize the element?

>> No.62364747

>>62364672
>Talent is a meme; there's no such thing.
>t. talentless hack
I hate to inform you, but some people are naturally more adept at programming that you will ever be, and no amount of practice is going to bring you up to their level.

>> No.62364759

>>62364741
time to write a constructor

>> No.62364826

>>62364747
Keep telling this to yourself and achieve nothing lazy fuck.

>> No.62364843

>>62364759
But you can make it only with classes, can't you?

>> No.62364856

>>62364741
struct A {
private:
int x;
int y;
}

A a;
int* ptr = (int*) &a;
//set x
ptr* = 1337;
// set y
ptr++;
ptr* = 8008135;

>> No.62364860

>>62364843
No. You can make a constructor in struct just fine.
>>62364731

>> No.62364867

>>62364843
Nope.
Like >>62364731 said, there are only two major differences between structs and classes in C++.
>Members of a struct are public by default. Members of a class are private by default.
>A struct is public-inherited by default. A class is private-inherited by default. I don't know why the fuck this is the case because you almost always want to public-inherit a class and rarely want to inherit from a struct at all.

>> No.62364874

>>62363622
This is the cutest lain in the history of lainposting, maybe ever.

>> No.62364898
File: 3.01 MB, 1280x1813, 1473790965288.png [View same] [iqdb] [saucenao] [google] [report]
62364898

Link me to your favorite C++ lecture on YouTube. I always find them motivational.

>> No.62364917

>>62364573
I've seen people argue TIS-100 is actually a better game. If you like the idea of ASM try out WireMod for Garry's Mod and it's basically a simulated robotics toolkit (eg. https://gitlab.com/BobBarker/hoverbob )

>> No.62364924

>>62364917
WireMod was a lot of fun. E2 was the first time I had programmed.

>> No.62364946

>>62364856
But this is a hack which assumes we have data in struct placed together. What if data won't be placed such way?

>> No.62364966

>>62364946
Go read the C and C++ standards to see what guarantees are made about struct layout if you really care.

>> No.62364991

>>62364966
What if there are nested structs?

>> No.62365008

>>62364024
>Class-based OOP is a meme and there are superior alternatives.
Such as?

>> No.62365010

>>62364966
>There may be unnamed padding between any two members of a struct or after the last member, but not before the first member. The size of a struct is at least as large as the sum of the sizes of its members.

>> No.62365014

>>62365008
Prototypal inheritance I guess

>> No.62365064

>>62364898
https://www.youtube.com/watch?v=1i4-e1okZtw
:^)

Or pick one of these. Acton is a good one
https://www.youtube.com/user/CppCon/videos?view=0&flow=grid&sort=p

>> No.62365074

>>62364826
>anyone who calls me out on my bullshit is somehow lazy
Keep lying to yourself.

>> No.62365092

>>62365008
Prototype-based OOP. Far more flexible and expressive.

>> No.62365129

>>62365092
Are you talking about basically just using interfaces?

>> No.62365136

>>62364357
I don't think I ever read a proper book. I started around 10 years old or something, just learning from tutorials on the internet. Over time I developed my skills with more tutorials, actual experience working on projects, blog posts, StackOverflow, official documentation and reference material, etc.

>> No.62365141

>>62365129
No.
With prototypal inheritance, objects inherit from other objects and classes don't exist.

>> No.62365147

>>62365014
>>62365092
What's that?

>> No.62365150

>>62365141
I don't follow.

Isn't an object just an instance of a class?

>> No.62365157

>>62365141
Huh? Why is that better? And what languages work like that?

>> No.62365166

>>62365150
In a classical OOP language, yes. Different languages don't follow that model.

>> No.62365169

>>62365074
You're right. I wrote currently most popular operating system as soon as I popped out of my mom's cunt and I finished by lunch time. I was just bantering with ya.

>> No.62365177

>>62365166
Can you explain this interaction in another language that you're referring to?

>> No.62365191

How come when I call getopt(), "./prog -ab" works as expected, but "./prog -a -b" only gets the first option?
There's no real difference between my code and the code in the getopt(3) example.

>> No.62365219

>>62365157
Javascript is the most famous example, except that's kind of fucked.

>> No.62365227

>>62365169
>you don't think everyone starts on equal ground and everything depends on training?
>that means you think people are born knowing how to program!
It's neither, brainlet. Some people are more predisposed for certain kinds of tasks than others, so they pick up the necessary skills more easily and are able to master them to greater degrees.

>> No.62365282

>>62365147
Every object has a prototype. Every prototype is an object. If you try to look up a property that the object doesn't have, the property is looked up in the prototype instead.

>> No.62365306

Prototype based OOP is the ultimate meme of programming languages. Its programs cannot scale neither to machine nor to the human brain, it is unstructured, takes immense complexity to reify or do any kind of analysis and it's impossible to write an efficient compiler for.
>more expressive
That's a myth.

>> No.62365327

>>62365306
>muh subjective and unsubstantiated opinions about how hard it is matter
They don't.

>i-it's not more expressive
It objectively and undeniably is.

>> No.62365360

Why hasn't someone made a O(n) CSV parser?

>> No.62365371

>>62365360
O(log n)*

>> No.62365391

>>62365327
You want substance, fine. Reifying a prototype based program need context-sentive control flow analysis (call-path at least). EXPTIME complexity. In practice, not applicable to maximum call paths of length k=3 or more.
http://matt.might.net/papers/might2010mcfa.pdf

>> No.62365418

>>62365360
>>62365371
>read n lines in log n time
How?

>> No.62365434

I wonder how many C programs would break if you replaced int with int16_t (which is perfectly valid btw)

>> No.62365436

>>62365391
>completely failing to provide evidence that prototype-based programs are inherently incomprehensible and inefficient
Your paper does not back up your claims. Try again.

>> No.62365469

>>62365434
>I wonder how many C programs would break if you limited their integers to +/-32,767
wtf I hate C now

>> No.62365471

>>62363686
>never programmed in my life
>started CS
>read half of the book in two weeks
>can do fizzbuzz no problem

Why is it considered difficult?

>> No.62365494

>>62365418
quantum algos

>> No.62365502

>>62365469
int's are not mandated to be more than +/-32767

>> No.62365518

>>62365502
*ints

>> No.62365546

>>62365418
If you just want to look up you can do it faster though.
>get file size
>open file for reading
>seek to middle
>read until newline
>get primary key of line
>divide current position (bytes) to current position (key) to get average line length
>multiply best line length estimate with desired key
>repeat until key found
You can optimize it further by having a comment row at the top with the number of lines so you can get a better starting guess or even using DCT if you're okay with O(n) index creation.

>> No.62365696

>>62365434
C++ as well

>> No.62365715

>>62365434
I wonder how many would break if you replaced it with 128-bit ints or something similar.

>> No.62365721

>>62365546
It isn't done because that's not the purpose of the format. The purpose of the format is to be easy to parse. Once you parse it, you put your data in whatever specialized structure you need to facilitate the kind of processing you want to do.

>> No.62365746

>>62365471
No one considers that difficult. You should be able to do fizzbuzz as soon as you learn about branching statements.

>> No.62365751

>>62365471
>read half of the book
>>can do fizzbuzz
You'll never make it, brainlet

>> No.62365752

>>62365721
But if you want to embed any kind of database in PHP/JS/shell script, etc, this would be useful. There already is flatfile.php.

>> No.62365759

I just realized int32 can't hold my bank balance :^)

>> No.62365781

>>62365759
Because it's a double?

>> No.62365786

>>62365781
>double
I don't think anyone is that rich, anon

>> No.62365802

>>62365786
Float then. I just meant needed decimal precision

>> No.62365841

>>62365759
>wake up
>check bank account
>-2,147,483,648 dollars

>> No.62365873

>>62365759
You have some shit currency?

>> No.62365896

>>62365802
>needed decimal precision
i wonder

>> No.62365922

>>62365751
>not writing a cryptic one-liner fizzbuzz
for(i=1;i<=100;console.log([i++,f='fizz',b='buzz',f+b]['001021001201003'[(i-2)%15]]));

>> No.62365936

>Overloading the parenthesis operator
I'm reaching the peak C++ autism

>> No.62365945

>>62365936
Would you overload overloading operator?

>> No.62365959

>>62365936
I thought you loved lambdas

>> No.62365963

>>62365959
>what is std::function

>> No.62365967

>>62365922
>js
>>>/wdg/

>> No.62365975

>>62365963
a slow piece of shit

>> No.62365988

>>62365975
mice citation

>> No.62365990
File: 2.13 MB, 1280x720, holyshit.mov.webm [View same] [iqdb] [saucenao] [google] [report]
62365990

Holy shit guys,
never been so happy about a blinking LED.
Did some ARM assembly "os dev" tutorial the last few days for the raspberry pi. Since assembly sucks big nigger dick I wanted to transision to C, so I looked up the osdev.org wiki which gave a skeleton how to call kernel_main in C and now I merged those two tutorials and got a fuckin blinking LED.
Now """just""" gotta adapt my framebuffer and all kind of crap. Fuck yeah!

>> No.62365993

>>62365064
jesus, this guy is a fucking moron. i'll give him that it's true that stroustrup doesn't seem to get his hands very dirty, however he and the rest of the C++ committee are surrounded on all sides by industry professionals who *do* ship large-scale performance-critical applications and who have a vested interest in the improvement of the language from a technological as opposed to theoretical standpoint. do you really think he could get away with having no idea what he's doing? also pretty fuckin ironic to bitch about one of the very oldest (and entirely optional) parts of the language while apparently remaining blissfully unaware of the newer features, essentially none of which have anything to do with OOP and have rather had much more to do with functional/generic paradigms (generic lambdas, optional/variant types, variadic expansions, fold expressions, perfect forwarding), arbitrary compile time execution, drastic reduction of syntax (most notably template syntax), added value categories/aligned and uninitialized storage/placement new/etc to allow for better compiler and programmer optimizations, more data-driven approaches, etc. you know, practical shit, like this guy seems to care so much about. fuckin autists, man

>> No.62365999

>>62365988
nice*
>>62365990
Haven't you been doing this for the last 3 years?

>> No.62366006

>>62365936
Ultra autism is to overload unary +. This reminds me, I once wrote an extension method for METHODS in C#.

>> No.62366007

>>62365967
>implying only webdevs write short js snippets in their browser

>> No.62366009

>>62366006
>unary +
Not unary ++?

>> No.62366030

>>62365999
>Haven't you been doing this for the last 3 years?
Blinking an LED? Kind of, yes. But never done bare metal raspi stuff.

>> No.62366065

>>62366009
++ is always unary. Unary + has literally no usage but it exists.

>> No.62366074

>>62366065
Just like your moms pussy

>> No.62366077

>>62366074
BTFO

>> No.62366079

>>62366006
>>62366065
Lambdas use it to decay to a function pointer. It also converts implicitly, but it's nice sometimes.
auto lambda = +[](){}; // deduces to void(*)()

>> No.62366083

>>62366007
>it's another episode when webdev pretends to be desktop dev just because he uses electron
>>>/wdg/

>> No.62366090

>>62366074
Absolutely BLOWN THE FUCK OUT

>> No.62366119

>>62366083
>it's another episode of a full-blown retard who only knows C (and barely even that) trying to put people down for being proficient in many programming languages
>>>/trash/

>> No.62366131

I use hungarian.

>> No.62366138

BTFO BTFO BTFO THIS JUST IN

No UFCS for C++20

>> No.62366141

>>62366074
If it has no usage how did I get born
>ZIMBABWE
Plus, my mom's pussy can't be overloaded.

>> No.62366158
File: 52 KB, 728x546, aid3311343-v4-728px-Write-a-Reaction-Paper-Step-1.jpg [View same] [iqdb] [saucenao] [google] [report]
62366158

>>62366065
>>62366079
>mfw comma can be overloaded
Can I write a string library using this?

>> No.62366163

>>62366158
what do you mean, and why would you want to?

>> No.62366170

>>62366119
>being buttblasted that much
>>>/wdg/

>> No.62366171

>>62366006
i overload unary + for some arithmetic types. it's nice for symmetry when you're dealing with a mixture of positive and negative values. especially for spatial shit like linear algebra types since it's visually explicit. and it's defined for the primitive arithmetic types so it's more consistent in that way too

>> No.62366186
File: 47 KB, 645x968, 1481916546254.jpg [View same] [iqdb] [saucenao] [google] [report]
62366186

I can only find Chromium style guide comfy.
LLVM is a close runner-up but their preference of int &x over int& x is what I don't like. Same goes for Google style guide.

Webkit is okay and comfy too.

Mozilla style is highly autistic, only C89 fags will like it

>> No.62366205

>>62366171
What does it do though?

>> No.62366206
File: 50 KB, 1888x831, Untitled.png [View same] [iqdb] [saucenao] [google] [report]
62366206

>>62366170
Shoo, retard.
>>>/b/

>> No.62366214
File: 28 KB, 1080x144, Screenshot_20170911-172517.png [View same] [iqdb] [saucenao] [google] [report]
62366214

>>62366163
Dunno. Concat strings with it or something?

>> No.62366220

>>62365751
Did I say that I needed to read half of the book to do it? No. I just staited where I am now.
So watch who you call brainlet you illiterate fag

>> No.62366225
File: 45 KB, 620x420, i-have-no-idea-what-Im-doing-meme-4.jpg [View same] [iqdb] [saucenao] [google] [report]
62366225

Does anybody know how to create all possible case permutations from a string in C?

e.g. hi becomes:
>> hi
>> Hi
>> hI
>> HI

I know you will get 2^strlen number of permutations, but can't really figure out a good way to implement this. Maybe recursion?

>> No.62366228

>>62365988
>>62365999
It is. It's not templated so it needs to own a pointer to memory and it uses a function pointer that can't be inlined. Using a template F: Callable has zero overhead.

>> No.62366244

Is a laptop worth it? I started college last week and my only comp-sci class is in a computer lab and I don't wanna dump $500+ on something for school I'll hardly use.

>> No.62366245

>>62366214
I'd really rather not.

>> No.62366247

>>62365990
I remember the same feeling when I bare metal drew to a 240p screen

>> No.62366248

>>62366186
>LLVM is a close runner-up but their preference of int &x over int& x is what I don't like
Blame the language. int& x is not what you think it is. Sooner or later you will write int& x, y and then wonder why your shit doesn't work.

>> No.62366261

>>62366248
this.
I don't like the rules, but I do follow them, which is why I use int *ptr and int &ref

>> No.62366278

fizzbuzz proficient in 37 languages

>> No.62366305

Need an advice on how to approach the following NP-hard problem:

Given a sequence tan(1),tan(2),...,tan(n) insert '+', '-', '*' to minimize the absolute value of difference of n and value of resulting expression. (5 ≤ n ≤ 365).

>> No.62366329
File: 63 KB, 1206x904, Untitled2.png [View same] [iqdb] [saucenao] [google] [report]
62366329

>>62366278
I said shoo, retard.
>>>/b/

>> No.62366373

>>62366225
#define UPPER_CASE TRUE
#define LOWER_CASE FALSE
const signed int CASE_GAP = (int)('A' - 'a');
char _uppercaseCharacter(char character);
char _lowercaseCharacter(char character);
char caseCharacter(bool case, char character);
bool canBeCased(char character);
void casePermuteString(char* string);

Do you understand what to do now?

>> No.62366404

>>62366373
wow what a waste

char alterCase(char);
check range
upper or lower

>> No.62366419

>>62366225
dunno treat the string like a binary number 0 is lower case 1 is upper case

e.g. hi, hI, Hi, HI corresponds to 00, 01, 10, 11

>> No.62366423
File: 32 KB, 576x402, niggers.png [View same] [iqdb] [saucenao] [google] [report]
62366423

>>62366206
>webdev still tries to refuse the evident
>>>/wdg/

>> No.62366438

Where my /functions with 6 parameters/ bros at?

>> No.62366439

>>62364643
>some "C++" in high school, or as I've recently taken to calling it, C plus iostreams.
This is fucking perfect, I'm going to start using this

>> No.62366441

>>62366373
>trivialHelperFunctions();
>solvesTheActualProblem();
>See? So easy!

>> No.62366463

>>62366373
oops, casePermuteString() should be some kind of list struct, not void
>>62366404
If you want to go full autism you could just do character ^ 0x20, I think there's a bit hack to pad a bitmap with zeros so you can apply it to the whole string even
>>62366441
use a fucking bitmap you brainlet

>> No.62366480

Why are you guys still not programming your own OS? Linux will join the botnet force pretty soon. You should start developing guys

>> No.62366490

>>62366480
Your time must not be worth very much.

>> No.62366491

>>62366441
casepermutestring just checks how many caseable characters there are and then applies casecharacter for each one of them

>> No.62366497
File: 348 KB, 3000x2000, IMG_4711.jpg [View same] [iqdb] [saucenao] [google] [report]
62366497

>>62366480
lol forgot picture. Framebuffer seems to work. Next is input, which will take much longer I think

>> No.62366514
File: 3.87 MB, 600x253, 1505084502478.gif [View same] [iqdb] [saucenao] [google] [report]
62366514

>>62366480
Terry is our saviour.

>> No.62366520

>Big5 is the perfect character encoding
>used in 0.5% of all web pages
>instead have the clusterfuck known as unicode which manages to turn rendering text into a security vulnerability

>> No.62366524
File: 54 KB, 1014x898, Untitled3.png [View same] [iqdb] [saucenao] [google] [report]
62366524

>>62366423
I said shoo, retard. Who let you off the leash and allowed you to bark at your superiors? :)

>> No.62366532

>>62366158
>>62366214
there's not really any reason to overload comma anymore, if there ever even was. nowadays anything you'd wanna use it for would almost certainly be better handled by things like variadic templates or fold expressions

>>62366205
technically whatever you want if it's an operator overload. mine just return the value and probably get optimized out. the primitives return their value, technically after integral promotion and/or conversion to an rvalue, where applicable. but that would usually get optimized out too

>> No.62366534

>>62366438
if my function needs 6 parameters I'll give it 6 parameters

>> No.62366538

>>62366514
I was thinking about what it would take to port templeOS to the raspberry pi.
Now, since I am getting kind of into ARM, I obviously had to rewrite his whole compiler and compile everything for ARM. Would be a pretty fucking crazy project. Not sure if it is worth it.

>> No.62366540

>>62366423
This is all justified. JavaScript is the perfect language.

>> No.62366541

>>62366534
I'll give you six parameters

>> No.62366555

>>62366463
>>62366491
>all this talk
>zero implementations provided

>> No.62366556

>>62366524
>>62366540
>>>/wdg/

>> No.62366561

>>62366538
Well, the most of it is in HolyC, so you should only need to do the small parts like the compiler/loader. I think he would like it, the single board ARM computers are much more "bare metal".

>> No.62366579

>>62366540
This monkey is just sperging off because I posted a javascript snippet I wrote in the browser console, and he can't deal with the fact that I'm a compiler developer who happens to know multiple languages, and not a webdev.

>> No.62366582

nothing, after doing 100+ projects i've become bored and theres no point in making anything.

>> No.62366586

Redpill me on Swift

>> No.62366588

>>62366561
Yeah, but he said his compiler is like 20k lines or somethin. I don't even fucking know how to write a compiler, but this would be a good project to get to know it

>> No.62366618

>>62366586
Alterntive to objective-C, made by apple so they don't give a shit about supporting other platforms.
Otherwise looks kind of decent.

>> No.62366622

>>62366582
what age are you?

>> No.62366636

>>62366555
first a loop to get how many caseable characters
then nest loops, 1 for the bitmask, a while for the amount of caseable characters (use a bitmask and shift operator, only increment if it's caseable)
do you need me to implement it for you?

>> No.62366656

>>62366636
>do you need me to implement it for you?
Yes. Let's see your shit-tier implementation, because you're obviously nervous about that. :)

>> No.62366670

How do you deal with having really fun embedded work you want to do but lacking the EE skills to make it a full product?
Feels pretty painful desu. It's mostly EE tools I'm lacking at the moment.

>> No.62366694

>>62366670
>study and acquire skills needed
>implement project
>???
>masturbate

>> No.62366751

>>62366579
>>>/wdg/

>> No.62366771

>>62366141
These niggers yesterday had been saying something else when they were leaving your house.

>> No.62366814

>>62366694
It's the other way around.
>study and acquire skills needed
>masurbate
>???
>implement project

>> No.62366825

>>62366814
can i just do step 2?

>> No.62366834
File: 46 KB, 600x450, wikihow-funny-masturbate-ukulele.jpg [View same] [iqdb] [saucenao] [google] [report]
62366834

>>62366694
>>62366814

>> No.62366860

>>62366834
My cum is the glue code

>> No.62366882

>>62366860
Smells and gets crusty unless wiped?

>> No.62366884

>>62366497
What language do you write in? If it has a single line of something else than assembly than your opinion is pretty much discarded.

>> No.62366935

>>62366439
I didn't refer to C++, only the way they told us to use it in the school.

>> No.62366967

>>62366884
The framebuffer is completely written in asm. I now switched to C, since this gon be a little easier to handle

>> No.62366993

>>62366636
Still waiting for your brilliant implementation. Taking you quite long to write a 10 line program.

>> No.62366996
File: 8 KB, 420x420, 1504209769666.png [View same] [iqdb] [saucenao] [google] [report]
62366996

What is the best programming paradigm?

>> No.62367014

>>62366996
dumb frogposter

>> No.62367017

>>62366996
distributed metaparallel programming

>> No.62367025

>>62366996
programming socks

>> No.62367026

>>62366996
bytesex

>> No.62367032

>>62366996
All of them.
>He uses pure [anything] languages

>> No.62367056

>>62367032
>All of them
>except these ones

>> No.62367068

>>62366996
theorem proving

>> No.62367114

>>62366996
The question is based on a false premise.

It isn't proven that there is a single best programming paradigm.

>> No.62367171
File: 358 KB, 713x403, BB 51203.png [View same] [iqdb] [saucenao] [google] [report]
62367171

>>62363622
>Just got back a shitty grade on my java assignment because the instructions confused me and my anxiety kept me from asking questions
>Also compared to other languages I'm pretty fresh with Java and not used to some of the class stuff and java's arrays.

>> No.62367178

>>62367114
>The question is based on a false premise
Your answer is based on the false premise that it's proven that his premise is false. The truth value of his premise is currently unknown.

>> No.62367190

>>62367171
>get bad score on java assingment
better just give up now.

>> No.62367199

>>62367178
I know the truth

>> No.62367300
File: 53 KB, 450x600, thatfeel.jpg [View same] [iqdb] [saucenao] [google] [report]
62367300

>tfw valgrind clean

>> No.62367314

>>62367178
An unknown premise can be treated as a false premise logically until that premise is first explored and validated.

>> No.62367360
File: 311 KB, 640x1136, 1463700709695.jpg [View same] [iqdb] [saucenao] [google] [report]
62367360

>>62367171
>not asking for clarification when you don't understand project requirements
>making excuses

Yeah, you earned that grade. No one cares about your excuses. Lot's of stuff in uni doesn't match reality, but vague requirements are a fact of the job. Your job is to pin down the requirements.

If you want to improve, start writing down every question you have as soon as it comes to mind. If you can't answer them on your own, shoot your teacher or TA (CC teacher) a short email asking the specific question you need an answer for.

Being able to ask the right questions is one of the most important skills of the job, and you should practice as early and often as possible. Being quick to ask those questions is another useful trait to practice. No sense in wasting your time waiting around when you're blocked.

>> No.62367382
File: 111 KB, 1280x720, 1501190916314.jpg [View same] [iqdb] [saucenao] [google] [report]
62367382

What do you think is the best way to introduce kids to programming?

What technology to use and what kind of stuff to teach them to code first?

>> No.62367406
File: 36 KB, 480x360, hqdefault[1].jpg [View same] [iqdb] [saucenao] [google] [report]
62367406

>>62363622

Im working on reverse engineering firmware for wifi thermostat.

I had anon recommend some forums to check out, but they seemed to be dead.

Anyone have experience with reverse engineering?

I am mainly trying to figure out the OS the firmware runs on the wifi thermostat.

After using
>file, to determine its actual file
>string
>hex
>binwalk

I output strings to file, and I came across these
>fat12
>fat16
>fat32
>MSDOS5.0 < this makes my think its runs windows embedded.

and on binwalk I came across this
>ecos RTOS

Which quick google shows Embedded Configurable Operating System. Which seems to be using redboot? It also uses lzma compression algorithm. When I read about ecos the website says its common misconception to think ecos is linux, and its not, but its compatible with linux API.

This thermostat is
>Honeywell RTH9580WF

I also came across in a quick google search of a hacking messing with one in 2014 and guy mentions honeywell using Microsoft ASP .net framework.

>> No.62367419
File: 18 KB, 400x300, 1464061169625.jpg [View same] [iqdb] [saucenao] [google] [report]
62367419

>>62367314
The original question seems to be an exercise in exploring that premise though. How can we explore the premise without asking questions based on an unknown (false as you see it) premise?

>> No.62367428

>>62367314
>an unknown premise can be treated as a false premise logically
Nope. It can be disregarded "logically" (as in "rationally"). It can't be considered false logically.

>> No.62367462
File: 23 KB, 572x654, sp.png [View same] [iqdb] [saucenao] [google] [report]
62367462

>>62366636
>>62366225
Since none of the loud-mouthed brainlets are going to provide a decent solution, here it is:
repl.it/KwNe

>> No.62367500

>>62366993
Is your homework deadline coming up?

>> No.62367518

>>62367382
Python and some quick GUI toolkit+IDE that enables them to hack together GUIs like visual basic did back in the day.

>> No.62367526

>>62367462
Congrats, would you like a cookie for doing someone's homework?

>> No.62367532

>>62367500
>my homework
No, I just wanted to see that shit-spewing brainlet provide an implementation for his drivel. Unsurprisingly, he wasn't up to the task, so here it is: >>62367462

>> No.62367533

>>62367406
upload the file somewhere

>> No.62367617

>>62367533
its a bin file, but it cane be downloaded right here.
https://thermostatsetup.honeywell.com/en-US/SoftwareUpdates/Prestige/Pages/default.aspx

but if that doesn't work here is the direct link.
>https://thermostatsetup.honeywell.com/SoftwareUpdates/03040500.bin

>> No.62367654

>>62367014
What's wrong with frogs?

>> No.62367664

>>62367032
>>62367114
Then when do you use each one?

>> No.62367677
File: 44 KB, 636x616, 1474325315193.jpg [View same] [iqdb] [saucenao] [google] [report]
62367677

Employed Haskell programmer here

>> No.62367683

>>62363673
Which uC are you working on?
Nice to see some other embedded stuff, I'm doing some bare metal ARM Cortex-M programming atm

>> No.62367690

>>62367654
If you need to ask then you should fuck off back to r9k or ribbit or whatever shithole you come from

>> No.62367704

>Need to check in binary assets for windows & linux
>git-annex on windows is a dumpster fire
>git-lfs needs a seperate server and no open source implementations are up to date

I'm honestly considering going back to SVN at this point.

>> No.62367739

>>62365546

If the task is to parse any .csv file, you are being a bit presumptive in assuming the existence of a primary key, or that if there is one, that the lines are similar enough in length that if you jump into the middle of the file, you could reasonably assume to end up somewhere before the primary key on the line.

Honestly, it's best to just read the whole file into memory in O(n) time and do lookup in O(1).

>>62365434

Well first of all, any of them that don't #include <stdint.h> would immediately fail to compile. Of the rest, it would depend upon the platform, and how they would do it. If int is 32 bits, there's a good chance that int32_t is typedef'd to int, and depending upon where your macro replacement is done, int32_t might be typedef'd to int16_t, and break some code that relied on fixed width integers being correct. Now we have to consider that on many Unix platforms, as well as Windows, int is defined by the platform to be 32 bits, and the system calls for these platforms may often use int for arguments. You could easily break many POSIX-compliant programs.

I would not consider it a perfectly valid choice, since int is only 16 bits on platforms that define it to be so.

>> No.62367823
File: 7 KB, 250x241, 1503183347656.jpg [View same] [iqdb] [saucenao] [google] [report]
62367823

>>62367690
Maybe you should fuck off instead.

>> No.62367862
File: 606 KB, 1395x858, 1495230699862.jpg [View same] [iqdb] [saucenao] [google] [report]
62367862

>>62367677
How much do you make?

>>62367823
Shut the fuck up, don't you fucking talk back to me you pussy. Come back when you've got a fucking girlfriend.

>> No.62367875

I think I found a way to make my program run in parallel.

>> No.62367884

>>62367862
>>>/bant/
Get out, cirnocancer.

>> No.62367903
File: 68 KB, 400x400, 1504763712107.png [View same] [iqdb] [saucenao] [google] [report]
62367903

>>62367884
cirno website

>> No.62367908

>>62367739
>you are being a bit presumptive in assuming the existence of a primary key
Well, if there is one. There usually is something that works good enough like a timestamp, it's not like you insert stuff somwhere in the middle of the CSV file for no good reaon. If not, it would be easy to do `grep --color=never . csv.csv` to add line numbers.

>if you jump into the middle of the file, you could reasonably assume to end up somewhere before the primary key
Jumping into the middle of the file is just to get a good first guess for the line length, it's roughly as fast as reading a precalculated header but with the advantage of not forcing you to change the file structure. Reading the last part could work too, but then you would need to make a guess about the line length before you start and you don't really gain much from doing it. If you know how many keys there are this step can be skipped.
>that the lines are similar enough in length
They should average out, so that if you seek to the middle of the file you should end up roughly in the middle. You then use the primary key info to do a more optimized version of a binary search. Worst case should be O(log n), in theory but it should perform better if the lines are somewhere close to equally long. They can vary wildly individually, the only thing that's important for performance is that they're not, say, 20% longer towards the end of the file.

>> No.62367918
File: 167 KB, 500x500, 1491273439176.jpg [View same] [iqdb] [saucenao] [google] [report]
62367918

>>62367884

>> No.62367969
File: 78 KB, 1030x560, Capture.png [View same] [iqdb] [saucenao] [google] [report]
62367969

not really programming but I need help in ue4

I have 2 arrays and I need to set 2 variables, preferably not 1 by 1

if I use 2 loops it just sets all values to be the same

how do I do this

>> No.62368075

>>62367969
I'm not sure I understand what you're trying to achieve. What are your variables? Where are they in your picture and what do you want to set them to?

>> No.62368098

>>62365993
he's said before that if C didn't exist he would use assembly instead so I doubt he wants any of those features

>> No.62368128
File: 1.02 MB, 1500x1500, 1420062570323.png [View same] [iqdb] [saucenao] [google] [report]
62368128

>>62367884

>> No.62368257

>>62368075
I have a bunch of sliders (blue) collected in an array

then a float array (green) from a save file

set value sets the value of a slider with a float

I want to set all sliders at once by the index but instead it sets all of them to the same value

>> No.62368300

>>62368257
Can you plug the green curve in the same box as the blue like?

>> No.62368309

>>62368300
no you can only loop 1 array

>> No.62368316

>>62368300
*blue curve

>> No.62368335

>>62368309
Really, there's no "for" construct instead of "foreach"?

>> No.62368403

>>62363819

BRAINDUMBFUCKINGLET

>> No.62368440

>>62367969
Surely there is an "index array" node that lets you plug that array index in?

>> No.62368812
File: 363 KB, 2048x1536, 1502102552455.jpg [View same] [iqdb] [saucenao] [google] [report]
62368812

>> No.62368822

I need to optimize my audio callback. It processes 22050 samples per second.
static void audioCallback(struct SoundIoOutStream *outstream, int frameCountMin, int frameCountMax) {
struct SoundIoChannelArea *areas;
char *readPtr = soundio_ring_buffer_read_ptr(dg.audio.ring);
int readyFrames = soundio_ring_buffer_fill_count(dg.audio.ring) / outstream->bytes_per_sample;
int framesLeft = NK_CLAMP(frameCountMin, readyFrames, frameCountMax);
while (framesLeft > 0) {
int framesWritten = framesLeft;
soundio_outstream_begin_write(outstream, &areas, &framesWritten);
framesLeft -= framesWritten;
while (framesWritten > 0) {
if (readyFrames > 0) {
for (int ch = 0; ch < outstream->layout.channel_count; ++ch) {
memcpy(areas->ptr, readPtr, outstream->bytes_per_sample);
areas->ptr += outstream->bytes_per_sample;
}
--readyFrames;
readPtr += outstream->bytes_per_frame;
} else {
for (int ch = 0; ch < outstream->layout.channel_count; ++ch) {
* (float *) areas->ptr = 0.0f;
areas->ptr += outstream->bytes_per_sample;
}
}
--framesWritten;
}
soundio_outstream_end_write(outstream);
}
soundio_ring_buffer_advance_read_ptr(dg.audio.ring, readyFrames * outstream->bytes_per_sample);
}

Right now I'm thinking of:
>reducing conditional count (I know how to remove the if-else clause from the main loop)
No more ideas come to mind. Any help?

>> No.62368860

>>62368812
Haha, us non-OOP programmers, right, anon?!

>> No.62368866
File: 152 KB, 1948x858, oop 2.png [View same] [iqdb] [saucenao] [google] [report]
62368866

>>62368860
OOP is an embarassment to programming

>> No.62368881

>>62368866
Haha, yeah, most stuff ends up looking like this. Gosh darn programmers from India really love those objects!

>> No.62368882

val files = (optRss
filter (_ match {
case Left(NonFatal(e)) =>
e.printStackTrace // TODO remove side effect
false
case Right(rss) => true
})
collect { case Right(rss) => rss }
flatMap (Rss.files)
filter (!_.exists)
toSet
)

How could I remove the side effect in the filter?

>> No.62368909
File: 69 KB, 1210x467, OOP.png [View same] [iqdb] [saucenao] [google] [report]
62368909

>>62368881
you sound unhappy about something

>> No.62369005

>>62368882
To further elaborate, I'm looking for a method with the following signature: a -> a. This way I can keep side effects in a single block and not litter the rest of my code.

>> No.62369014

>>62368822
Oh, I will also replace for loops with memcpy.

>> No.62369034

>>62369005
why do you need to print a stack trace?

>> No.62369049

>>62369034
For debugging purposes.

>> No.62369061

>>62368882
dont pattern match, keep mapping or flatMapping, return an Either

>> No.62369072

>>62369049
that sounds like a side effect

>> No.62369084

>>62369061
I'm interested in the throwable for each Either, not just one of them.

>> No.62369088

>>62368882
It's debatable whether you would even want to model it as a side effect. Can printing a stack trace affect anything else in the program, or can it fail for reasons that come from somewhere else in the program, etc. If not, I'd just leave it.

>> No.62369129

>>62369088
The only side effect of e.printStackTrace writing to stdout. It doesn't affect anything else in the program.

>> No.62369136

How can I synchronize one clock to another? I am trying to render video stream and it contains PTS data that I want to sync up with an external clock so that I render frames when they need to be rendered, however I struggle to visualize how exactly I am meant to work out the right timings. Any resources or pointers on this?

>> No.62369139

can ur language even do this?
(princ "enter 10 ints: ")
(let* ((line (read-line)) (ints (with-input-from-string (x line)
(loop repeat 10 collect (read x)))))
(format t "unique ints: ~a" (remove-duplicates ints)))

>> No.62369146

>>62369129
Then I wouldn't bother. You turn side effects into first class effects only when it assists reasoning (on your part or the compiler's part).

>> No.62369175

>>62369139
Yes, yes it can.

>> No.62369176
File: 50 KB, 749x469, Screenshot from 2017-09-11 21-12-54.png [View same] [iqdb] [saucenao] [google] [report]
62369176

FUCK

>> No.62369179

>>62369129
It's still a side effect, if you don't want it return a list of messages instead

>> No.62369190
File: 67 KB, 440x190, code::blocks.png [View same] [iqdb] [saucenao] [google] [report]
62369190

>>62369176
this is Code::Blocks btw

>> No.62369219

>>62368866
I get why writing boilerplate just to write it is bad, but that is seldom solved by not writing OOP.
Having a logging system has nothing to do with OOP or not.
Something like cout is much more low level than printf, but it is also so much better.

>> No.62369237

>>62369219
>I get why writing boilerplate just to write it is bad, but that is seldom solved by not writing OOP.
Not true, OOP is innately more boilerplate-y than proper solutions.

>> No.62369242

>>62369176
>>62369190
so? fix it

>> No.62369243

>>62369175
uh ah

>> No.62369249

>>62369179
I understand that, but I don't know how to solve it. I cannot find a `next` or `onEach` method in the docs to perform side effects in.
I'll leave it in like >>62369146 suggested, until I (or you) come up with a better solution.

>> No.62369261

>>62369242
I know neither C++ now wxwidgets. But I found a way to reproduce it, I'm gonna send my compressed project with precise instructions on how to reproduce it.

>> No.62369271

>>62369249
Just don't perform side effects.
Just return a list of messages.

>> No.62369280

>>62369237
Depends on what you write.
I get that when you inherit a class you need to implement some functions, but that is usually the point of inheriting.
Rewriting functionality just because you feel like it is a bad trait for a programmer.

>> No.62369292

>>62369261
compile with release flag enabled.
It removes the warning, don't know if the application crashes.

>> No.62369295

>>62369271
I cannot return a list of Throwables because I require a list of Files.

>> No.62369311

>>62369295
return a list of throwables and a list of files, or a list of (Either Throwable File)s

or use writer monad

>> No.62369314
File: 178 KB, 794x900, 2017-09-11-082211_1920x1080_scrot.png [View same] [iqdb] [saucenao] [google] [report]
62369314

working filtering
rn theres a big bottleneck on creating thumbnails, i think i need to learn dbus-cxx and use the thumbnail service

>> No.62369332

>>62368882
var lefts = filter { .... }
var files = val files = (optRss
filter (_ match {
case Left(NonFatal(e)) =>
false
case Right(rss) => true
})
collect { case Right(rss) => rss }
flatMap (Rss.files)
filter (!_.exists)
toSet
)

// later stacktrace the lefts

>> No.62369418

>>62369311
>>62369332
I'll keep a list of Throwables and print all of them at the end of the program.

>> No.62369445

>>62368822
What are the bottlenecks?

>> No.62369480

>>62368822
do you wan't this to be used on more than one machine?
I'm asking because a lot of optimizations may not apply everywhere, and the performance will be hard to predict, I'm assuming your callback HAS to run at a certain speed, so optimizing to specifically may cause it to fail on other computers.
In general I'd try making sure the data has good locality and check the assembly code

>> No.62369493

>>62365434
>int with int16_t (which is perfectly valid btw)
No, it's not.
Fixed width integer types must be two's complement and have no padding bits which is not required of ints.

>> No.62369549

>>62369445
The callback is the bottleneck. It has to copy 22050 * 2 floats per second, which is 172kB/second.

>>62369480
I'm interested in running on x86 and x64. Currently I'm removing for loops and the conditional in favor of memcpy and memset.

>>62369493
Replacing int with int16_t is perfectly valid, but not the other way around.

>> No.62369550

What's the deal with languages with syntax like ada, sql, vhdl?
>case insensitive, SO EVERY FUCKING THING IS WRITTEN WITH CRUISE CONTROL FOR COOL
>begin ... end

>> No.62369567

>>62365434
pretty sure int width is implementation defined (correct me if I'm wrong)
I wouldn't be surprised if a program written for one implementation of C would break if compiled with another

>> No.62369590

>>62369567
Int is defined to be capable of holding +/- 2^15-1. If you assume it to be something else, don't use it. Use int32_fast_t

>> No.62369597

>>62369549
I'm assuming memcpy and memset will use vector instructions, but I think you should make sure. Also I think it would be helpful to know the access patterns for your data and the new version of the code

>> No.62369615

>>62369549
>Replacing int with int16_t is perfectly valid.
No. sizeof(int) is allowed to be greater than sizeof(int16_t) for example.

>> No.62369631

>>62369590
long int will do

>> No.62369633

>>62369590
that just means an implementation has to make int atleast that big, it's perfectly ok to make it bigger, as long as it's documented. If I'm not planning on using an implementation where int is smaller than 32 bit, I can very well use it like that
I agree that you should specify the size if it matters, but Imo it's false to say it's always valid to replace int with int16_t.

>> No.62369636

>>62369550
begin...end is pure cancer
but cruise control is based, its like ordering your computer around

>> No.62369660

>>62369549
>The callback is the bottleneck. It has to copy 22050 * 2 floats per second, which is 172kB/second.
Are you sure?
What in that callback is taking the most time?
What/how have you measured?
What theoretical upper limit on throughput have you estimated for your target hardware?
If you don't have those answers yet, that should be your first step before you do anything else.

>> No.62369672

>>62369631
Long int isn't guaranteed to be larger than int. In fact it often isn't.

>> No.62369676

>>62367382
Scratch, then python maybe in middleschool or highschool.

In my HS programming classes we learned visual basic lmao. No idea if they changed it by now (probably not).

>>62369314
Don't you have some threads to spam with your mentally deficient friend?

>> No.62369702

>>62369676
what?

>> No.62369782

new thred when???

>captcha: anime robinson

>> No.62369791

Why should I learn R?

>> No.62369799

New thread:

>>62369794
>>62369794
>>62369794

>> No.62369823

I have trouble understanding how fork works, I know that it creates chid processes with the same code as the father has, I just don't understan how to use wait to kill the processes. My code returns me a father's ID, then a child process ID as zero, and then three times the same father ID.

The purpose of this code is to create four child processes for the same father, so I could understand fork but I'm doing it wrong.

#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdlib.h>

using namespace std;

int main()
{
pid_t pid = fork();

int number, i=0;

do
{
if (pid == -1)
{
perror ("fork");
}

if (pid == 0)
{
cout << "son: " << pid << endl;
exit(0);
}

if (pid > 0)
{
cout << "father: " << pid << endl;
wait(&number);
}
i++;
} while (i<4);
return 0;
}

>> No.62370000

>>62369823
the child's pid is returned to the parent, and the child get's a zero, so it knows it's a child
you're printing "father :[PID of child]"

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action