/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1551859259606.jpg (540x720, 86K)

Other urls found in this thread:

seenaburns.com/dexui/
siliconbunny.com/fsn-the-irix-3d-file-system-tool-from-jurassic-park/
github.com/GitSquared/edex-ui
hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/
papl.cs.brown.edu/2018/
quora.com/What-does-Professor-Shriram-Krishnamurthi-expect-a-student-to-know-after-he-she-works-through-his-book-Programming-and-Programming-Languages-How-long-until-the-student-is-ready-for-an-interview-at-a-top-software-company
twitter.com/AnonBabble

First for Scheme

Attached: 1547405292093.png (1280x720, 625K)

why is the book so big

Need to store some references in a vector. std::shared_ptr or std::reference_wrapper?

Haskell!

What is hands down the most versatile language?

no more new languages beyond this point

Attached: 1531182613704.webm (1280x720, 2.51M)

Second half of "Metaprogramming Ruby 2", my brain is full of fuck.

Do you guys prefer to write new programs in Crystal or Pony?

Getting back into programming after years and i've been trying out various languages. I decided to make a music player where you can search stream from youtube and have playlists. Simple stuff. It was really easy in python except for when i try to make into an app package for osx use. I fucking hate osx right now but cross platform is one of the features that ranks high on my list. Next was javascript with node and electron. Again, really easy but that file size...So today i thought i'd give java a try but i found the whole making an uber jar that can run without having to install jvm process confusing so now i'm done programming for the day

just use a regular pointer

Would be cool as fuck to have a 3D full screen view for arbitrary data structures. For example, you'd be able to see the file system as a 3D graph of linked nodes. Wouldn't be very efficient but it would look awesome. The briefings of the game are showing 3D map data overlaid with war information. What if we had similar visualizers for all kinds of data?

I also like the tiled window management.

3d file systems have existed
they universally suck

c++

file managers*

I know they suck. They'd probably look good though.

files are not data structures... files are dynamic and being manipulated, that's the problem with fancy graphics, a static 3d view of a limited set of data that is heavily nested and linked would be useful

but what I'm telling you is that they don't.

Python and [spoiler]Javascript[/spoiler]

Why the fuck is dereferencing the result of map.find() giving me an rvalue

It's late so I'm probably doing something extremely stupid but this code is throwing an error:
map foo;
foo[an_A] = a_B;
pair& element = *(foo.find(an_A));

Says it can't bind a non-const lvalue reference of type "pair&" to an rvalue of type "pair".
Removing the & (making element a non-reference) works with the expected result that it's not a reference and I can't modify the B stored in the map.

Again I'm tired as fuck and probably missing something really obvious but how the fuck can I get a reference to a map's value_type?

seenaburns.com/dexui/

Can you post screenshots of existing 3D file managers?

>a static 3d view of a limited set of data that is heavily nested and linked would be useful

Exactly.

I feel like this kind of thing is what smalltalk tried to accomplish ages ago. All data was smalltalk data and lived in a smalltalk virtual machine, and you could manipulate everything via the GUI. It wasn't 3D but it was really fucking dynamic.

Attached: dexui.png (1916x1199, 929K)

A static 3D view of anything is useless. Can you honestly tell me that you can glean any useful information out of this graph where nodes are websites and edges are hyperlinks?

Hell I challenge you to come up with a useful and meaningful 3D interpretation of a file directory structure.

Attached: Internet-Graph-1069646562.LGL_.2D.4096x4096.png (4096x4096, 2.74M)

siliconbunny.com/fsn-the-irix-3d-file-system-tool-from-jurassic-park/

