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

If you can see this message, the SSL certificate expiration has been fixed.
Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 49 KB, 800x450, Microsoft_GitHub.jpg [View same] [iqdb] [saucenao] [google] [report]
66179261 No.66179261 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous Thread: >>66170997

>> No.66179284

Fuck opengl

>> No.66179309
File: 2.66 MB, 346x195, sweaty.gif [View same] [iqdb] [saucenao] [google] [report]
66179309

>>66179261
>Doing a game for fun to keep programming skills up
>Fourth game, made about 2000 dollarinos from previous ones in total, so not too scrubby for someone doing it for fun
>Decide that this game is going to be moddable
>Decide that this game is going to be script-moddable
>Mfw I start typing shit out and the whole project migrates from the original language to the script language to slowly enable modding of any and all parts of the game
>Mfw I accidentally is halfway done making a shitty and slow engine rather than a game

Fuck me.

>> No.66179327
File: 53 KB, 600x599, 1527885654423.jpg [View same] [iqdb] [saucenao] [google] [report]
66179327

>>66179309

>> No.66179430

>>66177381
>optional<unique_ptr<>>
>auto return type with concrete trailing type
but why

>>66178982
writing a simple program that uses OpenGL requires a lot of OS-specific boilerplate, which libraries like SDL, GLUT, and GLEW abstract away
you can go ahead and just use the windows version if that works for you, but the tutorials are trying to be os-agnostic

>> No.66179447
File: 19 KB, 595x577, 1472704534317.png [View same] [iqdb] [saucenao] [google] [report]
66179447

>>66179327
>working on security camera setup using raspberry pis just as a fun project
>want to have cameras be 100% wifi so that I don't need to run ethernet
>spend last 5 days debugging shitty internal wifi of raspi 3b and zero w
>finally break down and spend money on USB Wifi adapters to connect to my pis
Hope to god this is a somewhat reliable solution. The wifi dropping out whenever I use too much bandwidth is annoying the shit out of me.

>> No.66179450

That GitHub poster looks like communist propaganda

I never understood open source... why give away for free something that took you effort to develop?

Closed source ftw. It's more secure and more just

>> No.66179478

>>66179450
There's a reason open source is always playing catch up with closed source software anon: it's because no one wants to work for free.

>> No.66179500

Why is perlin noise needed?
Why can't we just do it like this:
>generate noise [0, 255] for each pixel, scale it 2^n times in either direction, add it at 50% opacity
>generate noise [0, 255] for each pixel, scale it 2^n-1 times in either direction, add it at 50% opacity
...
>generate noise [0, 255] for each pixel, scale it 2^n-1 times in either direction, add it at 100% opacity

It's fast, and it works when I try it in gimp with layer blending.

>> No.66179545

>>66179450
>why give away for free something that took you effort to develop?
because I like showing off
and it's fun

>> No.66179559

>>66179500
You are scaling the same size [0, 255] by different amounts.

>> No.66179578

>>66179309
You're not supposed to write the engine in the scripting language, just game logic.

>> No.66179607

>>66179559
>at 50% opacity

>> No.66179636

>>66179607
It's a different size you idiot.

>> No.66179681

>>66179450
Maybe what you are programming is a piece of shit.
Open source != Free as in gratis
If a software is to be copied illegally, it will not matter if it is closed source, just look at 90% of domestic users using pirated copies of Windows, and millions pirating videogames.
Meanwhile it is of public knowledge there are millions paying for Red Hat servers compared to a tiny fraction that pay for Windows Server licenses, why? If Linux is open source and even FREE (as in no cost) in this case?
My company also sells software and gives away the source code (it requires a license though), people pay to have the latest version and priority support, the software is obtainable by other means anyway and the license isn't even that hard to bypass, it is just that most common users would not know how and would rather do things well, and the ones that are tech savvy often find bugs or improvements to make in the code which are very welcome.

>> No.66179714

>>66179309
What languages did you use for the games you made money from? I’m still a few years away from my Bachelor’s and the extra money and being able to say I have monetized my programming ability would be amazing

>> No.66179719

>>66179450
>Closed source ftw. It's more secure
This is hilarious. No, it's more duct-taped and relying on security-by-obscurity

Which crypto would you trust, both claiming some equal amount of security, but one open source and one closed source?

>> No.66179764

I want to do some kind of project to learn perl 6 because it seems very fun to write but I'm utterly out of ideas right now.

Can anyone post one of those 'roll a programming project' pictures or something?

>> No.66179784

>there are people in this world that doesn't realize that fork() can fail

>> No.66179791
File: 38 KB, 500x493, 2b9f0728d3fcbd5484ba7c4cbe7b6565.jpg [View same] [iqdb] [saucenao] [google] [report]
66179791

>>66179261
trying to get travisCI to work

>> No.66179793

>>66179764
>perl
literally why

>> No.66179798
File: 31 KB, 350x350, 1526602752369.jpg [View same] [iqdb] [saucenao] [google] [report]
66179798

>>66179719
>Which crypto would you trust

terry derived his divine directives from NIST

>> No.66179807

>>66179791
>travis.yml is hard

>> No.66179846
File: 3 KB, 638x47, travis.png [View same] [iqdb] [saucenao] [google] [report]
66179846

>>66179807
>implying it just werks

>> No.66179871

>>66179846
Poorly written software, or you require something more professional that (((travis)))

>> No.66179884

>>66179719
>Which crypto would you trust
VeraCrypt, as far as I know, nobody has broken it yet, and the only reason you'd get busted with something on a VeraCrypt folder/drive is giving into scare tactics, and violations of your constitutional privacy.

>> No.66179887
File: 5 KB, 583x147, ddd.png [View same] [iqdb] [saucenao] [google] [report]
66179887

>>66179261

Clickable button in html with changes color with javascript help.

Cant really think of how to make it change color with if statements. Implemented it with a switch but its buggy. Why doesnt this work?

>> No.66179898

>>66179887
What do you want to do? Change the color when you click the button?

>> No.66179899

>>66179884
Your reading comprehension is very bad my friend, in any case it looks like VeraCrypt is open source.

>> No.66179900

GIMME SOMETHING TO DO IN C

>> No.66179905

>>66179898
Yes, for example, its grey, then i click it it changes to green, then if i click it it changes back to grey and so on.

>> No.66179908

>>66179900
make a hex editor

>> No.66179920

>>66179900
opengl/SDL2 3d maze

>> No.66179923

>>66179899
I don't get it, I just entered the conversation with this post, >>66179884.
>Which crypto would you trust, both claiming some equal amount of security, but one open source and one closed source?
>open source
VeraCrypt
>closed source
>trusting closed source "encryption"

>> No.66179932

>>66179900
Dual-boot x64 kernel with basic input handling.
Will require some asm knowledge, but I'm sure you'd figure it out.

>> No.66179956

>>66179900
sudoku solver
>>66179905
Just change it to a = for assignment then?

>> No.66179957

>>66179500
IIRC Perlin noise is designed to have fewer axis-aligned artifacts than your approach of adding a bunch of octaves of white noise together

>> No.66179966

>>66179871
I got it to work, the issue was that the installed packages were all from 2011 or something, apparently before concurrency was invented.

I mean it's their own bandwidth, and I don't really care that I have to reinstall everything, but in my naïveté I assumed a company would do what it can to save money by keeping their default configs updated.

>> No.66179978

>>66179957
That makes sense, the individual octaves have many such errors but they get masked by adding them together.
Does rotating the noise randomly after scaling help?

>> No.66179982

>>66179966
>but in my naïveté I assumed a company would do what it can to save money by keeping their default configs updated.
First off, never assume anything.
Second, this would probably be a safe assumption if you used a service you actually paid for.
But good for you, at least you got it working.

>> No.66179987

>>66179887
The browser normalizes the values you write into .style. Example:
someElement.style.backgroundColor = '#f00';
console.log(someElement.style.backgroundColor);
// prints 'rgb(255, 0, 0)'

That's in firefox, by the way - it may normalize differently in other browsers.

You should keep your own variable indicating which state the button is in, rather than relying on the current style to figure it out.

>> No.66179989

>>66179956
but i need to know what color it is to change it back and forth

>> No.66180000

