/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

kernel.org/doc/html/v4.10/process/coding-style.html
youtube.com/watch?v=vRHCp9Wblro
gtk-rs.org/
twitter.com/AnonBabble

just because the language isn't elegant doesn't mean it's not useful

>how else would I do such a thing in C?
The user that suggested C++ isn't wrong, OOP does have a nice way to model this but you should be doing it in C.

If C and not C++ is a requirement than carry an enum on your structs that indicates what the corresponding function is and delegate on whatever take the structs as an arg.

Other synthesis engines like Puredata are written in C. Plus the audio API for my OS is C as well. I don't see what's harmful with sticking with C for audio processing.

>than carry an enum on your structs that indicates what the corresponding function is and delegate on whatever take the structs as an arg.
How is this any better than just having a function pointer in the struct itself?

C++ is way beyond "not elegant": it's full-blown retarded.

Why do Cfags have to go and make everything inefficient with their shitty inefficient language?

...

When you have two independent phrases that you want to link together, you use a semicolon rather than a colon. A colon is used to add an incomplete phrase: something that wouldn't stand as a sentence unto itself.

F# question:

If an F# function has type 'a -> 'b when 'a : comparison, which of the following is not a legal type for it?

(float -> float) -> bool

or

int list -> bool list

And please explain if you can. From what I get, its basically saying if you input sometype 'a and its a comparison (bool val, ,etc) you'll output sometype 'b. Explaining what the types are basically saying would help

If you think having no features somehow makes your language efficient, you are wrong.
You will just do stupid inefficient and dumb shit to work around your shitty language, when the thing you're doing could be done a whole lot more efficiently with language suppport.

Reminder that "typedef struct" is terrible style.
kernel.org/doc/html/v4.10/process/coding-style.html

Alright, I figured out the illegal type is the first one by playing with it. Am I right in saying it's cause it takes in a function type, which is not a comparison? Seems simple just wanted to make sure i was getting it before moving on

>How is this any better than just having a function pointer in the struct itself?
Function pointers make jump prediction functionally impossible, the enum approach allows the CPU to make informed decisions about what it's going to be doing for the next instruction. I'd argue it's also more idiomatic than function pointers.

Interesting. That's definitely worth considering.

My uni is switching our intro CS courses from using Java to using c#

>Switching from Oracle Java to Microsoft Java
Same shit, different dick to take.

you only have 1 lang?
We had c++, java and c#
For web php and js
Now they added python too

We have 2 intro courses, and they bothered used Java

Overall we cover c++, Java, mips assembly, ruby, sql, python, and lisp but for the most part after the intro courses you can use whatever language you want as long as it fits the project.

I am trying to use some business reporting program that has Javascript based scripting for report automation and it's hell on earth.

I had no previous experience with Javascript, and I've been asked to create this custom report from an orgnizational model inside the program using the program's built in script editor, which is Javascript based but has its own set of rules.
I've been given no training on this, my boss is constantly busy outside and my only coworker is on vacation.
I asked for help to someone who has more experience with this program than me in another department and they sent me some "example" scripts and they're the worst spaghetti code mess I've ever seen, over 1k lines of code to print 4 lines in a table view, because the guy constantly reuses the same script file and just comments out or edits whatever to make the new reports.
Trying to decipher this mess, while trying to learn to use this Javascript based monstrosity and do this custom report I've never done before is driving me crazy.

And since it's a paid for business only program, there's basically ZERO tutorials online except the super old and outdated "official" ones on the program's page that actually contain zero scripting examples I could use.

On a scale from 1 to 10, how fucked am I?

That sounds pretty gross and unwieldy
Would just make me wish I were writing Rust desu

Quit and become NEET master race
youtube.com/watch?v=vRHCp9Wblro

Java has at least 2 independent FOSS implementations

My uni teaches Pascal, Delphi, VBA, C, C++/Java and PHP in their courses. How fucked am I?

user please, I need money to survive.
I am completely lost with this thing.
The guy that gave me his spaghetti code "examples" told me that the best way to check if the tool is using the right data is to use the debug function constantly.
There has to be a better way.
I wanna kill myself.

1104 lines of code to print 4 fucking lines on a table for Christ's sake

dumb frogposter

Refactor the code piece by piece into functions without side-effects, that can be more easily tested and understood independently

Quite...

>cmake
>autotools
which should I learn Sup Forums?

both?

Meson. It's the "in" build system right now.

None. Learn to make proper configure scripts and make files.

I know makefiles and what are configure scripts?

cmake triggers autists because it just works and their arcane autotools knowledge becomes useless.

>optimizing your code in compilation process
>interpreting your code and optimizing JIT
Why can't we do both? Some optimizations are too time and resource heavy to do then JIT and compiler can't predict everything that happens in runtime. Why not bring all the heavy optimizations in compile time and optimize the binary further in runtime?

You know... ./configure

Some language actually do that. But having a massive runtime to do that sort of shit is just not acceptable for a lot of languages.

I know, I just never looked into them.

