/dpt/ - Daily Programming Thread

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

Attached: 1543874106187.jpg (1500x1500, 1.26M)

Other urls found in this thread:

youtube.com/watch?v=M4KSZQYmuMQ
developer.android.com/studio/write/java8-support
androidhive.info/2014/07/android-speech-to-text-tutorial/
geeksforgeeks.org/clone-directed-acyclic-graph/
sites.math.rutgers.edu/~cherlin/History/Papers2000/wilson.html
twitter.com/SFWRedditVideos

On pounding your thicc girly boypussy

Why would anybody pay to use Delphi? It is so great or what?

Attached: Screenshot_2019-01-09-06-59-07.png (1023x295, 25K)

so in c++ can someone explain arrays? It's basically a reference to a grouping of pointers?

Lisp is the most powerful programming language.

as a 2 years professional /wdg/ fag, should I start learning C/C++ and some other big boi lang?

I know typescript, js (and use it mostly with react and vue recently), python (django rly).

are you using std::vector or pointers? Just use std::vector desu

What are you working on?

actually no

Hey I am trying to develop an Android app for the blind and I would like the users to be able to use the entire program using only their voice.
Ideally, the app should have a single button for voice command and the user can say certain keywords to do certain task.
I am not sure how to proceed with this. Namely, what is the kind of program architecture/algorithm that is best suited for this kind of task.
Currently, what I am thinking of doing is to get the strings spoken by the user, match this against an array of the predefined keywords, the highest scoring one will then be the keyword
Problem is, Java (Its an Android app) does not have function pointers, so I can’t do something like HashMap to simply call the required function that will execute the action requested
Using switch(...) seems like a bad coding because it’s not really scaleable.

>user talks about arrays
>hurr durr vector

fuck the blind, they use proper software not some android shit, and they are not the group of ppl who would buy an android device just to discover some fag have made something 2% useful

just answer my programming question.

Adding OOP to Ada was a mistake

Don't waste your time with programming something useless.

You're asking a general that doesn't program anything and just circlejerks FP languages. They also hate people with jobs.

God save us everyone
Will we burn
Inside the fires of a thousand suns
For the sins of hand
The sins of our tongue
The sins of our father
The sins of our young

Attached: 1503725475673.png (1120x1078, 1.45M)

youtube.com/watch?v=M4KSZQYmuMQ

How good is something like Lua for creating a DSL for specifying complex configurations? I'm want to have a configuration for what is essentially a graph, and I can't think of any way this could sanely be done as a traditional config.
I've never embedded a scripting language before, so I'm not entire sure what good use cases for them are.

Attached: 1542844397259.jpg (270x400, 104K)

>Problem is, Java (Its an Android app) does not have function pointers, so I can’t do something like HashMap to simply call the required function that will execute the action requested

developer.android.com/studio/write/java8-support
You can use Function with Android and Method references which are effectively function pointers. Likewise, lambda too.

Why not just a plain old textfile with tab or something signifying children?
No need to embed a whole turing complete language for something that can be done without it.

Arrays in general are just a group of values that have the same type. You can think of them as a list (in the common usage of the word list). IRL a person might have a list of several phone numbers, or a to-do list of tasks, or whatever. In C++, such a real world list can be represented by a C++ array.

> It's basically a reference to a grouping of pointers?
Not exactly. It isn't so much of a reference as it is the group of values directly.

You certainly can have an array of pointers, but arrays need'nt be so.


int myNumbers1[6]; // an array of 6 numbers, we haven't set their values
int myNumbers2[6] = {10, 11, 12, 13, 14, 15, 16 }; // an array of 6 numbers, their values are set
int myNumbers3[] = { 1, 17, 7, 2, 28, 8 }; // also an array of 6 numbers

myNumbers2[0] = -18; // set the FIRST number. In C and C++, arrays are zero indexed, so [0] is the first
myNumbers2[5] = 2938; // set the LAST number. Since arrays are zero indexed, [5] is the LAST of an array with a size of 6

androidhive.info/2014/07/android-speech-to-text-tutorial/

You shouldn't need that big of a command vocabulary, but you might need to swap vocabularies depending on language settings. Scanning a list of words shohldn't be too bad if tge vocabulary is small.

As with crude text prompts, you MIGHT be able to get by with just recognizing numbers. Think of number presses with robo-calls only voice numbers, or other suitable vocab.

