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

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

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 846 KB, 1200x1600, Edsger_Wybe_Dijkstra.jpg [View same] [iqdb] [saucenao] [google] [report]
61939273 No.61939273 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Old thread: >>61932358

>> No.61939306

I'm attempting insertion sort without copying psuedocode, what am I doing wrong?

void insertion_sort(int *arr, int len)
int i, j;
for (i = 1; i < len; i++)
j = i;
while (--j)
if (arr[j] > arr[i])
int tmp = arr[i];
memmove(&arr[j + 1], &arr[j], i - j);
arr[j] = tmp;

>> No.61939311

Porting dwm to wayland.

>> No.61939336

iirc dwm is a single 2k loc file

>> No.61939340
File: 44 KB, 643x220, dijkstra.png [View same] [iqdb] [saucenao] [google] [report]

Way too early edition

>> No.61939345

Replace that while with a for.
Create a swap function.
Don't use fucking memmove.
Use RAII, i.e. declare variables where they're used, unless you're writing C89.

>> No.61939395

mine will have even less code since I'll be using libweston. it's the equivalent of libxcb or libx11 that dwm uses except it's lighter.

>> No.61939399

I wish I was an accompilshed science fella
that way I could be an edgelord like nigguh Edsger

>> No.61939400

Is there an easy way to simulate manual reset events under linux?

I have a circular buffer implementation that I wrote for windows and it uses SetEvent and ResetEvent to make the producer and consumer threads block when the buffer is full or empty.
How would I port this to linux without just polling?

>> No.61939416

Is it weird that I find Dijsktra kinda hot?

>> No.61939429

He isn't exactly a trap

>> No.61939444

(therefore you are gay)

>> No.61939479

>use RAII
There's no opportunity to use RAII at all here. He can't construct an object lifetime for the incoming array. That'd be madness.

>> No.61939495

But I'm a girl..

>> No.61939501

Can any rust fags recommend me a book?

>> No.61939514

Tons of young girls like older not obese men for whatever reason. And yes it's weird and you should be ashamed.

>> No.61939555

i totally believe you are a girl(boy)

>> No.61939614
File: 509 KB, 440x330, 1499806181420.gif [View same] [iqdb] [saucenao] [google] [report]

>tfw finished remaking my shit algorithm
>it's now much less shit
is there a better feeling lads?

>> No.61939637

>Hurr Durr girl devs don't exist.

>> No.61939654

now make the code more concise and the comments more verbose

[citation needed]

>> No.61939674

>now make the code more concise and the comments more verbose
on it
this mess is spread amoungst 3 different functions and makes no sense whatsoever

>> No.61939969

prove it then.

pro tip: you can't.

>> No.61940025 [DELETED] 

>What are you working on
Watching and reading about politics in America all day long.
Why can't I get away from this shit?

>> No.61940061

nice blogpost how can i subscribe

>> No.61940074
File: 292 KB, 1140x813, 15026422252132.png [View same] [iqdb] [saucenao] [google] [report]

Don't forget these

>> No.61940448

is he just hoping that the uninitialized data section he's reserved for the string will have the input terminate with a 0, or does fgets append a 0 to the end of the user's input? if the former, what if the user puts in exactly the maximum number of characters to fit in the section?

>> No.61940455

Post penis then or no one will believe you

>> No.61940498

I'm reading book on C before my semester starts.
2 chapters in, did bunch of programming exercises from that book using Pelles C and now at the end of the 2nd chapter they decided to talk about common errors?
Seems kind of dumb since I encounters almost every error they're describing during those exercises.
But the other thing is that author says that he has a compiler that tries to fix syntax errors automatically. Wouldn't that be a bad thing for students to have auto correct on?

>> No.61940568 [DELETED] 

/dpt/ is such a great thread for reminding myself that no matter how dumb I sometimes feel when programming, even me five years ago was much, much smarter than most /dpt/ posters

>> No.61940580

>he has a compiler that tries to fix syntax errors automatically
Why would anyone want that?

>> No.61940672

>programming for at least 5 years
>still coming to /dpt/
That's like winning special olympics

>> No.61940688

I am glad my self confidence isnt bad enough to come to threads to compare myself to others to feel better.

>> No.61940766
File: 12 KB, 232x271, 979829185795752325.jpg [View same] [iqdb] [saucenao] [google] [report]

This desu senpai baka
The guy can't even banter without making a fool of himself.

>> No.61940797
File: 199 KB, 1024x768, google git contributions.png [View same] [iqdb] [saucenao] [google] [report]

they are rare in the wild, something akin to a galapagos turtle. they only appear to breed and then they disappear afterwards

>> No.61940824

If I am doing this: card test = new card{.rank = ranks[Rank::King], .suits = ranks[Suit::Heart]}; in the main function, do I have to delete test? test is a struct.

#include <iostream>
using namespace std;