>>66179978
No idea. Do you care about having visible artifacts? If white noise works for what you're doing, then use it. If it doesn't, consider switching to Perlin or something.

>> No.66180001
File: 13 KB, 200x200, syd_consider_the_following.jpg [View same] [iqdb] [saucenao] [google] [report]
66180001

If you were designing a uni course for software development, would you teach your students Python or C?

>> No.66180010

>>66179887
>Clickable button in html with changes color with javascript help.
What's the basis of your color change?
You want it to change color, based on user input?
for example, red for invalid date and green for valid date?

>> No.66180018

>>66180001
C first so they understand how computers work, then probably C++/Java/C# for development. My school did half C half Java and I it worked out pretty well.

>> No.66180026

>>66179908
Like get_bitsey_bit kinda things? already done that in ASM
>>66179920
Are those on Raspberry pi?
>>66179932
was actually thinking of making an os for rapsberry pi...
>>66179956
>sudoku solver
Hmm that could work actually

>> No.66180027

>>66179982
the learning never ends

>> No.66180029

>>66180001
C, if they can't handle basic pointer arithmetic, they are not software developer material.
Abstractions can be thought/introduced over time, but if they have no idea of, nor care, how it actually works at "ground level", they do not belong in your course.

>> No.66180035

>>66179987
I sort of made it with a switch case.
It start with a var that is false, and changes to true when its green, and to false when its grey, so to keep track of what color it is, but its buggy, cause i sometimes have to double click it and sometimes not

>> No.66180043

>>66180035
>It start with a var that is false, and changes to true when its green, and to false when its grey, so to keep track of what color it is
That's definitely the right way to do it. Not sure what your bug is but just try dumping console.log()s everywhere so you can see what's going on.

>> No.66180049

>>66180010
currently is this. Its just to switch from grey to green when its clicked
var cont = true;

function calcular(value) {
"use strict";
switch(cont){
case true:{ document.getElementById(value).style.background = '#00FF7F';
cont = false;
break;
}
case false:{
document.getElementById(value).style.background = '#d3d3d3';
cont = true;
break;
}
}

}

>> No.66180050

