/dpt/ - Daily Programming Thread

Should have been an engineer edition

Previous thread:

Attached: FeaturedImage2.jpg (594x396, 80K)

Other urls found in this thread:

en.cppreference.com/w/cpp/language/range-for
youtube.com/watch?v=eC9-iRN2b04
youtube.com/watch?v=bsXLMQ6WgIk
github.com/ericniebler/range-v3
twitter.com/SFWRedditImages

First for Object-Oriented-Programming :^)

nth for how's that project you're 4 months behind on going?

New to sepples, what does a single colon mean/do? An example from the specific case that's confusing me:

for (auto target : weakNeighbors)
{ ... }


I think weakNeighbors is a vector. When I put my cursor over it in VS it tells me:

std::vector weakNeighbors

4th for what should I work on today? Looking for something new to do.

Attached: 1523741012412.png (800x800, 553K)

it's just a foreach loop
for every target in weakneighbors
other langs do:
foreach(x; numbers)

>4th
yeah

learn vulkan
make a stallman game where he topples FANG Corp.

>spent hours and hours trying to figure out a problem
>finally get a working implementation
>realize i was a retard that read the problem completely wrong from the start
>realize it was piss easy all along and instantly figure out a solution
just take me out back and blow my brains out like the diseased dog i am

Attached: FkjxNfT.png (349x491, 203K)

welcome to programming.
wait until you spend weeks to months rat holing on a problem only for a 10000x simpler solution to hit you right before you fall asleep.

I shoulda said new to programming. I don't know what foreach is/means either.

Dude that's great.

foreach is just a for loop designed to iterate through a range.
so you have
foreach(x; [1,2,3,4,5,6,7,8,9,10]) echo(x)

would just print 1,2,3,4,5,6,7,8,9,10
as a regular for loop it'd be:
for(auto x = 1; x

So boys, GC or BC?

Attached: 1527100908678.png (498x710, 290K)

I'm making a PIC24 simulator/VM thing. Will take arguments from command line specifying the device to simulate, and the location of the machine code to be executed. It's a little overwhelming, the spec for the instruction set is massive and I want to add support for at least some of the special function registers for peripherals (e.g. I2C registers and shit)

it's a shorter way of saying:
for(int i = 0; i < things.length; i++) {
auto thing = things[i];

}


IIRC Java uses the same syntax. So, this:
for(auto thing : things)
would look like this in a Kotlin or Python-like language:
for(thing in things)

Attached: 1527752787561.jpg (786x1024, 237K)

>weeks
Try having a debugging JOB. Took more than a month to figure out the source of a fax->tiff problem. When we decompressed and recompressed an image to the same compression type, we didn't update the bytecount, writing too many bytes (fax is based on timings and bit-wise, TIFF is byte-wise and has no "network" stuff in it's fax compressions). Since the code was part of a HUGE codebase and much of it is ancient, it runs on like 50 platforms (cloud, embedded, application, app, etc), lots of data is kept "pseudo-stored" i.e. a bytecount could be kept as the difference of two pointers. I had no fucking clue WHY the compression bug cropped up, and WHY it would only effect an image being recompressed to it's own compression type, but I found it and "fixed" it.

Another issue was our software could deal with faxes to ourself, but not through some other clients. The only presentation was a single receiver not ready message per page. Lots of stuff going on, so not even THAT was isolated by the time I was asked to work on it. I spent weeks on it, going through the state machine because only by printing a comma every pass through the state machine did I find it was going one byte more before triggering a reset to receive the next page. The bug only existed on the fastest transfer rate AND the best compression. The worst time to effectively have 1.5x round trip lag or so per page. I strongly isolated the issue and presented the scenario to my 'boss', and he acknowledged this was likely the causative factor, so another guy dug through the data we process. Turns out we didn't catch the final ECM block properly.

>it runs on like 50 platforms
ripip your sanity
neat bugs though.

this sounds like it pays well at least

Anyone have any good resources for CMake? I have had a really bad experience googling problems because you get terrible results with bad practices.

You want to know the definition of insane?

1) My backups were failing when I checked the exist value of this script. THE EXIST VALUE OF THE SCRIPT WAS THE EXIT VALUE OF THE IF [ REEEEEEEEEEEEEEE

2) I thought I saved it, it might be on a flash drive. I wrote a perl+resource->C file encoder, for turning a binary/hex representation of black and white characters into a pre-allocated "resource" file to be included in a draw-er function

