/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

web.archive.org/web/20121218042116/http://shootout.alioth.debian.org/u64/ats.php
github.com/LunarG/VulkanSamples/blob/master/scripts/vk.xml
twitter.com/NSFWRedditGif

UWP and D3D12 bindings for Rust. Already got the COM base down and the D3D12 bindings started (just enough to test COM). Working on parsing WinRT metadata for UWP binding generation now.

all those colons

First for #etc on rizon

First for C++ is the greatest language of all time. No other language can provide zero cost abstractions of "You don't pay for it if you don't use it"

>tfw you realize that for years, you've been committing with your stupid personal email address on every commit instead of your "professional" email

FUG

Can I noob out right now?

I just had a huge breakthrough with scope...passing variables, functions etc pretty much all the basics

I did not get it at all but it just clicked- fixed the code I've been struggling with for weeks right up

feelsogood

Scope's kinda tricky desu. Really, really old programming languages didn't fuck with scope. So there'd only be one X variable and only one Y variable in the entire codebase and all func—subroutines would share the same X.

ATS can with greater accuracy. It's performance matches C++ in use and it's capable of real high level programming while being suitable as a C "replacement".

C++ code is a mine field

Separated by files.

Read SICP

Exactly how I thought of things... but now I see they're instanced in the function unless passed :o

What's the difference between Feeenode and Rizon?

Any language with compile time expansion feature can provide that

Atari Basic did copy and paste includes, so not separated by files.

> It's performance matches C++ in use
Got any data for that or is that coming out of your ass?

Rust. Trait objects with dynamic dispatch are more efficient than polymorphic objects and virtual functions.

My ass. :^)

What is the time compleity of Bayesian optimization? I know the canned response is always O(n^3), but what about in terms of the dimensionality? I remember hearing that it was O(n^(3*dim)), but I'm having a really hard time finding a source to cite.

Yet Rust is slower than C

web.archive.org/web/20121218042116/http://shootout.alioth.debian.org/u64/ats.php

On the whole, yes. It has abstractions which do incur some overhead. But then, so does C++.

>"zero cost abstractions"
Huh.

Are we looking at the same numbers? Looks like C++ is faster than ATS. Any data that's not more than half a decade ago?

Zero cost is a weasel term. Not those guys, I don't like using it. If it's not run time overhead, it's compile time overhead. But there is certainly truth to the idea that you don't have to pay for abstractions you don't use.

a replacement to systemd

Would have to bench again. You could always look at the generated source as it's quite clear. If you only use unboxed types and restrict yourself to tail calls only then it will match C++ quite well.

Plus that was for ATS1 and we're at ATS2 now.

Not as much truth as sepplesfags or rustlets would like you to think.
It's difficult to use a single sepples feature without dragging the whole sepples ecosystem into your program.
In Rust you're pretty much forced to so the borrow checker won't scream at you.

The BC isn't an abstraction, it's an analysis.

Fuck I hate sepples programmers. Watching Herb Sutters 'Meta:thoughts on generative C++'
There's people up voting a comment that suggests that constexpr should be a compiler hint 'just like inline' when sufficiently developed.
These people don't know anything about the fucking environment they're working in.
What they're asking for is to remove constexpr while they're obviously praising it in use.
How can you be this retarded?

I'm not saying it is.
I'm saying that in order for the BC to approve of your program, you must use Rust features which may incur more overhead than optimal implementations.

I'm working on a C++ program that depends on an external dll. What's the right way of dealing with that? Copying the dll into my project directory? Making some kind of development library folder, dumping all my dll files in there, and adding it to my path? Something else?

To me this is a bigger issue than whatever overhead is introduced due to compilers inability to sort the mess sepples has them deal with.
Irrelevant. He's clearly talking about programming overhead being regarded as part of the cost. In that view the BC is not zero cost. Which it otherwise would be (I'm told).

>he's clearly...
Oops I guess he was not exactly saying that. Not sure I agree anymore. I don't know what overhead Rust constructs bring.

Like what?

That's a good point too, you can interpret "cost" in terms of more than just computation required.

just finished a cronjob watcher for kubernetes cluster. Really odd that it isn't a built in functionality. Great thing is that the python library is extremely well documented. Sadly, the go one seems like a x-go-horse development. My system uses k8s health check to request an url that health-checks all cronjobs and reports failures to a sensu server, running on the same pod. Enjoyable work

>programming overhead

>programming underhead

Also, consider that while BC requires more effort in some ways it requires less effort in other ways. Instead of having to worry about whether your code is correct, you have to worry about whether the BC will accept it, which is easier but may require more code.