>>66179989
if(document.getElementById(button).style.background == "rgb(211, 211, 211) none repeat scroll 0% 0%";){

use the JS console to check
>>66180001
C. Even if python would be more useful later on, they'd get a better foundation in C. Start with simple tools (notepad, static gcc for windows, simple "build.bat"), only when they master them they get to use advanced tools such as IDE, autocomplete, syntax highlighting

>> No.66180057

>>66179989
let e = element.style.background
switch(e)
case: "#wqeqwe": e = "#qweqw"; return;
case: "#weqwew": e = "#gerere"; return;

>> No.66180058

>>66180049
https://stackoverflow.com/questions/3366828/how-to-disable-submit-button-once-it-has-been-clicked

>> No.66180060

>>66180001
Haskell

>> No.66180062
File: 24 KB, 269x234, ss-2018-06-01-17-39-18.png [View same] [iqdb] [saucenao] [google] [report]
66180062

>>66180049

>> No.66180069

>>66180049
It's been over 2 years since last I had to deal with JS, but this just seems "not right".

>> No.66180090

>>66180001

programming: c++
software engineering: java
scientific computing: python
math: maxima
machine learning: matlab
theoretical comp sci: brainfuck, prolog, and lisp

>> No.66180092

>>66180026
>was actually thinking of making an os for rapsberry pi...
Go for it dude, learn a skill nobody else will in our current CompSci/CompEng environment.

>> No.66180102

>>66180090
>theoretical comp sci
>brainfuck
Thank god you're not employed in any form of learning institution.

>> No.66180150

>>66180001
C but from a very high level to begin with. Using any library we need, focusing on build tools, git, namespaces, program flow, then data structures.
Optionally towards the end, get into a bit more of the specifically C stuff.

>> No.66180160

>>66180102
brainfuck is very similar to straight up programming a turing machine. I'd assign something like "write a little program in BF that adds two arbitrary length numbers separated by a +". for a week's homework.

why are you so against that?

>> No.66180165

>>66180057
The issue is that it's not a hex string, it's a RGB/CSS string like "rgb(211, 211, 211) none repeat scroll 0% 0%"

>> No.66180169

>>66180090
matlab is really pointless in 2018

>> No.66180170

are there any reasons to use malloc over calloc?

>> No.66180205

>>66180160
I'm not against brainfuck, however, I'm against teaching it to anyone.
It holds no practical value, you can teach pointer arithmetic without having to resort to using a literal joke language.
All you have to do is teach them C, and gradually step up the difficulty curve.
You don't have to introduce a foreign syntax that literally(in the literal sense) has no application beyond a fucking esoteric programming language.

>> No.66180218

>>66180169
>>matlab is really pointless in 2018
>t. someone who's never worked withing any engineering field the last decade

>> No.66180225

>>66180090
programming: ASM
software engineering: C/C++
scientific computing: Julia
math: Julia
machine learning: C/C++
theoretical comp sci: ASM

If you need more than that you're cancer.

>> No.66180228

>>66180170
If we're going to copy something else into it anyway
Also, calloc looks butt ugly, why not just make it work like malloc but zero fill? Why does it need the nmemb shit?
#define zalloc(n) calloc(1, n)

good riddance

>> No.66180234

>>66180218
Many better options for performance, many better performance for prototypes and modeling.
I'm sorry if your company got cucked into continually buying a matlab license because of sunk cost and myopic management

>> No.66180269

>>66180234
Give me an example of any (serious) company that chose anything else above matlab, and I will concede defeat.
Not joking, we had to do Matlab as a 1st semester course, and I fucking hated it.
But as far as I know(granted my knowledge is limited) Matlab is "the" goto tool-chain for engineering companies.

>> No.66180275

What is some fun stuff you can do with macros in C?

>> No.66180285

>>66180275
>fun
>macros
>C

>> No.66180336

>>66180275
https://ideone.com/q5Tj8k

>> No.66180347
File: 34 KB, 557x411, 1515008340117.png [View same] [iqdb] [saucenao] [google] [report]
66180347

>>66180275

>> No.66180372

>>66180165
well translate it to a hex string ya faggot
or json stringify it if you're too retarded.

>> No.66180379

>>66180269
I could list many companies because you haven't specified a domain of engineering so that really isn't fair.
But it's like saying SAS for data science. Yes, maybe, in many cases, but it's really out the door in light of other, better solutions. Matlab was historically good but it's just not keeping up with alternatives, performance-wise or high level for prototyping

>> No.66180394

>>66180225
I think you're retarded

The reason why I think you're retarded is because you're suggesting the equivalent of teaching a woodworking class by sending a bunch of kids into the woods with nothing but sandpaper and telling them to make some planks.

>> No.66180395

whats the smugest lisp weenie dialect?

>> No.66180412

>>66180379
>I could list many companies because you haven't specified a domain of engineering so that really isn't fair.
I didn't specify a domain, I left it open to you.
Again, I'm not arguing against what you're saying, I just wan't proof.

>> No.66180425

>>66180394
The best place to start is the absolute bottom anon. Its more like me giving them a log and a saw and saying "make me some planks", then afterwards i would give them the hammer, nails, and everything else (C/C++). For the more mathy and neural shit, Julia.
Can you even into assembly brainlet?

>> No.66180429

>>66180395
shen

>> No.66180440

>>66180285
How would one go about fixing C macros, anyways

>> No.66180446

>>66180412
So go look for some. My laziness doesn't say anything about it. There's probably a "companies who use..." with Mathematica, or Julia, or "C++ in engineering" or so on.

>> No.66180454

Friendly reminder that C has generics

>> No.66180459

>>66180205
it's just 8 symbols.
in c++ you just put the inputs into two vectors and zip them. that doesn't force you to think about - or give you a hands on experience of - how a pushdown automaton works.

after that, they can forget BF, but they'll have a lasting impression of how to think about this type of problem.

now, I get what you're saying, I wrote this post >>66180394, but in this instance it's about learning how the sandpaper works.

>> No.66180471
File: 60 KB, 640x625, 1523583416660.jpg [View same] [iqdb] [saucenao] [google] [report]
66180471

>>66180446
>>>I could list many companies because you haven't specified a domain of engineering so that really isn't fair.
>>Ignore the domain, just list any
>I can't just go look for some

>> No.66180472

>>66180001
How much experience are these students expected to have? If it's basically none, Python easily. If the course is for smart people, C. They'll all had learnt Python by themselves already.

>> No.66180487

>>66180425
machine learning in c++? it's mostly matrix transformations and regression, why?

>> No.66180498

>>66180471
You're completely right, that definitely secures Matlab as a relevant language in 2018.

>> No.66180499 [DELETED] 

>>66179900
build binary logic gates. create circuits

>> No.66180538

Ive been doing stuff in SQL/excel lately and it got me thinking
wouldn't all the under-the-hood functions (like group by) run in O(nm) where n is the number if rows and m the columns? or would it technically be O(n)?

basically my point is it got me interested and i think im going to write a little spreadsheet program. what would be the best data structure for the spreadsheets? i was thinking 2d arrays but it would be hard/inefficient to implement adding rows/columns

>> No.66180582

>>66180538
>wouldn't all the under-the-hood functions (like group by) run in O(nm) where n is the number if rows and m the columns?
(This applies to SQL only because I don't know anything about spreadsheet engines.) Depends on the operation, but I'd expect O(n) at worst, since the query optimizer will only look at columns that are actually relevant. But if you have good indices and a good WHERE clause, it could easily be O(log n) or even O(1).

>> No.66180607

>>66180538
>i was thinking 2d arrays but it would be hard/inefficient to implement adding rows/columns
never worked with it before, but maybe vector/list of length n*m with a specification of how many rows (or columns), as that would fully characterize the matrix right?

>> No.66180634

>>66180582
>indices
Oh ok so i just started this job so i havent worked with SQL a lot yet but ive seen indices come up a few times but idk how they work. are they like hashes?

>> No.66180651

>>66180634
They can be implemented several different ways; the default in Postgres is a BST

>> No.66180652

>>66180607
right but then if you wanted to add a new row/column you need to allocate more memory and then copy everything over. i guess you could just have the matrix array thingy always be a fixed capacity and then double it if you need more room

>> No.66180661

>>66180498
Well, I've yet to see you propose any alternative.

>> No.66180682

>>66180651
>binary search tree
oh interesting... i hadnt thought of that
would it be a bst for the whole table? what would be the comparison function?

>> No.66180722

>>66180682
Yeah, the whole table. There's an entry for each row, where the key is the column being indexed (you can put an index on any column of the table, or on combinations of columns and other shit sometimes too) and the value is the location of the row. So if you put an index on the "name" column, and then do "SELECT * FROM table WHERE name = 'anon'", it will look in the "name" index for the entry with key "anon", and return the corresponding row.

>> No.66180747

>>66180682
>what would be the comparison function?
In Postgres, it's whatever you specify. UNIQUE will create an index automatically, or you can use CREATE INDEX on any expression (column, set of columns, or operation on any number of columns). It also allows partial unique indeces where only keys or sets of keys matching a certain condition must be unique.

>> No.66180848
File: 263 KB, 656x793, 1400444593618.jpg [View same] [iqdb] [saucenao] [google] [report]
66180848

Is there any reason to use a map instead of a dynamically sized array, if you're never going to store 2 values under the same index/key?
I see people use maps for this a lot and I can't tell if they're doing it because they're lazy or if they're doing it for a special reason.

>> No.66180880
File: 12 KB, 463x355, tyeree.png [View same] [iqdb] [saucenao] [google] [report]
66180880

Im having trouble generating a random value between number in korn shell, , anyone know how? it works but the numbers end up excedding the values needed

>> No.66180882

>>66180848
If you want fast value access or membership checking. If the idea is simply to store a bunch of items then using a map would be pointless.

>> No.66180906

>>66180848

Arrays don't have keys. Unless you are using a hash function to convert a key to an index, then you are implementing a map. A map is almost always implemented in a way that uses arrays.

>> No.66180929

>>66180722
>>66180747
that pretty neat. They think of everything dont they?
thats probably a little too complicated for what i wanna do but still pretty cool

>> No.66180941

>>66180882
>fast value access
I should have specificed. The pattern I'm seeing is basically just using an incriminating int as the key and some struct as the value. The only assumption I can make is that they're using it to handle freeing the resources by deleting it from the map (using a language builtin keyword).

It seems like you could really just get away with an array that grows and shrinks, but you'd have to write it yourself.

I figured in this case the value access would be faster with a plain array+index than a map+key lookup.

>>66180906
Interesting. I haden't considered it. I will try and look at the standard implementation for the language. Compare it with some of my implementations, learn from it.

>> No.66180944
File: 888 KB, 750x1000, 1509523258130.png [View same] [iqdb] [saucenao] [google] [report]
66180944

Reminder that C and other languages are 100% obsolete and there's literally no reason for them to exist anymore.
If you're not programming with performance and efficiency in mind, you outright should not be allowed by law to touch or go near a computer.

With that, C++ is the only acceptable language to program in. All other languages have no place.

>> No.66180949

If i have a function in c that returns a char* and i have a while(1) loop does returning in the loop automatically break the loop or do i have to add break?

>> No.66180962

>>66179309
Nah... you're just making a lisp.

>> No.66180968

>>66180949
should be easy enough to load up a minimal example into gdb, or even just run it

>> No.66180982
File: 86 KB, 400x330, 1434191264038.png [View same] [iqdb] [saucenao] [google] [report]
66180982

>>66180944
One day I wish to learn C++ completely, but it feels impossible.

>> No.66180983

>>66180944
C++ is the most useless language in the world. If you want performance there is C, for everything else you can find something better like Java, C#, F#, Ocaml.
Most of the time you can also keep developing in a real high-level language write only the performance-critical parts in C.

>> No.66180986

>>66179887
You can use css if you just want it to change during the click or when the mouse hovers over it.
Otherwise, apply action listeners to each button by dumping them in to an array.

>> No.66180996

>>66180983
>Most of the time you can also keep developing in a real high-level language *AND* write only the performance-critical parts in C.
Sorry, typo.

>> No.66181007

>>66180949

Return breaks any loops.

>>66180941

I assume the id is just a simple way to create a unique id for referencing the object. The array would only work if you knew the objects got deleted in the order they were created. Other wise if objects in the middle of the array were deleted you would have a lot of wasted memory between the new and old objects, and might have to move the objects to condense them eventually. With a map the order of insertion / deletion doesn't matter.

>> No.66181031

>>66180848
a mapping is normally just a function

a "map", or a "hashmap" or such is a function that translates a key value into an index of an array

some languages or libraries have implemented it so that they are almost synonymous with arrays to the untrained eye, but they are not.

traditionally, a map would look something like this f(x) = x-1.

this, applied to a classical array that starts with 0, like arr[0]... etc, would translate that to an array that starts with 1. so accessing arr(1), if it was mapped with f(x), would return the first element. arr(0) would yield an array out of bounds exception or something.

however, most implementation of maps, such as hashmaps are more sophisticated than that. in fact, hashmaps are generally loose implementations of the hashtable datastructure.

they take your key and hash it to a value that falls within the bounds of the length of the array. for instance, if you have an array of size 2, you could insert an object into "position" (which is now actually a key) 100, via arr.set(100, "something"), but the size of the array is now only 3, as long as nothing else with the key 100 existed before. in a hashmap, you can generally also use anything else as a key, including strings, and in some implementations even objects or types.

behind the scenes the function above might calculate the "hash", which is the map in this case, simply by taking the key modulo the length of the array.

now you might see the disadvantage of maps: when you extend their size, the whole array needs to be reordered.

so if you know how big your array is gonna be beforehand, and you need to store and retrieve things based on an index, but instead a string for example, a map easily translates whatever as a key to an index for you. this is very good for "sparse" arrays too, if you know how many actual elements are in it.

if, however, you need an array where you don't know how many elements are gonna be inside, you will not want to use this.

>> No.66181071
File: 357 KB, 1920x1080, 1498444243631.jpg [View same] [iqdb] [saucenao] [google] [report]
66181071

>>66180983
C doesn't need to exist anymore now that C++ exists and has better and more efficient abstractions.
And there's no reason to use any other poolang because C++ supports all the abstractions you need with max efficiency.

And of course, you also need to not be a total brainlet, but brainlets shouldn't be allowed near computers anyway.

>> No.66181074

>>66181031

Maps are also frequently implemented with balanced binary trees, in c++ for example, only unordered_map is a hash table. So a map in c++ only uses as much memory as there are objects, never has to be resized, just gives you log n lookup instead of constant.

>> No.66181075
File: 3.39 MB, 480x480, 1521625458641.gif [View same] [iqdb] [saucenao] [google] [report]
66181075

>get a codemonkey job they said
>it will be easy to get hired they said

>> No.66181086

>>66180983
this
dev in high level, profile, drop to C where needed

>> No.66181097

>>66181075
dumb kermitthefrogposter

>> No.66181101

>>66181007
Thank you for the explanation. I had implemented something that trims from the right side of the array on release(), for all null elements and wondered if it would be faster. The problem with that though, is that it leaves gaps on the left side that are just waiting to be reaped.

Ultimately, this is a micro-optimization consideration, but I was curious about it. Since I have the option to use both, I'd rather get in the habit of using the practical one for these situations.


>>66181031
Good breakdown.

>>66181074
>implemented with balanced binary trees
This was interesting to think about. I don't often interact with the mathmatical, and datastructures side of programs, it's typically just some logical set of instructions, simple structures, or something handled by the runtime, etc.

They didn't teach us much of it in school for some reason.

>> No.66181106

>>66181086
>>66180983

cuda is c++

>> No.66181141

>>66181074

true, didn't consider that

I generally understand map to be the function, not a type, that's probably why I didn't think of that.

>>66181101
where/what for did you go to school?

>> No.66181153

>>66180983
Okay, from an outsider perspective, I'm wondering if C++ has changed in a way to incorporate features from "higher level" languages. That is to say, I would typically agree with you, but then again I haven't learned any of the new C++ standards (because I typically am using plain C, so I have no reason to keep up with C++).

That seems like it could be possible and good, in all ways except existing documentation. (people posting deprecated practices).

>> No.66181174
File: 91 KB, 336x523, 1474884215155.png [View same] [iqdb] [saucenao] [google] [report]
66181174

>>66181141
>where/what for did you go to school?
I'd rather not say.

>> No.66181190

>>66181153

The latest c++ sure does have a lot of features newer languages have, it just doesn't have the integration with things like json / http that newer languages have. You can write a golang http server in about 15 seconds, while it would probably take you 10x that just the research and pick what http library you can use in c++.

>> No.66181193

>>66181174
just what degree?

>> No.66181204

>>66181190
That's true.
I wonder if they will solve this problem. If they did, I bet people would be mad at the headlines
>C++ implements std::http
jej

>> No.66181211

>>66181204
does c++ have decent event loops yet? just wondering

>> No.66181225

>>66181211
event loops are the one thing that c++ has always been best at

>> No.66181244

>>66181225
really? i must have completely missed that, and a quick google doesn't reveal anything that isn't horrendously verbose

can you give me a quick link to something?

>> No.66181263

>>66181193
Gender studies.

>> No.66181269

>>66181204
>std::http
Fuck, then all my effort on an HTTP server would be wasted

>>66181211
>>66181225
>>66181244
What do you mean by "event loop" specifically

>> No.66181276

>>66181263
So you learnt Rust?

>> No.66181281

>>66181269
they're referring to threaded message relay systems

>> No.66181284
File: 1.07 MB, 3840x2160, challenges.png [View same] [iqdb] [saucenao] [google] [report]
66181284

>>66179764
other anon also posted https://better-dpt-roll.github.io/ yesterday

>> No.66181290
File: 52 KB, 644x500, Mozilla - what.png [View same] [iqdb] [saucenao] [google] [report]
66181290

>>66181276
holy kek

>> No.66181304

>>66181290
>Women are 50% less likely to be able to use the internet
I wonder why

>> No.66181306

>>66181290
>mozillafags will defend this

>> No.66181312

>>66179450
it's always been like that until the new generation of faggots like you started to write crappy shit for iphones. look here, my cool fart app, pay me $2 or endure the adds. *tries to fart, crashes* . it is a parallel culture you will never understand. tons of people write quality code for free because they pride themselves in that.

>> No.66181313

>>66181306
I literally can't.

>> No.66181323

>>66181290
I'd love to know where that number came from.

>> No.66181339

>>66181281
So just like a queue + mutex or something?

>> No.66181340

>>66181323
Once a month they poll their bodies for a few days.

>> No.66181344

>>66181339
you need one or two more working parts to avoid certain situations that can cause thread lockup but yeah basically

>> No.66181359

>>66181344
I mean I've written that kind of stuff before so I know, just sounded like anon was looking for some kind of first-class language feature

>> No.66181369

>>66181359
as someone who learned to program from c++ i have never been more upset than i was when i tried to use javascript's built in """asynchronous""" feature

>> No.66181380
File: 763 KB, 943x1200, 1522076833201.jpg [View same] [iqdb] [saucenao] [google] [report]
66181380

>>66181339
>mutex
Yeah maybe if you hate efficiency.
Design lockless data structures and use atomic instructions.

>> No.66181389

>>66181380
Bro, lockless event queues break the moment you stuff too many messages into them.

>> No.66181415

>>66181369
you didn't understand promises?

>> No.66181422

>>66181380
>Design lockless data structures and use atomic instructions.

not sure if you're trying to be ironic here but that's is a contradiction if I've ever seen one.

>> No.66181427

>>66181369
I thought I had read something recently on that
http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/

>>66181380
You don't magically get a performance hit from using locking structures, the problem is waiting on locks to free. Locks are still required for thread-safety of the event/task queue, but as long as you design your system so deadlocks rarely occur then you're fine. What I've built have been task-execution systems, so things need to wait on empty queues anyway.

>> No.66181433

>>66181427
>deadlocks
I meant waits, sorry

>> No.66181658

>>66181269
>>66181204
I mean, there is boost.beast for http and websockets...

>> No.66181745

>>66181658
I'll say this. Golang has spoiled me in terms of cross platform tooling.
I'd be more willing to use C++ and its libraries if there was standard tools (not just de-facto ones).
i.e. a build system, dependency managment, documentation generation tools, etc.

Setting up GNU make, learning a system's package format, setting up Doxygen, sub-modules, etc. is a pain in the ass just to assure some compatibility, where a ton of other languages get this for free.
1 standard for your projects and everyone's projects, less domain specific things to know.
>do they use make, cmake, some self-made bullshit
>did they bundle deps
the meta around C++ seems like the worst part to be honest not even the language itself.

That's not to say good tools don't exist, it's just that you're left on your own to decide on whichever one you want, and people use different things, and it makes dealing with third party things a nightmare.

>> No.66181758
File: 1.19 MB, 1000x1000, tumblr_p01eouD8OR1vzpl8vo1_1280.png [View same] [iqdb] [saucenao] [google] [report]
66181758

>>66179764
Ah, a man of great taste. May I ask what attracted you to Perl 6? Did you happen to see the brochure I sometimes post?

>> No.66181759

>>66181745
you forgot autotools, aka pure evil

>> No.66181765

>>66181415
there's nothing difficult about promises anon

>> No.66181766

>>66181759
I forgot it because it never fucking works. Oh I'm angry now.

>> No.66181778

>>66181765
so what was the issue?

>> No.66181783

>>66181778
>i have never been more upset

>> No.66181787

>>66181783
but why, it works great? it even optimizes tail calls on your recursions?

>> No.66181793

>>66181745
I totally agree.
However, lately I've been using conan, and it just works.

>> No.66181814

>>66180090
>machine learning: matlab
>theoretical comp sci: brainfuck,
Wew

>> No.66181823

>>66180001
c++ and python at the same time

>> No.66181901

I'm in android studio and basically need to assign a listener to an EditText so that I can check for pressing the enter key, keep the keyboard up when pressed, and do a bunch of other stuff when enter key is pressed. The problem is that everything inside the listener needs to be declared as final but I need to change things. I was a little confused about this so I just found some code that worked well enough until now.
syllableEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if((keyEvent != null && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (i == EditorInfo.IME_ACTION_DONE)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(syllableEditText, InputMethodManager.SHOW_IMPLICIT);
// do stuff here
return true;
}
return false;
}
});

