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

/dpt/ - Daily Programming Thread

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

Thread replies: 329
Thread images: 23

File: learncppin9seconds[1].jpg (421KB, 1200x1725px) Image search: [Google]
learncppin9seconds[1].jpg
421KB, 1200x1725px
Last thread: >>59687408

What are you working on, /g/?
>>
File: ccleaner.exe.png (182KB, 674x482px) Image search: [Google]
ccleaner.exe.png
182KB, 674x482px
what is the best programming language?
>>
>>59695564
Sheeit.
Is there way way to maintain a reference like that or no?
>>
Why is gprbuild so comfy?
>>
decoupling sytemd in go
>>
>>59695583
You could have them reference a manager of some sort.
I don't like oop but that's probably how you'd do it.
Have a manager people reference the manager and it contains the reference to the object. If you change the reference in the manager and everyone accesses it through the manager then the change will be felt throughout all the different objects.
>>
>>59695559
OCaml of course.
>>
>>59695559
C#
>>
File: AAAAAAA.png (576KB, 531x720px) Image search: [Google]
AAAAAAA.png
576KB, 531x720px
Repost from last night!
Rate my sudoku solver~
I got my code attempting to 1.4 million iterations per second, single threaded.
int sudoku_deduce(struct sudoku *pz)
{
/* attempt to compute missing numbers w/ vectors
* return 0 if stuck
*/
short box[3][3] = { { 0 } };
unsigned i, j, k, l;
for (k = 0; k < pz->size; k += pz->sq) /* 3x3 box */
for (l = 0; l < pz->size; l += pz->sq)
for (i = 0; i < pz->sq; i++)
for (j = 0; j < pz->sq; j++)
box[k/3][l/3] |= (1 << (pz->arr[k+i][l+j] - 1));
for (i = 0; i < pz->size; i++)
{
for (j = 0; j < pz->size; j++)
{
if (!pz->arr[i][j]) /* next missing no. */
{
short row = 0, col = 0;
for (k = 0; k < pz->size; k++) /* row / col */
{
row |= (1 << (pz->arr[i][k] - 1));
col |= (1 << (pz->arr[k][j] - 1));
}
short vec = row | col | box[i/3][j/3]; /* vector */
if (vec == 0x1FF) /* maxed out all 9 bits */
return 0; /* stuck */
while (!pz->arr[i][j])
{
unsigned num = prng() % 9;
if (!(vec & (1 << num)))
{
box[i/3][j/3] |= (1 << num); /* update state */
pz->arr[i][j] = num + 1;
}
}
}
}
}
return 1;
}
>>
>>59695559
8086 asm
>>
>>59695559
I do C but I think math is probably the best language right now. Shame I don't get to use it.
>>
File: 1438828254117.jpg (49KB, 550x535px) Image search: [Google]
1438828254117.jpg
49KB, 550x535px
>>59695661
>O(n^3+) algorithm

you still need to improve it
>>
>>59695661
you used too many braces and put them on the wrong line
>>
C, my program just exits with letting me stdin in this. I don't have a scanf previous to this like online people seem to have problems with.

        char *inname = NULL;

if (inname == NULL) {
printf("Insert input filename: \n");
fflush(stdout);
fgets(inname, 25, stdin);
}


In fact, if I printf something after this if statement, it does print so its just ignoring my fgets for some reason so i cant stdin. help?
>>
>>59695695
I don't remember but I think your problem is that your fgets which you use for pausing (if I understand you correctly) eat characters which weren't handled by the first fgets. Maybe. There was something like that when I started.
>>
>>59695624
So, what, a wrapper class of some sort that contains the ref to the second object?
>>
>>59695695
Don't use fgets.... insecure.
>>
>>59695725
Im using fgets to get a filename from stdin. The program when i run it just ignores it on my windows machine, I tried it on my linux machine and it takes my stdin but then i get a segmentation fault.

I dont have a previous fgets before this.
>>
>>59695754
he's using C, do you think he cares even the slightest bit about security?
>>
>>59695754
what should I use?
>>
>>59695739
I'm on my phone and I don't remember whatever syntax you're using well enough to explain to you well. But you make a class and instantiate it. It contains the object you actually want everyone to reference (you should make it private). The classes that need the shared object all take references to the manager and do something like manager.getObject() whenever they need it.
If you need to change the object they're referencing you call manager.setObject(new Object()).
So yes a wrapper. It's very simple double indirection.
>>
Are there many programming jobs in Norway?
>>
>>59695797
fgets is fine. He was probably mistaking it for gets.
>>
My project is now over 20k lines of C.
>>
>>59695795
He's using stdin. The OS is probably already compromised so why bother?
>>59695819
Yes. I'm gonna go work there. Can't stay in Sweden. I hope they don't raise barriers before I get there. We swedes already have many of the same things being said about us that the US says about Mexicans. Hard working, taking all the jobs, strange culture, poor background.
>>
>>59695781

