/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Old thread:

Attached: Alan_Kay.jpg (800x582, 166K)

Other urls found in this thread:

scratch.mit.edu/
thingiverse.com/thing:2204279
greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf
peanuts-search.com
pastebin.com/Xq051ktd
cve.circl.lu/cve/CVE-2014-1912
download.oracle.com/sunalerts/1019740.1.html
youtu.be/UtD41bn6kJ0
en.wikipedia.org/wiki/Shunting-yard_algorithm
cve.mitre.org/cgi-bin/cvename.cgi?name= CVE-2018-1000657
coconut-lang.org/
twitter.com/NSFWRedditImage

gps tracker for avr

nth for nim!

Wish I could use lisp, Haskell and other hipster langs to do shit but python have more libs. Literally import 'shit' and everything works in a few minutes

Can we make a comprehensive list of all hipster useless meme langs advocated by /dpt/?

- LISP
- Haskell
- Nim
- Smalltalk
- Elixir
- Scala
- Idris
- Rust
- Kotlin
- Clojure
- Go
- Rust
- Ada
- OCaml
- Scheme

What else?

Ruby

Then we should also make a lisp of all POO langs
>C++
>Java
>Python
>C#
And then decrepit langs that have are past their prime
>C

list*

Is there a way to construct a const temporary in C++?
I have something like this:
template void bar(T &&);

int bar(const int & i)
{
return i;
}

template int foo(A && ... args)
{
return bar(std::forward(args)...);
}
I can call non-template bar like that:
bar({int{1}})
but I need to pass a temporary to foo without providing type parameters (it either doesn't know what type to use if I keep extra braces or tries to call the template if I don't). Adding extra functions here and there is too inelegant (like everything in C++ but w/e).

I love ruby >_

>we should also make a list of all languages I don't like
Not really, no one's interested in your opinion.

considering it's what you/he did, it's only fair.

>C
>decrepit
Too brainlet for manual memory management detected.

This is an abuse of overloading. Don't do this.

Not really, I like many languages on that list. But let's face it, none of them have any real world relevance.

>C is the only language with MMM
literally all those langs except maybe idris are used by actual companies.

Why?

>What if you have operator== that returns true for two different arguments?
Define different.

Overloading in general is dangerous because it encourages you to write code which does different things for different types. Overloading on reference-ness just makes it even more opaque and unpredictable.

What is the goal you're trying to accomplish?

Desu I'm not sure. But to me it seems like an excuse for the language.
I read the Twitter thread where they tried to clarify just recently. But after reading that I get the sense that was mostly an attempt to cover their own ass in making that statement. I would expect this view to come from someone working in an environment where launching a debugger is just not feasible. Problems are discovered latent and the software needs to be run as a live service to find most bugs.

To forgo program state inspection in C/C++ as a language principle is foolish. And usually when we're talking about debuggers that's the primary thing people think about. Not program tracing.
If you're only doing program tracing you could probably do without a debugger.

>What are you working on, Jow Forums?

Procrastinating with a single tab of Treehouse open.

Attached: 0702095207864_10506_tumblr_inline_mpyueibdc51qz4rgp.gif (500x414, 945K)

>Overloading in general is dangerous because it encourages you to write code which does different things for different types.
That's so vague, it can be applied to all code.
>Overloading on reference-ness just makes it even more opaque and unpredictable.
There is nothing to worry about if you don't write code that can blow up in runtime due to type mismatch.
>What is the goal you're trying to accomplish?
Too much to explain.

damn, this shit is stable as fuck. I am impressed by my work.
I think ima hardcode every move right now and just give a fuck about a real kinematic model. I just want to see it move.
If it moves nice i can still implement is seriously

Attached: totalcontrol.webm (1280x720, 2.34M)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

That anime girl has a pretty nice moustache.

Attached: 1543067084615.jpg (1200x675, 76K)

>javascript is for little kids.
Yep. Scratch 3.0 just got released.
scratch.mit.edu/

>Overloading in general is dangerous because it encourages you to write code which does different things for different types.
=polymorphism?

That's not overloading. That's overriding.

Polymorphism is dangerous but useful. Overloading on referenceness is more dangerous and less useful.

where to start with something like that?
Did you just buy a kit?

it's all so overwhelming

>where to start with something like that?
I can't really tell. You just have to pick one controller family and try to do something with it. Or, which was easier for me, pick something you want to do and then find out what you'll gonna need for that. Generally arduinos are a perfectly fine way to start.
I started with the raspberry, which was then too big for most projects and went down the arduino road, tried myself in pure AVR C then (aka the same µC as in the arduino uno) and by today tried lots of microcontrollers. There spectrum is so fucking huge that it is hard to tell.
But, if you went down the hoarder road and tinkered around with quite a bit of stuff you get a sense of what could be possible with wich hardware.
>Did you just buy a kit?
No, I never bought a kit. Always bought stuff I needed (or might need) from ebay/aliexpress. Depending on how long i want to wait i just ordered it from a national or chink supplier (chink takes about 3-4 weeks usually).
Though i think there are perfectly fine and nice kits, even though there are a bit expensive mostly