How should I be going about this?

>> No.66182073

>>66181901
use closures

>> No.66182130

Anybody have an experience with phonegap?

When I view my pages in my browser they look fine, but when I run it through the phonegap application, none of my css styles are applied

>> No.66182183

>>66181814
>>theoretical comp sci: brainfuck,
>Wew
The simpler a system is, the easier it is to prove theorems in it. And Brainfuck is very simple. Same with simply-typed Lambda calculus.

>> No.66182253

>>66182183
You can prove theorems just using standard ML now, doesn't get simpler than that. http://www.redprl.org/en/latest/

>> No.66182289

>>66180001
haskell

the students would all have math backgrounds, so it would be quite easy for them not to wrestle with obscure concepts like memory management or the FIOC

>> No.66182290

>>66179447
Should have immediately purchased cheap Atheros wifi adaptors of which free drivers exists a plenty for. Rasberry Pi is a pile of broadcomm tightly sealed patents protecting mystery blobs, impossible to rely on them for anything.

>> No.66182296

>>66179261
I've been in CS for 3 quarters now, I've had close to a years experience with Java, I know basic algorithm analysis, understand data structures & ADTs, and have a good understanding of sort and find algorithms.

My problem is that I've been struggling to find way to practice my knowledge outside of class in order to help solidify it. Does anyone have any or know of any projects that I could work on to practice my programming?