use sscanf
>>
>>59695852
>Hard working, taking all the jobs, strange culture, poor background
shitty language
retarded flag
>>
>>59695848
That's approx 1/11th of Quake 3.
Pretty impressive anon.
>>
>>59695878
I've heard they like our accent though. We get hotel jobs and stuff like that because of it. Last I checked anyway.
>>
>>59695559
The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages.
- Richard Stallman
>>
>>59695942
>Stallman
Stopped reading there.
>>
>>59695695
>inname = NULL;
>fgets(inname, ...);
>>
File: 1437005687877.jpg (83KB, 396x385px) Image search: [Google]
1437005687877.jpg
83KB, 396x385px
>>59695942
Damn right stallman. Taught me how wonderful meta programming is with a powerful macro system which is also why Rust is so good.
>>
>>59695942
But I didn't ask stallman, I asked /dpt/
>>
>>59695852
Are Swedes really like Mexicans?
>>
>>59695971
>Rust is so good.
>>
>>59695969
Are you posting this and then replying to your self? It's not a good joke.
>>59695971
>Metaprogramming
Very underapprechiated aspect of programming but I dislike most language implementations of it.
How does rust handle it?
>>
Common Lisp or Scheme?
>>
>>59695996
Common Lisp if you like writing programs and good implementations.
Scheme if you like memes.
>>
>>59696012
But isn't Scheme simpler than CL?
>>
>>59695980
No not in the absolute sense. But in the relative sense. It's just the nature of immigrant workers though.
I'm cherry picking though.
http://sciencenordic.com/swedes-oslo-are-tired-negative-stereotypes
>As a result, Norwegians have coined the phrase “party Swedes”, used in a derogatory way to describe migrant Swedes as party animals who drink heavily and live in crowded collectives.
I don't think Mexicans have this same reputation. I appreciate that they have distinguished slurs though. I wouldn't like being called whatever the equivalent of wetback would be.
>>
>>59695815
goootcha
The thing is that I didn't want to store a ref to the original and then make it so that the original publicizes it.

I've decided to use a class that acts like a struct to keep the refs the same between the two without making it all public, but thanks a ton for the help!
>>
>>59696051
Forgive my cultural ignorance and insensitivity, but aren't Norwegians and Swedes far more similar than they are different?
>>
>>59696051
>I don't think Mexicans have this same reputation
Kind of.
Theyre always in massive groups who have no concern for the people around them. Its pretty accurate 2bh.
>>
>>59695993
Rust has a similar implementation to how Lisp does it. Not exactly as good but still a good one compared to most which are lacking or non-existent.
>>
>>59696070
>Norwegians and Swedes
Not him but that would be Norwegians and Danes.
But they'd behead me for telling that.
>>
>>59696070
>more similar than they are different
This is a meaningless phrase
What do you actually mean?
>>
>>59696105
As someone on a different continent, all three nationalities seem pretty similar.
>>
>>59695604
Cause linking multiple languages should be easy.
>>
>>59696125
>As someone on a different continent,
is the anon who asked on a different continent?
>>
>>59696117
I mean that Swedes are much more similar culturally, behaviorally, genetically, linguistically, spiritually, etc. to Norwegians than they are to the French, let alone than they are to Mexicans.
>>
>>59696070
Small differences become more significant the closer you are. On the grand scale we're indistinguishable though, including Denmark.
Sweden certainly does have more of the liberal tinge to it that /pol/ happily points out.
>>
>>59696142
>than they are to the French
Swedes and French are far more similar than they are different.

I mean that Swedes are more similar culturally, behaviourally, genetically, linguistically, spiritually, etc. to the French then they are to Mexicans
>>
>>59696151
Congrats on completely missing the context.
>>
>>59696170
The point is that you can always find something to point to and say "we're different, but he's even more different"

your question is completely meaningless
>>
>>59695559
There is no objective way to determine and to also establish a maintained hierarchy of languages.
>>
>>59695848
almost there
$ cloc . --exclude-dir=obj,bin
68 text files.
68 unique files.
16 files ignored.

https://github.com/AlDanial/cloc v 1.66 T=0.10 s (664.1 files/s, 104610.9 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C/C++ Header 45 911 670 5005
C++ 19 338 304 2965
make 1 12 0 34
-------------------------------------------------------------------------------
SUM: 65 1261 974 8004
-------------------------------------------------------------------------------
>>
>>59696199
I bet you're an atheist
>>
>>59695993
No, I didin't.

>>59696025
I thought just like that; but then I noticed that CL standard is so well defined compared to Scheme's minimal and implementation-dependent standard.
Common Lisp is ugly compared to Scheme; but it allows you to build better abstractions (non-hygienic macros, read-macros, (declare (type ...))s, etc).
>>
>>59696070
Norwegian here. Yes, Swedes are extremely similar to us in every sense. We understand each others languages perfectly fine. Lots of Swedes live and work here, and we get along with them for the most part.
>>
>>59696217
Nah, I love me some Jesus.

I suppose a better way to answer would have been "To each his own".
>>
>>59696223
Swedes are condescending and impish.
you norkies are decent tho.
>>
>>59696229
some languages are objectively bad
>>
>>59696237
Doesn't stop people shilling then here everyday.
>>
>>59696253
People don't shill PHP or Java very often
>>
>>59695664
this
>>
>>59696237
sssshh, don't let the c-tards hear you
>>
>>59695848
How many memory leaks?
>>
>>59695848
What exactly is it that it needs 20k loc?

>>59696285
valguard my friend and simply get better design and leaks keep to a min.
>>
Reminder that if you use any other language than python(unless its for work) you're a retard
>>
>>59696237
No shit, Sherlock.
The fact of the matter is that not one of you autistic faggots could ever collaborate with one another to collectively determine a hierarchy of programming languages.
>>
>>59696313
Because different programming languages are good for different things. Some are shit for everything, others are good at some things but bad at others.
>>
>>59696308
Python is fine for quick stuff, but it sucks if you need performance. But I know you're just pretending to be retarded so I'll overlook it.
>>
>>59696347
Most of its libraries are written on C though
>>
>>59696347
>>59696308

Python is garbage
>>
>>59696308
But what if I want to do something other than process strings?
>>
>>59696357
python confirmed objectively bad
>>
>>59696357
They don't provide the apis necessary for efficient processing.
>>
>>59696308
>>
>>59696285
2, both in third-party libs so not my fault.
>>
Nobody should call themselves a professional if they only know 1 language.

Five is a pretty good number for the number of languages you should know, but 3-7 is a good range too.