Do the blind use TTY phone connections? That might be another input option but I dunno.

Attached: 73628034-8eac-4373-ba14-f9f96ea2786c..jpg (564x750, 115K)

And why the fuck would anyone use Java over python for these stuff?

why the fuck would you ever use python for any reason

>python
>hadoop
>spark
Hello retard poster.

Brand new programmer doesn't know any better.

If the graphs in the config file don't need to be human read/writable then just using index numbers as references should do.

Coding in Python and Assembly. Fuck midtards who use anything else.

Checkem. 27 trips.

>Why not just a plain old textfile with tab or something signifying children?
Because it's a graph, not a tree. What I have "sort of" looks like a tree, but things can cut across the branches and things can have multiple parents.

Here is a possible routing I could have. Each of the vertical levels are a certain type. Some of the types the user can specify, some of them they can't. It's also missing some links, because technically everything should link to something at the top level. There are also a bunch of other attributes and other related shit would would also go on top of this. It's too complicated for a config file.

Attached: output.png (768x1366, 84K)

Arrays in general are just a group of values that have the same type. You can think of them as a list (in the common usage of the word list). IRL a person might have a list of several addresses, phone numbers, or a to-do list of tasks. In C++, such a real world list can be represented by a C++ array.

> It's basically a reference to a grouping of pointers?
Not exactly. It isn't so much of a reference as it is directly the group of values. You certainly can have an array of pointers, but that doesn't have to be the case.


int myNumbers1[6]; // an array of 6 numbers, we haven't set their values
int moreOfMyNumbers[6] = { 10, 11, 12, 13, 14, 15 }; // an array of 6 numbers, and we've set their values
int myNumbers2[] = { 1, 17, 7, 2, 28, 8 }; // also an array of 6 numbers even though we didn't specify the size of the array

moreOfMyNumbers[0] = -18; // set the FIRST member of the array moreOfMyNumbers. In C and C++, arrays are zero indexed, so [0] is the first of an array with a size of 6
moreOfMyNumbers[5] = 2938; // set the LAST member of the array moreOfMyNumbers. Since arrays are zero indexed, [5] is the last member.

int test = *myNumbers2; // the name of the array is the address of the first element
assert( test == myNumbers2[0] ); // true, see above

test = *(myNumbers2 + 0); // identical to *myNumbers2
assert( test == myNumbers2[0] ); // true, see above

test = *(myNumbers2 + 2) ; // the name of the array is the address of the first element
assert( test == myNumbers2[2] ); // true, see above

Do you guys like illiterate programming languages or literal programming languages?

its good for scripting, mockups, or any small application where performance isn't critical
has great libraries (unlike lua) and the syntax is easy enough to onboard anyone in a few days

Python dominates data science, ML and Math&Engineering fields and has much much better libraries than whatever Sanjeet, the Poo analyst came up with.
Just stick to your enterprise $500 a month job

me and my wife hehe

data science and ml yes, but it's definitely not the language of choice for math or engineering.

That is a job for R and matlab which are influenced big time by python

std:vector is just an array that adds 2s to your compilation time for each new type you use it with

Looks like a Directed Acyclic Graph (DAG). geeksforgeeks.org/clone-directed-acyclic-graph/

It looks like edges never jump over a step... Instead of index numbers you could use keyword names instead. Maybe each layer could be a section and later sections would have nodes with keywords refering to nodes above.

You don't have to climb up the multiple-inheritance trees do you? That would take backlinks and breadth-first search during runtime. If hierarchies ever get too complicated consider using composition.

Attached: fff1cb5f-3e44-48ca-8354-426641daf6b9..jpg (960x953, 127K)

Not a java programmer but if you're really dedicated to stupid OOP you can just make "function objects"

you have myfunctionclass that implements some method execute(), and then new classes (one per function you want) that inherit from it and implement their own execute() method

then you can use your function objects in place of where you want function pointers and just call foo.execute() when you want to call the pointed-to function

i only implement my algorithms in scratch or in fpgas

>not a java programmer
>suggests something that pajeet needed years to think about before finally addding to "newer" versions
The absolute state of java devs

>it's too complicated for a config file
am i missing something because this seems like it would be trivially easy to record

node 0 points to node 2 and node 3
node 1 points to nodes 4 5 and 7
node 2 points to node 6 and node 9
and so on for the rest of the graph.
it would be extremely easy to parse information like that and reconstruct it in memory