>> No.66182309

>>66179447
also you should have just used old android phones for this, forget pi junk. Go on CL and buy up a dozen shitty old nexus phones or any phone that used to work with LineageOS. You can just edit the Android build to start your security cam software upon boot. A bonus is, if the power is cut to a building, your cameras still have juice to record for a few more hours and you're just using off the shelf phone equipment and not some generator/lithium backup/ect.

>> No.66182314

>>66182296
Yes they are called open source projects, you find them on github, you click on 'issues', you fix bugs then move to writing features.

>> No.66182335

>>66182289
>the students would all have math backgrounds
topkek

>> No.66182342

>>66182335
don't tell me you didn't do high school maths

>> No.66182456

Doing K&R. I had to rewrite my detabbing program because I at first wrote a function getline_detabbed that detabs a string as it reads each character in.

This time I separated detab into its own function:

#define TABWIDTH 8
#define MAXLINE 65536


void copy(char dst[], char src[])
{
int i = 0;
while ((dst[i] = src[i]) != '\0')
++i;
}

int detab(char line[], int len)
{
int c = '\0';
int i = 0;
int newlen = 0;
int spaces = 0;
// The length does not include the '\0'
char oldline[len + 1];

// Create a copy of the line as a reference
copy(oldline, line);

c = oldline[i];
while (i <= len && newlen < (MAXLINE - 1)) {
if (c == '\t') {
c = ' ';
// delta = n - (i mod n) - 1
// The extra '-1' is for the space of the tab character itself
spaces += TABWIDTH - (newlen % TABWIDTH) - 1;
}
if (spaces > 0) {
line[newlen] = ' ';
--spaces;
} else {
line[newlen] = c;
++i;
c = oldline[i];
}
++newlen;
}

return newlen;
}

>> No.66182483

>>66180001
Intro to Programming where you get a 30min crash course in a simple language like Standard ML or Lisp on how to use al iibrary and make an API, and you build something the rest of the semester. Intro to Discrete Math where you turn sets into types and mainpulate them. Intro to Imperative Programming where you write loops in Standard ML or Lisp, then Intro to Functional Programming where you prove tail recursive functions. Parallel Algorithms, which is already done http://www.parallel-algorithms-book.com/

The rest of the courses are Computational Complexity Theory courses. This will take about a year. Congrats you can develop software everything else you'll just learn from industry periodicals or programming manuals, like reading the syscall manpages in order to get your api to send something.

>> No.66182486

>>66180001
Why not both?

>> No.66182487

Now I've gotta split out entab into its own function:

int getline_entabbed(char line[], int max)
{
int c = '\0';
int len = 0;
int blanks = 0;
int pos = 0;

// If it reaches max, then there will be no
// \n character; only a \0 at the end.
c = getchar();
while (len < (max - 1)) {
// First, count the sequential blanks
if (c == ' ') {
++blanks;
c = getchar();
} else if (c == '\t') {
// If a tab is encountered, then we just
// count to the next tabstop from the current position
// plus any offset given by accumulated blanks.
// This means that a single tab will be inserted overall.
blanks += tabstop_delta(pos + blanks);
c = getchar();
// If we've reached a non-blank character
} else {
// ...and the number of blanks accumulated
// is enough to insert a tab, then insert a tab
if (blanks >= tabstop_delta(pos)) {
line[len] = '\t';
blanks -= tabstop_delta(pos);
pos += tabstop_delta(pos);
// otherwise, just pad out the rest with spaces
} else if (blanks > 0) {
line[len] = ' ';
--blanks;
++pos;
// If we've reached the end of the line, break out of the loop
} else if (c == '\n' || c == EOF) {
break;
// if there are no blanks, then insert the non-blank character
} else {
line[len] = c;
c = getchar();
++pos;
}
++len;
}
}
if (c == '\n') {
line[len] = c;
++len;
}
if (len > 0) {
line[len] = '\0';
}

return len;
}

>> No.66182511

>>66182483
>Intro to Imperative Programming where you write loops in Standard ML or Lisp
>Imperative Programming in ML or Lisp
But why? Do it in C, Golang, Rust or Python.

>> No.66182537 [DELETED] 

>>66182511
Because you can't cheat in SM or Lisp, you'd have to write it yourself as there exists only hacky libraries around and no massive industry ecosystem where you can just string libraries together. Compiling is also straight forward, and awesome shit like whole program optimization can be done.

>> No.66182564

>>66182537
I'm not sure what SM or ML are, but Lisp isn't designed for imperative programming. When you have a hammer, everything looks like a nail. The students need language diversity outside of functional languages, just like other students also need functional programming experience

>> No.66182586

>>66182511
Because you can't cheat in SML or Lisp, you'd have to write it yourself as there exists only hacky libraries around and no massive industry ecosystem where you can just string libraries together. Compiling is also straight forward, so is writing DSLs, and awesome shit like whole program optimization can be done in addition to proving properites about whatever you're writing. You could pick up Programming Rust after this and figure it out yourself, which is the point of school, to teach you a base so you can teach yourself after.

>> No.66182588

>>66179261


Homework for collage, deciced to use create-react-app. I don't mind react but FUCK FUCK FUCK FUCK FUCK redux.

>> No.66182589

>superior c-like syntax
>comfy dynamic typing/casting
>support for multiple paradigms: OO, imperative, functional
>every idiot uses it so easy to quickly google answers and learn

why did you guys lie to me about how horrible javascript is?

>> No.66182600

>>66182564
You can write imperative style and reference memory locations in any language, including Lisp

>> No.66182605

why can't I post!?

>> No.66182610

>>66182600
Just because you can, doesn't mean you should.

>> No.66182640

>>66182342
comparing high school maths to the math involved in Haskell is like comparing checkers to chess.

>> No.66182642

>>66180001
First Lisp, then Haskell, then C.

>> No.66182646

>>66182589
are you saying Javascript is good or bad? I can't tell.

Javascript is not *that* bad. It's just annoying IMO.

There are too many idiot hipsters writing new libraries in it.

Again: hammer, nail.

I also wish PHP would just hurry up and die. We've got Python, Ruby and Golang now. Why do we still use PHP?

>> No.66182683

Reminder to learn vert.x

>> No.66182690

>>66182646

look at this faggot gopher. PHP at least has generics fag.

>> No.66182699

>>66182690
and what's your amazing rebuttal to Python or Ruby as a PHP replacement? You can't just pick one part of my post and attack that, idiot.

>> No.66182702

>>66182564
>Lisp isn't designed for imperative programming
Why? The most popular dialect, Common Lisp, has a macro for mutating almost every object and sophisticated looping constructs. You can program in pretty much any paradigm in Common Lisp because of how diverse it is. You're probably talking about Scheme, where you would have to write setf and loops yourself.

>> No.66182724

>>66182702
You could make the same argument about using another language for functional programming.