enum class Rank {

enum class Suit { Club, Diamond, Heart, Spade, count };

int ranks[Rank::count] = {Rank::Two, Rank::Three, Rank::Four, Rank::Five,
Rank::Six, Rank::Seven, Rank::Eight, Rank::Nine,
Rank::Ten, Rank::Jack, Rank::Ace, Rank::Queen,
int suits[Suit::count] = {Suit::Club, Suit::Diamond, Suit::Heart, Suit::Spade};

struct card {
int rank;
int suit;

void print_card(card this_card) {
// unimplemented

int main() {
card test = new card{.rank = ranks[Rank::King], .suits = ranks[Suit::Heart]};
return 0;

>> No.61940899


Oh, there's plenty of female devs these days... but female 4channers? Much less likely.

>> No.61940919

is it true OSGTP is a Haskell shill now?

>> No.61940947

Go back to plebbit, fucking faggot

>> No.61940962

4chan's majority userbase is school going girls actually

>> No.61940963

Have you seen /u/ or /cgl/?

>> No.61940978

why create enum classes if you are going to declare the arrays like that, use a loop bro

>> No.61940998


Exceptions to the rule. /soc/ also has a few girls, but boards like /g/? Pretty much just men and traps.

>> No.61941015


>> No.61941017

Just started learning Java coming from C and IntelliJ is comfy as fuck

>> No.61941048

sauce on pic?

>> No.61941056

I'm sure he has a nice firm ass and giggles when you grab it though.

>> No.61941112

For some reason I'm convinced that most of those posters are men whose lesbian fantasies have deluded them into posting as "women".

>> No.61941121
File: 303 KB, 800x485, 1502565217110.png [View same] [iqdb] [saucenao] [google] [report]

What is the best programming language if both my development time and my hardware resources are limited?

>> No.61941130

wanna port posix to sel4 on aarch64 together?

>> No.61941145
File: 29 KB, 600x600, 150204048302.jpg [View same] [iqdb] [saucenao] [google] [report]

What's your excuse for not using Go?
>super comfy to program in
>strong concurrency
>expressive like a scripting language, fast like a compiled one
Literally no reason to not use Go.

>> No.61941146


>> No.61941150


>> No.61941160

kill yourself

>> No.61941169

>What data types would you use to represent the following items: number of
children at school, a letter grade on an exam, the average number of school
days a child is absent each year?
I answered int, char, int.
Solutions says. int, char, double.

Who is right here?

>> No.61941171

Go is for literal brainlets, it's been well established. Furthermore it's a mediocre language, only alive because of google pushing it, Now fuck off

>> No.61941173

>retarded vermin: the language
I'll pass

>> No.61941181

Don't post your homework here.

>> No.61941189


I'm going to be honest... as fun as that might sound, I'm starting a PhD program in 5 days, and my advisor has recommended that if I want to become a professor (which I already told him), that I should publish a paper every semester. I'm going to be very, VERY busy with research.

>> No.61941193

Nobody, how you choose to represent data is up to you.

>> No.61941198


>> No.61941233

I mean double isn't wrong in that case but just because it's average doesn't mean you have to use double.
>average amount of students in school at any given time
Not aesthetic

>> No.61941250

int, float, float

>> No.61941255

Lolol no generics

>> No.61941263

even if it had you wouldn't use it


>> No.61941268
File: 35 KB, 400x400, 1501743893143.jpg [View same] [iqdb] [saucenao] [google] [report]

Using go is like a statement. A declaration that says "I'm an idiot"

>> No.61941269

Just tried the Jackson JSON library for the first time. Recursive object (de)serialization is refreshingly concise and flexible.

>> No.61941283

Nim... assuming it's not a large project

>> No.61941286


>> No.61941296

Go is a disservice to intelligent programmers. It's an insult to human brain

>> No.61941309

not an argument.

try again, kid.

>> No.61941317

The fact that it has less support of generics than C89 is pretty embarrassing
>Let's take the control away from the devs
>Also let's take the abstraction away too
>lul u don't need them
>"Our language is made for people that don't understand brilliant languages"
Go is the true cuck language

>> No.61941347


And what are we supposed to do, create our own vector type for every type parameter we'd want?

>> No.61941350
File: 1.70 MB, 532x7428, screenshot-nomad.so-2017-08-17-10-38-10.png [View same] [iqdb] [saucenao] [google] [report]

dumb brainlet

>> No.61941367

Damn, google shills

>> No.61941374

Lolol fgt who doesn't meta program detected

>> No.61941379

C#, seriously

>> No.61941381


>> No.61941386

its ok ruby senpai, i'll wait for you <3

>> No.61941393

Memes aside, Go is basically the new Java. It eschews a lot of important modern concepts like generic programming in order to make it easy to use for the idiot code monkeys that Google usually hires. The end result is a potential increase in code complexity instead of a decrease.

>> No.61941394

Not an argument.

>> No.61941395

You mean python, right? It's lighter than C#

>> No.61941406

>hardware resource limited
>lmao let's shill him our rebranded java that spawns a 300 Mb GC before even doing anything xd

>> No.61941410

.NET Core is objectively superior to Python in multiple metrics.

>> No.61941425

>python still lighter than botNET core

>> No.61941479

>lmao let's shill him our rebranded java that spawns a 300 Mb GC before even doing anything xd
I work with C# and this is true, sometimes the GC doesn't work as efficiently as it should. It is still a pretty easy and quick language to develop to though.

>> No.61941499

You can make that argument when Microsoft relinquishes their software patents.

>> No.61941509

In Java's defense, it was originally created a long time ago, and they've tried to keep it backward compatible.

Go has no such excuses.

>> No.61941583

i dont think you know what that means

>> No.61941586


Thanks all, will consider (except >>61941160

>> No.61941622


Why would they need to relinquish their patents? They've already given you free license to use their product however the hell you want, and to modify it as you please, so long as you don't try and claim a patent over their shit (Apache 2 License)

>> No.61941749

>write any program more complicated than a simple exercise
>main class ends up being >1000 lines
What can I do to stop this from happening?
If I try to split the main class into smaller classes then I run into the issue that methods from the smaller classes all need to use certain functions.
Then I run into the issue of having to make a header file full of static functions to include in all those classes and it seems kinda stupid.

>> No.61941761


Apache 2 has a patent grant clause as well so... they already kind of have relinquished their patents?

>> No.61941785

Just making everything static famlam. Objects are for losers.

>> No.61941803


Guess so. .NET Core is sort of a mix between MIT on some parts and Apache 2 on other parts. Either way, it's all GPLv3 compatible.

>> No.61941824

>guys we super duper promise not to sue you for technically violating our intellectual property rights, pinky swear

Nah. No one's that stupid. There's a reason Mono hasn't even taken off with official backing.

There's probably no difference if you only develop for Microsoft platforms though.

>> No.61941861

>use OOP
>code is ugly and overengineered

really makes you think

>> No.61941869

I'm kind've getting to the point where I don't like even using enums because it's a huge pain in the ass to have static casts riddled everywhere throughout the code.

>> No.61941897


They legally can't sue you for it now though. In releasing .NET Core under a permissive license, and buying up Mono and continuing to release it under a permissive license, they have revoked their right to sue for patent infringement for using or modifying those products. Your article from the FSF is out of date because all of these products are in Microsoft's hands. You can't just give someone something and then sue them for using it under the terms that YOU agreed upon.

>> No.61942023

You make it sound like a Java problem and then go on about header files. What exactly is your problem? "the smaller classes all need to use certain functions" doesn't explain shit.

>> No.61942031

fgets writes a string, so it is always null terminated
It will only read up to the storage size minus 1 byte for the null terminator, so the last character will still be in stdin if that's where you're reading from

>> No.61942039

>You make it sound like a Java problem
literally wat
>the smaller classes all need to use certain functions" doesn't explain shit.
How doesn't it?

>> No.61942041

>You make it sound like a Java problem and then go on about header files.
kek at first I thought he was talking about Java or C# too

>> No.61942184

Where do you get your books from /dpt/? If you know what I mean

>> No.61942200

i do not know what you mean, please elaborate???

>> No.61942201


I pay for them you commie.

>> No.61942211

Books are communism themselves, there's no denying this

>> No.61942214

not in my book

>> No.61942217

>not googling every single detail of every language

>> No.61942225

literally book_name.pdf in your search engine of choice.

>> No.61942240

Your books is trash

>> No.61942255
File: 11 KB, 328x277, 94522245.jpg [View same] [iqdb] [saucenao] [google] [report]

>not just downloading the documentation and learning from that

>> No.61942271

book is inherently communism

>> No.61942307


Show your working..

>> No.61942333

No I won't. I'm not a commi

>> No.61942334
File: 60 KB, 550x366, 2014_was_20_years_ago.jpg [View same] [iqdb] [saucenao] [google] [report]

James how do I become a good programmer. I try to learn Go but it is too hard. ;_;

>> No.61942373


Okay, this is twice that you have called me James. Who the hell is this person, and why do you have me mixed up with him?

Also, why the hell are you trying to learn Go?

>> No.61942383


>> No.61942386
File: 37 KB, 1127x685, sad_pepe_at_the_computer.png [View same] [iqdb] [saucenao] [google] [report]

>Who the hell is this person, and why do you have me mixed up with him?
I dunno, you just seem like a James to me.
>why the hell are you trying to learn Go?
Because Go is supposed to be super comfy ;_;

>> No.61942395

And if you want to make your own C# implementation for whatever reason, you're still fucked. Microsoft realized it can't kill free software in the same hamfisted manner it killed its proprietary competitors, so it's trying to reign it in by abusing it like it does its own paying customers.

Not that I care of course, since the FOSS community doesn't want it anyway, like I said before. Go respects your rights if you want to be treated like an idiot by your computer. :^)

>> No.61942396

You are misguided

>> No.61942409


>> No.61942411

You were lied to mr fin.
Give Nim a shot, its pretty brainlet friendly.

>> No.61942421


Well you shouldn't go around calling people random names. If you will look in the name field, you will see I am called Ruby. If you want to call me Anon just like everyone else, that is fine too. But go making up new names. That's almost as bad as people calling me a girl.


You fuck off with that shit too.

>> No.61942423

Or D

>> No.61942444

But James, I just wanna know how to become a good programmer. ;_;

>> No.61942449


>And if you want to make your own C# implementation for whatever reason, you're still fucked
Nope. What part of free as in freedom don't you get?

>> No.61942454

>I am called Ruby
That's gay.
Being a tripfag is also gay.
You're double gay.

>> No.61942461

>crying about people calling you a random name
Youre such a hypocritical twat, if you didnt want the attention, you wouldnt be using a trip.

>> No.61942467

>license = patent
I'm not a lawyer, but I'm pretty sure these two things are not the same.

>> No.61942468

>What part of free as in freedom don't you get?
I'm not american, sorry.

>> No.61942473


Don't get shirty James.

>> No.61942478

You must be willing to suffer. "It's too hard" is the excuse everyone uses.

>> No.61942488

feeling frisky huh? post boipucci pls

>> No.61942518

>That's almost as bad as people calling me a girl.
I thought you were a girl?

>> No.61942550

spending this much time on a hobby that will at best get you the job of a code monkey

>> No.61942556


Write code and read other people's code, and you will eventually become a good programmer.


Don't be a cunt, David.


A. This is a blue board
B. No.


I'm not.

>> No.61942559
File: 110 KB, 1280x720, 1483073157801.jpg [View same] [iqdb] [saucenao] [google] [report]

Employed Haskell programmer here

>> No.61942571

What language do you use at work?

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

>not using the proper image
It's like you aren't even trying.

>> No.61942591
File: 100 KB, 821x695, 979839377774978999.jpg [View same] [iqdb] [saucenao] [google] [report]

>Remember that while MD5 and SHA-1 are both popular hash functions, MD5 is considered completely broken, SHA-1 is considered weak. SHA-2 and its variants are to be crowned the new king.
What did they mean by this?

>> No.61942594

>I'm not.
I don't believe you, it seems unlikely that you're male.

>> No.61942606


>> No.61942609

it means computers have gotten fast enough to brute force a colliding hash in the space of a few months instead of millions of years as previously predicted

this is going to keep happening until the end of time

>> No.61942610

The only male thing about him is his fem penis.

>> No.61942618

Actually SHA-3 is the new standard

>> No.61942623

Best Python talk: https://www.youtube.com/watch?v=uqsZa36Io2M

>> No.61942643

So can I still use MD5 to find duplicated files? SHA-2 seems to be slow.

>> No.61942644
File: 102 KB, 425x450, fug.jpg [View same] [iqdb] [saucenao] [google] [report]

Anyone here gave up on video games? I'm trying to get serious but I always have an urge to play. Longest I can go without games is like 3 days. I'm 28 already and I need to give up games and do shit with my life. I am also addicted to browsing 4chan

>> No.61942650

At what point do you know that you know the language to at least land you junior position?

>> No.61942655

When you've been working in a junior position for about a year

>> No.61942657

I'll give things up for weeks at a time in order to work on a project but then I burn out and go back to video games or anime.
Why would you want to stop doing something you enjoy?

When you can use it without looking up the standard library every 10 seconds.

>> No.61942658
File: 445 KB, 424x453, 443174864598.png [View same] [iqdb] [saucenao] [google] [report]


>> No.61942659


23, they do nothing for me anymore. Blocked all social media websites except dpt.

>> No.61942666

SHA-3 is faster than MD5

>> No.61942667
File: 92 KB, 560x555, sadness.jpg [View same] [iqdb] [saucenao] [google] [report]

What is the best programming language if both my development time and my hardware resources are limited?

>> No.61942671

>I'll give things up for weeks at a time in order to work on a project but then I burn out and go back to video games or anime.
>Why would you want to stop doing something you enjoy?

So you live a more fufilling life than just short term pleasure to your 30's, then testing how strong the light fittings are.

>> No.61942673

thats the wrong way to go about it, desu.
You shouldnt dev 24/7 and completely give up vidya.

>> No.61942675


>> No.61942680

C++17 if you mastered the STL and Boost

>> No.61942687

What's a fulfilling life to you?
Time you enjoyed wasting is time not wasted.

>> No.61942688


How limited? And what kind of project is it for?

>> No.61942696

I'm not talking about going hard on programming 100%, gaming is just too addictive and I would love to change it with something I can stop doing after an hour.

>> No.61942701

Yes, the chance of an accidental collision in a set of files with MD5 is zero in practice.

>> No.61942707

Consider if that I need to be productive enough to complete tasks quickly, and the program needs to run with minimal resources.

>> No.61942713

Try Dota 2. It's so aggravating that you'll force yourself to play less anyway.

>> No.61942717

Does that require a special set CPU instructions to be that fast? If so, I'm out.

>> No.61942727

Ruby when did you become a guy?

>> No.61942731

Do you only play multiplayer or something?
I started appreciating games much more after I went all single player.
Online gaming becomes a repetitive blur and hanging out with stupid kids and 23 year old neets isn't fun.

>> No.61942734


Spending time with friends, working out and taking responsibility for the people around you. Once you start that depression death spiral it's super hard to come out of it.

>> No.61942736


>> No.61942738
File: 173 KB, 600x355, old_hag_langs.png [View same] [iqdb] [saucenao] [google] [report]

Still waiting, "Fortran programmer".
>C for retards

>> No.61942747

>i'm having a midlife crisis in my 20s

get a grip you loser

>> No.61942749

Pascal is a semi-pseudo language though.

>> No.61942766

>Once you start that depression death spiral it's super hard to come out of it
Jesus Christ, go see a therapist then.

t. guy who saw a therapist and is now on anxiety meds and feeling legitimately happy for the first time in years.

>> No.61942767


You just repeated your original requirements without expanding upon them as asked for. What is the project? What is your deadline? How limited of computing power do you have to deal with?


When I was in my mother's womb.

>> No.61942768

Exactly why no one likes it, similar to how no one like Skank-nako

>> No.61942773

Don't fall for this memelord.

>> No.61942779


I come out the other end bro, but your advice is correct.

>> No.61942783

I don't want to give too much details. I just want a general purpose programming language that has high programmer productivity and minimal resource usage with speed.

>> No.61942788

Yes, but when did you transition?

>> No.61942797


>> No.61942806

I thought therapy was a meme too, but actually talking about my fucking problems with an actual doctor instead of random Anons on the internet a c t u a l l y h e l p s.

The meds wouldn't have been nearly as effective without the pep talks.

>> No.61942810

he said speed.

>> No.61942823

I know that many dynamic languages, like Python and JS, are slow, but SBCL happens to be very fast.

>> No.61942836

I'm actually trying to learn C. I tried to write an ncurses app today.

>> No.61942844

The last time, i was showed benchmarks which put it 9/10 times slower than java.

>> No.61942859

I play bunnyhop maps on csgo. Literally waste 3 to 4 hours a day on it. I waste 4 more hours watching videos and browsing 4chan.
dota doesn't give much pleasure per minute since you spend time dead so much. It feels like a time waste. For the same reason I don't play ranked csgo.

>> No.61942887

So, in Linux there are full fledged programs (not just libraries) that are installed as a dependency of bigger programs. for example, ffmpeg is required for many video tools.

I want to use radeonsi-git as a back end to my task manager. radeonsi is a full fledged program on its own. How do I integrate this program to mine? How would I call radeonsi from my program?

>> No.61942898

This I hate to say it but I'm literally becoming a "dad". Term /edg/ uses for middle aged guys who only have few hours a week to play.

>> No.61942899


Performance and programming time both fit on a spectrum, so it's very difficult to guess what you need. If you're working on a machine where your memory requirements are in kilobytes, or maybe 1 or 2 megabytes, you're probably going to be using C, or maybe C++ if it's on a more common platform. Where C++ is viable, Rust can also be viable (unless you have certain library requirements), though it is worth noting that to effectively make use of either of these languages, you need to sink some time into learning them proper.

If you have a bit more memory to spare, and expect your project to be a long-running program, rather than one that is run several times a minute, a language that compiles to bytecode and is run on a virtual machine such as the CLR or JVM, may serve your needs well. You have less to worry about memory management, and can run reasonably fast after the VM has had some time to get things cached and JIT all of the code.

If the memory cost of such a language is too high, you should stick to C++ or Rust. If the memory cost is acceptable, but you would rather trade runtime performance for more productivity, switch to a dynamic language such as Python or Ruby.

>> No.61942938


I have never done any such thing. I have always been a man.


fork() and exec() or just run a shell script.

>> No.61942951

On the inside maybe, but when did you change the outside?

>> No.61942959

>I have always been a man.
But you said you became male at one point in >>61942767. You can't keep your story consistent. I'm gonna be honest, it's not looking good for your claim of being male.

>> No.61943063
File: 2.99 MB, 1280x720, 1418081126229.gif [View same] [iqdb] [saucenao] [google] [report]

Good job, Anon!

>> No.61943097


>> No.61943392
File: 58 KB, 245x327, Ovadia_Yosef.jpg [View same] [iqdb] [saucenao] [google] [report]

in CSLR when it gives the algorithm for searching BST's it says that the iterative version is more efficient than recursive, why is this?

>> No.61943412

Which page?

>> No.61943435

Bottom of 290

>> No.61943444

Archaic farce given most languages ability to do TCO.

In the recursive, without TCO, you would have to actually save intermediate results on the stack, which is completely unnecessary for a search. Maybe a full traversal, but not a search.

>> No.61943453

Recursive process =/= recursive program

SICP chapter 1

>> No.61943455

Because what anon said >>61943444
Basically, to make a function call requires putting arguments onto a stack then jumping to the next function. This uses up more memory as you are basically putting data on the stack which you don't need anymore since you are only doing a search.

>> No.61943468

TCO isn't something that can be applied to every recursive function, only specific functions. Especially in the BST algorithm given in CLRS which you wouldn't be able to TCO anyway. Also some language nowadays don't use TCO or guarantee TCO, notably Python and Rust.

>> No.61943549

It's 2017 and the JVM still doesn't have value types or TCO. How is this even possible?

>> No.61943604

Is there a way to force matlab compatibility when using octave?
Or is there some way to easily convert from octave compatible to matlab?

>> No.61943660

I don't think such a thing is feasible.
The two software use the same language but Octave only has a subset of the functions, or is not compatible with every combination of arguments Matlab supports.
I'm afraid you have to convert manually.

>> No.61943707

Stop using Java

>> No.61943710

Total Cost of Ownership?

>> No.61943721

>Total Cost of Ownership?
Tail Call Optimization
>It's 2017 and the JVM still doesn't have value types or TCO. How is this even possible?
Many language nowadays dont use tco bevause they wsnt meaningful stack traces, like go.

>> No.61943753
File: 399 KB, 1000x800, 1472034764327.png [View same] [iqdb] [saucenao] [google] [report]

Total Cunt Obliterator

>> No.61943783

So how is Kotlin? A meme? Actually good?

>> No.61943788


>> No.61943843

I'm not using Java.

Tail call optimization

>> No.61943856

A wasted opportunity.

>> No.61943873


>> No.61943880

Far too conservative.

>> No.61943895

Oh, so that's why it made it onto android.

>> No.61943929

What I mean is that its type system is barely better than Java's.

Look at Scala for a more capable type system. It gets a lot wrong, but it gets a lot right too.

Adding a new language is an opportunity to really improve things. Kotlin only slightly improves things.

>> No.61943997

What reasons would you have to work in standards like c89, c99 etc. over c11 other than working on legacy systems?

>> No.61944009

In embedded systems, anything other than C89 compliance is a luxury.
Non-standard GNU extensions also prevent you from using compilers like clang which CLAIM to be GNU compatible but simply IGNORE all __attribute__() modifiers when given.

>> No.61944030

your memmove args are fucked bro

>> No.61944040


>> No.61944073


Windows drivers. You're basically forced to use MSVC, which doesn't support C11.

>> No.61944076

>while (--j)
Trying to be too clever, just use a fucking for loop.
>memmove(&arr[j + 1], &arr[j], i - j);
This is fucking dumb, you are passing an integer array and are using memmove, just fucking swap the values, unless you are trying to make it portable for other data types, in which case you are doing it wrong.

>> No.61944088

>doesn't support C11

Not him but how is this possible? A company with insanely deep pockets that hires the best minds in the world loses out to a toe-jam eater and his hippie henchmen?

>> No.61944089

>MSVC, which doesn't support C11.
kek I'm tempted to move completely to C11

>> No.61944097

I'm used to using memmove for char * arrays, so I completely forgot that the last value is literal bytes.

Also this would look clunky as shit rewritten as a for loop.

>> No.61944100
File: 234 KB, 1577x987, 1498430950893.jpg [View same] [iqdb] [saucenao] [google] [report]

>hires the best minds
Micrtrash is a pajeet company now, and it's beyond redemption

>> No.61944137

Who are you? Why do I see you in all these threads?

>> No.61944169

How do you like my all new insertion sort?
void insertion_sort(int *arr, int len)
unsigned i, j;
for (i = 1; i < len; i++)
j = i;
while (--j && arr[j] > arr[i]);
if (j < i) /* found */
int tmp = arr[i];
memmove(&arr[j + 1], &arr[j], (i - j) * sizeof(int));
arr[j] = tmp;

>> No.61944214

>works with ints only

>> No.61944221

I have the option of writing it like cstdlib's qsort or as a template macro.

>> No.61944253

Because none of Microsofts paying clients, or Microsoft themselves use C11? They still don't have a fully C99 compliant compiler or standard library. The parts of the NT kernel that are written in C use ANSI C, with some Microsoft extensions -- which get compiled by a C++ compiler with a 'C quirks' mode.

Speaking about C11 though, not many mainstream compilers fully support it. Most refuse to implement the optional features (Annex K, Annex L, etc). GCC still isn't even compliant with the required standard because of issues inside of glibc. And to be honest, most of the standard stuff added in C11 is generally pretty useless when its already existed as a gnu99 (non portable, though) extension, or thru library features (eqv. of stdatomic, etc). Things like the _Noreturn attribute can be done with pragmas, which already exists in C99 (for gcc/clang: _attribute__((noreturn)) and msvc: __declspec(noreturn))

And to not ignore the elephant in the room, _Generic is quite ugly and I wonder how the last 35-40s years of C have managed without being able to use it..

In my opinion, there's no reason to use C11. Unicode? Thats a portable library issue, not a standard library problem. Which unicode? UTF-8? UTF-16? MBCS? UCS-2? Oh, its locale and implementation dependent? Then why not just #include ICU or similar (depending on your project needs.). Anonymous structs and unions? Fuck, you got me there, literally the only feature. But it already exists in C99 MSVC and gnu99 specific extensions (and Clang generally defaults to GNU C11..).

But idk, I write C++ because I'm not living in the 80s.

What about C11 _Generic :^)

>> No.61944267

anonymous structs and unions have been supported by every compiler worth using since before C89 was even standardized

>> No.61944271


>> No.61944276

looks like u figured it out

>> No.61944288

>Be pajeet
>Open a github account with "Jefferson"

>> No.61944299

Thats clever. (But calling _Generic "Generics" is an insult to Phillip Wadler. Its a "Go 2"-tier solution to the problem-space)

Exactly, which is why C11 is pretty much pointless.

>> No.61944300

It doesn't even support c99

>> No.61944308

non-standard anon-structs aren't supported by MSVSC

>> No.61944325

>worth using

>> No.61944333

C11 master race

>> No.61944346

Does this mean this guy doesn't know shit?


>> No.61944347

/Ze enables them. With all of the other Microsoft extensions (most are actually C++ extensions that have an internal quirks mode if it can determine the file is actually C and not C++). Just like using -std=gnu99 with GCC / Clang will let you use anonymous structs pre-C11

>> No.61944382

I think your implementation is broken because for j = 0, it is false and exits the loop too early when j = 0 could actually be a valid index to insert into. Have you actually tested it though?

>> No.61944386

he deleted the comments section because it was entirely full of grown men calling him a retard

>> No.61944425

That's because he is retarded tho.

>> No.61944535

Is it possible to replace text with / or \ characters in sed?

>> No.61944568
File: 22 KB, 1314x97, Screenshot from 2017-08-17 15-50-26.png [View same] [iqdb] [saucenao] [google] [report]


>> No.61944575

I'm currently working through the K&R C book, and I have a quick question about style. Is there a specific reason why functions are written in the style of

as opposed to
main() {

Is it just the style of C code, or is there a specific reason why the curly bracket is on the next line?

>> No.61944595

depends on people, i always use the former, but the latter is nice too

>> No.61944598

use clang-format to format your code, your editor should take care of this for you, I suggest using the WebKit or Mozilla indentation rule. Both are good.

To answer your question, it's only a matter of your taste. Legacy formatting style like K&R, Allman, GNU have different features.

>> No.61944602

You can do either, and you'll have endless amounts of people from both sides yelling at you to use the one they think is superior

protip: 1st style is better

>> No.61944617

Writing ANSI C++ with Mozilla standard indents is pretty comfy

>> No.61944625


Pick one and stick to it.

>> No.61944705

With sbcl

>> No.61944728

Because it actually compiles lisp to asm i think

>> No.61944760

Better than java at least lol
Clojure is still the best for jvm tho

>> No.61944775
File: 46 KB, 545x960, 19748717.jpg [View same] [iqdb] [saucenao] [google] [report]

Am I doing it right?


>> No.61944839

>implying you use _Generic
>glibc still doesn't support C11 threads
The only usable thing there are the alignof and related functions which are already in the POSIX.

>> No.61944851

Will C22 standardize #pragma once?

>> No.61944879

>implying he doesn't use unnamed structs and unions

>> No.61944884

even if you mean to turn this into a proper poker game, you're still overthinking it

>> No.61944930
File: 191 KB, 2048x1360, casual-cia-57de462598c8c.jpg [View same] [iqdb] [saucenao] [google] [report]

Hello, I'm a stinky millennial. How do I into mailing lists?
I've never used them and am pretty confused by the idea.

Is there something like what Slack is to IRC -- a sleek wrapper around a basic concept that hides "rough edges" and makes the whole thing easier to swallow?

>> No.61944956


>> No.61945068

you should be passing by const reference in C++, senpai.
if you aren't modifying the pointer, then use a reference. if you are modifying the pointer -- use a smart pointer.

also, this isn't valid C++:
card{.suit = s, .rank = r };

>ISO C++ does not allow C99 designated initializers.

also, why new / delete[]?
card* test = new card{.suit = int(Suit::Heart), .rank = int(Rank::Four) };
// ...

>> No.61945082

basically those are just email, you send an email and everybody receives it and vice versa. There are kind of sites that render them as a forum, but it's read only and basically are made so you can find mailing list's content w/ google

>> No.61945106

reference feels somewhat hard to track for me, if I'm passing a pointer to a function, I know it's a pointer.

>card{.suit = s, .rank = r };
says its fine

>why new / delete[]?
Don't want to overflow the stack

>> No.61945138

That is for C. Its even in the URL.
>Struct and union initialization
>C language

I was being subtle with a jab at not using

You should never have to manually call new/delete in C++.

>> No.61945140

Clang and GCC supports it, it's not native C++

>> No.61945146

Oh, I haven't reached smart pointers' chapter yet

>> No.61945152

you can store an entire deck in 52 bytes if you bitpack like so.
cards[k++] = (i << 4) | j
you already have integers 0-4 and 0-12 defined as enumerated values, so you can get those values back when it comes time to read the cards back.

>> No.61945227

It should be an a compiler error if you're using proper flags. (-Wpedantic -Werror).

Say you have this:
struct Foo {
int a;
int b;
int c;

int this_is_ugly = 5;

int x() { return this_is_ugly++; }
int y() { return this_is_ugly--; }
int z() { return this_is_ugly * this_is_ugly; }

Foo f = {.b = x(), .c = y(), .a = z()};
// what is f.a, f.b, f.c?

C++ will evaluate x, then y then z, but C will evaluate it as ??? because (although all 3 major vendors have agreed on having consistent behavior).

From the C standard.
>The order of evaluation of the subexpressions in any initializer is indeterminately sequenced

From the C++ standard:
>Within the initializer-list of a braced-init-list, the initializer-clauses, including any that result from pack expansions (17.5.3), are evaluated in the order in which they appear. That is, every value computation and side effect associated with a given initializer-clause is sequenced before every value computation and side effect associated with any initializer-clause that follows it in the comma-separated list of the initializer-list.

Using the C form may work, but it may not because the compiler is required to implement the behavior of C++-style initialization, not the C style.

>> No.61945254

>mutating a global variable

>> No.61945265

That's not the fault of designated initializers though

>> No.61945318

Does anyone here have experience using lldb?
When debugging something as simple as this:
#include <stdio.h>

int main () {
int i;
for (i = 0; i < 199; ++i) {
printf("%i\n", i);
return 0;

Setting a conditional breakpoint such as "br -l main.c:6 -c 'i == 19'" will make lldb stop when i is 19, but then using "next" twice in order to run two iterations of the loop will make the program run till its end instead. How can I make lldb run two iterations instead?
Binaries are compiled with gcc -g -O0

>> No.61945325

T'was a terrible example, hence the name. But the easiest to demonstrate. Say you're messing with the this pointer and you're changing stuff in your initializer (or your base class -- or derived class if you're a big fan of CTRP), the same thing can happen.

Because they don't exist in C++. Brace initialization is a very core, and important principal in C++.

And I forgot to add how to do initializer lists in C++:
struct Foo {
Foo(int a, int b, int c) : a(a), b(b), c(c){};

int a;
int b;
int c;

Foo f{1,2,3};
// or
auto f = Foo{1,2,3};

// bonus for default values with a compiler-generated ctor..
struct Bar {
int a{42};

Its more typing, but thats C++.

>> No.61945405
File: 24 KB, 1174x97, Screenshot from 2017-08-17 17-31-04.png [View same] [iqdb] [saucenao] [google] [report]

Why isn't this a bad idea? Chances are, more than 1 card in the deck will have the same rank and suit.

I'm just going to swap with a card that's constantly higher in the deck index, and have it wrap if it reaches card number 52+

>> No.61945433

Scan the whole deck if that card exists before inserting it.
Don't be dumb

>> No.61945437

I think you don't understand the instructions. For each element, you pick a number between 1 and 52. This means that card 52 can still be swapped with card 1.

>> No.61945597

I'm seriously thinking of switching to C++ from C because of operator overloading (matrix/vector math) and better standard library support.

>> No.61945639

Try it. You won't hate it until you've dug deep enough for it to bite you in the ass though.

>> No.61945720
File: 160 KB, 463x179, 1429037809603.png [View same] [iqdb] [saucenao] [google] [report]

I finished it. Can't into unique_ptrs right now because that's like chapter 15

>> No.61945766

Are you me? Basically the best thing to do is just accept that you're a failure and embrace your pathetic life to the fullest by playing games even more.

>> No.61945828

Some ext.js garbage for work.

I want to die.

>> No.61945840

It doesn't matter which one you use, just be consistent and don't alternate.

>> No.61945889

Why does webdev induce suicidal thoughts :thinking:

>> No.61945900

I use the second one except when the line is too long and I have to split it, then I use the first one.

>> No.61945901

how to set my custom icon in WNDCLASS anons? why cant i just point to an image file


>> No.61946128
File: 384 KB, 980x606, dumbfucks.jpg [View same] [iqdb] [saucenao] [google] [report]

Who the fuck was so retarded to think that allowing using functions without a declared prototype as external linkage functions with FUCKING "DEFAULT" arguments was a good fucking idea? Is this fixed in C++?

// will be even more after refactoring and resulting granularization
static void initGame(const char *levelPath, const char *framesPath, const char *sframesPath);
static void exitGame(void);
static unsigned long tick(void);
static void camera(void);
static void moving(void);
static void switchHeroes(void);
static void collision(unsigned long n);
static void doStaticCollision();
static void doFull(void);
static void doCornerSouthWest(void);
static void doCornerSouthEast(void);
static void doCornerNorthWest(void);
static void doCornerNorthEast(void);
static void doSouth(void);
static void doNorth(void);
static void doWest(void);
static void doEast(void);
static void doDiagSouthWestNorthEast(void);
static void doDiagSouthEastNorthWest(void);
static void doSouthWest(void);
static void doSouthEast(void);
static void doNorthWest(void);
static void doNorthEast(void);
static void doEmpty(void);
static float penSouth(void);
static float penNorth(void);
static float penWest(void);
static float penEast(void);
static float vecLen(float x, float y);
static void doHeroCollision(void);
static void collectCoins(void);
static void collectGravitons(void);
static void doPulsatorCollision(unsigned long n);
static void doShrinkerLogic(void);
static float getShrinkerSize(size_t i);
static void doEjectorLogic(void);
static void killHero(void);

>> No.61946163

>with FUCKING "DEFAULT" arguments
wat? I know about the implicit declaration thing, which isn't C++, but I don't know what you mean by this

>> No.61946188

default promotions are applied (anything smaller than int -> int, float -> double), return type defaults to int. As of C99 they're forbidden, but you still have to crap your code with needless prototypes when there's literally no need and compiler could figure that shit out very easily by itself. The year is 2017.

>> No.61946193

I automate shell on aix.
Is it programming?

>> No.61946201

>this isn't C++
That's why I'm asking if this is fixed in C++. I got memed into C.

>> No.61946220

And I'm telling you, you need to declare your prototypes in C++.

>> No.61946232

Is this going to get fixed with C++20? The compiler can extract the prototypes from the translation unit without a programmers help.

>> No.61946237
File: 95 KB, 600x672, 13664030903.jpg [View same] [iqdb] [saucenao] [google] [report]

>software that can't update itself inplace

>> No.61946238

You're saying that if you were to call a function in one translation unit with no declaration like this
short s = 10;
float f = 0.1f;
func(s, f);

The implicit declaration would be int func(int, double);

>> No.61946254

It was removed intentionally. Why aren't you including your headers?

>> No.61946255

That's never going to happen kek

>> No.61946260

>blindly pasting code into the source and then compiling it

>> No.61946264
File: 74 KB, 640x640, tmp_18570-1502292216790645454756.jpg [View same] [iqdb] [saucenao] [google] [report]

>software needs to update

>> No.61946270

Yup. In C89, at least, it was. As of C99 and later, implicit functions are prohibited.

I *am* including my headers. I don't want clutter my code with needless prototypes. That's redundant.

Why? That would be a nice feature.

>> No.61946319

One more reason not to use C89 I guess. The last thing I want is my compiler guessing what I meant.

>> No.61946337


whats the difference between

static int foo();
int foo();


in java its pretty obvious when to use static (when its a function that does not belong to any class) but in cpp this is not so obvious, i have a bunch of functions in a seperate file that does not contain any constructor or whatever but it compiles just fine.

>> No.61946360

static has about 4 different meanings depending on context.

If the symbol isn't part of a class, then static means that it won't be visible to the linker. It's roughly the same as "private"
If the symbol is being declared inside of a class then static means the same as in Java.

>> No.61946401
File: 16 KB, 399x297, 1461186573800.jpg [View same] [iqdb] [saucenao] [google] [report]

>In C89
>eighty freakin nine
Why would you ever, in this day and age?

>> No.61946410

C99 onward isn't portable and C++98 onwards really isn't portable.

>> No.61946411

Because portability

>> No.61946414


Isn't that the default for most languages? I mean, it's shit. I don't understand its existence. But a lot of languages do it.

It was even built into fucking Solidity


>> No.61946424

Why would you be interested in writing software for PDP-10?

>> No.61946436

Why would you choose a language that limits your portability?
I'm not specifically targeting PDP-10 but leaving it out for no reason makes no sense, dumb webdev poster.

>> No.61946445

What platform can't I run C99 or even C++11 on?

>> No.61946448 [DELETED] 

I need help, I'm going crazy trying to debug something. This should always be true, shouldn't it?
i = 0;
for (y = 0; y < matrix.length; ++y) {
for (x = 0; x < matrix[y].length; ++x {
if matrix[y][x] != matrix[i / matrix.length][i % matrix[y].length] {
return false;
return true;

>> No.61946460

>Why would you choose a language that limits your portability?
If the computer I'm targeting can't run C99 then it probably can't run my programs either.

>> No.61946462


>> No.61946468

Do you have a resource editor? (as in, are you using Visual Studio?)

If you want to have an icon on your exe you'll have to use a resource editor.
If you just want to load an ico or png or whatever from disk at runtime and use that as the window icon (titlebar, in the shell (alt-tab), etc) then you can use the LoadImage function.
HANDLE icon = LoadImage(nullptr, "path/to/my_icon.ico",
0, // h
0, // w

wc.hIcon = static_cast<HICON>(icon);
wc.hIconSm = static_cast<HICON>(icon); // for small icons (WNDCLASSEX)

Static means a few things in C++. One means static storage, one controls its linkage and another means its not being to an instance.

The third is what you're thinking of from Java, where its not an instance method of the class
class Foo {
// don't need an instance of Foo to call Bar();
static void Bar();

// static storage -- stored in the same place for the duration of the program (or in a thread-local storage since C++11..)
// also has "internal linkage"
static int answer = 42;

// not visible outside of this translation unit (internal linkage)
static void Bax();

// bonus: is visible outside of the translation unit, but has static storage (external linkage)
extern int answer = 42

// more bonus: equivalent to declaring both as static
namespace {
void Foo();
void Bar();

>> No.61946469

I need help, I'm going crazy trying to debug something. This should always be true, shouldn't it?
i = 0;
for (y = 0; y < matrix.length; ++y) {
for (x = 0; x < matrix[y].length; ++x) {
if matrix[y][x] != matrix[i / matrix.length][i % matrix[y].length] {
return false;
return true;

>> No.61946484

>Why would you choose a language that limits your portability?
Because I already chose libraries (OpenGL ES 2.0, GLFW 3, libsoundio) that already limit my portability to the three major desktop operating systems.

With some work my abstraction layer could be ported to android/iphone (NDK) and consoles (idk if xbox supports C but PS does, I think).

Anyway, none of platforms that do have support for graphics wouldn't have support for C11 compilers.

>> No.61946504

is visual basic a useful language to learn?

I don't know a lot about it but I've been screwing around using VBA in excel to make macros at work and I'm wondering if VB might be useful to make small windows programs or something

are there better options for creating GUIs?

I've never really made anything in any language that does much besides calculate stuff or read/write files

>> No.61946509

not really, use c# or something

>> No.61946517

Do GCC and Clang not work on Windows?

>> No.61946520

C#, or VB.net (if you're that kind of person).
or Qt + C++ if you want something a bit more crossplatform, and/or if you want more control.

VBA reeks of classic VB which is outdated trash.

>> No.61946548

New thread:


>> No.61946558

MSVC support most of C99 and all of C++11. (since 2015, the third vesion of 2017 is out which has more than half of C++17 (C++1z) implemented..)

But Pelles C supports all of C99 and is rather fast/lightweight. Perfect as long as you don't need high-end compiler optimizations.

>> No.61946568

MinGW-w64 is on Windows and it supports a lot more shit than MSVC.

>> No.61946595


>Put C code on GitHub
>Immediately get an issue demanding autoconf
>"muh portability"
>Can anyone name any platform it's not currently portable to?
>"Z/OS on IBM mainframe"
>Does anyone actually have access to that platform and the desire to at least show me an error in the current state?
>"muh portability. Must have autoconf".

>> No.61946639


It's great if you want to be an accountant and "write code" without ever writing code anyone respects.

>> No.61946674
File: 19 KB, 1044x200, i understood FUCKING NOTHING.png [View same] [iqdb] [saucenao] [google] [report]


where in this description does it say file path?

>> No.61946709
File: 51 KB, 1120x717, here.png [View same] [iqdb] [saucenao] [google] [report]

Scroll down.

>> No.61946746

Is this true, /g/?


>> No.61946755


>> No.61946938


are there any instance where this will fail?

#define array_count(array) (sizeof(array) / sizeof(array[0]))


>> No.61946961

I don't know cpp but in C this would fail for heap-allocated arrays.

>> No.61946962

When array isn't an array, but a pointer.

>> No.61946977

Why not do
#include <iostream>

const int ARRAY_THING[] = {1, 2, 3, 4, 5};

int main()
for (int i = 0; i < std::extent<decltype(ARRAY_THING)>::value; i++)
std::cout << ARRAY_THING[i] << '\n';

>> No.61946986

That's cool, I think.

>> No.61947058


cpp newbie here, can you tell me whats happening exactly? the one that i wrote seems intuitive enough when thinking in the literally bytes written in the memory

>> No.61947086

The macro can compile but give you an invalid result (e.g. if you give it a pointer). std::extent is typesafe.

>> No.61947098

anon how do you react to user input in winapi?

what i do is have a struct containing booleans for acceptable key inputs like up,down,left and right, then have win_call_back set the boolean when buttons are pressed

then pass this struct to the my game engine

>> No.61947135

I'd listen for the WM_KEYDOWN message that puts the key (and related state/data) in a threadsafe queue / time series queue that the game loop reads within a specific delta (and clears out previous entries from the past). Similar to how GetMessage / TranslateMessage / DispatchMessage works.

>> No.61947167


Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.