Need some opinions here

Im doing freelance work for a small business owner (Android app). Google decided to fuck me sideways and kill the drive api and now I have to reimplement it using rest and oauth and write offline sync from scratch. Who should pay for this? Do I just tell him the app won't work unless you pay me for a lot more time? Or am I obligated to just do it without compensation as part of my agreement in supporting the app?

Don't work for free.
If a tree falls down and smashes your garage you don't get to make the construction company come in and rebuild it for no pay.
>Do I just tell him the app won't work unless you pay me for a lot more time?
This is a pretty shitty way to word it though.
You'd be better off saying something like "Google changed how things work and broke the app, and it will take a lot of work to get it running again"

Should I learn Haskell or common lisp and why?

Read SICP first
you'll learn MIT Scheme as a side effect
all the lisps are one giant incestuous blob so it won't be that hard to jump between them i'm sure

Attached: 1545866300373.png (796x720, 456K)

Just use an adjacency matrix

If you had a contract then you will need to either fulfill it, renegotiate, or breach. Consulting contracts usually have Requirements For Payment (RFP). :/

Good luck, hope they understand!

Attached: db3e06aa-7be3-44ce-92ed-a719db863188..jpg (459x294, 35K)

is that a new hidamari on the right?

>What are you working on, Jow Forums?
Reposting the webm of my walking robot ;-)

Next steps:
- clean up kode
- rotate coordinate systems to make input easier
- make it walk more eleganz
- put the kode on github and spam it everywhere
- make it remote controlable or something

Attached: math.webm (1280x720, 1.76M)

looks like it has parkinsons

Huge C noob here, started to give it a shot yesterday after coming from python.
I made a simple pi program using the leibniz calculation. The problem is that long double division doesn’t seem to be precise ( a lot of zeros at the end ). I’d include a screenshot but I’m phonefaggit atm. What am I doing wrong?

Am I supposed to get a segfault if I pass a string with nulls only to strtok()?

No.

you are probably having promotion somewhere in your code.

the problem is either with your code or your interpretation of the output
we can see neither
try a crystal ball

thanks! ;)

Does it have any sensors? I don't see them

Same but the opposite. Anyone cares to explain how "with await" even a thing? Why people do that? The whole async bs is obscure in the first place, but this construction doesn't make any sense at all to me. Why make an awaitable object returning context manager instead of using it directly?

No. Not yet.
Not sure if I'll add some anyways. The plan is to build a bigger one if I get this one walking more or less good.

That power series converges slowly if doing the basic `arctan(1)`.

Usually you want to use the angle addition trick(-s): `pi/4=4*arctan(1/5)-arctan(1/239)`. Those converge much faster. There are other variants listed under Wall of Text here. sites.math.rutgers.edu/~cherlin/History/Papers2000/wilson.html

Doing a numerical integral of a unit circle is good too, or a quarter-circle of radius 2.0. Everyone tries to code the Monte Carlo method but the accuracy is at best mediocre that way...

Of course, floating point numbers have limited precision anyways... If you're worried about that then do the series to ten thousand terms, backwards. If you do a converging series backwards the little parts accumulate first reducing the round-off error. But there will always be a little round-off error.

hey guys, I need to write a high-bandwidth transaction server for a school project and want some advice on what to use
it needs to take some input from a web-server, query a db, and run some business logic.
what are some good frameworks I should look at (any language is fine) to maximise transactions per minute?

>to maximise transactions per minute?
C.

You might have done integer division instead of floating point division... Everyone makes that mistake sometimes. You only said the decimals had too many zeros though? Whatever, you can still try other methods!

Attached: 4c8c2bbd-62d5-4d3e-b391-fdadf70a8d21..jpg (607x505, 30K)

>after 3 hours of trying to understand why my program doesn't work someone tells me to replace strtok() with strsep()
>bug is gone
Wish C had documentation as good as python.

>strsep
Non-standard garbage.
C docs are file; look at the man pages.

a.c:9:1: error: C++ style comments are not allowed in ISO C90

Why should I run the compiler with -ansi parameter?

Attached: proxy.duckduckgo.com.jpg (599x416, 23K)

Remember that pointer book i was reading?
One review on amazon sums it up perfectly.
>Half of the book is pointers to other half.
Who allowed this to be printed and published.

*siiip*
C89/ISO90, now THAT was a good standard

