/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

people.gnome.org/~federico/blog/rust-things-i-miss-in-c.html
docs.python.org/3/library/enum.html
indeed.com/salaries/SQL-Developer-Salaries
twitter.com/NSFWRedditGif

If C++ sucks so much, then why is it so popular?

Threadly reminder to use #![feature(nll)].

>Not writing in the common subset of C89 and C++98
Either you care about portability or you don't.

Threadly reminder not to use Rust.

Good library, works on most devices unless you are really strapped for memory, newer dialects (C++11 onwards) are actually not as cancerous as the earlier ones, acceptable tradeoff between build time, runtime performance, memory consumption, and coding ease.

That, and there's just a fuckton of legacy software that's already written using it and so must be maintained.

...

wtf I love pointers now

What the hell am I supposed to use then?

> programming language
> sql
Who is challengerocket and why should we care.

C, or a strictly enforced subset of C++.

Might as well say to use HTML. Rust and C/C++ are not used for the same things.

I originally was going to use an enum but it looks like they don't exist in python 2.7. I assume you mean something like this?
BASE = 0
GARBAGE = 1
state = BASE
# etc
if state == GARBAGE:
# etc


As far as I can tell this isn't any faster than what I was doing.
import timeit
print timeit.timeit("a = 'STRING'; a == 'STRING'", number=10000)
print timeit.timeit("a = 'STRING'; a != 'STRING'", number=10000)
print timeit.timeit("a = 1; a == 1", number=10000)
print timeit.timeit("a = 1; a != 1", number=10000)

0.000676445565313
0.000690878429704
0.000633146972137
0.000625170915499

But what about the things I would miss: people.gnome.org/~federico/blog/rust-things-i-miss-in-c.html ?

Python 2 is at EOL in 2020

docs.python.org/3/library/enum.html

Rust is a systems programming language. This is the domain of C and to a lesser extent C++.

Not worth it if it means fighting the borrow checker.

>Almost 10% faster
>Its not faster!

Yeah, one of them is used to write software that actually works, while the other is a good justification for hiring neon haired "coders"

>Reading the GTK+ source code and learning a C style that was legible, maintainable, and clean.
Whatever he has to say is 100% worthless.

>he's intimidated by the borrow checker
Fear no more! See .

I should clarify. I understand in principle comparing strings is slower than comparing integers. I just don't think its meaningful here.

Yeah, I'm planning on switching soon. I don't really want to mess with the already awful development environment I set up on Windows.

>>> (0.000690878429704 - 0.000633146972137) / 10000
5.773145756700002e-09

0.000000005773145756700002 seconds.

> One of the largest C project out there
> Not really a good C project
It's just like every time a vulnerability is found in C code, soon C-tards will have to no-true-scotsman away all the major C projects out there.

If Qt5 is so popular, why the fuck is it so hard to find a good guide/tutorial that gives complete overview of the library? Im specifically struggling to get the View-model-model-viewmodel-model-view shit working in PyQt in a consistent way, I follow one vague tutorial, it works, try it later with something else it doesn't work, need to find another small vague tutorial on that topic. Oh wait this one used Qt4 and now I need to finds another quide with the changes between 4 ad 5 to convert it because it wont compile. The reference docs are also complete shit and cant be used on its own.

>Using unstable features.
Not that it matters. The flaw in the borrow checker is a conceptual one, and no amount of new features will make it worth using.

>Not knowing how percentages work.

>C
Eww yuck

Your reading comprehension needs work. Or maybe you just don't understand how to measure performance? I'm not sure. Both relative and absolute measures are important user.

>federico
Mfw he's actually working on the gtk file picker

>cs101 student
sql is probably the most declarative of all programming languages.

Did you even read the chart in question? What job pays 80000 for writing SQL queries?

SQL is in high demand right now because no new programmers can actually write it anymore, yet everyones databases still run on it.

a database administrator is paid more than that.

It's specious to call a DBA an "SQL programmer", do better user

>SQL monkey
>database administrator
war

i know dba who the job is only about verifying sql scripts

otherwise,
indeed.com/salaries/SQL-Developer-Salaries

I'm slowly turning into a black person.

