[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: 342
Thread images: 38

File: rust_programming_instagramm.jpg (137KB, 800x800px) Image search: [Google]
rust_programming_instagramm.jpg
137KB, 800x800px
What are you working on, /g/?

Old: >>59423393
>>
We chose C over ML and have been paying for that mistake ever since.
>>
>>59430265
Thankfully we can redeem ourselves by switching to Rust.
>>
>>59430284
You mean ignoring Rust, right?
>>
>>59430291
C fag here.
Rust is actually pretty good.
>>
nim is better than rust fight me
>>
fuck it all, i'm creating anime thread
>>
>>59430291
No, I mean "switching to" Rust. Can't you read or what?
>>
>>59430307
>veryImportantVariable and very_important_variable are the same identifier
You can't make this shit up.
>>
>>59430319
Apparently you confused "switching" with "ignoring", friend.
>>
anime thread:

>>59430383
>>
>>59430216

>instagram
>CS
>Rust

Fuck this gay earth and fuck San Francisco. This shit is cancer.
>>
File: 1488243967606.jpg (405KB, 900x1200px) Image search: [Google]
1488243967606.jpg
405KB, 900x1200px
>>59430291
You can keep ignoring
>>
what is the best general purpose language and why is it python with pyqt for guis.
>>
>>59430429
Now run Lisp on this joint
>>
>>59430430
I'd say D sinse python is incredibly slow. Python's syntax is being used in Nim though
>>
>>59430430
You're completely delusional, seek treatment
>>
>>59430399
not meant to be rude, but this picture is fucking annoying, why reposting the same pic every day
>>
>>59430444
python is the best to get it done

once it's done you can use Rust/Java/D/C++ to rewrite it
>>
>>59430457
This is called rapid prototyping, it's what python is very good for.

You can translate it to Nim, it compiles to C. Best of both worlds
>>
would you say ruby is better than python?
so far it feels better for me since it feels like python without whitespace, don't have much experience with ruby, shoul I switch?
>>
>>59430467
wait so nim takes straight python? you don't need to write a nim variant?
>>
>>59430430
That's a weird way of saying Lisp.
>>
>>59430265
>ML
?
>>
>>59430483
Nim's syntax is incredibly similar to that of python and you can learn it quickly if you are used to python.
>>
>>59430496
Machine Learning
>>
Finding common substrings between two strings. Now I only have to add a method to return the biggest one.
import std.stdio;

void main(string[] args){

string str1 = "abcder";
string str2 = "xwbcmaabcr";
string[] commons;

for (int i = 0; i < str1.length; i++){
for (int j = 0; j < str2.length; j++){
if (str2[j]==str1[i]){
string current = ""~str1[i];
for (int a = 1; (a+i < str1.length && a+j < str2.length); a++){
if(str2[a+j]==str1[a+i]){
current~=str1[a+i];
}
}
commons~=current;
}
}
}
writeln(commons.length);
}
>>
>>59430522
do your own homework
>>
>>59430534
That's not a homework
>>
>>59430496
Meme Language
>>
>>59430456
This picture for the America is the same through 235 years, why /dpt/ must change its picture?
>>
>>59430496
Ocaml's ancestor, we owe to it the greatest language of our time.
>>
>>59430608
Too bad it had been deprecated since Haskell came out.
>>
>that OP
Lmao literally placebo tier
>>
>>59430608
Tell me 5 things good about Ocaml
>>
>>59430589
Because /dpt/ is not the United States of America, and because right now, on this thread, there are anonymous individuals who "fight" in order to assert their political view of what /dpt/ should be!
>>
noob question

if im on lunix do i actually need to use a VM to properly code c/c++ with windows functions (for timing cpu etc) or is there some gangsta way around that
>>
>>59430284
>Thankfully we can redeem ourselves by switching to Rust.
kys, sjw scum.
>>
>>59430589
We don't endorse the NSA here
>>
>>59430681
>lunix

Google "MinGW".
>>
>>59430681
mingw i think
>>
>>59430715
>>59430718
neat i always thought mingw was just for the reverse (mimicing lanix on windows) but it appears that isnt the case
>>
>>59430708
>Rust OP
>do't endorse
funny joke
>>
is there anything better than anime fags getting BTFO?
>>
>>59430779
You going back to R*ddit.
>>
>>59430786
what makes you think I don't have it open in another tab right now?
>>
Learning Ionic v2. Pretty easy so far, but I'm still having doubts about the best project structure. Liking AngularJS so far, but still having trouble with huge single line functions with Promises inside promises.

Also is there any legal way to virtulize a OSX?
>>
>>59430786
>tfw reddit is the superior website for actual discussion but it got so popular that 50% of the posts are coming from paid shills to brainwash and control conversations
>tfw 4chan is one of the last beacons of true free speech and thought
>>
File: 1479120583570.jpg (42KB, 948x669px) Image search: [Google]
1479120583570.jpg
42KB, 948x669px
>he ports his software to windows
>>
>>59430835
>50% of the posts are coming from paid shills to brainwash and control conversations
>implying the shills don't ruin 4chin too
>>
File: 1469231192063.png (386KB, 458x514px) Image search: [Google]
1469231192063.png
386KB, 458x514px
>>59430835
>>tfw 4chan is one of the last beacons of true free speech and thought

>people unironically believe this
>>
Trying to write a terminal multiplexer in Haskell.
>>
Does anyone know how to crack Steam games or how I can replace the steam_api library with a spoofed one so I can play my steam games without steam>
>>
File: 1453144083632.png (48KB, 325x286px) Image search: [Google]
1453144083632.png
48KB, 325x286px
why is Visual Studio so shit and bloated


I wish I never had to use it
>>
>>59430894
Tried Visual Studio Code ?
>>
>>59430894
try using netbeans or eclipse my good lad
>>
>>59430337

Someone decided that the programmer can use camel case and snake case interchangeably.

Odd, but some might like it.
>>
>>59430894
>bloated
What type of development do you do? What does your dev process look like? Are you developing on a machine with a 16GB hard drive?
>>
>>59430863
Does it allow you to use it with no I/O?
>>
>>59430845
I wouldn't
>>
File: 1457464180065.png (440KB, 645x1260px) Image search: [Google]
1457464180065.png
440KB, 645x1260px
>>59430903
I have not, what makes it different from things such as Atom?

>>59430955
>>59430960
Sometimes Unity (Although I prefer Monodevelop mostly)
But I'll be using it for Vulkan etc,
I might just switch to my linux machine but it's just tedious.

VS has crashed like 3 times today it's pretty autistic
>>
>>59430958
Mixing of naming conventions reduces code readability, it's better to enforce a standard naming scheme at the language/compiler level, like Haskell or Rust do.
>>
>>59431021
use sublime text
>>
>>59430741
Actually, Mingw just crosscompiles to Windows, but you can use mingw on lunax no problem.
>>
>>59430216
Anybody here is 3D web programming ?
I work a lot with BabylonJs, and it's rather cool.
At first I was sceptic about using Javascript in big projects but I'm starting to like it actually (ES6)
>>
>>59430845
I have no option
But I always develop on Linux first
>>
>>59431029
I'd rather use a language that works with me, not against me.
>>
>>59431021
>VS has crashed like 3 times today it's pretty autistic
literally never happened to me since vc 6.0 days,

Maybe there is something wrong with your windows os?
>>
>>59431079
>>>/g/wdg/
>>
>>59431021
Vscode is lighter than Atom, but anything is so idk
>>
File: 1486428981152.jpg (111KB, 420x550px) Image search: [Google]
1486428981152.jpg
111KB, 420x550px
r8

>find commons substrings between two strings
>find the largest common substrings between two strings
import std.stdio;

void main(string[] args){

string str1 = args[1];
string str2 = args[2];

string[ulong] commons;

for (int i = 0; i < str1.length; i++){
for (int j = 0; j < str2.length; j++){
if (str2[j] == str1[i]){
string current = ""~str1[i];
for (int a = 1; (a+i < str1.length && a+j < str2.length); a++){
if(str2[a+j] == str1[a+i]){
current ~= str1[a+i];
}
}
commons[current.length] = current;
}
}
}
writeln(commons);
}

/main asdf asdfasdfc
[4:"asdf", 2:"df", 1:"f", 3:"sdf"]
>>
>>59430845
>he ports his software for actual people to use
>>
File: 3..jpg (50KB, 644x591px) Image search: [Google]
3..jpg
50KB, 644x591px
>>59431096
Maybe, I've not really used VS much on other machines so I couldn't really say if its just an autistic instance I'm in

>>59431105
I'll check it out thanks
>>
File: 1487974409142.jpg (79KB, 640x640px) Image search: [Google]
1487974409142.jpg
79KB, 640x640px
>>59431125
what is an actual people?
>>
>>59431109

>n^3 complexity
>no suffix tree or array

Seriously, some googling on some of the algorithmic problems you want to solve does wonders.
>>
I didn't believe it either, but you can ACTUALLY get better at programming just by watching anime!
>>
File: 1454353443729.png (126KB, 670x870px) Image search: [Google]
1454353443729.png
126KB, 670x870px
>>59431139
I don't know anon

who even are we? Really?
>>
>>59431100
Well, I don't program website but create 3d web applications in Webgl. And I'm rather happy that way, web development isn't that interesting.
>>
Has anyone tried compiling c++ with opengl into js? My simple sdl shit seems to work fine
>>
>>59431162
This is true.
>>
I just decided to start using checkstyle, it had at shitfit about using tabs and when I changed to spaces, it had a fit about it using 4 spaces not 2, so I changed that too.

So is this actually a typical standard?
>>
>>59431109
I was going to show a cool solution to this and then I saw
>two strings

Do a collection of strings, mate. Then you can do this for any number of strings, rather than be stuck with two.
>>
File: switching_from_to.png (790KB, 3720x3720px) Image search: [Google]
switching_from_to.png
790KB, 3720x3720px
>So I wrote a script for it. You can query Google from a script and get the number of search results using a tiny snippet. I tried a few different query strings, like move from <language 1> to <language 2>, switch to <language 2> from <language 1> and a few more ones. In the end you get a nice N * N contingency table of all languages:

C-fags are on suicide watch. Also Perl and Lisp are officially dead now.
>>
>>59431546
you can configure checkstyle to use your indentation preferences
>>
>>59431595

>everyone switching to java
>>
>>59431595
This is as useless as TIOBE.
>>
File: 1481659600223.gif (3MB, 300x212px) Image search: [Google]
1481659600223.gif
3MB, 300x212px
>>59431590
okay wait
>>
What's the best resource for learning Prolog?
>>
>>59431595
https://pypl.github.io/PYPL.html
>>
>>59431595
>C-fags on suicide watch
>From * to C yields the highest results.
Are you too dumb to interpret the (irrelevant) results of your shitty script?
>>
>>59431692
Paradigms of Artificial Intelligence Programming
You'll end up learning Lisp too, but you'll learn how to make a Prolog compiler.
>>
>>59431726
There are more people fleeing from C to C++, Java or Go than in any other direction. The only people interested in C are script kiddies.
>>
>>59431759
rekt again
>>
>>59431759
Prove it by constructing a covariance matrix using the data.
>>
>>59431759
It doesn't even mean that you dense motherfucker.
Google probably interprets your stupid request as "Need help to translate x language to y language".
What it shows is that C yields a fuckton of results in Google search, nothing more.
You should be the one on a suicide watch, you absolute cretin.
>>
>>59431819
angry C manlet can't accept the truth
>>
File: 1487550646729.jpg (84KB, 648x720px) Image search: [Google]
1487550646729.jpg
84KB, 648x720px
>>59431590
I need should use concurrency for this, don't I?
>>
>>59431872
neet to/should
shouldn't
>>
File: anal beads.png (11KB, 987x163px) Image search: [Google]
anal beads.png
11KB, 987x163px
>>59431109
>>59431590
Something like this for a list of strings...not sure if it's right.

static List<string> AllCommonSubstrings(List<string> muhStrings)
{
var ss = muhStrings.ShortestString();
return ss.AllSubstrings()
.Where(x => muhStrings.Where(y => y != ss).All(y => y.Contains(x)))
.Distinct()
.ToList();
}
>>
File: 1376519405639.jpg (53KB, 421x834px) Image search: [Google]
1376519405639.jpg
53KB, 421x834px
>>59431834
Keep on memeing brainlet. That's all you have left.
>>
Currently learning D, is there any way to make executables smaller while using DMD? I would like my hello world program to not be 400 Kb
>>
>>59431906
>ShortestString()
?
>>
>>59431942
>using DMD
m8 either use GDC or LDC2
>>
>>59431944
public static string ShortestString(this List<string> input) => input.OrderBy(x => x.Length).First();
>>
>>59431928
Reminder to ignore the obviously underage trolls.
>>
>>59431949
Not the quoted but why?
>>
>>59431973
https://youtu.be/ntdKZWSiJdY?t=25m55s
>>
void* operator new(std::size_t n)
{
auto p = std::malloc(n);
//std::clog << "malloc 0x" << std::hex << n << " bytes at 0x" << (int)p << '\n';
*reinterpret_cast<std::uint32_t*>(p) = 0;
return p;
}


[[gnu::optimize("no-omit-frame-pointer"), gnu::noinline]] void operator delete(void* p)
{
std::uintptr_t called_from;
asm("lea %0, [ebp+4];"
"mov %0, [%0];"
:"=r"(called_from));

if (*reinterpret_cast<std::uint32_t*>(p) == 0xDEADDEAD)
std::clog << "DOUBLE FREE 0x" << std::hex << (int)p << " called from 0x" << called_from << '\n';
*reinterpret_cast<std::uint32_t*>(p) = 0xDEADDEAD;

//std::clog << "free 0x" << std::hex << (int)p << " called from 0x" << called_from << '\n';

//std::free(p);
}


I just wrote this bullshit because std::map is double-freeing somehow and I can't figure out why.
>>
0XBACABABE
>>
>>59432155
epic
>>
File: NizqdMjKIBA.jpg (320KB, 1000x749px) Image search: [Google]
NizqdMjKIBA.jpg
320KB, 1000x749px
I am notoriously slow learner. Should I drop programming? Things like >>59432100 or answer >>59431151 want me to kill myself, especially considering how fast other people learn. I still can't fucking comprehend pointers fully after several months.
>>
>>59432187
what about pointers do you not understand?
also, double pointers are autism, stay away.
>>
>>59432162
0xDEFEC8
>>
>>59432187
Programmers who use pointers are a minority.
>>
>>59432212
0xBAAAAAAD
>>
File: 1450600770847.gif (3MB, 286x258px) Image search: [Google]
1450600770847.gif
3MB, 286x258px
>>59432200
>double pointers are autism
Spoken like a true brainlet.
>>
>>59432246
Are you that angry C manlet?
>>
File: 1489461328707.png (740KB, 1834x1200px) Image search: [Google]
1489461328707.png
740KB, 1834x1200px
>>59432246
no u
>>
>>59432259
C TODDLERS BTFO!!!!!
>>
is android studio actually the best android IDE or is it just the most mainstream?
>>
>>59432100
Just use valgrind.
>>
>>59432353
I hear shitbrains IDE is pretty nice
>>
File: pajeetmyson.jpg (406KB, 1834x1200px) Image search: [Google]
pajeetmyson.jpg
406KB, 1834x1200px
>>59432259
fixed your meme Xd
>>
File: 1488243967666.jpg (27KB, 300x492px) Image search: [Google]
1488243967666.jpg
27KB, 300x492px
>>59432417
>He's autistic enough to make this
Why are c pajeets so butthurt?
>>
>>59432214
It's not about minority, it's about solving tasks and not being able to use shit more complex than that. I stuck for hours upon solving a simple problem, and I am afraid that when I struggle at basics that much, it won't be possible to comprehend problems more complex things.

>>59432259
basically this
>>
File: java-vs-haskell.png (102KB, 2435x913px) Image search: [Google]
java-vs-haskell.png
102KB, 2435x913px
>>59432417
>>
>>59432445
>>He's autistic enough to make this
You were autistic enough to make the original Xddd
>>
>>59432356
does valgrind run in dos?
>>
File: sd.png (159KB, 426x552px) Image search: [Google]
sd.png
159KB, 426x552px
No negative comments please
>>
>>59432445
>space in header filename
>using undeclared identifier (or worst, declared and initialized in header)
>conditional expression in do while is nonsense
>getch ()
Well, at least she's pretty and cute.
>>
>>59430430
>with tkinter for guis.
ftfy
>>
Program that detects when a new /dpt/ needs to be made and preempts other anons, making sure that we will always have an anime OP. From my loli collection of course.
>>
>>59432463
>>59432417
>>59432246
>>59430216

Important poll
https://www.strawpoll.me/12543202
>>
>>59432483
>Indian woman
>pretty
>cute
>>
>>59432498
Post your sample from colletion.
>>
>Programming in C by Kochan somehow got the day-of-the-week that August 8, 2004 occurred on wrong

I guess what bugs me is that this could easily be checked on a goddamn calendar, but they still concluded that it was a Tuesday.
>>
>>59432530
>lets compare mental illnesses
>>
>>59432531
>'c'
Found your problem
>>
>>59432187
>I am notoriously slow learner.
So a retard in other words? At least you acknowledge it.
>>
>>59432347
Is that anything new?
>>
>>59432523
Shit taste spotted
>>
>>59432570
rajesh spotted
>>
>>59432590
No sir I'm true American sir.
>>
>>59432590
>>59432523
>>>/pol/
>>
>59432680
>>>/shittingstreet/
>>
File: LbjJWb06.jpg (18KB, 400x400px) Image search: [Google]
LbjJWb06.jpg
18KB, 400x400px
>>59432523
>ywn practice agile c++ pair programming with a indian qt
why live
>>
I'm proud of George.
>>
Who wants to code a game engine with me?
>>
>>59433013
Don't ask, start doing it
>>
I did a git commit but accidentally pressed enter before I finished writing the commit message
it looks really silly now
how do I undo it?
>>
>>59433032
Try to amend it?
>>
>>59430444
>D best general purpose
Probably. Its a shame they're marketing to C/C++ people and not Java.
>>
>>59433073
Heh, good point.
>>
>>59433068
oh thanks, that's the right word.
git commit --amend -m "msg", that did it
>>
>>59433032
git reset, mixed so it doesn't revert your code. I would recommend gitk to do it.
>>
>>59432734
how is he so lucky?
>>
>>59433073
There is literally no reason for Java people to switch to D. They have way more libraries, mature developer tools, better performance and state-of-the-art GC. Java has been in production use for more than 20 years now and D is a hobby project.
>>
File: received_1286299698103653.png (756KB, 720x1280px) Image search: [Google]
received_1286299698103653.png
756KB, 720x1280px
>>59430216
>How often do you get drunk /dpt/?
I drink on Fridays and after the Subday lunch. I mostly drink beers or a bottle of wine on Fridays or if I am in the mood I drink some polish wodka and on Sundays I drink whiskey.

I mostly drink to suppress my depression and to gain health benefits.
Even though I drink, I kinda hate it I waste so much time by doing it I would rather work but the emotions I have are just too strong or I just tell it to myself.
>>
>>59433176
>D is a hobby project
D Internet Defense Force in 3...
>>
>>59433176
>State of art GC
>Fast

>Literally slower and takes more memory than JIT scripties

lol
>>
>>59433261
>I repeat stale memes without providing sources
Sucks to be you.
>>
File: Screenshot_2017-03-16_19-24-42.png (102KB, 1282x745px) Image search: [Google]
Screenshot_2017-03-16_19-24-42.png
102KB, 1282x745px
>>59430216
My game.
Artificial life with custom physics engine. C++, OpenGL 1.1, SDL2, LodePNG, 1 year of weekend devving. Lot of things rewritten and rewritten as I got better and better in C++.
You can try the last public version at https://bela.itch.io/blob
It still has the Box"D physics lib.

>>59433188
What is that picture?
>>
>>59433319
https://attractivechaos.github.io/plb/
>>
Is "learning python the hard way" worth it?
>>
>>59433349
>Debian GNU/Linux 5.0
>GCC-4.3.2
>[email protected]_25
>The benchmark was originally conducted in June, 2011.
Wew, lad, why don't you dig up some Java benchmarks from mid-90s, that will show them.
>>
>>59433348
where's the source code though
>>
>>59433357
Anything by Zed Shaw is not worth it. Choose a textbook from a college course or Automate the Boring Stuff if you're yet another "how do I into programming" fag.
>>
>>59433349
Just so you know:

LuaJit: 2.5s(33.2MB)/6.2s(?)/4.5s(123.8MB)
Java: 2.5s(67.1MB)/6.8s(?)/6.7s(314.8MB)

>>59433388
Feel free to make your own benchmark and your own criteria to fulfill, until then Java is REKT
>>
>>59433357
you'll learn it just was well doing it the easy way
>>
File: 1446072375920.gif (196KB, 500x281px) Image search: [Google]
1446072375920.gif
196KB, 500x281px
>Last week: call C programmers NSA agents and shill Rust
>This week: call C programmers retards and shill whatever acceptable because shilling Rust is a huge joke after the last week
What are we going to get on the next week?
>>
File: 1467903937138.png (697KB, 654x810px) Image search: [Google]
1467903937138.png
697KB, 654x810px
>>59433390
You can disassemble the exe.
>>
>>59433409
>2017
>caring about memory overhead
>>
>>59433188
I don't drink at all because my uncle died from alcoholism and my father is an alcoholic
>>
>>59433494
Next week will be spaces vs tabs
>>
>>59433512
You must like haskell's GC too.
>>
>>59433512
who said that??
>>
>>59433562
We need something fresh
>>
>>59433512
>2001>, caring about anything
>>
>>59433512
You are literally the reason why modern fucking text editors can't fucking open 100+mb files you mongoloid, kill yourself please.
>>
>>59430216
Static types merely hinder the programmer, forcing him to bend to the will of the compiler, rather than the other way around, like it should be. A programmer should be allowed to sketch his ideas freely without the fear of upsetting a perpetually angry static type system.
>>
>>59433594
OOP vs FP
>>
vector <int> f() {
vector <int> v;
// ...
return v;
}

void g() {
// ...
}



How do we work with the size of vector in g() returned by f()?
>>
>>59433714
literally >2016
>>
>>59433494
> shilling Rust is a huge joke after the last week
> Rust shilling is literally in the OP
>>
>>59433671
>Static types
No such thing. You've showcased your retardation in the first few words. Didn't even read past this point.
>>
>>59433719
Meant to answer
>>59433714
>>
>>59433720
>this thread isn't a joke
>>
>>59432100
FINALLY fixed it. turns out static destruction order bit my ass once again.
the whole map was already deleted when I tried to access it.
>>
>>59433497
not good enough pal
>>
>>59433714
wat
std::vector<int> v = f();
std::cout << v.size() << '\n';
>>
>>59434033
Shit, I am retarded. Thanks.
>>
Best python book?

>inb4 1k pages
>>
>>59434118
the best course of action, when learning python, is to stop
>>
>>59434118
stop reading books like a monkey to learn shit

unless you have absolutely no programming experience you don't need a book to learn a new language
>>
>>59434118
http://www.effectivepython.com/

>>59434132
no u
>>
>>59434150
How did you learned python?
>>
>>59433494
Rust > Anything > Pile of trash > 'c'
>>
>>59434118
Practical Common Lisp.
>>
>>59434162
i think of a simple script i want to make then i just break it down into parts and search "how to do x in python"

you already know programming (i hope) all you are learning is a new standard library and syntax, books will just harp on about data structures and algorithms.
>>
>>59434150
even experienced python programers will benefit from reading a good boodl. python has a number of gotchas and best practices that are not obvious to people from other languages. the fact that you think you can learn everything via trail-and-stackoverflow is somewhat worrying
>>
>>59434150
stupid comment but true
>>
Quick question.

string s = "";
string x = "%";
int y = 0;
Stopwatch test = new Stopwatch();
test.Start();
for (int i = 0; i < 1000; i++)
{
Thread.Sleep(1);
if (i % 100 == 0)
{
y = y + 10;
s = s + "-";
Console.Write(s+y+x);
}
}
test.Stop();
Console.ReadKey();


Instead of -10%--20%---30%----40% etc, how do I make it so that it shows ----40% etc, but changing constantly.
>>
>>59433176
kek GC of D is optional. Can't say the same thing about Java...

Furthermore D can use C/C++ libraries and performs x20 faster than Java.
>>
>number of useful software written in rust
....

>number of useful software written in C
linux, bsd, gcc, quake, etc
>>
On a side question on Python; I am supposed to use Matlab for Analogic Control Lab. But I've heard you can do everything in Matlab better on Python. Is this true or should I stick with Matlab for this specific assignment?
>>
>>59434211
b..but they are rewriting emacs in rust
>>
>>59434197
luckily he's not an experienced programmer yet so he doesn't need to know why doing X in some extreme circumstance is worse than doing Y
>>
>>59434211
By this logic Java, C++, JS and C# makes C pretty irrelevant
>>
>>59434203
carriage return
'\r'
>>
>>59434211
>number of 0days found in other languages
n
>number of 0days found in C
97n
>>
>>59434203
write enough newlines so that the console is refreshed and it appears to be in the same location. or just don't do what you're trying to do
>>
>>59434211
Don't forget DOOM.
>>
>>59434240
I feel retarded that it's such a simple solution. Could you explain what actually \r does?

>>59434263
Why?
>>
>>59431409
How the heck?

No, seriously, I might learn things
>>
>>59434238
Java/C#/JS don't run on the bare hardware and C goes usually together with C++.
>>
>>59434296
because you don't understand that you're not creating some type of gui object, you're just outputting characters to a stream
>>
>>59434308
Who was talking about "bare hardware"?
>>
>>59434296
Sets the cursor back to the beginning of the line so you can write over characters already there.
>>
>>59434302
Stick to anime /dpt/s
>>
What advice would you give to someone who has to understand a complex project made by someone else?

I'm a beginner at Spring and I'll have to work on a project already made for my internship. I understand most of the things but not how to project works (like what this class does and for wich purpose)

It's the first time I'm working on someone else project so I was wondering if there was a correct methodology on this.
>>
When is it "allowed" to use a singleton?

I'm writing a game (and its accompanying engine) in order to learn OpenGL, and have a class called ResourceManager that's used for managing resources (textures, materials, various game data, etc) whenever another class needs to load or fetch loaded resources.

Since almost every class accesses some resources, up until now I've been passing a reference to the resource manager in every constructor where it's needed. What would the disadvantages be if I were to transform it into a singleton instead of passing references all over the place?
>>
>>59434255
And here I thought our super smart turbo (((expert))) kernel hacker master C programmers don't make mistakes
>>
>>59434393
Passing argument is more flexible but it's cumbersome and less optimal (except if the compiler is a marvel).
>>
>>59434427
>Passing argument is more flexible
In what way? I find it quite tedious to pass it around to over 9000 intermediary classes just because another class at the other end have to use it a single time.
>>
>>59434505
>In what way?
You can, when you want, change it, duplicate it etc. But if you'll never need that just it would be useless.
>>
>>59434393
>>59434505
>when should I use global state?
when it makes sense
>>
>>59434520
Ah, yes, I see. If that's the major advantage of not turning it into a singleton, I'll probably turn it into one. It never changes, which means that I really can't find any downsides of making it into a singleton.

>>59434558
Obviously. I just wanted to make sure I hadn't neglected any aspects.
>>
File: 1483239533988.png (358KB, 389x507px) Image search: [Google]
1483239533988.png
358KB, 389x507px
I'm trying to free up an array of pointers in C, and running valgrind comes back clean.
However, to do this, because I don't know what indices have been allocated to and which ones haven't when I'm freeing, I'm doing
if (ptrarr[i] != NULL)
free (ptrarr[i]);

inside of a for loop.

This spits back
Conditional move or jump depends on uninitialized value(s)


Reading the valgrind documentation tells me that this error could be serious or fairly innocuous, as it just means the execution of the program went down a different branch due to said uninitialized value.
Since I'm basically checking to see if that index is initialized or not, that's obviously what's happening. If it finds one that isn't, then it does something different.

TL;DR Is there a better way to check if a pointer has been allocated or not than doing an if != NULL check?
>>
>>59434622
as long as you initialized all pointers as NULL you should be ok.
>>
>>59434622
Always NULL the pointers if they're not going to be used immediately.
>>
File: crlf.jpg (39KB, 512x384px) Image search: [Google]
crlf.jpg
39KB, 512x384px
>>59434296
>what actually \r does?
In a classic typewriter, you had to carial return, to have the “cursor” back to the 1st char, then line feed to get to the next line. That’s why you have to get CR+LF at the end of a line on Win to get a “true newline”. Nowadays, in the UNIX world, and maybe in the Win terminal too, \r “return” to the beginning of the line, so that you can “write over” the previously written text, and that precisely what you’re looking for. So, just add it at the beginning of your text
>>
>>59434318
So? You can draw with console. A loading bar like this is fine.

>>59434335
Thank you.
>>
>>59434600
For a game you'll probably never need to duplicate or locally change the resource manager. So you can use a global variable. I just hope that you'll never regret it.
>>
>>59434392
Depends. If you have access to another developer who knows the project, ask her questions like crazy. Otherwise, look at unit tests, pick a piece of text in the UI and trace it through the code to see how it got there (and repeat), drop debug statements everywhere, grep for usages...welcome to the nightmare of maintenance engineering
>>
>>59434622
Oh and as a side question:
Is it even necessary to do != NULL? Can I just have if(ptrarr[i]), since if its not NULL or 0 it should be considered "true"?

>>59434646
>>59434666
I'm declaring the array as
char* ptrarr[LENGTH];

and assigning into each index with
ptrarr[i] = (char*)malloc(strlen(tok)+1);

Should I run a loop right after declaration to assign each to NULL or something?
>>
>>59434684
>Instead of -10%--20%---30%----40% etc, how do I make it so that it shows ----40% etc, but changing constantly.
that's what you initially said you wanted, which isn't achievable by just a newline. a newline would make it
-- 10%
----20%
etc

you originally wanted it to be
--10%
and then the 1 magically changes to a 2 when it goes to 20%
>>
>>59434705
Checking for NULL lets you and other readers instantly know you're checking for a null pointer, Keep it if you care about readability.
>>
>>59434705
>Should I run a loop right after declaration to assign each to NULL or something?

most definitely

if you don't initialize with a value immediately always initialize to NULL

other wise you could just get random data
>>
>>59434701
> her
I wish anon, I wish.

But yeah I'm working with the team that created the project and they're pretty nice. It's just that sometimes I feel like a retard for asking questions with obvious answers (sometimes I block on something really stupid) but it's why internships were created so I'll just have to swalllow my pride instead of blocking for hours.
But yeah tracing shit is a good idea, I'll do that.
>>
>>59434721
I never said I wanted to write it in a new line.
>>
>>59434727
Noted

>>59434746
Would have thought that would have been implicit on declaration. Slapped one in and all the warnings went away though.
>>
>>59434622
Stop using brainlet language
>>
>>59434698
Wish me luck!
>>
File: 1222642172997.jpg (9KB, 121x125px) Image search: [Google]
1222642172997.jpg
9KB, 121x125px
>>59434821
>>
>>59434821
Stop being retarded.
>>
>>59434727
>other readers
that don't know C?
>>
>>59434622
C tards busy with irrelevant autistic garbo while real men are busy getting shit done
>>
>>59434844
>I don't wanna learn what a computer is actually doing, I just wanna write it all in python and let the interpreter figure it out! ITS MAGIC!
>>
>>59434865
>It's another programmers pretending to be EE episode
>>
>>59434791
i never said you wanted that, i said you wanted it to magically update. in fact i said you explicitly DIDNT want that. you utter idiot
>>
>>59434827
Luck has nothing to do with coding.
>>
>>59434872
>It's another skiddie pretending to be CS episode
>>
>>59434834
Only oeople using C in 2017 are retarded
>>
>>59434902
>It's another CS pretending to not to be a skiddie episode
>>
>>59434929
That's the kind of statement that help me to recognize code monkeys at first sight.
>>
>>59434968
What are you using C for?
>>
>>59434968
That's the kind of statement that help me to recognize NSA shills at first sight.
>>
File: 161093861073.jpg (24KB, 227x173px) Image search: [Google]
161093861073.jpg
24KB, 227x173px
>>59434929
Retard.
>>
>>59435043
Not him but consider you are going to start a project. Why are you going to use C?
>>
>>59435001
Low level.
>>
>>59435061
>Why are you going to use C?
I would be working on a kernel or hardware drivers.
>>
>>59435066
>>59435071
You can do that in C++.
>>
>>59435094
>You can do that in C++.
wrong
>>
>>59435094
>C++
C++ is a pile of wrong design choice.
>>
>>59435104
no.
and it would probably work better than whatever pointer pasta you come up with in c.
>>
>>59435104
How? And what are the chances that you are programming a micro controller
>>
>>59435066
>>59435071
Thanks to you, IoT is full of backdoors.
>>
>>59435130
>C++ doesn't use pointers
>>
>>59435183
less than C in any case.
>>
What will Rust shills do once Mozilla finally goes bankrupts?
Are xey doing it for free anyways?
>>
>>59435202
Fuck off NSA
>>
>>59435202
Shill Servo like there's no tomorrow.
>>
File: 1361734873016.gif (3MB, 278x296px) Image search: [Google]
1361734873016.gif
3MB, 278x296px
>>59435061
Because instead of losing your time finding a way to use the gimmicky features of certain languages you can actually focus on how your program will work using simple and meaningful elementary programming "bricks" much like building something with Lego.
>ASM can do that too
C removes most of the thing you have to worry about in ASM.
It is an excellent compromise between simplicity and powerfulness.
The people hating on C never tried to understand it. They prefer to hide their inability to write productive code behind a shitload of unnecessary concepts that makes you look clever when you brag about it online.
Never trust someone who hates C.
>>
Does g++ compile these two code snippets into the same executable?
calculate1(foo());
calculate2(foo());

int n = foo();
calculate1(n);
calculate2(n);

I.e. does the two function calls in the first example get optimized into a single one?
>>
>>59435242
I love you anon.
>>
>>59435242
>void*(pointer*)(void*(pasta*)(void*))
>>
>>59435275
Depends on register allocation but it should. Why don't you see for yourself? Build with the -S flag and it will generate assembly.
>>
>>59435275
Depends if it can deduce that foo() is pure.
>>
>>59435242
>C removes most of the thing you have to worry about in ASM.
This.
>It is an excellent compromise between simplicity and powerfulness.
Not this.
>>
>>59435299
>what is a typedef
>>
>>59435242
>you can actually focus on how your program
You are right. Instead of producing actual software you focus on "how you program" like this c tard here >>59434622

>C removes most of the thing you have to worry about in ASM.
Modern languages remove most of the things you have to worry about in C

>It is an excellent compromise between simplicity and powerfulness.
No, C is a timesink, a worthless one unless you are developing a microcontroller

Never trust someone who posts anime
>>
>>59435299
And yet you probably never saw something like this nor had to write C code using this kind of statement.
>>
>>59435324
>#define TYPEDEF_POINTER_PASTA typedef void*(pointer*)(void*(pasta*)(void*)) pointer_pasta;
>>
>>59435324
Thinks you don't have to worry about in 2018 no #56
>>
>>59435337
if you're declaring a function pointer you do
>>
>>59435325
>Never trust someone who posts anime
That's why 4chan should never had been taken seriously.
Do you think "anime website" is a fucking joke?
>>
>>59435344
And it's not something you have to break your mind to understand.
>>
File: FYvmeBK0_400x400.jpg (21KB, 400x400px) Image search: [Google]
FYvmeBK0_400x400.jpg
21KB, 400x400px
>>59435325
Ah yes, the now infamous anti-C shill is onto me because I just spoke the truth.
That's the only reply you'll get from me until you educate yourself.
>>
>>59435344
What's the point of function pointers if c barely supports things like delegates, callbacks etc
>>
>>59435382
>loose argument
>"anti-c shill"
Anime posters, everyone
>>
>>59435394
>>loose
Learn English Pajeet
>>
>>59435384
You do realize that delegates and callbacks are glorified names for (or for procedures that use) function pointers, right?
>>
>>59435384
what do you mean barely supports?
>>
>>59435403
Boy oh boy you successfully found a typo, Are you going to celebrate this even by watching some naruto?
>>
>>59435413
It's "glorified name" because your shitty language barely supports anything advanced like that

>>59435422
What's the standard syntax of a closure?
>>
Why would you even learn anything higher level than other other than OCaml? Here's the quick rundown:
>Haskell developers bow to Xavier Leroy
>used to implement the calculus of inductive construction which is the ultimate step in unifying formal verification
>utop is the greatest top-level interpreter of all time
>used to run banks and financial servers all around the world
>the community implemented a formally proven web framework in Coq
>makes every user gain 10IQ points by day using OCaml
>in reality it is a timeless language which will allow humanity to move onto Mars and beyond
>>
>>59435452
>What's the standard syntax of a closure?

just put a fptr and void pointer together
>>
>>59435452
>advanced
Your language hides function pointers by wrapping them in delegates, and you think it's C's fault. Right.
Nice try.
>>
>>59435465
That's not what it looks like
>>
>>59435464
>level than other other than
I meant
>higher level than C other than
>>
>>59435464
>(((impure)))
nice try, rothschild
>>
>>59435426
>even
Apply yourself Pajeet before arguing on things you don't understand.
>>
>>59435452
A closure is a function pointer without a name to hold it, retard.
>>
>>59435478
Not an argument. You can program purely in OCaml.
>>
File: Your brain on anime.png (72KB, 928x359px) Image search: [Google]
Your brain on anime.png
72KB, 928x359px
>>59435472
That's the most retarded thing I've read in a while. Not surprised it's coming from a C tard
>>
>>59435464
I'm a professional OCaml coder.
>>
>>59435497
>can
>must
>>
>>59435498
What is a delegate but a variable holding a function pointer with a compile-time typechecker?
>>
Wait
c has standard anonymous functions?
>>
>>59435498
>>59435435
>>
>>59435478
Oh, so it's impure even. I thought they had better standards. Now it's clear that I was deeply mistaken.
>>
>>59435517
C doesn't have delegates
>>
>>59435517
Aren't C function pointers typechecked too (assuming you don't cast)?
>>
>>59435541
It doesn't
>>
>>59435510
Only non-brainlet in thread.
>>
New thread when?
>>
>>59435569
C doesn't have anonymous functions? How do they use closures?
>>
>>59435579
Pointless to make more threads as long as the shills are awake since they will invariably turn to shit.
>>
>>59435515
>he allows himself to be limited by his compiler
>>
>>59435571
Only a brainlet would program in a language with POO support.
>>
>>59435558
I never said that. My point is tgat delegates are syntatic sugar and could be even implemented in C.