Here's my list personally for most used and most useful.

C++ of course
Java
Python for mainline work

If you know those you can't help but know about Ruby, JS, and C and of course C#. These languages basically form a cluster which is why if you know one you know a few more as well really.

Outside of that maybe one of the crazy functional languages would be a good pick just to keep your head spinning.

If you looking into HPC then you'll need to learn one of those languages but otherwise it's not worth your time.
>>
>>59696384
But that's a toolchain feature not a language feature.
>>
>>59696384
s/can/should/g
>>
>>59696389
How about this for a repertoire?

>C
>CL
>Java
>Haskell
>>
File: thinking.png (6KB, 80x80px) Image search: [Google]
thinking.png
6KB, 80x80px
>>59696384
There have been LISP OSs made
>>
>>59696389
>knowing C++
>possible
Pick one. Anyone who thinks they know C++ is simply deluded or has made major compromises on what knowing a language means.
And a language like C++ where details is important simply doesn't lend itself to make compromises in a way that'd let you call it 'knowing the language' without asterisks.

That said, knowing some C++ isn't bad. Some of it is C. Some of it is good. But you really shouldn't express it this way. The committee doesn't accept that they're creating dialects but that doesn't mean we shouldn't.
>>
>>59696389
I can agree with this quote.
>>
File: guE7LX0.png (51KB, 657x527px) Image search: [Google]
guE7LX0.png
51KB, 657x527px
What editor do you guys use? Typically I do:
Java - InteliJ/Emacs
C - CLion/Emacs
CL - Emacs
C++ - VS
>>
>>59696406
There are*
https://github.com/froggey/Mezzano
>>
>>59696476
emacs, for everything
>>
>>59696481
Oh wow Mezzano is still in development? I thought they gave up long ago.
>>
Are Norwegian or Icelandic useful for programming?
>>
>>59696476
Ive been trying to convert everything to vim since its ultimately where ill end up. That is until I write my own comfy, lang agnostic IDE.
>>
Evens - Begin writing an OS in C
Odds - Keep going with my game engine in C
>>
If I were to use Python for something, against my own volition, which version would be best for portability?

2.7, presumably?
>>
>>59696666
Nope.
>>
>>59696666
1.0.0-rc8
>>
>>59695514
Will I get to be an elitist if I learn an assembly language.
>>
>>59696766
Nope.
>>
>>59696766
If you make something impressive in it, sure.
>>
f (typeof S3BL_IGNORE_PATH == 'undefined' || S3BL_IGNORE_PATH!=true) {
var S3BL_IGNORE_PATH = false;
}

if (typeof BUCKET_URL == 'undefined') {
var BUCKET_URL = location.protocol + '//' + location.hostname;
}

if (typeof BUCKET_NAME != 'undefined') {
// if bucket_url does not start with bucket_name,
// assume path-style url
if (!~BUCKET_URL.indexOf(location.protocol + '//' + BUCKET_NAME)) {
BUCKET_URL += '/' + BUCKET_NAME;
}
}

if (typeof S3B_ROOT_DIR == 'undefined') {
var S3B_ROOT_DIR = '';
}

jQuery(function($) {
getS3Data();
});

function getS3Data(marker, html) {
var s3_rest_url = createS3QueryUrl(marker);
// set loading notice
$('#listing').html('<img src="//assets.okfn.org/images/icons/ajaxload-circle.gif" />');
$.get(s3_rest_url)
.done(function(data) {
// clear loading notice
$('#listing').html('');
var xml = $(data);
var info = getInfoFromS3Data(xml);
html = typeof html !== 'undefined' ? html + prepareTable(info) : prepareTable(info);
if (info.nextMarker != "null") {
getS3Data(info.nextMarker, html);
} else {
document.getElementById('listing').innerHTML = '<pre>' + html + '</pre>';
}
})
.fail(function(error) {
console.error(error);
$('#listing').html('<strong>Error: ' + error + '</strong>');
});
}