merits of exceptions vs other error handling? right now, for error-handling between backend and frontend, backend writes false on method failures and stores an error message in most classes. frontend displays the error on failure. some programmers shit on doing it this way and insist that exceptions are better in every case. i feel like this is python cancer, to abuse exception, when exception is not meant for expected failures (database doesn't have key, for example). why do the python programmers do this? which way is better?

3D visualizations of anything that isn't distinctly spatial are always more useless than 2D

github.com/GitSquared/edex-ui

They made this shit with fucking electron. Be triggered.

That's old as fuck, mostly a tech demo. Surely a modern design would look better?

Attached: edex.png (1600x900, 1018K)

that particular image? no but if I could zoom in I would be intrested in seeing which websites linked to Jow Forums.
>Hell I challenge you to come up with a useful and meaningful 3D interpretation of a file directory structure.
pic related

Attached: 1527779096792.png (650x300, 186K)

>i feel like this is python cancer, to abuse exception, when exception is not meant for expected failures
The only thing wrong with this is when you're using Itanium exceptions which are extremely expensive when thrown (and free when not thrown). I don't think Python exceptions have the same performance characteristics.
>right now, for error-handling between backend and frontend, backend writes false on method failures and stores an error message in most classes. frontend displays the error on failure.
This is far worse than a possible performance imbalance.

Exceptions are IMO horrible. The best place to handle an error is where it happens.

how is that 3D?

Error handling in general obfuscates code, making the programmer's intent less clear.
Exceptions often force a style of programming where exceptions MUST be handled as soon as they occur.

Whereas error handling using optional types, pattern matching, binds, fmaps often allows you to handle errors wherever you want to handle them.

its a top down view of boxes

That's not inherently spatial, that's just useless phong shading on a colored plane to make the borders more obvious

that's 2D though

no way that's the whole code and the whole error

i think operator[] should do what you want

>optional types, pattern matching, binds, fmaps
why did you assume he was talking about Haskell?

why?

why?

What do you think about the upcoming C++20 ranges?

why did you assume that optional types are exclusive to Haskell?
he asked for error handling techniques and I gave him one.

take your meds

unless you can rotate it around and view it from other angles, a top down view is a 2D view

I'm procrastinating on work and, my side project, the /dpt/ archive. I'm tired of styling.

>why did you assume that optional types are exclusive to Haskell?
the rest are

No, operator[] only returns the B. I need the pair.
If that's not possible I could try to fuck about as long as I can at least get a reference to B, but everything would be a lot easier if I could just have a reference to the whole pair.

I mean of course it's not the whole code but it's what I believe is relevant to the error. Should my example work without throwing an error? If so then I'd be very confused because I can't think of what else would be relevant, but it'd at least tell me where not to look.

you specified a "static" 3D view, doesnt that mean you cant change the angle or zoom? if you can, I have a lot of possible ideas

other features simply make it easier and more versatile, you don't need most of those features to make optimal use of optionals.

why does it have to be a reference

Yes, it should return an iterator and the iterator should dereference to a std::pair.

Now that I think about it, the only reason C++ exceptions can be expensive is because of RAII. In a garbage collected language like Python, exceptions should be quite cheap no matter what.

So I can modify it
So no way to get a std::pair&? Fuck's sake.
Maybe I should go to sleep and redesign my code to be saner tomorrow. Or just give up and use a vector of pairs or something.

Exceptions should only be used for exceptional errors, not expected errors, hence the name

messing around with Flutter/Dart

Looks promising enough so far, time will tell

i dont think youre supposed to mutate the map through the pair

C++ exceptions are expensive because of Itanium, the defacto standard ABI. Itanium exceptions cost nothing during normal code execution, but are incredibly expensive once thrown.

You should be getting a pair& from that code. If you're not getting one of those then something's wrong.

There's no such thing as "exceptional" and "expected" errors. There are programmer errors, and there are logical errors. Programmer errors shouldn't exist, and you certainly shouldn't try to recover from them. Thus, exceptions are fine for logical errors.

Fuck's sake. Fine I'll redesign my everything tomorrow.
For context my scenario is that I have a data type that's really inherently a pair but needs to be searchable on A (which is why I didn't go the natural route of a vector of pairs from the start). So I'll need to decouple A and B in my logic into two half-datatypes in order to properly operate on B&s.

