/dpt/ - Daily Programming Thread

IEC 61131-3 edition.

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

pastebin.com/pPeaF9Uk
en.wikipedia.org/wiki/Homelessness_in_San_Francisco
srfi.schemers.org/srfi-119/srfi-119.html
twitter.com/SFWRedditGifs

>No animu
I'm disappointed. Make sure to use an anime image next time.

Hello there. How do I implement C#'s Double.TryParse in C++? Dicking around with sstring or stod allows me to parse strings like "20+5" with result of "20", while C# returns false. Sstring and stod doesn't parse the entire string at once, whic is my best possible option

dynamic programming means dynamically typed programming, i.e python, lisp, JS

> these diagrams
I remember using this shit in uni, that's a retarded way to describe simple logic rules.

>3D
please make a new thread

>tfw you know the different between dynamic programming and dynamic languages
wish I was better at dynamic programming though

didn't know you programmed, Jay.

Is Go a meme language or should I spend time learning it? I mostly know C.

learn C++

AHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA
Good one.

learn go then, brainlet

No.

Rust's safety features are more like a transmission with a button you need to press to shift into reverse.

Driving in reverse is sometimes necessary (say, to pull out of a parking space), but it's less common and also less safe due to poor handling and limited visibility. Pressing the extra button to shift into reverse is your way of signaling that you're knowingly doing something dangerous and are confident that you can do so without crashing.

>instead of learning a relevant meme language, learn this dying meme language
Great suggestion

This is a very unflattering analogy.

Business idea: A proof for an actually good programming analogy generator.

>go
>relevant
>C++
>dying
t. rob pike

>It's perfect for it's intended purpose (exploratory scientific programming). For that application, it feels like the language of the gods.

it's a fitting analogy for an unflattering language

Rust's safety features are more like a quick-release voluntary straitjacket. If you're a typical schizophrenic Rust user, it may give you a sense of safety from yourself, but only as long as you're not having a severe episode. When you finally do have that episode, you take the jacket off and harm yourself and others due to your inability to handle your own limbs out in the real world.

how do i find out where the segfault is in my code?

Parse like you already do, then check for end of input. If not at end of input, conclude that there is trailing garbage and act accordingly. That's how all parsers work.

Reminder not to acknowledge the autistic anti-Rust shitposter.

Reminder that any Rustposting is effectively anti-Rust from the perspective of sane people, and it should all be ignored.

Use a debugger.

use GDB

This little Fortran program should read in names and then print them out in reverse order. However it doesn't seem to understand space characters (pic related). How to store space characters in the array?

!
! Read names and print in reverse order
!
PROGRAM names
IMPLICIT NONE

CHARACTER *50, DIMENSION (:), ALLOCATABLE :: names
INTEGER :: n_people
INTEGER :: i = 0

PRINT *, 'Enter number of people.'
READ *, n_people

ALLOCATE (names(1 : n_people))

DO i = 1, n_people
PRINT *, 'Name of person', i, ':'
READ *, names(i)
END DO

PRINT *, ''
PRINT *, 'In reverse order:'
PRINT *, ''

DO i = n_people, 1, -1
PRINT *, 'Person', i, ':', names(i)
END DO

END PROGRAM names

Rustposters, please for the love of god ignore the anti rust bait. Make /dpt/ great again.

Anyone here experienced in databases and/or Entity Framework?
+----+-------+----+ +----+-------+----+
| Id | CB | .. | | Id | CB | .. |
+----+-------+----+ +----+-------+----+
| 1 | a1b2d | .. | | 1 | 8df18 | .. |
| 2 | a222q | .. | | 2 | 8ee53 | .. |
| 3 | 3df99 | .. | | 3 | 71b22 | .. |
| 4 | fb2d8 | .. | | 4 | f736c | .. |
| 5 | f736c | .. | | 5 | b21a7 | .. |
| 6 | 71504 | .. | | 6 | 0e38d | .. |
| 7 | 84d77 | .. | +----+-------+----+
+----+-------+----+
CB and CB are non nullable varchars and I want to link them together. Both tables can contain CBs that don't exist in the other table. If this is not possible how can I fix it in Entity Framework?

Redpill me on Rust

pastebin.com/pPeaF9Uk

It makes programs safer by making its own target audience unable to write any.

It's mostly a meme language. The GC is kinda slow but it has relatively short pauses, and the concurrency/parallelism model is pretty good. This makes it OK for network code, where you can give each connection its own goroutine (green thread), and little GC pauses aren't noticeable due to the network latency.

...

does it still work if i need to read a file so the program runs?

If you link them together even though they are not referencing each other, you will get null values.

friendly reminder that you might encounter a mentally ill person whose sole reason for living is repeating the same non-applicable-in-real-life-scenarios arguments against rust.

Rate my code?

Can you rate my code?

terrible
truly terrible

the sole fact you're using php gives you a maximum of 2 on a 10 point scoring scale

I forgot that it's also a pretty small language. So if you "spend time learning it" that should only take you maybe a weekend (work through gobyexample). Either you'll find it useful or you won't. Personally I think it's kind of a shit language, but I'd still use it for server or peer-to-peer code.

Yes

ok
thanks
will look into it

Try rendering the code.