function createS3QueryUrl(marker) {
var s3_rest_url = BUCKET_URL;
s3_rest_url += '?delimiter=/';



https://opensource.apple.com/static
>>
Say I have a simple implementation of dynamic resizing arrays in C and now I'm doing threading stuff. Should I manually manage a mutex for keeping it thread safe or would it be more wise to just make a slightly modified version of my array implementation that does the mutex stuff automatically on everything?
>>
>>59696960
>jQuery
delet this
>>
>>59696960
I don't get how code like this is written.
There's no way people think this is a good way to write this.
>>
what's a good resource for learning haskell?
>>
>>59696962
Depends on what you're after. In the general case I think modifying the dynamic array to handle multithreading is good.
>>
matlab masterrace reporting in
>>
>>59697025
haskellbook.com
>>
>>59697025
whats a good reason to learn haskell?
>>
>>59697038
Fuck matlab
>>
256-color palette question.
do I use 0 or 255 as transparency value?
>>
>>59697097
What?
If you're doing 8bit per channel rgba you have 0-255 as your alpha channel values.
Are you asking if 255 or 0 should be full opacity? Depends on what you label it. Alpha channels tend to have 0 signify full transparency and 255 full opacity.
>>
>>59697097
Jazz Jackrabbit 2 used index number 0 and 2 if my memories do not fail me.
Zero would be a better idea.

>>59697139
He said pallete.
>>
>>59697153
thanks. I thought 0 made most sense too but I recall seeing 255 used before. not sure where though. figured maybe there's a standard for these things I should be following.
>>
>>59697153
So he's programming all to himself.
Why would he ask us? That's dumb.
>>
>>59697038
Shitty shitty language.
>t. daily user
>>
Why aren't you using Ada and C, since they work seemlessly together?
>>
>>59697307
Why aren't you using C++, since you don't need anything else?
>>
>>59697307
>since they work seemlessly together?
I can do the same with D.
>>
>>59697336
>C++
Embarrassing
>>
>>59697307
Garbage and hot garbage working together? What a surprise!
>>
>>59697429
That's no way to talk about the language your OS was written in!
>>
>>59697456
Windows is written in C# and C++
>>
>>59697503
>using Windows in 2017
>>
>>59697429
>>59697503
>Uses widows
>Thinking his opinions have any merit
>>
>>59697503

Windows is by and large written in C. C# is not a part of any of the OS internal components.
>>
>>59697094
https://www.youtube.com/watch?v=WO23WBji_Z0&t=10s
>>
>>59695514
>What are you working on, /g/?
Just finished a Mass Deleter for my Discord Bot.

Well, the sort-of BETA version, anyway.
I need to add a number of options to choose from.

ATM, I'm using it to clear an entire channel that's been up for like 5 months.

Set it to loop 100K messages

LET THE PURGE BEGIN!
>>
>>59695514
>What are you working on, /g/?
Dependently typed C.
>>
>>59695514
>What are you working on, /g/?
Web server with no I/O.
>>
>>59697763
Are you also working on a proof of the universe being deterministic? I'm almost there.
>>
File: 1472493166371.png (179KB, 463x492px) Image search: [Google]
1472493166371.png
179KB, 463x492px
>>59697763
>Web server with no I/O

how does it... get a page or give a page?
>>
>>59697503
Someone needs to translate RMS interjection to Windows lingo.
>>
i made some completely free software today

https://github.com/sailormoon/stopwatch
>>
int main()
{
FILE *file = fopen("C:\\Users\\JP\\Desktop\\text.txt","r");
if(file == NULL){
puts("Error opening file...");
return 1;
}

int c;
int i = 0;
char* array = (char*) malloc(i*sizeof(char));
while((c=fgetc(file)) != '\n'){
array[i++] = c;
}
puts(array);
fclose(file);
free(array);
}


Why is this giving me garbage and sometimes crashes?
>>
>>59697886
garbage in, garbage out.
>>
>>59695661
Cyclomatic complexity too high shift more bits.
>>
>>59697886
>malloc(0)
Doesnt make sense.
>>
>>59697886
>file == NULL
lol faggot, use !file
>>
>>59697926
even if I initialize i to 1 it still does the same
>>
>>59697886
You legit malloc'd yourself a zero-length buffer good job.
>>
wait, I think the problem is I didn't put append a file terminator at the end of the array
>>
>>59697886

try malloc(99999999999999999999)
>>
>>59697935
Yeah. But maybe you should support more than 1 character. Try 10000 then switch to measuring the filesize.
>>
>>59697886
You need to use realloc inside the loop to allocate more memory as you get chars.
>>
>>59697935
You dumb nigger, you have to malloc -at least- the number of bytes in the file. If you must put the shit on the heap you should know the length of the file beforehand, use fseek/ftell.
Nigger.
>>
>>59697933
No, why would you do that? file==NULL is more readable, and that's what counts the most.
>>
>>59697957
No it's wiser to measure the file first. Amortised growth is for when you don't know the size. If he was reading stdin it'd make sense.
>>59697971
>n-word
Not cool man.
>>
>>59697982
Are you a CIA nigger?
>>
>>59697982
True, I'm just used to measuring shit off stdin I guess.
>>
>>59697991
>a
I think you mean 'the' and no, I'm not.
>>
>>59696969
but muh effiuncy
>>
>>59697933
>Implementation defined behavior
>>
>>59697971
>-at least- the number of bytes in the file.

Even if I'm only storing a line from the file? I'm looking to build a parser and I'm thinking of parsing one line at a time.
>>
>>59698024
#define NULL 1
where's your god now faggot?
>>
Fact: OCaml programmers are the most powerful race in the world.
>>
>>59698047
enjoy your GIL
>>
>>59698040
When the loop exits the array should contain a line. You need enough memory for the line. That's likely more than 1. It's the line length+1 (because C strings are null terminated).
So allocate that much.

The easiest way to get by is to give yourself a static array that's longer than the longest line you will have.
>>
>>59698040

http://man7.org/linux/man-pages/man3/getdelim.3.html

enjoy friend
>>
>>59695583
hi 3rd anon here
>>59695624
what if that anon's code was on the last line
           this._obj &= obj;

(or however you assign byref in java or what was the language)

full code from previous thread with just the last line changed

class TestClass{
public TestClass() {
SomeObject obj = new SomeObject(2);
TestClassB b = new TestClassB(ref obj);
obj = new SomeObject(1);
//Is TestClassB's _obj equal to obj at this point?
}
}

class TestClassB{
private SomeObject _obj;
public TestClassB(ref SomeObject obj) {
this._obj = obj;
}
}


or is the issue the 5th line when obj gets assignned a new initialized object?
obj = new SomeObject(1);
>>
>>59698149
>with just the last line changed
FUCK i didnt change it

class TestClass{
public TestClass() {
SomeObject obj = new SomeObject(2);
TestClassB b = new TestClassB(ref obj);
obj = new SomeObject(1);
//Is TestClassB's _obj equal to obj at this point?
}
}

class TestClassB{
private SomeObject _obj;
public TestClassB(ref SomeObject obj) {
this._obj &= &obj; // or whatever the ampersand goes
}
}
>>
>>59698178
What fucking language is this? Looks like someone made C++ and Java fuck
>>
File: CirnoVSTheMessages02.webm (1MB, 480x360px) Image search: [Google]
CirnoVSTheMessages02.webm
1MB, 480x360px
>>59697649
Just made a short video.
>>
>>59698209
that's literally what it is. it's called C#
>>
File: mad.jpg (781KB, 1303x1037px) Image search: [Google]
mad.jpg
781KB, 1303x1037px
trying to make my own programming language
>>
>>59698301
Whats it gonna be like?
Any languages you're specifically trying to improve on?

I love talking about language dev.
>>
>>59698301
Me too, sort of, for a class. I'm trying to write the lexer right now implementing FDAs. I already have the FDA for the pattern recognition, now I have to write the parser.
>>
I posted before, but still cant figure it out. Im getting Segmentation Fault (core dumped) errors when I'm using fgets and I've searched online but nothing i found worked. C

char *inname = NULL;

if (inname == NULL) {
printf("Insert input filename: \n");
fflush(stdout);
fgets(inname, 50, stdin);
}


It's simple, but why the fuck isnt it working?
>>
>>59698301
It's too late. Humanity already has the best programming languages, but it chooses not to use them.
>>
File: truly_free.png (10KB, 397x95px) Image search: [Google]
truly_free.png
10KB, 397x95px
>>59697307
>he also walks wherever he chooses
>>
>>59698331
I've already marked your error.
>>59695970
Allocate some fucking memory where you can write to.
char inname[50];
// or
char *inname = malloc(50);
>>
>>59698343
>Humanity already has the best programming languages
Examples?
>but it chooses not to use them
How can humanity choose something? It's not a singular entity.
>>
>>59698178
No there's no way to make it work with the code provided.
Man. I can't really help people who haven't done C programming well. It's so obvious why it doesn't work when you haven't handled pointers or references in any half sophisticated manner for more than 10 minutes.

You have to understand that an object and its reference is entirely separate. If you take a reference to something it's like taking an index into an array. If you later say that someone else should use a different index into the array that doesn't change the first array. Ever.
You need double indirection to make this work as you wanted it to. Which is why I suggested a manager object. Just something that gets the objects away from dealing with a reference to what they actually what to get at directly. There's no other way except for very very silly things nobody would actually do. (like overloading assignment operators to add the lhs to a table where you can access them to update the reference to the object when it's constructed or something)