Rust lacks in situ constructors and uses static methods to construct data objects. This is useful for tracking lifetimes, but can easily incur more cost if heavy objects are frequently being passed by value.

>Rustlets shitting up the thread with their toy lang yet again

Trying to make an app in android studio with sqlite database and im lost af since i never used it and in my class no one explained shit about it.
Where should i even start? what are good and simple tuts i can read about sqlite and how it works? i have to finish the app in 8 days, will i make it in time?

True, but Rust's rules also mean the compiler can elide intermediate copies much more aggressively.

>watch talk where Stroustrup goes on and on about how amazing the GSL is
>"instead of passing an array and an array size, which is error prone, you can just pass a span!"
>span's implementation literally just holds a container and a size

I'm pretty sure this concept has existed since the 60s.

Is it anything more advanced than what C++ (and C compilers by association) are able to do?

Regardless, it's not the point. Pluslets and Rustlets harp on a lot about zero cost abstractions. And it's true, they have a lot.
But it's often impractical to use those features which have minimal to zero runtime overhead without getting sucked into the paradigm of the language as a whole, which inevitably has you using a feature with suboptimal implementation.

...

Well it's a judgment call.
Does the errors the BC catch costs you more than the constant struggling with the BC? Does the consideration of ownership and adherence to the BC cost you mental real estate that slows down other thinking (very hard to judge)?
I can see methods such as the BC or other forms of proving like Idris being very good where a bug will cost you a lot after shipping. Like if you send a probe to Mars. The actual in the wild bugs are extremely expensive. That's why they test their software to the point where it seems excessive even. You can take much larger penalties to development speed there and still be ahead.
In other applications bugs have cost mostly in their discovery and resolution. There a constant overhead can very easily be something that costs more than whatever bugs which may have slipped when you ship.
I personally find much of the C++ std offensive in many ways and I doubt I could ever justify the BC. With how rare the ownership bugs are for me especially.

Yes, primarily because moves in Rust are guaranteed to be plain memory copies, and they're the default (as opposed to deep copying in C++, which also has less efficient move semantics).

>But it's often impractical to use those features which have minimal to zero runtime overhead without getting sucked into the paradigm of the language as a whole, which inevitably has you using a feature with suboptimal implementation.
Fair enough. Personally, my approach to Rust is more "guns blazing" than most. I tend to cut out the standard library and have no qualms against using unsafe code. Basically as C with modules, generics, traits, and RAII.

>GSL

377 pages of partially documented guidelines and an almost completely undocumented unfinished library that hypothetically might be supported by static analysis tools at some unspecified point in the future (at which point you'll have to remove all references to GSL and replace them with the standards-approved implementation of the parts of the GSL they deem useful.

Sounds reasonable.

How practical is it to use unsafe really? It always looked like quite a pain to use Rust as a better C.

It's not a problem at all. It's the exact same language plus just a few capabilities (most notably, you can dereference a pointer), and the actual unsafe blocks are nice, greppable delimiters that tell you when to switch your brain on (joking).

C += 2

{ C, C++, C++++, C++++++, ... }

>use 4chanx to force noscript captcha and keypad entry support
>actually faster to shitpost than with the old legacy captchas

C must be a modifiable lvalue ;^)

Not the guy you're responding to, but it's not that bad. Most things you need can arguably be done without unsafe, but if you need it, you can usually contain it to a short block. If you need pretty much an entire function to be unsafe, you can actually just declare the function unsafe and not even bother with the blocks.

i'll modify your Love-value

c-fags btfo

amazon proves that c++ was the first programming language

That sounds tolerable. The whole
>immutable by default
Thing sounds like a pain but at least I can keep the unsafe noise to a minimum.

>If you need pretty much an entire function to be unsafe, you can actually just declare the function unsafe and not even bother with the blocks.
Eh, there's a difference. Marking a function unsafe is saying that the API doesn't guarantee safety, but it's possible to have a safe API where the whole body of the function needs to be in an unsafe block. Plus you'd still have to have an unsafe block at some level.

How to make a parsing function in C to detect the own program name that supplied by bash's *?
I have a bash script that call a C program to modify something.
The program call using an absolute path, but if i locate the script in the program's location, then bash will expand the * into its own name.
The problem is the argv[0] will be /path/to/program/program_name , but somewhere in another argv there is program_name , and therefore the program will try to modify itself.
How to make a parser to detect it?

github.com/LunarG/VulkanSamples/blob/master/scripts/vk.xml
>horribly structured XML that misuses attributes all over the place
>on top of that it's practically XML-decorated C instead of XML all the way down
What was even the point

>1709
user you're confused. C++ builds on C. That's 1709 cycle 2 of our universe.
Both C and C++ were made in the previous cycle.