This. You bad a maths and still want a job related to programming? Learn SQL and its related tools.

I stand corrected.

Is there a downside to making structure definitions global?

namespace collisions

Will learning Haskell enrich me as a human being?

null-terminated strings were a horrible mistake

Any job you want
300k starting

No shit, even the authors admit it.

MSVC is garbage.

Pascal strings are better but not as portable.

>PyQt
Found your problem.

Is PySide better?

>description
Doesn't make sense to me why they'd do that. If we're looking for performance breaking these individual components up more would probably not be all that good.
If their goal with the change was primarily to improve performance this is probably a rather high level aspect of the system for pruning updates without conditionals. For instance if you wanted all physics but no gravity for an entity type they could generate an update cycle that only does that for all of them. Instead of setting the gravity constant to 0. For more complicated behaviors that would be a lot harder of course.
Doesn't seem entirely related to the new setup though, if I understand you correctly.
>how do different entities reference each other
Well there's the index. If you split types into groups you'd either set the range of entities and then subtract to adjust for the actual indexing. (since one type of entity will always start indexing on 0, unless you're really tricky).
Occupancy is usually flagged. So you don't start operating on a dead object.
This can be more complex if you defragment the arrays often. You might have a field for checking if the type was moved. But that's a can of worms. Ideally you'd only keep that info around for one frame and update everyone.

I meant you should be using the native C++ API or QtQuick. Bindings in other languages are typically terrible.

yeah rust is good and all but will it solve the travelling salesman problem?

no but the solution to the travelling salesperson problem is making progress

Just out of curiosity, what does /dpt/ class as webdev?

I always get shut down when discussing projects that have an online component. I can't take it to /webdev/ because they just copy stackoverflow and can't have a meaningful discussion.

*salesperson

>online component
That'd fine. I don't consider it webdev if you're writing a server to match your client.
The problem is when you do what /wdg/ does and throw library names around as if everyone knows what a react is. That doesn't happen here really. Doesn't happen here really outside of the generic CS stuff mostly.
And I'd also classify JS/HTML as webdev. Though JS at a small scope is still /dpt/ relevant. Use the DOM and you're in /wdg/ suddenly.

Anyway user. I don't think you should have too much respect for not cluttering /dpt/. We have junk here all the time.

anyone ever use .net Core?

>not mankind
>peoplekind
>*Canadian applause*

More like LLVM bitcode, or a strictly enforced subset of C.

I know some JS, HTML, CSS, Java and Python. Should I go with Express.js or a mix with React/Node for my first web dev project ?

It will - once communism is established, there will no salesmen to have traveling problems.

Any autist here participated to the google summer of code? Can i participate with only medium programming skills ?

Yeah, it's aimed at second year CS students, and all of the typical second year CS students I've met are pretty shit.

If you're intimidated, work on a simpler project.

Either or neither. You can get away with just vanilla js. Es6 is comfy.

Can I apply as a postgrad? Looking for something fun to do. Do they actually check/ care?

>I'm slowly turning into a black person.
The longer you stay on welfare, the blacker you will get. I'd start looking for a Java job if I were you.

There are other huge C projects out there.
Some people don't like the idea of GObject.

You should be looking for work. : ^)

I have work. It's dull and doesn't strain the brain much.

Like it or not, but it's apparently the best way to write GUI in C, which is basically all you need to know about C.

You need to leave. shill.

Is this kind of comments supposed to be hints for automatic documentation?
If so, what program do I use to make such automated manuals?

doxygen.

>halRfReadRxBufPgEscIntVmParCgWriteFnCkInsecure
Why would you do this?

If only Qt got rid of MOC and used C++ with metaclasses. It'd be so nice. C and Gtk is absolute cancer.

How do you stay motivated to finish useless projects that most likely no one will care about?

Can anybody tell me what the difference btw sed '1,/^$/ d' and sed '3,/^$/ d' is?
I know that the former deletes everything up to first blank line in a file like:
blank
blank
blank
ABC
BCD

But when I substitute the '1' with other numbers the results don't make any sense at all.

I don't think Google will give you money if you're a postgrad, but there's nothing stopping you from volunteering to do a project anyway.

>5 spaces indentation
and here I thought I had seen everything