You really can't go to the abstract before you understand the reality of computers.
>>
>>59698364
Best Programming languages are:
C

Python is pretty good, too
>>
>>59698376
>that doesn't change the first array
Array index I mean. I need to sleep.
>>
>>59698364
Lisp, Stallman has choosen it for us.
>>59698383
C is OK.
Python is a pile of trash language that just werks.
>>
>>59698383
You're pretty delusional if you think so.
>>59698410
Lisp is webdev-like garbage, no wonder Stallman likes it.
>>
>>59698410
>just werks
What? No it doesn't. It has a slightly simplified toolchain for basic programs than many languages but it suffers a lot of flaws even with its modules.
>>
>>59698415
>I don't understand a language so it's trash
>>
>>59698423
>What?
I wouldn't be surprised. You are talking to something non-human.
>>
>>59698415
>webdev-like
Do you even know how Lisp-based languages work?
>>59698423
There are a lot of projects that use Python. I hate that language, but a lot of good applications are written in top of it (e.g.: deluge)
>>
>>59698447
There isn't much to understand about Lisp. Also, who are you quoting?
>>59698463
Yes, which is why I said it's pretty much the same level of cancer as any webdev trash.
>>
do you guys like jetbrains
>>
>>59698513
no
>>
>>59698463
Didn't say it was bad but you're giving it credit inappropriately.
Not sure I found the deluge to be a great achievement really.
I've written my own application in it though and it was relatively easy considering I didn't know the language before. I think that's where it shines.
It doesn't seem to have that many oddities. It's quite intuitive.
>>
>>59698349
God among men, my man.
>>
>>59698362
"Can't open bmp file to read: No such file or directory"

i tried those, now my readFile(...) method wont read inname.

its fine if i set inname to the filename with strcpy, so something is going one with my fgets. Prehaps its adding something extra like \n or spaces? idk
>>
>>59698482
Defining your syntax.
Defining your our language on top of Lisp.
Abstractions without limit but your brain.
JVM-like performance (sometimes better).
JIT compiler.
Data as code, code as data.
Runtime debugger.
REPL interaction.
Older than C.
Compiled to native code.
>webdev trash
>>
>>59698597
Most of these things are literally webdev garbage. The rest aren't even relevant.
>>
>>59698597
stop feeding the pajeets
>>
>>59698595
if (NULL = inname)
{
inname = malloc(64);
//assert(inname);
printf("Insert input file name: ");
fgets(inname, 64, stdin);
}
// use innme input
// done?
free(inname);
>>
>>59698616
lisp is a pajeet language.
>>
>>59698653
pajeet is a lisp language
>>
>>59698653
>>59698657
1/0 = 1
>>
>>59698641
if (NULL == inname)

Sorry, forgot. fgets() writes an '\n' so:
inname[strlen(inname)-1] = 0;

after fgets().
>>
>>59698641
>having to know how long your file name will be at compile time
c fags will defend this
>>
>>59698688
>muh efficiency
>>
>>59698688
You could just reallocate memory as you read but using fixed size buffer is just easier.
>>
>>59698688
size_t pos = ftell();
fseek(stdin, 0, SEEK_END);
size_t len = ftell() - pos;
fseek(stdin, pos, SEEK_SET);

Am I evil?
>>
>>59698688
>>59698697
who said this?
>>
>>59698718
I did.
>>
>>59698680
yep, the \n was the problem. Thanks for the help, now I know next time
>>
>>59696313
Collective determination is inherently flawed by human interaction. A democratic consensus will always be an inferior product. Compromise produces poorer products and outcomes because of social pressures which ignore reality in favor of trying to please a broad group of people.
>>
I was reading the Rust faq and found :
>Can I implement data structures like vectors and linked lists efficiently in Rust?
>If your reason for implementing these data structures is to use them for other programs, there’s no need, as efficient implementations of these data structures are provided by the standard library.