This was asked in a previous thread.
See

>not replacing all error handling with asserts

Any mistakes should be punished with death.

the glasgow Haskell compiler once had a bug that deleted your source code if you made a type error

Yeah, well, in C++ if you make an error Stroustup comes to your house and fucks your wife.

I think I'd prefer the nasal demons.

Sometimes you rely on unreliable functionality of the system.
I.e. Anything your OS does.
Handling this gracefully makes more sense.

dubious claim

REEEE

EARTHQUAKE

CALIFORNIA IS DOOMED

Magnitude 4.1 - revised local magnitude (Mlr)
Time Thursday, January 25, 2018 at 2:09:56 AM (PST)
Coordinates 33 deg. 44.7 min. N (33.744N), 117 deg. 29.2 min. W (117.487W)
Depth 10.14 km (6.3 miles)
Quality Good
Location Quality Parameters Nst=96, Nph=111, Dmin=2.0 km, Rmss=0.22 sec, Erho=0.27 km, Erzz=0.62 km, Gp=23 degrees
Event ID# ci38092312
>Quality: Good

any watch any shows on the CW app (Windows 10)?
they somehow have it coded to stop playing when the user does something on another screen. (like checking a message/email on 2nd screen during a boring part or commercials) the main screen will pause audio/video and go black.

wondering how they do that. how are they reaching outside their own app to see that the user is using another app?

would it be unethical to include such a feature in apps we create? what if spotify did this?

interpreted c++

you mean the CBS app?

No idea what a CW app is, but it's trivial to check if the current window has focus or not. If that's a UWP application then I'm sure UWP includes similar functionality.

constexpr

Rate my branchless, C standard-compliant, industrial-strength fizzbuzz:
#include
main()??

beautiful

3/10

No it's different. He was asking how to do a file search or file open from the program's directory instead of current directory.
My problem is for example:
~/
program/
the_program
data1
data2
data3
script/
the_script.sh
data1
data2
data3

in the the_script.sh there is this line of code
~/program/the_program *
and the program open all file in the ~/script/ including the script itself (i manage to bodge it by copy a disposable script for every call).
But when I need to modify all the data file in the ~/program/ by copying the scrip to the directory,
bash will expand the asterisk into the_program , and the parser in the program could not detect the similarities between
~/program/the_program and the_program .

Oh, you of small minds...

>let's take the most massive and complex language on the planet and then do massive revisions to it every 3 years that completely changes how you're supposed to use the language

BRILLIANT

How is that bad? The world will be better off when people give up on C++.

I was referring to JavaScript

Is there an anthropomorphic anime girl for Erlang?

>javascript is the most massive and complex language

>implying C++ templating has anything on JavaScript typecasting rules

pls respond

JS is a simple language

interface Invokable
{
void invoke();
}

class If
{
Invokable[] arr;

public If(Invokable trueCase, Invokable falseCase)
{
arr = new Invokable[]{ trueCase, falseCase };
}

public void invoke(int b)
{
arr[b].invoke();
}
}

public class Demo
{
public static void main(String[] args)
{
new If(() -> System.out.println("Hello, World!"), () -> System.out.println("GoodBye, World")).invoke(0);
}
}
Java is the most powerful programming language

>tfw no hardware color inversion button on monitors

I've been bitten in the ass by unexpected behavior in Javascript more times than I have in C++. If only because C++ tends to warn me during compilations, whereas a Javascript error will only manifest itself during execution 50 lines later.

Solution: stop being a bad programmer that doesn't know what they want to write and needs to be told by the compiler.

>watch presentations by the few living renowned people who shaped modern programming
>they pull out a laptop for a live demo
>start pecking at the keyboard with their index fingers like a grandma who never saw a keyboard before

Meant for

hobbyist programmer here, is kotlin worth to try now?
currently love python, interested to it (statically typed, faster yet concise like python) but it's still new

>implying you ever need to care about JavaScript typecasting rules
Relying on any of them besides the most trivial ones (x + str => str, str + x => str, null => false, 0 => false, undefined => false, anything else => true) is patently insane. They're not there for you to know them. They're just there to make debugging harder.

If you want speed, use C. If you want a high level language with lots of libraries, use python. If you want both, use ctypes. There is no practical reason to learn anything else.

Yeah programming used to be a lot more about premeditating what you do than writing code and then looking at your understanding of it.
My mom is like that. She started with punch cards.
Though she does touch type, probably because she was working with data entry for a while during university.

>if you want to write shitty unix command line tools that nobody will ever use, use C

ftfy

(Unless you're developing for embedded systems professionally, but you're not)

I type with only my pointer fingers and do it pretty quickly. git gud