>>59435561
Yes but they don't have fancy names to fool idiots
>>
>>59435593
>not having cancer built-in is a limitation
>>
>>59435593
Yes, I made the compiler to limit myself. That is precisely what compilers are for.
>>
>>59435612
>could be even implemented in C.
keep waiting
>>59435591
By using a compiler extension. What a fucking joke
>>
>>59435579

>>59430383
>>
>>59435591
ASM doesn't have garbage collection? How do they make lists?
>>
>>59434622
free(NULL); is perfectly legal (i.e does nothing), your check is useless.
>>
>>59435623
>>59435628
>he can't do something as simple as modifying state
>he will never be a computer god
>>
>>59435629
>By using a compiler extension
kek I new C was shit but this is a different level
>>
>>59435654
>he can't embed stateful operations in a pure fashion as a generic datatype structure and have the compiler convert it to efficient machine code
sad!
>>
Swear to God anyone who shitposts in next thread gets instantly reported. Stop ruining my dpt REEEEEEE
>>
new thread
>>59430383
new thread
>>59430383
new thread
>>59430383
>>
>>59435654
It's clear that you have never programmed in either Haskell or OCaml. It's simply retarded to claim that they don't "modify state".
>he will never be a computer god
I already am, at least compared to plebeians like you.
>>
>>59435704
kek your thread is so shit
>>
>>59435718
it's not my thread
>>
can someone make a non anime new thread?
>>
>>59435761
No. Shut up.
>>
>>59435805
kys pedophiile
>>
>>59435761
Sure, here you go.
>>59430383
>>
>>59435384
C does not support closures at all, but it does support callbacks just fine. You don't need closures in order to make function composition useful, closures are often nothing more than a nice-to-have. Check out C's qsort for example. Another example is a dispatch tables.

>>59435413
"Callback" is often used in a more specific way than "function pointer". As for delegates, they allso allow multicasting, at least in C#'s implementation.

>>59435612
Most other features in HLL's are syntactic sugar from that POV, so it's a pretty pointless argument to make. What really makes a difference is usability. Baked in features are usually done with the whole language design in mind rather than as an afterthought (the obvious exception here being C++) and often leverage each other to make a cohesive whole.
>>
>>59435591
Why would you need closures in C?
>>
>>59435968
Not enough UB. The funarg problem would be an excellent opportunity to fuck with devs even more.
Thread posts: 342
Thread images: 38


[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.