This attitude is disturbing. I can't trust a language like this. Also this strikes at biggest concern. They claim to be zero cost but if I need to use the unsafe keyword they're clearly not the kind of zero cost abstractions I much care for.
Their comments on compile times are also concerning. C++ is very slow and if they're comparing themselves to C++ they're probably not comparing to accelerated builds. Which I consider a necessity. I have no idea what kind of facilities exist to speed up rust builds but I don't deem it likely to be great.
>>
>>59698688
You don't.
>>
>>59698718
I said it out loud in a voice making the intent clear that I was reflecting my opinions on what the code was implying.
Get with it anon.
>>
>>59698763
>can i do this
>we already have that, so you dont need to

I dont really read that as anything else, its just a little clunky.

Rust is a meme regardless.
>>
>>59698763

The reason they dance around the question is because Rust makes it incredibly hard to design self-referential data structures.
>>
>>59698796
even with simple induction?
>>
>>59698763
>They claim to be zero cost but if I need to use the unsafe keyword they're clearly not the kind of zero cost abstractions I much care for.
When you use "unsafe" you are only adding three responsibilities you must take care of. Correctly dereferencing pointers, correctly accessing static variables, and correctly calling foreign functions. Everything that isn't that is still completely safe and can be type and lifetime checked. Plus, you can grep for unsafe blocks the moment you find a bug, and they're likely to be a very small portion of your codebase.
>>
>>59698113
>C
>Strings
>>
>>59698688
>implying computers are omniscient
>>
File: 1487295915998.png (423KB, 720x720px) Image search: [Google]
1487295915998.png
423KB, 720x720px
>>59698906
>>
File: Sif.gif (35KB, 230x200px) Image search: [Google]
Sif.gif
35KB, 230x200px
https://forum.dlang.org/thread/[email protected]

Happening

Go forth Walter you madman
>>
>>59698972
Why doesn't he just use monads?
>>
>>59698972
Oh boy here we go, haven't even finished learning D2 and D3 is starting to happen
>>
>>59698972
TOLD YOU NIGGERS.
>b-b-but the gc will never be removed
>>
>>59699005
>2017
>not yet removed
>years to come before it's removed
>>
>>59698717
It's undefined behavior
>>
>>59698717
>Am I evil?
No, you are a retard.
>>
>>59699016
A change like this will force them to assess the redundancy of nogc. Thus assessing the very idea of the GC in the first place.