>If you're not getting one of those then something's wrong.
Yeah I can't get the & out of it. Says it's returning an rvalue. Something's definitely very wrong.

>There's no such thing as "exceptional" and "expected" errors
There's bad user input errors, like trying to load a malformed file, which is a good place to throw an exception

Which would be a logical error. Call it what you want, but saying exceptions are only for programmer errors is fucking retarded.

>2 years of classes in probability and statistics in uni
>pass exams
>know shitall
>dick around with randomness/simulation in sepples for a couple of days
>this is actually not that bad
gamers rise up

That is what I meant to say
Obviously nobody should be throwing an exception for a bug that a programmer is supposed to fix

Then we (probably) agree that there's no reason to say you shouldn't use exceptions for every instance of error handling, in Python at least.

Exceptions obfuscate cause and effect and can have performance penalities, which is why overusing them is bad, but I guess Python programmers don't care about performance

>Exceptions obfuscate cause and effect
Uh, no they don't, since you can throw whatever data you want.
>and can have performance penalities
Only if they need to unwind the stack to call destructors, i.e. not in Python.

python exceptions do not have the same performance characteristics, but is right, exceptions tend to lead to a sloppy style of programming in my opinion. i'd rather store the error and handle it in a higher level

Was gonna make my own thread, but maybe you guys can help me out: Is Codecademy worth shit? I got an email from them about some React.js course, and they have this 1 year training program for $240 or something which they claim will give you enough of a knowledge base to be employable. Is that true or are they lying, because I'm getting desperate about my career prospects and don't know what else to do with my life, really

shared_ptr so the destructors will be called when the vector is deleted

anyone who isn't a chucklefuck is using context managers and object destruction is most assuredly occurring in exceptional cases.

value_type std::pair
so use
map::value_type& element = *foo.find(an_A);

>i'd rather store the error and handle it in a higher level
What do you think exceptions do?

>anyone who isn't a chucklefuck is using context managers
What the fuck is a context manager? Sounds like some OOPsie bullshit.

>Uh, no they don't, since you can throw whatever data you want.
It has nothing to do with WHAT you're throwing, it's the fact that exception handling disrupts the normal flow of the call stack

So?

Thoughts? hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

exceptional vs expected errors are different than that scope. an expected error is an error case that may happen due to some input or some condition, but it isn't program-breaking when it happens, you don't have to terminate. exceptions are an exceptional, this-should-never-happen type of case that generally can't be recovered from very easily, it may be program-breaking or not.

I don't care if Python follows an exception model. Guido is wrong on that one

value based exceptions are superior.

>an expected error is an error case that may happen due to some input or some condition, but it isn't program-breaking when it happens, you don't have to terminate
So, use exceptions because you can catch them and recover.
>exceptions are an exceptional, this-should-never-happen type of case that generally can't be recovered from very easily, it may be program-breaking or not
Otherwise known as a programmer error?

So that's why it obfuscates cause and effect
you're throwing something at the top level and it's instantly jumping to something several levels deep

Map has an internal data structure (probably a tree or a hash table) that uses A as a key. This is the underlying reason that the provded interface of the map does not allow you to directly modify A. You could remove the pair from the map and insert the modified one.

You've got your top and bottom mixed up. But I really don't see what you're getting at. It jumps up just as far as it takes to be caught, i.e. at the point where you can recover from it. If you don't catch the exception in a particular procedure, it means that you can't recover from it there, and every statement after the possibly thrown exception can execute under the assumption that everything went OK.

>what do you think exceptions do
bitch and moan "handle me NOW!"
"no honey, I need to close this connection"
"NOOOOWWW!!"

>context manager
>OOPsie bullshit
take your meds, weenie.
It's something that wraps around a closure and takes in a function which handles the safe creation and destruction of allocated resources
it's literally RAII for specific objects but only when you ask for it.