Why not just use Python, or C++, or Java, or Rust instead of a Lisp?

Lisp is a great set of languages, and I plan on adding Scheme to my list of language skills, but

a) use the best tool for the job, and
b) teach students other languages *as well* so they at least have a better standing for the industry, and for their own mental flexibility.

>> No.66182747

If you don't teach your students Java, C# or C++ you are setting them for failure in the real world, where wanking about pureness or sophistication of a language doesnt matter

>> No.66182753

>>66182747
As much as it annoys me, this.

Also, students should at least also learn a lisp, and C and ASM.

>> No.66182762

>>66182589
JavaScript is a good language as long as you refrain from using its bad features like type coercion. People who say that JavaScript is shit are either complaining about the bad features as if they were forced to use them with no alternatives (which is not the case), or simply disdain dynamic typing.

>> No.66182763

>>66182699
no rebuttal because i haven't used them. but i would imagnie them being in a less akward spot since at least those languages don't pretend to be have a static type system.

>> No.66182772

I fucking hate gcc.

>> No.66182788

>>66182772
https://msdn.microsoft.com/en-us/library/bb384838.aspx

Here, use cl instead then.

>> No.66182799

>>66182747
>teach your students X that will be outdated in Y
You're doing it wrong. Trivial stupid details such as a programming language should be taught by themselves. You can't master a PL by just wanking and talking over it, it requires practice and a fair amount of experimenting and reading that would be useless to cover in class.
You should teach your students the tools to easily learn a programming language, concepts and other shit agnostic of particular syntax.

>> No.66182814

>>66182788
fuck off shill

>> No.66182822

can anybody explain a call with a current continuation aka call/cc?

>> No.66182824

>>66180090
Seems like a waste of time to learn more than 2 or 3 languages for specific tasks where you already have existing libraries for those tasks on the more popular languages.

Switching from language to language is already tricky enough, let alone so many

>> No.66182827

>>66182747
Teaching Java or sepples is the easiest way to make programming unappealing to any sane student.

>> No.66182828

>>66182788
>"""""C compiler""""" that really is a C++ compiler with C++ syntax disabled
The absolute state of Microshit.

>> No.66182833

>>66182724
Because those other languages are not the best tool for the job, which is teaching a semester class. Industry programming can't be taught. You use highly abstract shit like actor models and objects, internal libraries, internal test suites and proprietary analysis programs. Everywhere has it's own style and silly development strategy. They probably won't be using Python or C++ or whatever it is you taught them in anyway.

>> No.66182836

>>66182799

In a perfect world, that would happen. In the real world, students will stick to what they are familiar with. If you are teaching them garbage like python, thats all they will use for at least 3 years.
Also big languages don't really die anymore, too much momentum. C, Java and C++ will be around forever

>> No.66182841

>>66182824
>Switching from language to language is already tricky enough, let alone so many
if you're a brainlet or a greedy jew, maybe.

>> No.66182843
File: 207 KB, 1415x826, Screenshot from 2018-06-02 20:10:17.png [View same] [iqdb] [saucenao] [google] [report]
66182843

>>66182814
>>66182828
I was joking desu. It's kinda hard to convey that across the internet, but meh

I'm actually using gcc rn to compile with.

>> No.66182844

>>66182827
yay more job security.

>> No.66182847

>>66182827
I learned programming with Java and found it comfy, because it let me do everything I wanted quite easily. GUI applications, webservers, etc. Things were you get an immediate feeling of accomplishment

>> No.66182859

>>66182836
That's what they said about COBOL and perl too. These are disappearing though.

>> No.66182875

>>66182836
Okay after reading >>66182847, I get what you mean. Maybe I'm too naïve for this shitty industry.

>> No.66182887

>>66182799
>>teach your students X that will be outdated in Y
The languages he listed have been in extensive use by the industry since at least 12+ years in case of C# and much longer in case C++ and Java. They're not going anywhere in the next 3 years (the time it takes to complete basic computer science education in a university in my country), regardless of what FP-fags think. Also, much of the industry still uses the oldest viable standards/versions of those languages.

>> No.66182901

Is it possible for GCC's C PreProcessor to expand in step?
I think somewhere in my program there is a circular #include without headerguard.
Is there any way to fix this other than manually inspecting tenths header file?

>> No.66182913

>>66182887
retard

>> No.66182916

>>66182859
The amount of programmers now is completely different to the days of COBOL. COBOL was before the dotcom boom and explosion of the internet.

Even so, you can still make bank with COBOL because a lot of banks are looking for people who can maintain / migrate their legacy code bases.

COBOL can't really be compared to Java or C#/C++, it never had a wide adoption as them, simply because software engineering wasn't as popular/needed as a career yet

>> No.66182917
File: 38 KB, 550x754, zkaSamfOXvQ.jpg [View same] [iqdb] [saucenao] [google] [report]
66182917

How do I make a comparator/function/whatever to work with objects of different template arguments?
A<24> > A<32> ? std::cout << "OK" : std::cout << "NO";

>> No.66182938

>>66182916
>Even so, you can still make bank with COBOL
>literally

Dohoho.

>> No.66182939

>>66182913
>when you have no arguments and resort to name calling

>> No.66182948

Is this a good way of defining a leap-year function?

I feel like either I made a small mistake or there's a better way of writing it:

func isLeapYear(_ year: Int) -> Bool {
let divFour = number(year, isDivisibleBy: 4);
let divOneHund = number(year, isDivisibleBy: 100);
let divFourHund = number(year, isDivisibleBy: 400);

return divFour &&
((!divOneHund) ||
(divOneHund && divFourHund));
}

>> No.66182949

>>66182901
>I think somewhere in my program there is a circular #include without headerguard.
Wouldn't it be easier to just check all of your header files and confirm each one of them has a unique guard?

>> No.66183025

Whats the best doc/book for learning python from scratch?

>> No.66183038