It wont happen anytime soon, but its inevitable.
>>
>>59699005
>>59699016
It's a good first step, a lot of GC allocations done in Phobos is due to exceptions
Next step would be array operations
>>
>>59699071
>e array operations
https://dlang.org/phobos/std_container_array.html
>>
File: Screenshot_2017-04-02_01-17-38.png (232KB, 509x304px) Image search: [Google]
Screenshot_2017-04-02_01-17-38.png
232KB, 509x304px
>>59699087
I'm talking about in Phobos though
You get a lot of pic related if you download it, cd to std and run the following
for file in ./*; do echo $file; dmd -vgc -o- $file; done
>>
>>59698972
I tried to use D for freestanding code in osdev but why is it so impossible to get the D compilers to make freestanding code they always emit crap that depends on the standard library.
>>
>>59699113
But its there until phobos gets overhauled.
And yeah, I always keep -vgc on
>>
>>59699121
https://theartofmachinery.com/2016/12/18/d_without_runtime.html
You have to strip out quite a bit
>>
I've taken a C codebase and fixed it up enough to compile as C++ and have started hacking away at i. Problem is, C++ is a gigantic pain in the dick and I don't really enjoy using it at all, but I also don't really like being stuck with C's feature set.

Are there other alternatives to C++ that allow me to make use of an existing C codebase? Nim seems like the most promising lang I've found, as it can interface with C libraries, but C calling into Nim seems more complicated and prone to breakage.
>>
>>59699176
http://ecere.org/
https://github.com/ecere/ecere-sdk
or vala
>>
>>59699176
>If it has no C API, it's probably shit
https://wiki.installgentoo.com/index.php/Programming_languages

Keep using C.
>>
>>59699176
>C++ is a gigantic pain in the dick
You mean hacked together C that happens to compile as C++ is a gigantic pain in the dick.
C++17 is comfy as fuck.
>>
File: Untitled.png (466KB, 597x519px) Image search: [Google]
Untitled.png
466KB, 597x519px
I'm really feeling discouraged, /g/. There's a lot of thinking involved with programming and the practice problems in this book I'm trying to learn is asking me to make some "simple" programs for my learning level and it's making me feel stupid because I can't figure it out.
I'm not giving up though, but it's really fucking pissing me off right now. I understand the concept and everything but when it comes to putting together what I've learned so far into one small project and that it's telling me to do, I just can't do it. Fuck, I'm frustrated. This is pissing me off and it's so low level that it's pissing me off and fuck. This is the second time I've gone over this lesson and I understand it and know the syntax and terms and everything but arranging shit and fuck, i don't know.
>>
>>59699470
dumb frogposter
>>
>>59699470
Theres no shame in looking up an example to consciously learn from if youre honestly at a wall.
>>
>>59699500
Alright, thanks, anon
>>
>>59699382
If it compiles with the C++17 flag, it's C++17. Deal with it.
>>
>>59699592
>ANSI C is c++ 17
wew lad
>>
>>59699631
Does it compile?
>>
>>59699668
C++ doesnt break code.
>>
>>59699672
Are you drunk?
>>
>>59699668
in C++, you can also write the program entirely in inline assembly
>>
>>59699684
It doesnt break backwards compatibility*
>>
>>59699706
So it's still valid C++17?
>>
>>59699728
yes.
>>
File: 3421.png (13KB, 720x480px) Image search: [Google]
3421.png
13KB, 720x480px
REEEEEEEEEEEEEEE

Practising drawing stuff on the HTML canvas with JavaScript and I'm struggling to get the blue circle to line up properly.
>>
>>59699737
Alright
>>
File: doge (14).jpg (190KB, 630x418px) Image search: [Google]
doge (14).jpg
190KB, 630x418px
>>59695514
I am going to have a c++ class next Semester.
Where do I start?

PS: I already know C, Java and OOP
>>
File: 31.png (14KB, 720x480px) Image search: [Google]
31.png
14KB, 720x480px
>>59699741
I could do it manually through trial and error but I want it so when I change the triangle size it does everything automatically.
>>
>>59699757
Stfu. No one cares
>>
>>59699751
>PS: I already know C, Java and OOP
then you don't need to learn anything besides the C++ STL containers
spend an hour dicking around with vector and unordered_map and you're done
>>
>>59699741
Probably a dumb question but does the Pythag theorem work in circle form?
>>
>>59699777
Yeah, red + green = blue.
>>
>This is illegal in Rust
Oh boy
fn to_farenheit(c: i32) -> f32 {
return c*9/5.0 + 32;
}
fn main() {
for celsius in 1..11 {
println!("{}C = {}F", celsius, to_farenheit(celsius));
}
}
>>
>>59700171
Do you have to explicitly cast if rust doesnt/cant infer type cast?
>>
>>59700188
As far as I understand, yes. Rust is not into implicit conversions too.
>>
>>59700198
>Rust is not into implicit conversions
what a shit language
there's no excuse for that
>>
>>59700198
>Rust is not into implicit conversions too.
meh, i could see the reasoning, but yeah thats still a pain when implicits are so common anymore.
>>
>>59700209
Honestly, I don't think it's that bad, just have to stop being lazy. I can understand the safety concerns there by losing data with implicit conversions
>>
>>59700209
I dislike rust for being NIH and people praising it for that so done reason, but requiring casts isn't bad design.
>>
>>59700265
>but requiring casts isn't bad design
what's wrong with giving a compiler warning?
it's just needlessly verbose to require a cast when it's so obvious what the desired conversion is
>>
>>59700305
I don't know how rust does typing, but it might not be obvious. 5.0 could be multiple types in even C.
>>
>>59700344
A theoretically infinite number of types.
>>
>>59700344
>5.0 could be multiple types in even C
No, that in particular would be guaranteed to be a double in C.
>>
>>59700355
>>59700358
Nicely done, /g/
>>
>>59700358
You probly don't have much of a grasp on bindings either, they aren't just a size/shape of memory.
>>
File: 1467413586527.webm (802KB, 1280x720px) Image search: [Google]
1467413586527.webm
802KB, 1280x720px
here's an interesting little thing
>>
>>59700387
looks like it breaks the API rules
>>
>>59700387
assuming your sentiment analysis is even worth shit
>>
>>59700387
post sentiment code
>>
>>59700344
>but it might not be obvious
but in this case it is, because I assume f32 means 32 bit float
>>
>>59700407
>>59700397
it's not really. i'm just using the natural language toolkit sentiment api
>>
>>59700393
didn't know. im not using the main API but rather a python library called basc-py4chan. in any case, i'll retire this program then. thanks for the tip :)
>>
ITT children fail to understand the resolution of floating point numbers and why implicit casts are undesirable.
>>
>>59700434
also borrow checking
>>
>>59700413
Float can't even represent all 32-bit integers you idiot.
>>
>>59700434
pointless busywork and pointless verbosity
>>
>>59700469
yes it can
and if it couldn't it would have zero impact on this discussion
>>
first for functional programming is the future and will deprecate """""""""quantum""""""""" computing when utilizing massive parallel clusters
>>
>>59700524
why not functional quantum programming
>>
>>59700486
>yes it can
No it can't.
>>
>>59700486
Floats lack precision, even if they can cover the range.
>>
>>59700574
>>59700553
now explain why you think this has any impact on this discussion or in this scenario
hint: it doesn't
>>
>>59700585
I didn't say it did, I saw you, being wrong, and I pointed it out here >>59700574
That you think floats are magical is laughable
>>
>>59700601
except I'm not wrong
you can represent every int as a float and cast it back no problem
>>
>>59700610
a few weeks ago i would've accused this post of bait

but finally i've given in and accepted that people actually are this retarded
>>
>>59700619
Advocate of implicit cast are always retarded
>>
>>59700635
depends on the language and the context
>>
File: 1475866179953.png (992KB, 1023x1555px) Image search: [Google]
1475866179953.png
992KB, 1023x1555px
    loop{
mpdc.wait(&[mpd::Subsystem::Queue, mpd::Subsystem::Player]).unwrap();

if let Ok(Some(cursong)) = mpdc.currentsong(){
if let Some(ref title) = cursong.title{
if let Some(ref lastsong) = lastsong{
if let Some(ref lasttitle) = lastsong.title{
if lasttitle == title{
continue;
}
}
}

println!("Currently playing: {}", title);
}

lastsong = Some(cursong);
}else{
println!("Nothing playing");
}
}

>Rust

Although what's the idiomatic and clean way of doing all those nested if's in rust? I feel like I'm doing it wrong.
>>
>>59700663
That's pretty idiomatic if you ask me
>>
>>59700663
>
if let Ok(Some

rust was a mistake
>>
>>59697831
Those are just unnecessary side effects.
>>
>>59700672
That's perfectly reasonable.
>>
>>59700663
monadic bind

dunno rust syntax

mpdc.bind(\x -> x.currentsong()).bind(\x -> x.title).bind(\x -> ...)

in Haskell

do
a <- mpdc
b <- currentsong a
title1 <- title b
d <- lastsong title1
title2 <- title d
pure (title1 == title2)
// do something with the Maybe Bool
>>
>>59700672
>>59700209
Your existence is a mistake
>>
>>59700619
by your own admission, your posts have no impact on this discussion
so clearly, you are the retard
>>
>>59700663
no way around it.
compiler will output the same shit no matter how you format it.
>>
>>59700692
Are you old enough to use this website?
>>
>>59700678
its really not, it reads really awkwardly.

Why do you need OK & Some?
>>
>>59700171
Your rust is not idiomatic enough:
use std::ops::{Add, Mul, Div};

fn to_farenheit<T, U>(c: T) -> <<<U as Mul>::Output as Div<U>>::Output as Add<U>>::Output
where T: Into<U>, U: From<i8> + Mul, <U as Mul>::Output: Div<U>, <<U as Mul>::Output as Div<U>>::Output: Add<U> {
c.into() * 9i8.into() / 5i8.into() + 32i8.into()
}

fn main() {
for celsius in 1..11 {
println!("{}C = {}F", celsius, to_farenheit::<_, f64>(celsius));
}
}
>>
>>59697503
I'd just like to interject for a moment. What you’re referring to as Windows, is in fact, NSA/Windows, or as I’ve recently taken to calling it, NSA plus Windows. Windows is not an operating system unto itself, but rather another non-free component of a fully functioning NSA botnet made useful by the NSA, CIA, spyware and vital system malware comprising a full botnet as defined by /g/. Many computer users run a modified version of the NSA botnet every day, without realizing it. Through a peculiar turn of events, the version of NSA which is widely used today is often called “Windows", and many of its users are not aware that it is basically the NSA botnet, developed by the National Security Agency. There really is a Windows, and these people are using it, but it is just a part of the system they use. Windows is the kernel: the program in the system that allocates the machine’s personal information to the other government agencies that you didn't elect. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete botnet. Windows is normally used in combination with the NSA botnet: the whole system is basically the NSA with Windows added, or NSA/Windows. All the so-called “Windows” versions are really distributions of NSA/Windows.
>>
>>59700707
what the hell is that abomination
>>
>>59700707
>
fn to_farenheit<T, U>(c: T) -> <<<U as Mul>::Output as Div<U>>::Output as Add<U>>::Output

now thats pod racing
>>
>>59700706
std::Result and std::Option
https://doc.rust-lang.org/std/result/enum.Result.html
https://doc.rust-lang.org/std/option/enum.Option.html

If you're asking why they are together, it's because even if the request does succeed over the mpd protocol, it's not guaranteed that there is even a song currently playing at all.
>>
>>59700684
Did I fucking ask about Haskell? Fuck off.
>>
>>59700698
The formatting is what I'm interested in fixing though.
I know it's going to be outputted the same, I just don't want the source to look like unreadable garbage.
>>
>>59700706
Generics, OK is a member of the Result enum i.e. the operation didn't Err. Some is a member of an Option enum, either a thing is a Some or it's a None.
>>
>>59700739
I'm not even going to explain it to you, because you're so rude
>>
File: 1485473684854.png (408KB, 824x792px) Image search: [Google]
1485473684854.png
408KB, 824x792px
>>59700715
>>59700719
I can think of same ways to make it even more idiomatic and safe, but it would require nightly rust and I can't be bothered installing it.
>>
>>59700707
teach me, senpai
>>
>>59700707
Enterprise tier
>>
>>59700730
>it's not guaranteed that there is even a song currently playing at all.

seems like you could just do a -1 enum, but i guess.
>>59700748
yeah i looked them up before asking
just seems redundant and also a bad word to choose.
>>
>>59700781
Ah well it's a safe way of handling
unwrap()
with a set of predictable conditions. Unwrap could do a bunch of things and you sort of create a pattern of error handling around it.

I don't know if there's a more terse way to write that though, it would certainly lose some obviousness.
>>
>>59700781
I agree that 'Some' is not exactly the best word to choose, but whatever.
>>
>>59700707
Rust has the same recipe of C++, turn simple things into nightmares
>>
>>59700797
It makes sense in the namespace but less sense outside it.
>>
>>59700781
>seems like you could just do a -1 enum, but i guess.
Option IS an enum under the hood, and None is effectively a '-1 enum'.
>>
>>59700803
Yeah, and then Rust users pretend it is the C++ killer. lel.
>>
Dumb question, but how do you check the type of variable in Rust? Like typeof(x) == i32
>>
File: yodabait.jpg (147KB, 500x378px) Image search: [Google]
yodabait.jpg
147KB, 500x378px
>>59700845
>>
>>59700739
in Rust it's called and_then
>>
>>59700856
you sure knowyourmeme
>>
>>59700875
That's my favorite.
>>
>>59700772
Always make everything as generic as possible, even if it makes no fucking sense.
I wanted to make it even "better" by adding some checked arithmetic in there, but Rust doesn't have a trait for that, for some reason, and they don't have the functions for floating point types.
>>
New thread: >>59700932
>>
>>59696666
Against your own "will", not " volition", you illiterate code monkey.
>>
>>59698717
No, you are just stupid. Do you even know what your result is lol
>>
>>59699470
Ignore the "I'm feeling stupid" and "it's pissing me out". As long as your ego has you convinced that you should be understanding something, you won't be able to approach it from the viewpoint of humble ignorance, which is what you need to learn. Master this and you will become "intelligent" seemingly overnight.
>>
>>59701180
*off
>>
https://github.com/ableiten/foldem
Thread posts: 329
Thread images: 23


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

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


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