otherwise known as, "this device stopped existing," or, "we can't run the file you're trying to run because it's an ascii dick instead of bytecode"

in practice, with exceptions, you end up with sloppy goto-style jumps throughout the entire call stack to some random handler, and we're not even getting into the fact that inherited exceptions never get used because everyone just uses the top level Exception anyway

What part of "obfuscating cause and effect" do you not understand? A function is returning to somewhere it didn't start from. If you use exceptions everywhere this can make following the flow of the program confusing as hell. Which is why they're for exceptions

>bitch and moan "handle me NOW!"
>"no honey, I need to close this connection"
>"NOOOOWWW!!"
autism

someone's not getting his tendies

Oh, I see. In that case, I guess exceptions can be more expensive. But I don't see how any other kind of error handling avoids the problem, unless you can recover from the error before jumping up past the scope of the context manager. Which you can also do with exceptions, by catching inside said scope.

>we're not even getting into the fact that inherited exceptions never get used because everyone just uses the top level Exception anyway
Don't blame the feature for how it's used by retards.

>If you use exceptions everywhere this can make following the flow of the program confusing as hell.
Unchecked exceptions, sure, but if you're using a dynamic language already then you've really dug your own grave here.

>Don't blame the feature for how it's used by retards.
a feature is only as good as how well it's utilized user

>I don't think Python exceptions have the same performance characteristics.
The main expensive thing with them is computing the stack trace.

small cat

Attached: 1548064551712.png (489x424, 129K)

lambdaschool doesn't cost anything up front if you live in EU, UK or US and Ayy

however it's not a given you'll get a job, you have to put your own time in doing secondary resources like this papl.cs.brown.edu/2018/ with info here: quora.com/What-does-Professor-Shriram-Krishnamurthi-expect-a-student-to-know-after-he-she-works-through-his-book-Programming-and-Programming-Languages-How-long-until-the-student-is-ready-for-an-interview-at-a-top-software-company

>the most versatile
It depends on the scope of "versatility." Looking only at modern platforms, then C and C++ are pretty much tied.
If you include legacy systems, then it's C and nothing else even comes close. In the realm of "things made in the last 50 years that you can write code for," C is pretty much always on the list of supported languages. The only unilateral exception to that would be FPGAs and their predecessors, but none of the HDLs serve any practical purpose outside of that specific realm.

>Unchecked exceptions
any exception can jump straight from A to Z without going through the rest of the alphabet first

This is really only true if you're working in a team of code monkeys, but again, digging your own grave.

Okay, what did he mean by this?

>a feature is only as good as how well it's utilized
You have an error in one place. The best spot for deciding what to do about it is somewhere else. You need to pass control between those two, and you need to clean things up along the way. ALL SOLUTIONS HAVE TO DEAL WITH THIS. You can write it all out by hand, or you can have the language provide you with some assistance.

I need to implement an import system for entities, which should help reduce the boilerplate and repeated information in various entities.
How would you design this system?
When I google this topic all I get are "how use import statement :DDD"

What I've done so far is recurse through the imports and merge the entities, but this has a side effect where I have to delete the imports to prevent infinite recursion, but I'd very much like to still record what files were imported from.

>what did he mean by this?
exceptions jump straight up the call stack to their handler as soon as they're thrown you fucking retard

Okay, but I don't really see how this is confusing in and of itself. If you have checked exceptions, you know if a particular procedure is going to be able to do that.

The same reason gotos are considered harmful

Exceptions are way more structured than goto. You can implement exceptions purely with branch and return, it's just easier to use the language feature if it exists.

Ok, I'll come clean: I just fucking hate using exceptions and writing try catch. It triggers my tism

well thats the point.
they get thrown when continuing along the current code path would result in errors and bugs and shit.
exceptions are very preferble to that

and if you want to avoid both exceptions and bugs you would do the same thing in either case.