>>66182901
If you are using header guard with the filename representing the guard name and not #pragma once
you can do this:
cat /header/*.hpp | grep -i '#define'

and manually matching which file doesn't have represented header guard. Be careful since it also print macros
it's still a terrible method, but it's easier than manually open the header file one by one.

>> No.66183054

>>66183025
Automate the Boring Stuff with Python

It doesn't assume too much prior programming knowledge, and it's fairly approachable in how it teaches the basic concepts/philosophy of python.

>> No.66183064

>>66183054
Anyone got a /t/

>> No.66183105

>>66183064
>>libgen.io is your friend

But just this once, I will give you the sauce
http://libgen.io/book/index.php?md5=054255117B2E86251415292EF48320FD

>> No.66183108

>>66183105
Thanks mang Ill use it wisely

>> No.66183159

I'm looking for a fast/robust way to xfer files over open sockets. Am I overthinking it?
int request_file(int sock, char* file_path)
{
size_t path_len = strlen(file_path)+1;
if( write(sock, file_path, path_len) != path_len)
error(-1, "request_file::write()");
}

int send_file(int to_fd, char* file_path)
{
int from_fd = open(file_path, O_RDONLY);
struct stat st_buf;
memset(&st_buf, 0, sizeof(struct stat));

if(from_fd < 0) error(-1, "send_file::open()");
fstat(from_fd, &st_buf);

//send file size
if( write(sock, &st_buf.st_size, sizeof(st_buf.st_size))
!= sizeof(st_buf.st_size))
error(-1, "send_file::write()");

//send file
if( copy_file(to_fd, from_fd) != st_buf.st_size)
error(-1, "send_file::copy_file() unsuccessful");

return close(from_fd);
}

off_t copy_file(int dest, int src)
{
char buf[WRITEMAX];
off_t read_bytes, accum = 0;
while( (read_bytes = recv(src, buf, MSGMAX)) > 0 )
{
if( write(dest, buf, read_bytes) < 0) error(-1, "copy_file::write()");
accum += read_bytes;
}
return accum;
}

int receive_file(int from_fd, char* filename)
{
char buf[MSGMAX];
off_t sz_total;
off_t sz_recv = 0;
int read_bytes;
int to_fd;

//receive file size
if( read( from_fd, &sz_total, sizeof(off_t)) != sizeof(off_t))
error(-1, "receive_file::read()_stat");

if( sz_total <= 0 ) return -1;
if( to_fd = open(filename, CREAT_OPT, CREAT_PERM) < 0)
error(-1, "receive_file::open()");

while(sz_recv < sz_total)
{
read_bytes = recv(from_fd, buf, off_t_floor(sz_total-sz_recv, MSGMAX), 0);
if(read_bytes < 0) error(-1, "receive_file::read()_file");
sz_recv += read_bytes;
if( write(fd, buf, read_bytes) != read_bytes)
error(-1, "receive_file::write()");
}
return close(fd);
}

off_t off_t_floor(off_t a, off_t b)
{
return ( a < b ? a : b );
}

>> No.66183162
File: 148 KB, 1200x900, mexican_andys_turn.jpg [View same] [iqdb] [saucenao] [google] [report]
66183162

I'm 27 and I still have 2 years before receiving my CS degree. Feels bad.

Just wanted to get this out there.

>> No.66183171

>>66182917
If you only want to use the result at runtime, you could try something like this:
template<size_t N, size_t M>
bool operator<(A<N>, A<M>)
{
return N < M;
}

then compare them like this:
std::cout << (A<10>() < A<20>()) << std::endl;
If you want to use the result at compile time, you can't use < operator and you have to do something like this instead (pretty complicated and verbose, but it's the only way to do it afaik):
template<class T, class U>
struct LessThan;

template<int N, int M>
struct LessThan<A<N>, A<M> >
{
enum { result = N < M };
// OR, if you can use C++11:
// static constexpr bool result = N < M;
};

and use it like this:
std::cout << LessThan<A<10>, A<20> >::result << std::endl;
This make use of template specialization. Realistically, you'd want to have a Cmp class that would have the difference of template arguments of 2 As as the result, then define every other "operator" in terms of it.

>> No.66183173

>>66182939
>when you can't be assed to read and just spout the first shit that came to your mind but still expect a serious answer

>> No.66183191

>>66183159
>C
>error checking literally every function call

>>66183171
>C++
>that atrocity

C and C++ everyone

>> No.66183196

>>66183105
libgen.io is actually quite confusing.
Most of the times there is multiple version on the same book with unlisted number of pages, and different file-size.
Also there is no "downloaded X times" so it's not so clear which one is the better one

>> No.66183200

Does anyone use python to connect to a mysql server?

My mysql error log is spammed with the following:

Aborted connection <NUMBER> to db: '***' user: '***' host: 'localhost' (Got an error reading communication packets)

Each time my scripts runs to query/insert the aborted connection number goes up. However there is no data loss...

I am using PyMySQL and open the connection "with open", so it should terminate properly by default.

Since there is no data loss, should I just ignore it and carry on as normal?

>> No.66183220
File: 65 KB, 480x411, 1495349169332.jpg [View same] [iqdb] [saucenao] [google] [report]
66183220

>>66183171
OK, gotcha. It's not that complicated. What if I want implement one algorithms if N > M, and another one if N < M? I've heard std::enable_if_t exists, yet I have never seen it.

>> No.66183225

>>66183171
cout is offensive to look at. Why don't people just use printf?

>> No.66183243

>>66183225
Because you can't define custom format verbs for printf in a standard way (I know glibc allows it) while you can overload << operator to work for any type.

>> No.66183246

>>66183225
does not work in for custom types, generic code, etc...

>> No.66183257

Anyone here have any experience with stream processing?
Apache Kafka, Mesos etc.

>> No.66183299

>>66183191
and it's still orders of magnitude faster than your shit language

>> No.66183310

>>66183220
I wouldn't bother with std::enable_if_t and use std::conditional_t instead (http://en.cppreference.com/w/cpp/types/conditional). It basically allows you to choose one type if the first argument if true, and other if it's false. Write two structs, each with one static method for its version of the algorithm, then call it like this:
std::conditional_t<LessThan<X, Y>::result, Struct1, Struct2>::algorithm(/*args...*/);

>> No.66183321

I'm a sepples fag. C++ is my language of choice.
But since everyone and theri grandmother seem to be hating on C++ I thought maybe I should try a better language.

So what are *good* languages that I might like?

>> No.66183326

>>66183321
C++

>> No.66183333

>>66183321
Go

>> No.66183340

>>66183321
>*good*
There is no such thing as good language. There is only bad language and Haskell

>> No.66183341

>>66183321
Haskell

>> No.66183344

>>66183321
C
it'll surprise you how much more elegant it is in its simplicity

>> No.66183345

Man, fuck ___C++___.

>> No.66183351
File: 106 KB, 750x924, 1527779824557.jpg [View same] [iqdb] [saucenao] [google] [report]
66183351

>>66183333
Go Forth

>> No.66183352

>>66183345
spoilerfag

>> No.66183362

>>66183321
What do you mean by better

>> No.66183367

>>66179261
>What are you working on, /g/?
>>66183363

>> No.66183368

>>66183321
Haskell, just pray that your brain is not completely damaged by all that sepples.

>> No.66183378

>>66183368
Is it rocket science?

>> No.66183381

Give me a quick rundown on the Haskell meme

>> No.66183385

>>66179500
Read this: http://libnoise.sourceforge.net/noisegen/index.html

>> No.66183388
File: 140 KB, 645x773, I+couldnt+find+a+asian+feel+meme+so+i+made+_6c0e2900f8a9d759b54b22380c2f41da.png [View same] [iqdb] [saucenao] [google] [report]
66183388

It's a dice game. My first python project :)
Feedback encouraged. Just remove [dot]


https://www[dot]dropbox.com/s/01732h2srtkyekv/dice_game.py?dl=0

>> No.66183390

>>66183344
I've been working in C since January. Honestly, I miss some of the basic object oriented features. Encapsulation and constructors/destructors. And also function overloading and to a lesser extent operator overloading.

>> No.66183413

>>66183159
You can use sendfile when sending data between a file and a socket.
The thing with sending struct stats on the wire is it's not guaranteed to be portable at all afaik. (It would be on Plan9 but we're not on Plan9)

>> No.66183416

>>66183378
No, it's just a sane language. Cabal sucks tho.

>> No.66183418
File: 12 KB, 402x344, refused.jpg [View same] [iqdb] [saucenao] [google] [report]
66183418

>>66183388

>> No.66183421

Thinking on using different distro for my new machine (currently debian).
The only requirement is build in gcc's build essential, and able to run emacs
What is your guys opinion on CloverOS?
Is it good?

>> No.66183425

>>66183368
>just pray that your brain is not completely damaged by all that sepples.
I... think it might be too late for me.

>> No.66183447

>>66183388
>https://www.youtube.com/watch?v=41N4oi4Qmw8

Mister can you tell me where my love has gone
He's a Japanese boy
I woke up one morning and my love was gone
Oh, my Japanese boy
Ooh, I miss my Japanese boy

>> No.66183449

>>66183418
You have to replace the [dot] with "."

>> No.66183458

Done friendos.

I split >>66182487
into its own entab function


int entab(char line[], int len)
{
int c = '\0';
int i = 0;
int blanks = 0;
int pos = 0;
int newlen = 0;
char oldline[len + 1];

copy(oldline, line);

c = oldline[i];
while (i <= len && newlen < (MAXLINE - 1)) {
if (c == ' ') {
++blanks;
c = oldline[++i];
} else if (c == '\t') {
blanks += tabstop_delta(pos + blanks);
c = oldline[++i];
} else {
if (blanks >= tabstop_delta(pos)) {
line[newlen] = '\t';
blanks -= tabstop_delta(pos);
pos += tabstop_delta(pos);
} else if (blanks > 0) {
line[newlen] = ' ';
--blanks;
++pos;
} else {
line[newlen] = oldline[i++];
++pos;
}
++newlen;
}
}

return len;
}

>> No.66183474

>>66183447
No sing, too roud! You pray dice game for pleasure! More fun!

>> No.66183510

>>66183105
10% through and its looking good, grazi

>> No.66183574
File: 144 KB, 841x1200, DerFFJKUYAAWMRI.jpg [View same] [iqdb] [saucenao] [google] [report]
66183574

>>66183510
Don't mention it!!

Good luck with any pythonic endeavors!

>> No.66183578

>>66183105
>libgen.io
>nicht https
aber warum?

>> No.66183611