>apparently the best way to write GUI in C.
You're confusing things here user. The reason people claim this is because they like OO in their GUI applications. Not because this is the best way to write GUI in C.
Entirely different.
Making the claim you just did you're claiming that OO is the best way to write GUI in the generic case. Which is a different discussion. I say it's not true. It's good for a very specific subset of GUI which is data presentation that doesn't need updating. Both in the maintainence sense and the immediate sense.

The first number is the starting line, IIRC, so the second version will delete everything starting from the third line until the first empty line.

Because they think documentation makes for good understandable api.

- look good on your CV
- bolster your github/ insert vc platform
- exercise your mind
- potential for profit if you can build a business around an original idea
- programming is fun

Still tho, there's no C GUI library which comes anywhere close to GTK in terms of maturity and features.

It's a problem with the personality not motivation.

You would have to change as a person.

The leading number specifies where sed should work on. The comma tells sed to continue from the previous value or expression. So, "1,10" would tell sed to work on lines 1 to 10.

>look good on your CV
I already have a job.

>bolster your github
But nobody will ever notice it, senpai.

>exercise your mind
I guess there's that, but it only gets you as far as solving the interesting problems. It doesn't take you all the way to the finish line.

>potential for profit if you can build a business around an original idea
I leave profit-centric considerations for work.

>programming is fun
It is, except for all the parts that aren't. A lot of it is just filler: digging through some god-forsaken, badly documented API, debugging, handling issues you couldn't care less about.

Well I say that's because it's something C programmers and systems programming people in general don't have to care about. It's like looking for high performance python code that doesn't make use of C FFI.
It's pointless.
It'd be nice to have other extensive libraries that wasn't OO. But is it really realistic to expect that less popular methods of GUI is supported in something that's so relatively niche?
Now especially with people favoring embedding web browsers and giving the GUI work to webdevs.

>It's a problem with the personality not motivation
Sure, I guess there are people who actually enjoy struggling for its own sake, so they don't need external motivators. I'm just not one of them.

Domou arigatou gozaimashita

yeah that's it, was kinda confusing because I had repeating patterns in my file.
Thank you!

Honestly, it sounds like you've thrown in the towel. If you want to be motivated you have to want to want to be motivated.

Disagree. I think it is easier to change the projects or work selection than changing as a person.

Webdev for me would be if you're designing something that runs entirely in a browser. Most of my projects end up being "webdev" because they run in a browser instead of a standalone executable.

However, like this user says I differ from the posters on /webdev/ because I have no idea what all their frameworks and dockers and npms are. I just open up emacs and write code and try to avoid too much JS and CSS. One time I tried forking a neat online text-based RPG I found on github. The instructions said to run "composer install" and it would get everything ready to run. That command proceeded to download about 300MB of dependencies when the original file size of this project was about 50MB. That's why I don't like /webdev/.

>If you want to be motivated you have to want to want to be motivated.
I'm just curious if any of you actually manage it, and how you do it.

Who says it's harder?

How do you handle too many choices? As a simple example, lets say you have an object that should store a list of sortable objects, you should be able to add and remove objects, as well as find the nth object at some time. How do you decide what to do?
>Normal array and loop over it if performance doesn't matter
>Sort on insert and remove and just get nth item if add and remove is rare
>just append it to the end and sort when you want the nth object if finding the nth object is rare
>cach results in previous line maybe
>flat or tree structure?
>Some combination that changes depending on how its used

How do you choose? based on what the program does you should be able to at least narrow it down, but without testing you wont know which one is best, and you need to write them all to test them, so do you write each part of your program multiple times just to find out whats the correct way to do it?

>nth object
use a sorted vector

For me, it's a creative outlet. I like the feeling of creating something completely original -- a statistical certainly due to the vastness of the tech world and the rapidity of its change. That's the source of my motivation and it gives me a lot of energy.

>How do you choose?
You decide on the interface first. Then you choose the simplest implementation that would work. Then, if you run into problems with it, you at least know what they are, and what alternate solution fixes them.

>I like the feeling of creating something completely original
That actually seems borderline-impossible... what's something original that you've made?

ok, how did you get to that answer?