Attached: REEEEEEEE.png (1367x1149, 115K)

I'm currently off it, because I wasn't getting paid. I like the job, but 'lack of work', what can you do.

Attached: generator.png (2560x1440, 373K)

I found "trying to do a thing and googling the errors" is the "best" way. One of the most annoying aspects of CMake which cropped up quickly for me, it's meant to BE your build system, it's not designed to allow you to DEPLOY a "ready" system. This is most painful when you want to compile one program which could share object files with another. Instead of each program having an object file, CMake hordes your object files in it's cache. This gets annoying as fuck fast when you're doing out-of-tree or out-of-branch or whatever builds and all your object files are not where you want them to be.

Can anyone help me?
I mounted a drive from my WIndows partition so I could access it from Manjaro.
I can view, create and edit files, but when I try to run .exes I get "permission denied".
I can even compile my .c files with gcc, why can't I run them?
pls /dpt/

Attached: screen2.jpg (758x177, 23K)

>trying to run an exe in linux
m8....

?????

Attached: wtf.jpg (631x136, 12K)

based *nix

> being this dense

>it's a shorter way of saying
Not exactly. It uses iterators, so it uses begin() and end(), not length.

See en.cppreference.com/w/cpp/language/range-for for technical reference.

i hear you, man. CMake is a great tool but it seriously suffers from often-not-very-helpful documentation and widespread use of antipatterns / bad practices, lol. i highly recommend these videos:
youtube.com/watch?v=eC9-iRN2b04
youtube.com/watch?v=bsXLMQ6WgIk

the first covers the fundamentals (modern best practices, which differ somewhat notably from the old-school standard/widespread practices), and the second covers much of the same but goes more in-depth (into some of the things more applicable to larger / more complex projects, and into the broader set of ideal practices for a general CMake-based build ecosystem - the sort which library implementers who want to use/support CMake should take into account, but some of which would probably be overkill for smaller/personal/closed-source projects)

the modern fundamentals are mostly summed up by the slides in pic related (taken from the first video), but i recommend watching it through. these videos alone are honestly better documentation of CMake than the actual CMake documentation, lol

Attached: cmake.jpg (800x1350, 235K)

>CMake is a great tool
Nah, CMake is garbage. It's basically the Sepples of build system generators.

So do I need to read all the god tier programming books on the install Gentoo wiki? Planning on learning HTML and then C

Have you fallen for the neural network meme?

:DD

make an OS
we've all been there mane

>tfw my implementation of the Miller-Rabin primality test in my language is both more readable and faster than the one on rosettacode
neat, i guess

>making a linux device driver: write a fucking kernel module that will break on different kernel versions.
>making a windows device driver: simple api calls (will not break on different versions) and some .inf files

when used properly, it makes it relatively easy to set up complex and scalable/maintainable projects containing potentially multiple modules, each potentially with its own build and interface requirements/dependencies, and build- and install-time options/configuration/modes, and it manages to do this in a way that is platform-independent and supports generating a wide range of build system configs/scripts/project files (not to mention it has first-class support in multiple editors/IDEs allowing it to act directly as the build configuration in such cases). sounds like a good tool to me. it's a bit complex on the whole, sure, but that's because the problem it addresses is complex; any tool which sufficiently addresses the many customization points bound to be important to some users is bound to be comparatively complex. it's the same story with C++ itself

If you can get it mainlined it wont break

After having used Meson for several of my personal projects, I learned that it's actually possible to have a non-trivial build system that you don't dread having to touch.
I just can't go back to Cmake; it's such a fucking mess compared to it.
Sure, if you use "modern Cmake" "properly". it'll be less overwhelmingly horrible, but that's never how it turns out in practice.

>his project uses cmake

Attached: c39.jpg (352x450, 20K)

>Sure, if you use "modern Cmake" "properly". it'll be less overwhelmingly horrible, but that's never how it turns out in practice.
it's not hard to use it properly, it's just that how to do so has long been rather poorly documented. the only hardships i've had with CMake have always been a direct result of antipatterns i picked up from other people's projects, or my own trial and error. once i learned the modern best practices, it became very easy to use. of course it's probably not as pretty as it could be, but i don't particularly care about that, as long as it's consistent and supports what i want to do (and i have certainly made use of some of CMake's fringe functionality in the past) - and it helps that it has first-class support in the editor i use. i'm definitely the "function over form" type, if that wasn't evident from the fact that i use C++, lol