Android app or Minecraft clone (in C++ with opengl GUI)?

Why can't we just compile bytecode into an optimized executable based on the host architecture the first time a program is ran?

See

Which?
ART on android is the only thing I can think of

>ART on android is the only thing I can think of
That's what I was thinking of too.

Daily reminder that sepples users usually aren't proficient in any programming language, least of all sepples. Their opinions should be ignored and reported.

Programming in C
question about iterating over scanf

while (scanf("%d", n) == 1) {
...something
}

With this input:
1 2 3 4 11 23
Why can the input be parsed? How does it get around the spaces?

>How does it get around the spaces?
Are you asking how it's possible to ignore spaces when parsing a list of numbers?

Note this is from the scanf of a known amount of variables where you specify the delimeter yourself.
scanf("%d %d %d", a, b, c);
Here numbers are known to be separated by spaces.

>Splitting up a function which is logically a laundry list of things to do doesn't help
Reminder: if your functions are typically 500-line-long "laundry lists of things to do", you should probably find a new profession.

Woops forgetting the & symbol

Yeah so why doesn't it need to be specified in the loop. Putting 1a2a3 means that the values aren't read properly but in the one liner you can specify to delimit by the character a.

What kind of data structure is this? does this format have a name?

what do you mean?

it's called an intra-check-bit quantum-tensor. it has the ability to store datas that never before were storable

>CMake
>in 2017

>Yeah so why doesn't it need to be specified in the loop.
It's always treated as a delimiter.

nvm I'm retarded

Ask yourself why such input is accepted by scanf:
3a

;
WHY?!

I want to parse this data into a python array but don't want to re-invent the wheel (splitting/etc). I'm trying to figure out what I should search to get the job done. :c

Is it just the language that the 3 isn't attatched to the (decimal) conversion of the letter a in a single scanf(%d) ?

scanf will just buffer the line, discard spaces until it finds something, then try to parse it as a number until a non-digit character is found, and return that. Calling it again will continue this process until the buffer is empty, at which point it will try to read in a new line.

No. A C programmer does 1000 exercises, in which they learn to use the language's 50 constructs well by heart. The C++ programmer does 1000 exercises, in which he uses at most 10% of the 10000 constructs. The C++ programmer only learns to copypaste from SO.

Because scanf just werks. That can be valid input under many circumstances.

Dictionary? Struct?

How well will a compiler optimize code if you include the standard library as a single compilation unit instead of linking?

Thanks!

Sounds like my job tbqhwyf.
The problem is a business one, not a programming one. Set up a meeting with the example script guy to run you through what his mess does.

If you enable LTO, noticeably.

Currently scrounging the documentation of gtk for rust, gtk-rs.org/
Somewhere it says window.connect_delete_event(|_, _| {
It looks like a lambda but I can't seem to grasp the "|_, _|" part Any idea how I should read this?

_ means the argument is ignored.

Underscore is a valid variable name but it is used to signal that the variable is not used and not relevant in the lambda function.

But what does the | (pipe?) signify then? is it specific to the lib? Also the first param '|_' puts it behind, why is that? I even saw '|_|' being used.

What you're really asking (or should be) is how much of an improvement this is on just using LTO. I don't have numbers but people do this when they really care. May be legacy from when LTO sucked. Not sure.

Which language would Akari use?

pipe pipe is lambda

Akariposter uses C

winapi or cygwin?

Is Sup Forums much better than Samantha J. Froogis?

This hurts that much more when you recently wrote a multiplication algorithm to work in logarithmic time.

I post akari and I use C++

C++ is just C with shit on top

/dpt/ gimme something cool to write using wasm

It really isn't.

very little of that shit is well implemented

and there's so much of it that it pushes all the C to the margins

>objc is just C with shit on top
>C++ is a different language

how would you describe a well implemented shit?
kept inside of the toilet?

You are all wrong. C++ is just shit shovel onto C without addressing the shit in C. So basically, it is a huge piece of shit on top of another smaller piece of shit.

>>C++ is just C with shit on top
>you're wrong, C++ is just shit with shit on top

substitute C for shit into the original equation

What programming language would Iori use?

C works well enough in its intended problem domain. What problem domain is C++ supposed to cover? All of them, ostensibly. As a result, it doesn't cover any one of them well.

What was C's problem domain? Shitting out buggy software?

It's for people who think null-terminated strings are a good idea.

>What was C's problem domain?
Low-level programming on a relatively small scale. Why are you so butthurt about C?

Why is ruby so disgusting?

A variant of brainfuck called buttfuck.

She's feel sorry for the programming languages she doesn't use so she's learn all of them.

But C is a high level language.

>she's
she'd
Wew lad ruby gave me a stroke.

int product(int a, int b) {
int c = 0;
for (int i = 0, j = 1; j

made a simple bash script that messages white girls only on POF

anyone want it?

Why not just use Rust and not suffer the deficiencies of C?

int product(int a, int b) {
return a*b;
}

>But C is a high level language.
And Haskell is object-oriented. Okay, kid.

>buttfuck
kek