>>66183578
Warum nicht?

>> No.66183633

>>66183611
das ist aber nicht sicher, Brudi, besonders bei einer Torrentseite

>> No.66183636

>>66182843
Don't narrate your code anon

>> No.66183642
File: 141 KB, 1013x760, 1504301992734.jpg [View same] [iqdb] [saucenao] [google] [report]
66183642

So, after 10 years or so of programming, the one thing that still trips me up every time is text, especially parsing user text input correctly. Like, if I'm programming in opengl (which I nearly always am), am I expected to handle all those weird little quirks chink users have to deal with when they're trying to write text? How do most people do it, do they just say "fuck chinks", do they spend 1000+ hours implementing shit nobody but the chinks will use, or is there a super easy method to handle these things I'm missing? How acceptable is it to say "write in english, you subhuman" and be done with it?

Then everything seems so inconsistent coming from the keyboard, and (at least in SDL), it seems so cumbersome to get a simple unicode character from all the shit that's going on. On top of that, who even creates all those glyphs chinks need? It makes me think most fonts don't support chinks at all, and if that's the case, then what the fuck? And if the point is editing large texts, what's the correct way to separate editing buffers? By line? By editing break points? What about all those context boxes chinks need to write their shit, am i really supposed to handle all that?

Then there's rendering: am I supposed to render glyphs individually and sacrifice those fancy connections between words, or is the norm to render entire sentences or words in one generated texture? Do I render with tris or with quads? How do I not lose my shit when I realize 80% of the time I've spent on my project was dedicated to rendering text instead of the thing I'm actually trying to do?

Then there's text editing:

Is there like a document or book or whatever the fuck that might help me finally make peace with the topic of text?

I'm serious when I say that I've never seen a branch of mathematics that was half as hard, annoying, or confusing than the topic of handling text coming from a keyboard. Please guys, I'm about to go shoot up a school over this, or something.

>> No.66183658

>>66183636
I would usually agree with you, but

a) it's a learning exercise in C for me, since I'm doing K&R exercises
b) it's helping me understand my algorithm as I write it.

I first wrote that code a few weeks ago now, and so coming back to read the comments tonight was super helpful.

>> No.66183661

>>66183642
>How acceptable is it to say "write in english, you subhuman" and be done with it?
very
>or is there a super easy method to handle these things I'm missing?
https://en.wikipedia.org/wiki/Complex_text_layout

>> No.66183667

>>66183642
Is it a personal project or for a job?

If it's for a job, I just go back to the project manager or BA, explain the situation, and let them make a decision (with some recommendation of course).

If it's for personal project... Make a decision and stick with the consequences.

>> No.66183703

I always used windows forms do I switch to wpf if I want the gui to look better?

>> No.66183766
File: 840 KB, 600x603, 1525646113585.png [View same] [iqdb] [saucenao] [google] [report]
66183766

>>66183667
It's for personal projects, yeah, but more than that, it's a beef I've had for a long time now. The worst part is that I see NOBODY else even mentioning this struggle, leading me to believe that I'm a very special little boi like mother used to tell me, that this is something that's piss easy and I'm just not seeing it, or that there are tons of easy to find documents on the subject, that I've somehow managed to dodge every single time in my searches, since even the most free lance, free source, free beer, written by one guy in an afternoon program seems to be magically able to handle every language under the sun.

>> No.66183782

>>66183703
Yes, wpf (since ~v4?) got some pretty neat font and image rending.
The problem with wpf is that you can do anything from bad (code) design to a very large project with reusable views.
It has an overhead of ~20 MB but that is just initial.
The learning "curve" is only there if you want you don't want to write like a pajeet (UI logic in code behind yuck!)
TL;DR learn styling, bindings and events and consider avalonia after that.

>> No.66183819

>>66183633
Es ist nur eine Buchherunterladenseite. Nutzen Sie eine *nixmaschine für Ihre Sicherheit.

>> No.66183825

>>66183766
Is that a normies girl or a /g/-fag girl?

>> No.66183957

I've put in a function call from another library in a program, but when I try to debug using gdb it skips over the line no matter where I put it. Anyone know what's going on?

>> No.66183990

>>66183957
Are you using step instead of next?

>> No.66183994

>>66183171
>If you only want to use the result at runtime, you could try something like this
>"hur what is constexpr"
If you don't know C++ then don't fucking bother replying.
And stop living in the stone ages, it's fucking 2018, we have C++17.

>> No.66184029

>>66179450
People with this mindset produce shit.

If you make something thats good you will make money from it. If you produce shit, closed source & charging for it is an attempt to make some money of people before they release what you've made is shit.

>> No.66184053

>>66183642
User manuals for libraries like ICU explain well the details on handling international input
http://userguide.icu-project.org/

On the output side, I'd look into libraries like FreeType, which handle glyphs, kerning, etc.
https://www.freetype.org/freetype2/docs/documentation.html

>> No.66184056

>>66184029
>charging for it is an attempt to make some money of people before they release
That's the biggest problem in /v/ right now. Too many people buy the game before knowing their quality just because of the series.

>> No.66184070

>>66184029
I meant realise.

>> No.66184086

>>66184029
>If you make something thats good you will make money from it.
How? Ain't nobody going to be all "Take my money!".

>> No.66184099
File: 351 KB, 1200x1697, 1522460368010.jpg [View same] [iqdb] [saucenao] [google] [report]
66184099

>>66182917
template <size_t N, size_t M>
constexpr bool operator>(A<N>, A<M>) {
return N > M; // Or whatever you want.
}


Ignore the other retard and his dinosaur code making C++ look bad.
This simple constexpr function does what you want and the result is available at both runtime and compile time if your type permits.

>> No.66184106

>>66184086
A few ways are;
1. Donations
2. Consultancy (there are companies that produce exclusively open source software that have market caps of over 1bn; Elastic, Red Hat, etc)
3. Feature support
4. Getting acquired for your talent (acqu-hire)

>> No.66184119

>>66184086
>>66184106
and besides there are a lot of open source projects that have lasting impact on humanity. I'm glad money isn't the only thing that motivates people.

>> No.66184172

>>66183642
i18n libraries

You write you strings in one language, run the internationalisation lib over that file and it will output all the different language files for you.

You let your user select their language and the correct file is loaded in. You set up tags to denote that your strings should be localised in your application.

Here is an example for React, but there are libs for every major language and toolset;

https://phraseapp.com/blog/posts/react-i18n-best-libraries/

>> No.66184209

>>66183766
Remember all those iOS crashes due to text? You're definitely not alone here. Old programming languages tend to have problems with handling Unicode, newer ones like C# seem to be designed to handle that.

>> No.66184237

>>66184119
Certainly that can be worthwile consideration in it's own right, but it has nothing to do with getting paid.

Also, I think open source people in particular are wont to overestimate the "lasting impact on humanity".

>> No.66184266

I built an object file (A) that has functions from other libraries (B) inside it.

I'm trying to link the .o file with another program, and I'm getting undefined reference errors to functions in B. Is this normal? Should I need to link again in my new program?

>> No.66184286

>>66184266
You need to make sure the library functions that A calls are linked to the appropriate object/so file;

>> No.66184290

>>66179261
Teaching myself Python. Tis fun.

>> No.66184314

Anyone know of some beginner friendly github projects I can make contributions too? Out of ideas right now but just kinda wanna code

preferably in Java, but I can work with python as well

>> No.66184336
File: 32 KB, 631x259, 1527580285131.png [View same] [iqdb] [saucenao] [google] [report]
66184336

pure academics circlejerking without muh real world applic--

>> No.66184373

how do I learn programming? any good resource besides SICP?

>> No.66184384

>>66184373
http://haskellbook.com/

>> No.66184400

new thread
>>66184394
>>66184394
>>66184394

>> No.66184591

>>66184400
kys dumb frogposter

>> No.66184669
File: 30 KB, 710x577, apu-giggles.png [View same] [iqdb] [saucenao] [google] [report]
66184669

>>66184591

>> No.66185280

>>66180026
>was actually thinking of making an os for rapsberry pi...
check out this class. it goes through writing a raspberry pi os from scratch in rust
http://web.stanford.edu/class/cs140e/

>> No.66185554

>>66184669
dumb frogposter

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