Attached: boomer1.jpg (480x360, 30K)

Just target C11. There is no reason to retardedly restrict yourself like that.

Not portable.

This is the most retarded argument I have ever heard.

>Non-standard garbage.
Should I care about that if the program is written for linux and uses linux system calls?

strtok cant handle empty fields

Yes it can.
#include
#include

int main(int argc, char *argv[])
{
char def[] = "a b c";

char *ptr = strtok(argc > 1 ? argv[1] : def, " ");
while (ptr) {
printf("%s\n", ptr);
ptr = strtok(NULL, " ");
}
}
This program works perfectly well, even when given an empty string as an input.

Does ANSI C only refer to C89?

Technically no, since ANSI defers to the ISO standards, but C89 is typically what people mean when they say that.

Alright thanks.
My school teacher requires us to do our projects in ANSI C and I'm not sure if I'm allowed to use the newer standards.

Is there any advantage of C89 over C11?

>Is there any advantage of C89 over C11?
Only compatibility with ancient compilers that nobody uses any more.

What's a good convention for public and private/implementation headers in C?

I have mostly seen:
1)
public: foobar.h
private: foobar_i.h

2)
public: foobar.h
private: foobarp.h

3)
no private header, only a public interface in foobar.h and all implementation details including structs in foobar.c

4)
just a single header with all the structs and stuff there, even if they are implementation-specific

1) seems most logical to me

what do you mean, "implementation headers"?

Just store them in a different place.
project
include
project.h
src
project.c
project.h
Compile with -Iinclude (adjusted to whatever the correct path from the build directory)
Inside project.c:
#include "project.h" // This is src/project.h
#include // This is include/project.h
When it comes to installing headers, you just need to install things include include/.

There's plenty of C11 features that aren't supported by modern compilers. C99 on the other hand is mostly fully supported. There's also the issue of compilers for embedded devices in which case it really is usually better to stick to C89.

Well, apparently box drawing characters are filtered now.
Thanks, gookmoot.

Both Clang and GCC have C11 support, and have had so for quite a while.
Barely anybody uses anything else, even for embedded shit, where GCC is still the most prevalent. Maybe that's true for some DSP which isn't even running an operating system, but don't kid yourself into thinking that your code is going to be running on one of those.

Mostly internal structures and internal function declarations that are subject to change with the implementation and are not exposed in the public interface of the library I'm writing. I can keep them with the rest of the implementation in the c file but for tidiness and debugging purposes it's often useful to have them in a header.

>deadlines are getting closer
>days later still don't know why my code gives segfaults
Haha

Learn how to use a debugger.

>discussing available C compiler features
>outright dismissing one of the primary C use cases

Most "embedded" programming these days are literally just GNU/Linux systems running on shitty ARM hardware, where GCC is the compiler used.
But that's not even the point. You need to be realistic about what you're targeting. Why waste all of that effort for the 0.000000000001% chance that someone is going to try and use your code with some ancient compiler, and even then, do you even care if it fails?
Why don't you take it further? What about all of the C compilers that existed before C89? Why aren't you targeting those? I've heard that there is a mainframe out there that is still using B; why aren't you targeting that?

Can someone explain how video game consoles got away with having such little RAM?

Look at the Sony PlayStation 2
>Main memory: 32 MB PC800 32-bit dual-channel (2x 16-bit) RDRAM (Direct Rambus DRAM) @ 400 MHz, 3.2 GB/s peak bandwidth[6]

Attached: memory.jpg (2314x321, 182K)

They kinda can't. Compare the PS2 port of Deus Ex with its PC counterpart. Or even look at Invisible War.

Rewrite it in rust

lack of background processes?

serious hardware optimization and the fact game developers develop for the same hardware
PS3 has 512 MB of ram half of which goes to video

All resources dedicated to running the game, not much else going on in the background.

Working on a text editor. Have made progress. Gotta pick a name for it, abd decide on a license for it

Compromising graphics. A lot. Mostly textures. Those graphics aren't good.

2x Better graphics require exponentially more performance. Of course "2x better" is fairly subjective, but this is inherent.

Optimization. Not just console optimization. Pc games were much more optimized back then as well. Just because you had to. Now that you can get away with much less, that's what devs do because the time of skilled programmers cost money.

consoles games usually have more loading screens than theirs pc counter parts due to lesser ram available.