alrighty, thanks lad.
your webms just make me want to build tiny, cute robots.

How do I take a "screenshot" of my screen using imagemagick but save it to memory and then analyze the pixels?

My only solution so far is just take an actual screenshot then analyze the screenshot and delete it.

Oh and just because I just saw I had that link still open. I obviously got some impressions from other robot builds. The last few (and I think critical ones) came from this for example:
thingiverse.com/thing:2204279

The problem was that none of these things really tell what actually is critical and that physics is going to fuck you in the ass without lube if you dont be careful. For me it was that my legs were too long and they couldnt be orthogonal to the ground while siting on it. That's why i dont even think that the robot from the link above can lift itself (you dont see that in any video). So yeah I then made lots of changes and sometimes it worked out pretty good

How do I find the location of Java imports on my Linux machine?

I downloaded a large project, and I can call Gradle to build it and it works with all the dependencies, but when I try to include those dependencies in a small project of mine and compile with javac it doesn't find the imports

Then they are obviously not installed systemwide.
Gradle probably downloads them and puts them into the build folder.

PS: I dont know shit about gradle. It just works for me. But nevertheless that's what the problem sounds like

Interpreted languages are not only bad, but also morally wrong.

We need a green movement to combat wasteful languages.
greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf
Companies that distribute python/Javascript programs should face a carbon emissions tax based on an estimated energy waste metric.
Websites would have to start respecting client CPU time. Splash screen applications should be unsustainable.

Attached: energy-efficient-languages.png (907x814, 265K)

Simply pipe it to your "pixel analyzer" program, user.

No, it's got nothing to do with tree hugging. It's got to do with efficiency and performance.
Being slower than you should be is morally wrong. Think about the poor end users who have to suffer through your bullshit because you chose a shit and inefficient shitlang.

what does c, v and i mean?

God I wanna get fucked by 70s Alan Kay

Brainlet programmer here. I'm a C++ embedded software engineer and we work in a windows environment at my job. When job postings say C++ on linux are they simply talking working in a linux environment or is there some other aspect that I'm missing?

Attached: 73e.jpg (220x285, 11K)

>jobs
>linux
lol

compiled, interpreted, and .. ?

compiled, vm and interpreted

(its all in the linked paper)

*gets paid millions of dollars to maintain a kernel*

Attached: 1024025?s=460&v=4.jpg (460x460, 28K)

Trying to optimize (fool proof, really) the display of this little search tool I built peanuts-search.com
An issue raised by an user on /co/ was with how with very large search results, if someone continued scrolling endlessly it can screw with the browser performance. I guess because there is no limit to the number of results being attached to the DOM.
What I've tried to do is remove the first 16 results whenever the javascript is loading the next 16 results on the infinite scroll, under the condition that there are - say - over 150 results on the page loaded.
function load() {
if (Results == null) {
return;
}
var max = Results.strips.length;
for (var i = Loaded; i < Loaded+16 && i < max ; i++) {
if (ResultsPage.children.length > 150){
ResultsPage.removeChild(ResultsPage.firstElementChild);
} //this condition
var pic = img(Results.strips[i].date);
ResultsPage.appendChild(pic);
}
Loaded = i;
}

This works in chromium (I guess webkit) but not in Firefox; in Firefox whenever removing an element from the page, everything blanks out, and when the elements are removed the page is rerendered again and is scrolled back to the top. I wish for the scroll position to stay in place. Don't know what to do.

Reposting:
Can virtual memory be fragmented?
pastebin.com/Xq051ktd
I allocate memory with C for 4 identical elements of linear linked list and their addresses are separated by non-equal number of bytes.

Yes it's to prevent buffer overflow attacks

Wouldn't it be easier to just, like, not use an ancient language dating back from when memory protection didn't even exist like C?