>shoulder blades
the absolute posture

>Not exactly. It uses iterators, so it uses begin() and end(), not length.
it's the same thing, just an easier way to explain it to a beginner

what is this autism, is it just a style thing or did they change how for loops work

Attached: Capture.png (486x357, 19K)

>I found "trying to do a thing and googling the errors" is the "best" way.
My problem with this is so many google results have really bad practices, or plain don't work.

i think it either changes the types or stops it from doing extra work

Yes, now `begin` and `end` could have different types IIRC.

What the fuck is wrong with isocpp?

Looks so ugly and hard to read
C++ should be aborted

Of course it's hard to read, it's pseudocode for range-for.

it allows for the begin and end iterators to be of different types. more specifically, it allows for iterator/sentinel pairs as opposed to just begin/end iterator pairs. a sentinel is like a past-the-end iterator, but with distinct type and stronger semantics (they can't be advanced or dereferenced - enforced at compile time by the type system). another benefit of using a distinct type is that it's possible to determine if an iterator is "at" the sentinel / past the end of a range at compile time instead of runtime (since it's a matter of type, not value). so the iterator/sentinel approach is safer and more efficient than the begin/end iterator approach (it eliminates the aspect of iterators which would otherwise sometimes yield runtime overhead compared to analogous C). you can see this approach (and much more) utilized in the library that forms the basis of the formal "ranges" proposal for the C++ standard:
github.com/ericniebler/range-v3

>Looks so ugly and hard to read
that's why they added syntactic sugar for it

The defense of every over complex, over generic piece of shit tool always starts with the words
>when used properly

Why do common lisp return nil for (car '()) instead of an error like in scheme? It seems retarded to me, what is the real implication of this?

anything of nontrivial scale (hell, even most things of trivial scale) can be misused as long as it has parameters / customization points / degrees of freedom. that's an obvious natural byproduct of functionality; it doesn't serve as an argument against it. you could use a screwdriver to drive a nail if you wanted to, but you wouldn't call it a piece of shit because it allows you to do so

Common Lisp is an inconsistent mess of legacy hacks, just avoid it.

>auto
>shared_ptr

if it had been a unique_ptr your loop would've fugged you up

Attached: 1531136593418.jpg (383x353, 50K)

build tools are fucking obnoxiously poorly designed because no one cares to do them properly everyone just uses some random sperg hobbyist's basement project

Does java 7+ have something similar to range.contains()?

Is that Bjarne?

>build tools are fucking obnoxiously poorly designed because no one cares to do them properly
Which is why I was raving about Meson before. It actually feels like they've designed this shit to be sane and efficient.
They deliberately made their DSL not turing complete, so you don't get all sorts of weird shit with people programming things into their build systems and making a huge fucking mess.
I'm just coming off as a shill now, but coming from some god-awful Cmake things I've seen, I just can't get over how much more I like Meson over it.
>some random sperg hobbyist's basement project
Meh, I guess Meson fits under that too, but that's not an actual reason to not use something.
There are enough high-profile users for the "hobbyist stigma" to be gone.

Based Cargo

That's because it's not actual C++. It's standardese pseudocode for compiler authors.

Suggest an alternative to python for server-side scripting, task automation, directory/file traversal, string processing etc that isn't perl5 or ruby.

C

Trying to help a friend get into the database part of his python project.
I'm not good at python and his class management confuses me (many compositions).

Is there a tool with a python script or whatever as input and outputs how they are built ? The source code he made is a little confusing for me.

Like

classFoo
attr1 type object (otherClass)
attr2 type integer
method : getBar() returns bar (integer)

otherClass
...

Forgot to mention, I don't want 50 bugs each line and a language from this century.

>I don't want 50 bugs each line
Boy, you must be a fucking awful programmer if you do this.
>a language from this century
Of all the languages you mentioned, none of them originally come from this century.
Also, the latest C revision was in 2011.

Anyway, the typical modern webshitter answer to your question is Go.

fair enough. but it would follow, then, that a tool meant to serve as an abstraction of such tools, which attempts to unify as much of their functionality as possible through a common platform-/compiler-/build system-independent interface, while otherwise still allowing for the use of as much as possible of their remaining concrete functionality through platform-/compiler-/build system-level specialization, will necessarily inherit complexity somewhat proportional to that of the platforms, compilers, and build systems it supports, and the differences between them. CMake is less of a "build system" and more of a "build system system". while it's far from perfect (and setting aside the unfortunate matter of poor documentation), considering its overwhelming set of requirements (i don't envy the people who implement/maintain it, that's for damn sure), i'd say CMake manages to do a surprisingly decent job

>CMake is less of a "build system" and more of a "build system system"

Attached: 12d.jpg (567x561, 57K)

C is a piece of garbage. Take your weak typed steaming pile of shit out of my face.

>Goes on about weak typing
>Python, Ruby, Perl
Dynamic typing is 100 times worse than weak typing.

dynamic typing at least has some utility, weak typing does nothing but obscure the meaning of your program with implicit conversions

Ruby.
The new versions are not dogshit slow.
Crystal is also an option, it's compiled ruby with types and shit.

other than the placeholder tokens in italics, that code is actual C++. i don't think the placeholders are the part user thought was ugly

What are the fastest algorithms for calculating the inverse of a matrix?

It's a convenience thing.
The only implicit conversions in C are between the various "number" types (integers and floats), and between a void * and other pointer type.
That alone is not particularly much to deal with, and saves a lot of pointless casting.
There is nothing on the levels of retardation where integers are coerced to strings or vice-versa.

But user's right.. A build system system is exactly what CMake is.

You need modify the fstab file... And use ntfs-3g partition system... You should read more...

what's the problem? it's a frontend. it doesn't build anything on its own; it generates configurations for other build systems

haskell is a confusing shitshow of a language

and functional programming is a useless exercise in pure autism

what's confusing about haskell?

>dude, wanna do basic stuff OOP can out of the box with haskell? yeah?
>then good luck learning dozens of algebraic abstractions beforehand, cuz im sure as fuck won't hide the complexity from users LOL

It is all fun and games in theory. It worth talking about it but not actually use it

I'm new to programming and this may be a stupid question but what's the benefit of using text editors like Notepad++, Vim etc to program in rather than an IDE when they don't have a compiler?

Is "Java A Begginers Guide" by schildt a good book for starting out with Java? also will it matter that the current edition is about to be updated, or should I just buy the current one?
Also does anyone know if the mooc.ci course is good?
Thanks

do you need help?

>IDE when they don't have a compiler
What?
Main advantage of using text editor over IDE is language agnostic. IDE provide you better guidance than text editor (unless the text editor is fully configured for a language), but once you want to switch language, then the IDE is useless, and changing IDE means learning a new IDE, while text editor doesn't care what language you type in as long as the editor have the extension / tools for the language

it depends on the size, density/sparsity, desired accuracy / error tolerance, etc. are we talking like 2x2/3x3/4x4 matrices or do you need something generalized for high dimensions?

Is there a better/cleaner way to do this?
InputStream is = MyClass.class.getResourceAsStream("/MyclassRes/names.txt");
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line;
while((line = br.readLine()) != null) {
sb.append(line).append("\n");
}
System.out.println(sb.toString());

Maybe compiler isn't the right word, but if you're using visual studio and programming something in C# or whatever you can verify that the code is okay and you haven't made any mistakes, you can't do that verification in text editors can you?

That's how I mounted the drive... You can see in my pic that I have rwx permissions

What is the most anime programming language? I think it is Rust. Cute syntax, high performance, great parallelism and good productivity.

Attached: anime_pointing_dance.gif (243x270, 483K)

A rope around your neck

The word is analyzer and VS uses roslyn(compiler) to do that even for all .net langs and even JS/TS

>ironic weeb

So this is the power of POO

what makes Rust the most "anime" programming language is that its community is made up of insufferable autistic retards with shit taste who drank out of too many plastic water bottles growing up, which is the exact same demographic as people who like anime

Attached: 1509239233029.png (463x832, 409K)

>tfw drinking out of a plastic bottle right now
is it over for me? is there anything I can still do to save myself?

I'm thinking in the order of 1000x1000 or larger 2-dimensional matrices.

Can't really say about density or accuracy at the moment.