>PLC ladder logic

Just make sure to have debug flags enabled (-g when compiling) and run your program like
valgrind ./myprog arg1 arg2
or whatever.

I can see what the array looks like, it's still poorly written.

Why would I want to install something as horrible as a php interpreter on my computer?

how would you write it

this

array(1,0,1,1,1),
array(1,0,1,0,0),
array(1,1,1,1,1),
array(0,0,1,0,1),
array(1,1,1,0,1)

1,0,1,1,1,
1,0,1,0,0,
1,1,1,1,1,
0,0,1,0,1,
1,1,1,0,1

10111
10100
11111
00101
11101

1 111
1 1
11111
1 1
111 1

DELET.

xampp? How else do you run server-side scripts?

Why the hell would I install xampp?
I'm not some filthy webdev.

hey web dev makes plenty of money.

I already have a job as a C programmer. I don't need to lower myself to your level.

>I already have a job as a C programmer. I don't need to lower myself to your level.

enjoy that job security at marxist 20-something smug hipsterfag web startup #98301208

en.wikipedia.org/wiki/Homelessness_in_San_Francisco

Add a stylesheet, add an array colors like array('red', 'blue'), then do '

I don't have a problem with programming itself, but rather, the structure of a program. Whenever I star writting anything larger than "a program just to test out a neat idea I've got", I just have no idea how to design it all in such a way that it would make sense and be easy to expansion and/or modification. Could someone recommend me books or something about that?

I program mostly in C++ and Python, if that's relevant.

Are you implying that I'm not better than you as a programmer and as a person in general?

I just did it real quick showing it to a friend but yes you are right.

use a language with modules

>C programmer
>lower myself to your level
>lower level
>lower level than C

When is it right to use static variables? I feel like I should use them more.

>When is it right to use static variables? I feel like I should use them more.
At least 7-13% of your variables should be static.

Writing code is like building muscle desu. You do stages of bulking and cutting. Get a little bit working and then simplify it.

If you wanna sound fancy you could use the term technical debt.

I'd like you to answer the question now, please.

Well I completely forgot about this.

Also, rate my code, /dpt/
[CODE]
bool tryparse(string param, double &result)
{
try {
string::size_type sz;
result = stod(param, &sz);
if (param.substr(sz) != "\0")
{
return false;
}
}
catch (...) {
return false;
}
return true;
}
[/CODE]

I can't see here any string-to-double conversion

What do you mean by static variables though user? There's several meanings for static.

>I'd like you to answer the question now, please.
Use static variables if you're a static programmer. Superior dynamic programmer only use dynamic variables.

avoid static variables whenever possible
static = global

fcuk, that extension worked before

>he doesn't write everything in binary

>static = global
But that's wrong, you nigger. "Static" refers to the lifetime of the variable, not the scope.

They are mostly used for microcontrollers and ISRs

What is (in your opinion) the best functional programming language to learn.

If you need to have one variable declared on the first function call and be keeped in check on your next call.

>best functional programming language to learn
Rust. It's the only language with expressive and zero-cost functional abstractions that is also safe.

If you want a job, Java.

Hasklel, but just for fun

Scheme.

I want to learn one just for fun.

More like having safety rails on your balcony.

Sure, there might be a case where you want to hang off the edge to fix something. In that case you remove the railings. Otherwise, you keep them around because you don't want to fall to your death.

Shen

Scheme or another lisp. If you can't grok the parentheses, Julia is a lisp-1 with Lua-like syntax.

Then C++. C++ is great fun if you just want to experiment and don't have any real goal in mind.

When people, like a boss or a professor, start expecting results in C++ it stops being fun real fast though.

>C++ for functional
wew lad

What makes julia distinct from Scheme rocking a custom parser like srfi.schemers.org/srfi-119/srfi-119.html

Horribly verbose when you start writing Generic code (type signatures three times the length of the function body), and you just KNOW that some companies adopting it will make it company policy to write things that way.

It's just as good at Java for writing ten pages that do the same thing as what you could have done in one page if you took a more direct approach, but where the longer version is slightly more reusable. It's perfect for job security.

(The language itself is actually quite nice though. It's only excessively verbose for things that would be flat-out impossible to do in say C. If you stick to the close-to-c subset, it will literally just be a version of C which is easier to use safely.)

Sure, but all global variables have a static lifetime.

If Lisps are considered functional, then C++11+ should be as well. But we all know the right thing to do is to stop pretending lips have something to do with FP.

What drives a company to write software for which "close the program and wait a few minutes, then open the program again" is a valid solution to a problem?

That which invented functional programming isn't functional?

How can you declare a global var twice?

Legacy, low qualification of employers, faggotry, agile, etc

How hard is Java/Scala to pick up?

I currently do everything in Python.

easy as hell, easier than python, python is fucking garbage through and through

> I currently do everything in Python.
My apologies

For fun: Haskell. It's the best at teaching the FP paradigm properly with no escape hatches.

If you already have a Job and want to play around: Clojure if you work at a Java shop, F# if you are in a Microsoft shop. If you're doing webdev shit, Elm.

Elm is also quite good as the first language to do your first baby steps in since it has amazingly good error messages, and it's easy to reach the point where you can do something useful with it.