This is a very optimistic chart actually.
Computer
Language Benchmark Game is even explicitly stated on the site that it's not to be taken seriously.
Shitlangs do things like race to call C FFI and write horrid (in terms of what's language appropriate) code they'd never dream of actually writing for real programs.

Heh.. I posted right before the last thread got archived
Please answer. I can't find anything useful on search engines.

If you think switching languages prevents all buffer overflows ever, you're mistaken sir.
Pythong: cve.circl.lu/cve/CVE-2014-1912
Javag: download.oracle.com/sunalerts/1019740.1.html

>Python
>written in C
>Java
>written in, you guessed it, C
Your point?

How do you not use an ancient language dating back from when memory protection didn't even exist like C then?

Use Rust.

>all donations go to diversity programs

I have a conundrum
I really really want to learn how to program in literally any language
but I don't have any problems that programming could solve
Like the only reason I started gitting gud with linux is because I had a very specific idea of how I wanted my shit laid out
So I learned and did that(edited)
I have no such problem with programming. What do?

That's not really about virtual memory per se but just malloc. All of those allocations would easily fit in a single page, and they probably end up in the same page. Even then, malloc probably uses a contiguous range of virtual memory that of course could be all over the place physically.

There's a lot of different types of lists available for reducing dom pressure primarily.
youtu.be/UtD41bn6kJ0
This explains why and suggests one library. But there's lots of these. Infinite scroll lists/recyclerlists are common names.
They fit any use case where you have a large list of similar elements but only show a subset at a time (not for a visually tiny list with stupid many elements visible at once).

They address all the issues you have. I can see the value in implementing something like this for yourself but I feel it'd be rude not to offer this at least.

Can anyone explain string parsing to me?
Say we have an input string like this: 7*(3+4*(5-2))
Just an example obv, but how can I split it and get the result? Also assuming is has a lot of parentheses and different operations in it so you cant just go from front to back

If you raise your standards enough I'm sure you'll find it. Programmers are well known to scream at software that's not their own.

It might not be applicable but trying arbitrary automation is a possibility. You take tasks you're doing and just automate them. It could be as simple as making it so instead of using two applications manually you pipe the output of the first to the second.

You could also just attempt to do research. Write a web crawler for Jow Forums and mock people for their posting habits. Come up with well founded stats like how /dpt/ spends 20% of their time talking about transsexuals.

Ask someone else for problems they have and solve those. You don't have to phrase it like that. You can ask them for program ideas. People have them. They're usually awful. But sometimes they might be good enough to actually do. You can ask in random places where there's people not worth respecting like /sqt/.

S T A C K
T
A
C
K

By parse you mean you want to extract the operands and operators with precedence into an abstract syntax tree? Most advice you'll find on that is generic if searched in those terms.
It would be a bit much to explain here.
There's more simple things like:
en.wikipedia.org/wiki/Shunting-yard_algorithm

You can also see the 'see also'/related articles on that page for more suggestions.

Fortran strong!

Rust? This Rust?
cve.mitre.org/cgi-bin/cvename.cgi?name= CVE-2018-1000657

mixin("7*(3+4*(5-2))").writeln;

Doesnt this just print all operators after numbers? How is that any helpful

Any equivalent for this in c++?

>The shunting-yard algorithm was later generalized into operator-precedence parsing.
If you have RPN like "3 4 2 1 − × +" then you can easily go to the fully parenthesized expression "3 + (4 × (2 − 1))", which is a syntax tree.

No. What you get is a structure that allows you to more easily evaluate the expression than the string form would allow.
You can search for tutorials or whatever if you want to know more.

Some constexpr nightmare.
This is compile time values only right?

Yes

yeah.

Thanks, guys, I really appreciate it.

>comparing a small mistake made in the standard library with an intrinsic problem with the language design itself that makes it particularly and innately prone to buffer overflows

then you should add C# and F# too

F# yes. C# no.

Also Erlang.

>an intrinsic problem with the language design itself that makes it particularly and innately prone to buffer overflows
So like how you need "unsafe" to implement many non-trivial data structures because the type system is too conservative?

literally basedsoft's Java.

What does unsafe have anything to do with basic bound checking?

Obviously that vulnerability wouldn't have happened if they didn't have to use "unsafe" in the implementation.

And likewise buffer overflows in C programs wouldn't have happened if they weren't made in C to begin with.

You forgot:

- C
- C++

Writing in these languages today is the direct equivalent of the "I only listen to demos" from hipsters.

Not that user. That's obviously not true. Buffer overflows can happen in plenty of languages. And most languages (including C I'd argue) can implement bounds checking without fail.
Anons argument is about the necessity and problem of the feature use. Not that Rust is exclusively to blame for buffer overflow bugs in any sense.

coconut-lang.org/
what do you think about this?

>pythonic

Attached: trashman.jpg (620x412, 159K)

>pythonic
it's shit

database program

Why are the unemployed autists here so butthurt about C/C++?

I'm still working on improving on my C program that draws histogram-style vertical bar charts on the terminal screen. I've never written any programs spanning multiple .c/.h files, so I'd like to turn it into a little library "histogram.h" that I could #include in other programs too.
At first I thought I'd need to develop an interface for the histogram. I tried to come up with some basic operations that the user would need to manipulate the histogram. Does this look any good for a bare minimum set-up to get me started?

/* histogram.h */
#include

typedef struct {
char * id;
int val;
} Hist_data;

typedef struct {
Hist_data * hdata;
int size_x;
int size_y;
} Hist;

/* Interface functions: */
Hist * hist_create(int size_x, int size_y);
bool hist_remove(Hist * h);
bool hist_add_datapoint(Hist * h, char * id, int val);
bool hist_print(Hist * h, int offset_x, int offset_y);

>t. unemployed neet fizzbuzzer

>snek
abort

Attached: 1523576240940.gif (500x618, 421K)

>unemployed neet
excuse me sir, but I'm an employed NEET

>tfw they can actually be productive and use their meme FP
>they still hate it

>be productive
that's why Jow Forums hates it

*productively shoots your foot*