/dpt/ - Daily Programming Thread

Ethan Sullivan
Ethan Sullivan

What are you working on, Jow Forums?

Last thread: jowforums.com/thread/69734292/technology

Attached: dpt.gif (2.51 MB, 278x296)

Other urls found in this thread:

play.golang.org/p/EZZqB7mWbfq
wiki.haskell.org/Let_vs._Where
jowforums.com/thread/69741967/technology
sean-parent.stlab.cc/presentations/2013-03-06-value_semantics/value-semantics.cpp
scratch.mit.edu/projects/editor/?tutorial=getStarted
luna-lang.org/
en.wikipedia.org/wiki/Modulo_operation
haskellbook.com/
docs.python.org/3/library/curses.html
github.com/danistefanovic/build-your-own-x
jowforums.com/thread/69749453/technology
mega.nz/#F!DpAz2IgQ!nW7bPNnpJFk5CAV3ypiaHw
youtube.com/watch?v=dQw4w9WgXcQ

Levi Wilson
Levi Wilson

nth for Nim!

William Moore
William Moore

it's probably overkill for the use case, but here's an approach using parser combinators

module Quotes where
import Text.Parsec
import Text.Parsec.String

names = ["user", "Ralph", "Susan"]
notQuote = noneOf "\""
quoted = between (char '\"') (char '\"') (many notQuote)
skipQuote = quoted >> return Nothing
skipNQ = skipMany notQuote

match = try $ do
x <- quoted
string " said "
y <- many1 alphaNum
return $ Just (x, y)

matchNames n = try $ do
x <- quoted
space
n <- string n
return $ Just (x, n)

nameParsers = map matchNames names

matchText = between skipNQ skipNQ
(match <|> (choice nameParsers) <|> skipQuote)

test = do
x <- parseFromFile (many matchText) "test.txt"
case x of Right y -> (mapM_ . mapM_) (print . f) y
_ -> print "Parse error"
where f x = fst x ++ " said " ++ snd x

Brayden Jones
Brayden Jones

1th
oneth

Bentley Wilson
Bentley Wilson

zeroth

Luke Hall
Luke Hall

Friendly reminder that if you don't understand this code, you're literally dumber than the average Go programmer and the exact kind of person that Go was made for.
play.golang.org/p/EZZqB7mWbfq

Parker Ortiz
Parker Ortiz

nth for filtered

Zachary White
Zachary White

hasklel

Tyler Wright
Tyler Wright

Anyone got an idea if there's a better way to populate this structure without changing the mesh to a simple array?

typedef struct {
float x, y, z;
}SDLS3D_Vector;

typedef struct {
SDLS3D_Vector p[3];
}SDLS3D_Triangle;

typedef struct {
int tri_number;
SDLS3D_Triangle tri[];
}SDLS3D_Mesh;

SDLS3D_Mesh* SDLS3D_CreateMesh(int size)
{
SDLS3D_Mesh *mesh =
malloc(sizeof(SDLS3D_Mesh) + size * sizeof(SDLS3D_Triangle));
mesh->tri_number = size;
return mesh;

}

main()
{
SDLS3D_Mesh *cube = SDLS3D_CreateMesh(12);
cube->tri[0].p[0].x = 0;
cube->tri[0].p[0].y = 0;
cube->tri[0].p[0].z = 0;
cube->tri[0].p[1].x = 0;
cube->tri[0].p[1].y = 1;
cube->tri[0].p[1].z = 0;
cube->tri[0].p[2].x = 1;
cube->tri[0].p[2].y = 1;
cube->tri[0].p[2].z = 0;
....
}


You can tell what I'm doing here gets cumbersume really quick and I can't find any other methods

John Wright
John Wright

Does it look for the first duplicate in an array of indexes?

Jayden Gomez
Jayden Gomez

Take coding boot camp or self study?

Tired of working in trades, I unironically want to learn to code (web app dev). I've got the markup languages down and some JavaScript so far. I'm looking into learning mean stack or Rails/Ruby. But I'm having trouble with the big picture on how to put everything together to make professional grade products. Would it be better to take a code boot camp or just keep wading through free resources and udemy classes?

Kevin Peterson
Kevin Peterson

of all the trades to pick, why the fuck do you mongs pick programming?

Cooper Edwards
Cooper Edwards

use constructors

Robert Bailey
Robert Bailey

Web app dev is literally 100% self teachable. Just learn HTML, CSS, and some Javascript plus a framework (React, Angular or Vue).

Michael Torres
Michael Torres

because it's in demand

John Hernandez
John Hernandez

I'm having trouble with the big picture on how to put everything together to make professional grade products.
You'll get there, especially web development is such a mess of different technologies and languages and poor design decisions it does take time. Just learn one thing at a time, and practice making finished products and you'll get there in no time.

Chase Morales
Chase Morales

mesh is not ready to go after that function as you did not set tri. I probably would have done two separate allocations, but you don’t have to. What is cumbersome about your approach? The only thing I see is renaming the triangle struct member to point instead of p, and a few other nicer names so it’d read more like

myMesh.triangles[17].point[1].x = 1.2;

Levi Hill
Levi Hill

BuildIdentityMatrix();
BuildMatrix( 1, 0, 0
0, 1, 0,
0, 0, 1);
BuildTranslationMatrix(100, 100);

What do you have against functions?

Also I would really avoid making a 3x3 Matrix out of 3xVec3's. I get why it's tempting to, but not only is the naming weird and inconsistent with normal Linear Algebra practices, but it's less data-efficient and doesn't lent itself to the way values are actually piped through the graphics pipeline.

typedef struct {
n_00, n_01, n_02,
n_10, n_11, n_12
} MatrixTransform

etc.

Ayden Rogers
Ayden Rogers

When is a project "worthy" of being shared on eg. Github?

Kevin Campbell
Kevin Campbell

Github
"worthy"
I throw up any old test code on git hub. The only criterion of worthiness is if I want to save it for whatever reason, because I might want to look at it later, and whether I can be arsed to upload it.

Levi Morris
Levi Morris

Cool I'll keep plugging solo. What should I learn for back end?

Well I'm a broadcast/Telecom technician. So I'm literally driving up mountains and climbing towers. I'd much rather stay inside and type all day, I'm tired of physical exertion.

Nolan White
Nolan White

Always, user :)

Cooper Ross
Cooper Ross

It is actually possible to do backend in Javascript, but practically any language can be used as a backend if you use a RESTful API. Also at some point you will want an SQL database but that shit is very easy to learn and google so don't dive too deep unless you feel like you really want to be involved in database shit.

Lincoln Gray
Lincoln Gray

I would be glad for some physical exertion once in a while at my job, for a change. Sitting on the same chair in the same office corner day in day out gets old.

James Parker
James Parker

Anyone use Visual Studio?
How can I check the type of an expression/variable? Basically CTRL+Shift+P in IntelliJ but in Visual Studio.

Levi Cruz
Levi Cruz

I still don't quite understand the difference between let and where in Haskell.

Sebastian Turner
Sebastian Turner

i share stuff that i think others might find useful (e.g. libraries or applications i wrote) and projects that i'm proud of (works properly, has a good ui, i like the way the code turned out, etc.).
you never know who might use it.
at some point in school i wrote a library, never advertized it and didn't look at it for a few years, until i realized that a few years later it was forked to be used in a popular os. they rewrote a bunch of it, but i'm sure my initial codebase helped a bit with getting them started.

Jace Hill
Jace Hill

Yeah I feel the same. Also uploading stuff to public version control is a really comfy way to back up your project :)

Dominic Parker
Dominic Parker

foo {
...
}

or

foo
{
...
}

and why?

Jaxson Perez
Jaxson Perez

Whichever one you like best. It doesn't matter.

Luke Scott
Luke Scott

while they're often similar and only make you read the code differently, they sometimes can be used in different contexts and it may sometimes be easier for the compiler to optimize something.

Bentley Rodriguez
Bentley Rodriguez

you're everything wrong with nu-/dpt/

Attached: 1548911036299.jpg (402 KB, 1052x1342)

Michael Robinson
Michael Robinson

first one is boomer shit, an artifact of when vertical screen space was scarce. if you aren't working from a 1366x768 resolution, there's no reason to use it.

Christopher Sanchez
Christopher Sanchez

fuck off cshart

David Ward
David Ward

thanks, i love you too user!

Attached: 1525137042534.png (20 KB, 1172x675)

Easton Jackson
Easton Jackson

Personally prefer the second. It makes more sense and is more readable to have the opening and closing brackets align.

The former is more common though. Codestyle at work dictates the former. Frustrating.

Robert Walker
Robert Walker

So how do I know when to use which?

Austin Ross
Austin Ross

wiki.haskell.org/Let_vs._Where

William Myers
William Myers

print(y)
{
print(x)
}

// vs

print(y)
if z {
print(x)
}

Notice how the start and end of the blocks match regardless of whether the block starts with an if label or not. There's no semantic reason to try to align the actual braces, aligning the start and end of a block is enough.

Jace Ward
Jace Ward

weebshit
you're everything wrong with everything.

William Cruz
William Cruz

Yeah I read that before I asked here. Didn't stick.

Jordan King
Jordan King

in that case, maybe just write some more haskell code and don't worry about it.
you'll come across cases where it's obvious which one to use and cases where it's simply just a style preference.

Connor Fisher
Connor Fisher

not using c++ (yet?)

I think you misunderstand. my above code works, but it takes a ton of lines to populate a mesh and I want to reduce those.

I didn't think of using a populate function when I made that post.
Haven't read through all of the material yet so I don't get where the problem is, but I'll keep that advice in mind and maybe go back on my current approach.

Andrew James
Andrew James

Ok. Thanks.

Oliver Hill
Oliver Hill

When I disassemble an object I get this

0000.. second:
...
0080... first:
...

Is there any way to control the ordering such that first is at 0000..?

Robert Powell
Robert Powell

Why the fuck is everyone telling me this is bad style?

struct Base {
virtual ~Base() = default;
virtual void process() = 0;
};

struct Derived : Base {
const int x;
Derived(int x) : x{x} {}
void process() override;
};


SO told me to add ugly accessors... I don't need accessors. I just need an immutable data structure with those two virtual member functions.

Jacob Long
Jacob Long

it's fine

Joseph Perez
Joseph Perez

class Example {
// Method that takes a "method" as argument
static void exampleMethod(Runnable toRun) {
toRun.run();
}

// Method to pass
static void sayHello() {
System.out.println("Hello");
}

public static void main(String[] args) {
exampleMethod(Example::sayHello); // prints "Hello"
}
}

Does this create a new thread when .run() is called?

Asher Perry
Asher Perry

Forth!
How can I check the type of an expression/variable?
By hovering over it

Sebastian Watson
Sebastian Watson

Accessors for what?

Also, sorry if this is a dumb question, what's a SO?

Carson White
Carson White

stupid frogposter

Hudson Rodriguez
Hudson Rodriguez

No, it doesn't create a new thread. Runnable is an interface with a run method, that's it.

Gavin Miller
Gavin Miller

Another Haskell question.
How do I write a test module for another module, that tests functions that the module to be tested doesn't export?

Is that possible? Am I being an idiot?

Nicholas Scott
Nicholas Scott

Accessors for what?
The member variable of Derived.
Also, sorry if this is a dumb question, what's a SO?
I should have written Stack Overflow.

I think so too. The C++ community seems to be full of people who follow these OOP principles religiously.

Isaiah White
Isaiah White

no

Nicholas King
Nicholas King

Am I being an idiot?
yes
you *could* use the CPP extension to use C preprocessor macros

Michael Brooks
Michael Brooks

you need Thread::start to run the runnable in a seperate thread

John Powell
John Powell

jowforums.com/thread/69741967/technology

Jonathan James
Jonathan James

Thanks

Jaxon Cooper
Jaxon Cooper

It's ok. But you can go full sean parent and do type erasure to handle polymorphic objects as value types:
sean-parent.stlab.cc/presentations/2013-03-06-value_semantics/value-semantics.cpp

Samuel Turner
Samuel Turner

Lisp is the most powerful programming language.

Dominic Nguyen
Dominic Nguyen

That's pretty interesting. This kind of reminds me of Go's interfaces because implementation of the interface is implicit.

Adrian Fisher
Adrian Fisher

The member variable of Derived
Oh. I kind of thought of that as private. Dumb of me.
Nah, it's fine. No need to go overboard with unnecessary crud.
It's a bit of a style consistensy question to not mix code like

obj.x = x;
obj.setY(y);

but you seem to know what you're doing, so who cares. I'd say not using mutators if you can get away with it looks nicer.

Jordan Price
Jordan Price

he uses OOP retardation.
kys faggot.

Luke Brown
Luke Brown

C++ was a mistake.

Tyler Cooper
Tyler Cooper

OOP-style accessors, like singletons, are almost always a bad idea. If your type has strict invariants, you'd use methods that contain the logic to preserve them. If the type is just a record without any invariants, then just make its members public.

Parker Butler
Parker Butler

C++ was a lot of mistakes

Josiah Adams
Josiah Adams

C++ was only two mistakes.

Connor Nelson
Connor Nelson

This post is a mistake

Jackson Robinson
Jackson Robinson

Most C++ programmers have told me that structs should only have trivial member functions and never virtual ones. Then they tell me that classes should never have public variables. In the end, I'm left with

class Base {
public:
virtual ~Base() = default;
virtual void process() = 0;
};

class Derived : public Base {
const int x_;
public:
Derived(int x) : x_{x} {}
int x() const noexcept { return x_; }
void process() override;
};


which is kind of ridiculous.

Eli Robinson
Eli Robinson

"let x = ... in e" x is scoped to the expresison. You can only use variables that are known in the expresison and it can only be used in the expression.
"where x = ..." x is scoped to the current functionial equation. You can only use variables that are known in every part of it and it can be used in every part of it. Slight caveat in regards to "current functional equation": pattern guards are equivalent to a case expression, so they count as a single functional equation.
Every "where" can rewritten as a "let", but when you can use a where it tends to look better.

There are performance subtleties but don't bother with them for now.

Noah Wood
Noah Wood

the solution is to stop listening to C++ programmers

Hunter Hill
Hunter Hill

IMO structs should never have member functions, but it's fine to have a public variable in a class.

Liam Cooper
Liam Cooper

perhaps you should do what you feel is best instead of listening to other people
virtual functions are literally as expensive as dereferencing a poiinter (not expensive)

Carson Rodriguez
Carson Rodriguez

I know how virtual works. I'm mostly concerned about writing code which will get me a job.

Eli Moore
Eli Moore

then you should use virtual functions and maybe accessors too, C++ developers are not super-anal about encapsulation, that's more Java territory

Jordan King
Jordan King

how do I structure my GUI code? now it's just a single huge file with many functions in the same namespace, in the same class and with many global variables

Attached: 1530949478985.jpg (51 KB, 768x960)

Ian Campbell
Ian Campbell

Because they drank the OOP koolaid.

Christopher Brooks
Christopher Brooks

classes and global variables
why

Caleb Edwards
Caleb Edwards

I have a file for each gadget type
and then I have files for each visual style

Jason Richardson
Jason Richardson

classes should never have public variables

Only if you foresee changing how the variable is encoded. Like a complex class might change from storing real and imaginary and instead store magnitude and angle or store both with a flag stating which needs to be recomputed.

Matthew Perez
Matthew Perez

how do I GUI
nobody has figured it out yet

Connor Bailey
Connor Bailey

I'm mostly concerned about writing code which will get me a job.
This mentality is where 99.9% of the needless bloat OOP hierarchies and design patterns comes from. I bet whatever you're working on doesn't even need to use classes and inheritance and you're awkwardly shoehorning them in just to signal that you can use those tools.

Joseph Jenkins
Joseph Jenkins

dereferencing a pointer
not expensive

Anthony Barnes
Anthony Barnes

I bet whatever you're working on doesn't even need to use classes and inheritance and you're awkwardly shoehorning them in
extreme projection

Sebastian Mitchell
Sebastian Mitchell

I bet whatever you're working on doesn't even need to use classes and inheritance and you're awkwardly shoehorning them in just to signal that you can use those tools.
Absolutely, one hundred percent true. My project would be about half of its current length if I were writing C-style code.

Evan Ward
Evan Ward

correct

Brody Roberts
Brody Roberts

extreme projection

I've seen it before.

Grayson Carter
Grayson Carter

yeah let me just wait 100 cpu cycles just to call a function

Logan Foster
Logan Foster

Depends on the pointer. vtables tend to be pretty cache-hot.

Ryan Cox
Ryan Cox

t embedded dev

Joshua Campbell
Joshua Campbell

drinking the cache autist kool-aid
run some tests before you spout off retarded shit

Isaac Sanchez
Isaac Sanchez

Then why aren't you? You know C++ isn't Java and you don't need to use classes. Use C++ features when they makes your life easier. Nobody looks down at you for writing code that's C like (unless if you use #defines, those are cancer).

Logan Miller
Logan Miller

who

Oliver Bailey
Oliver Bailey

(You)

Justin Reed
Justin Reed

who?

Chase Rodriguez
Chase Rodriguez

What's an actual good book for learning C?
Something that teaches good practices, etc.

Bentley Wright
Bentley Wright

such a lust for revenge

Robert Collins
Robert Collins

Use a declarative Markup Language

Levi Hill
Levi Hill

c primer plus

Carson Collins
Carson Collins

MVP/MVVM

Cooper Ward
Cooper Ward

I actually think this best signals the intent of the code. Which if you intend to work in a team on a largeish codebase () is actually really quite important.

But this user has a very valid point. Part of being a skilled developer is the ability to make good judgement calls about the structure of your code.

Austin Adams
Austin Adams

GUI is probably the field where oop has the most merit.

Ian Gray
Ian Gray

C++

Have a method with a parameter value. I want this value to be available in a void pointer across the whole program after the function starts. Anyone know how I do the assignment correctly? The value will disappear after the function ends.

Elijah Morgan
Elijah Morgan

Copy that value.

James Peterson
James Peterson

Then why is GUI programming so shit?

Josiah Martinez
Josiah Martinez

When you say "available in a void pointer" what do you mean? You're gonna pass it around in arguments?

Will there be exactly one instance of this variable?

James Robinson
James Robinson

I want to write a "library" in c++ which I want to use in c# with native bindings. my problem is that I'm not sure how it works with context of said library.
can it have its own state? can I start new threads? and how can I interact with those threads if no states are saved? or is it that the context of library is preserved as long the program using is running?

Attached: 1543543896398.png (1.54 MB, 2012x1056)

Xavier Lopez
Xavier Lopez

Because

Chase Smith
Chase Smith

can it have its own state?

If the function creates the state at its calling point, yes. If it's defined somewhere else and would require the rest of the 'program' to create it, no.

If you want, you can have your library function return the 'state' to the C# program. There's a lot of inter-op goodies for structs, &c.

can I start new threads?

Yes.

and how can I interact with those threads if no states are saved?

Interop.

Further line of questioning: what are you trying to do? You might be able to just do it in C#

Luis Smith
Luis Smith

I have a C++ question guys.

I'm going through the Elements Of Programming Interviews book. In the array chapter, the arrays (actually std::vectors) are passed to functions using pointers and then assigning those to a reference type (pic related).

Why would you do this instead of passing a reference directly? It is also cleaner for the caller - foo(vec) instead of foo(&vec).

Attached: why.jpg (27 KB, 696x252)

Jacob White
Jacob White

I have no idea why you would ever do this.

Dylan Perry
Dylan Perry

It is not any different from using a C++ lib in a C++ program but you have to make functions to create and destroy C++ objects

Brody Brooks
Brody Brooks

literally no reason to do this except if you're refactoring iteratively

Connor Martin
Connor Martin

Some people like to make it explicit when a function can mutate a variable, and so choose to avoid passing by mutable reference. For example.

void foo()
{
std::vector<int> vec;
// this may pass by value or const ref.
// doesn't matter to us, observable behavior is the same.
bar(vec);
// this function mutates, so we should be explicit
baz(&vec);
}

Assigning to a reference inside the function is just a matter of convenience.

Bentley Nelson
Bentley Nelson

That code sample is totally fucked. Are you sure it's not an example of what NOT to do?

Colton Baker
Colton Baker

I want to make a program that reads my source files and checks for

TODO: ....
or
FIX: ....
so then I can do stuff with it

what language do you recommend? I don't really want to do it in python

Evan Price
Evan Price

It is also cleaner for the caller - foo(vec) instead of foo(&vec).
That's arguably a reason *not* to pass by reference.

Angel Wood
Angel Wood

How hard is it to learn xml or xsl? Anyone have a bookM

Jaxson Garcia
Jaxson Garcia

Any decent IDE

Easton Baker
Easton Baker

grep or ack or ag, one-liner. Anything different is overengineered and unefficient.

Oliver White
Oliver White

Regular expressions.

Camden Thomas
Camden Thomas

let me be more specific:
if I create an object with new, will it persists when the function in which it is created goes out of context?
do static objects persist in the same manner?

Easton Morris
Easton Morris

if I create an object with new, will it persists when the function in which it is created goes out of context?
Yes. That's the purpose of new.
do static objects persist in the same manner?
Yes. Static objects cannot be delete'd, though.

Chase Morgan
Chase Morgan

if I create an object with new, will it persists when the function in which it is created goes out of context?

As far as I know, the answer is yes, you just need to keep the handle via C# so that you can delete it later.

do static objects persist in the same manner?

Because you're only calling the function from it's EntryPoint, I don't know how statics get initialized. I think it happens when the DLL gets loaded, but don't take my word for it.

Ryan Nelson
Ryan Nelson

grep 'TODO' -nrl file.ext

Blake Long
Blake Long

Unfortunately, yes.

Thanks guys. really cleared it up, especially with the final remark - that was my guess too, but it seemed weird for such trivial functions.

Jaxson Ross
Jaxson Ross

Hey, /dpt/, I was thinking something

Are there any programs or API's that will take in a code in flowchart representation and produce code in python, C or whatever, according to how I define the exported functions?

Kinda like this:

scratch.mit.edu/projects/editor/?tutorial=getStarted

Lincoln Myers
Lincoln Myers

ok that answer my question. I wasnt sure if the heap was getting scrubbed everytime a function goes out of context when using native

Asher Howard
Asher Howard

how would you program an utility to draw vectorial shapes?
it would be like mspaint, but you can draw, move and resize any kind of shape just by pulling its vertices or anchor points.
I can't figure out a good way to structure my code so it doesn't turn out spaghetti

Landon Howard
Landon Howard

I wasnt sure if the heap was getting scrubbed everytime a function goes out of context when using native

There used to be an issue about DLLs getting unloaded randomly so your state would get nuked, but that hasn't been an issue for some time, as I recall.

Again though, do you want to discuss what you're trying to accomplish? There might be a better way.

Elijah Kelly
Elijah Kelly

doesn't account for multilines plus the sanitizing like removin // at the beginning of lines or the /* */

yes but this is for learning purposes and to distract me

Caleb Stewart
Caleb Stewart

That function signature let's clients pass a nullptr, which is not checked against in the function.
I'd say it's a much poorer design than just passing a mutable reference and making invalid states impossible (even if it's less explicit from the client's point of view that we're mutating the vector).

David Roberts
David Roberts

Rust doesn't have this problem.

Tyler Myers
Tyler Myers

Rust has entirely different problems.

Zachary Howard
Zachary Howard

Good observation regarding nullptrs. However, the book makes assumptions regarding the input of these small programs, so I guess it kind of works not to do checks in this context.

Brayden Murphy
Brayden Murphy

Because when you call the function, it's more obviously that it is by reference if you see it passing the pointer. You could do EvenOdd(std::ref(A)) but nobody codes that way.

John Parker
John Parker

make it explicit when a function can mutate a variable, and so choose to avoid passing by mutable reference
yes, please. you all should do this.

Cooper Edwards
Cooper Edwards

In practice that doesn't matter because it's generally clear from context if something is a modifiable parameter or not. Additionnal evidence: a lot of languages don't have const-correctness and do fine nonetheless.

Mason Rivera
Mason Rivera

Arguably, const-correctness is a misfeature since it bloats the language with extra keywords, makes it harder to learn, and slows everything down.

Christian Ross
Christian Ross

The lack of const correctness leads to clusterfucks like Java. Feel free to disagree, but you're wrong.

Benjamin Harris
Benjamin Harris

In practice that doesn't matter
wrong
Additionnal evidence: a lot of languages don't have const-correctness and do fine nonetheless.
yeah and you can individually assign the bits yourself instead of using a compiler. that doesn't make it any better.

Jaxson Robinson
Jaxson Robinson

anything that is not rust

Attached: emoji-update-2017-10.png (305 KB, 800x800)

Mason Collins
Mason Collins

Many languages have (im)mutability keywords. Java has final. Kotlin has var/val. None of these languages have const correctness because you can't assign const to references and values separately.

David Lopez
David Lopez

If you don't want to mutate a variable, don't mutate the fucking variable. What's the problem?

Attached: 125114121111.jpg (18 KB, 250x228)

Julian Collins
Julian Collins

Disagree. You could implement read-only views and stuff at the language level using a bunch of generic types and methods. No burden on learning the language itself, no keywords.

Ryan Phillips
Ryan Phillips

If you don't want to pass a string to a function that expects an int, don't pass a string to a function that expects an int. What's the problem?

Carter Allen
Carter Allen

I have to create 2 processes and iterate through them everytime I receive user input.

If input is 'a' or 'e' it has to be saved on a char buffer and piped through the first child process, else if the input is 'b' or 'c' it has to be saved on a char buffer and piped through the second child process.

When both buffers have a size of 5 the program has to print them and end. Any ideas for the looping? I've tried several things but it just ends up in an infinite loop.

Wyatt Smith
Wyatt Smith

while (buf1.count < 5 and buf2.count < 5)

Jayden Sanders
Jayden Sanders

retard

Jaxon Morris
Jaxon Morris

Why the hell would you want this in the first place?

In regards to existing solutions I think you're kind of out of luck simply because there isn't much interest in visual programming. The only thing I know off is Unreal Engine's Blueprint to C++ converter.

Rolling something yourself shouldn't be too hard if you don't want it to be very complex:
If you don't want static analysis it's almost trivial: Write/use a simple graphe editor and write a code generator that maps nodes to code. Transform it slightly so that it's essentially just a parse tree.
Otherwise my idea would be to create an intermediate DSL in something like XText, translate your graph into the intermediate language and do your static analysis on the intermediate language. This way you can just write multiple generators for your intermediate language and don't need to take care of static analysis for every single generated language or even worse on a graph.

Charles Morris
Charles Morris

not exactly what you want, but still might be of interest
luna-lang.org/

Kayden Cooper
Kayden Cooper

for
...

Jason Ramirez
Jason Ramirez

the loop condition seems kind of obvious, but how do I make sure the processes read and write the proper sizes for the buffers? i tried creating two integers to use them as counters inside the processes but i end up having segmentation fault

Jaxson Sullivan
Jaxson Sullivan

If everything is an expression then only the first makes sense. Compare

foo(bar {
baz
})

with
foo(bar
{
baz
}
)

Jackson Carter
Jackson Carter

I don't get what you're saying

Eli Green
Eli Green

this is how im building the loop, I used the fork() and pipe(fdV) calls to create the process and the pipe. I still need to code the b and c condition:

while((strlen(bufferV) < 5 && strlen(bufferC) < 5) && cin >> opc){
if(pidV == 0){
if(opc = 'a' || opc = 'e'){
read(fdV[0], bufferV, WHICH SIZE?);
bufferV[WHICH SIZE?] = opc;
write(fd[1], bufferV, WHICH SIZE? + 1);
}
} else {
waitpid(pidV, NULL, 0);
}
}

Parker Gray
Parker Gray

Excuse me while I talk to myself

"docker ps" to list containers
wtf is "ps"
apparently a ton of people had the same question
now it's docker container ls
wtf is a container

Landon Evans
Landon Evans

Why the hell would you want this in the first place?

Because people pay a lot of money for educational robotics solutions. You don't want kids trying to write HAL for obscure microcontrollers. This isn't for yout typical 400 pounds basement dweller piss jug collecting neckbeard gentoo user.

Levi Cruz
Levi Cruz

excuse the == and fdV type errors eheheh

Camden Hughes
Camden Hughes

infinite loop
You mean it hangs right? On the read() call? My guess is that it's odd that you would do

read(fdV[0], bufferV, WHICH SIZE?);
// and then
write(fdV[1], bufferV, WHICH SIZE?);

in the same process. You're reading from the pipe before writing into it, but what do you expect to be reading? No one is putting stuff into it, right?

Ayden Baker
Ayden Baker

Can I ask about AHK here?
I'm trying to make my on screen keyboard transparent so I don't have to keep minimizing it to see what's underneath. However it doesn't seem to work.

#Persistent
WinSet, Transparent, 50, ahk_class OSKMainClass
return

I tried it on Notepad and it made it transparent. Does it just not work on OSK?

Bentley Parker
Bentley Parker

The one big difference between containers and VMs is that containers *share* the host system’s kernel with other containers.

B-but how does it run on any OS if the applications Docker is hosting can't run on any OS?

Is this blog total bullshit?

Attached: docker.png (25 KB, 820x594)

Carter Wood
Carter Wood

Nah, with emulation and things like that you can do some seemingly magic things in term of transvestiting OSes. Ever heard of Wine or Windows 10 Linux Subsystem or Qemu ? If you provide adequate substitutes for OS interfaces that userspace programs call in you don't have to virtualize an entire kernel. At least that's how I interpret the main point of what you posted, and I have some personal experience with running GNU/Linux x86_64 binaries over an GNU/Linux armv7 system.

Luis Bailey
Luis Bailey

If you provide adequate substitutes for OS interfaces that userspace programs call in you don't have to virtualize an entire kernel.

That makes sense, appreciated.

Dominic Ramirez
Dominic Ramirez

You're welcome. What does Docker as a program do exactly? I've been in IT for a while but I don't actually know yet.

Adam Howard
Adam Howard

the buffer is empty before the first iteration. Which means that in that same iteration these calls would be executed:

read(fdV[0], bufferV, 0);
bufferV[0] = opc;
write(fdV[1], bufferV, 1);

Since bufferV is empty, ill be reading 0 bytes but after the assignment

 bufferV[0] = opc;  
the write call is a must in order to write the buffer through the pipe.

Now in the second iteration something like this would happen:

read(fdV[0], bufferV, 1);
bufferV[1] = opc;
write(fdV[1], bufferV, 2);

And so on. I'm not sure if this is the right logic but it kinda make sense to me.

Daniel Brown
Daniel Brown

*the Docker Engine

Elijah Miller
Elijah Miller

There! It's not the right logic. Once you read some data from the pipe, it's not stored in it anymore. When you read again, you start where you left off, like with files. Should have familiarized yourself with how pipes work prior to trying to throw 2 of them in a 3 process program.

Austin Perez
Austin Perez

Sorry for the slow replies, kind of running around.

Docker lets you spin up "containers" from "images."

Basically, an image is a "container definition" - what kernel to download, and what to install on it.

For example, you might want an Ubuntu kernel with curl and vim on it. Finally, the image contains a url or file path to the application you will be running in the container, so those files will be pulled into the container.

Once an image is defined, the "container" can be spun up on any OS that has docker installed.

The use case is this - let's say I have an Angular web app. If I put it in a docker image, I can get it running on windows, and then start up my raspberry pi with Linux, install docker, and start the container.

It will run with no issues, despite the different OS.

Hopefully that's sort of a clear overview. The articles I saw suck, so I didn't point you to one.

Nolan Gray
Nolan Gray

That's alright.
I see. That's what Docker provides in fine, but what I was asking is how it does that? And I got an decent first answer from the Wiki page: that's OS-level virtualization rather than VMs. It doesn't directly tell me how it is that in your case, a container can go from an x86 machine to an armv7 RasPi though, but I'll keep digging.

Colton Cooper
Colton Cooper

Thinking about learning Rust. Is it any good?

Wyatt Baker
Wyatt Baker

See for yourself. I personally don't like it.

Thomas Edwards
Thomas Edwards

compiler optimizations

Isaiah Torres
Isaiah Torres

depends on your use case

Jaxon Parker
Jaxon Parker

(foo ...)

Jackson Torres
Jackson Torres

I want to do wireless network simulation using NS-3. However it is suggested that its C++ heavy. Where should i start learning C++, have basic Java/Python experience.

Sebastian Gutierrez
Sebastian Gutierrez

Find a C++ book aimed at people with Java or Python experience.

Cooper Thomas
Cooper Thomas

Oh my fucking god SHUT UP, READ ONE OF THE HUNDREDS OF PAST THREADS WHERE THIS QUESTION HAS ALREADY BEEN ASKED AND ANSWERED

FUCK

Nicholas Harris
Nicholas Harris

google 'c++ for java programmers'

Owen King
Owen King

Most programming languages branded as safe and 'easier to reason about' have shit tooling, are slow, bloated and have slow compilation time even on debug builds.

Kayden Ramirez
Kayden Ramirez

unlike Haskell

Joshua Long
Joshua Long

easier to reason about
this is a signature Haskelltard phrase
along with 'powerful type system'

Liam Sanders
Liam Sanders

haskell
not slow, bloated or slow to compile

Leo Miller
Leo Miller

the worst part is that most of these haskelltards have never tried formally verifying their haskell code, i.e. haven't used something like liquidhaskell or idris to actually verify their shit.
not to mention that there's very good automatic verification tools for the likes of java too, that work very well unless you abuse the equivalent of global state like a motherfucker, which nobody in their right mind does anyways.

Ryder Cruz
Ryder Cruz

ye

Zachary Robinson
Zachary Robinson

Attached: 15498271984860.png (1.15 MB, 1280x720)

Caleb Martin
Caleb Martin

dependent typing = formally verifying code
pot, meet kettle
Also, _legitimately_ formally verifying Haskell is a lot easier than Java.

not to mention that there's very good automatic verification tools for the likes of java too, that work very well unless you abuse the equivalent of global state like a motherfucker, which nobody in their right mind does anyways.
Name a single tool that actually does automatic VERIFICATION.
Imagine defending a language that doesn't even have a sound type system

Jason Torres
Jason Torres

Redpill me on c# right this fucking instant

Levi Butler
Levi Butler

It's shit

Jack Price
Jack Price

java + syntax sugar - libraries & jobs

Samuel Cox
Samuel Cox

Are all these new c++ features actually usable? Or do people learn them to impress fellow autists

Eli Murphy
Eli Murphy

most of them are an improvement yeah

Anthony Hernandez
Anthony Hernandez

Making enterprise hell a bit comfier.

Carson Green
Carson Green

It’s shit.

Kevin Baker
Kevin Baker

dependent typing = formally verifying code
i never said that you fucklord

Also, _legitimately_ formally verifying Haskell is a lot easier than Java.
this is only true if you make extensive use of the heap in java, and the people i know that work in formal verification for functional languages agree that verifying imperative code isn't inherently harder than verifying functional code. java vs haskell type system doesn't make much of a difference either.

Name a single tool that actually does automatic VERIFICATION.
KeY, which has been used to verify the java standard library and exposed a bunch of bugs in the process, for instance that timsort, as implemented everywhere, is broken - even the haskell library of it :-)

Imagine defending a language that doesn't even have a sound type system
i didn't defend java anywhere you dumb fucker, did nobody teach you reading comprehension in school?

Camden Wilson
Camden Wilson

#include <stdio.h>

int main(){
int hr24, mins, hr12;
char ampm;

printf("Enter a 24-hour time: ");
scanf("%2d:%2d", &hr24, &mins);

switch(hr24){
case 0: hr12=12;
break;
case 1: hr12=1;
break;
case 2: hr12=2;
break;
case 3: hr12=3;
break;
case 4: hr12=4;
break;
case 5: hr12=5;
break;
case 6: hr12=6;
break;
case 7: hr12=7;
break;
case 8: hr12=8;
break;
case 9: hr12=9;
break;
case 10: hr12=10;
break;
case 11: hr12=11;
break;
case 12: hr12=12;
break;
case 13: hr12=1;
break;
case 14: hr12=2;
break;
case 15: hr12=3;
break;
case 16: hr12=4;
break;
case 17: hr12=5;
break;
case 18: hr12=6;
break;
case 19: hr12=7;
break;
case 20: hr12=8;
break;
case 21: hr12=9;
break;
case 22: hr12=10;
break;
case 23: hr12=11;
break;
}
if(hr24>=0 && hr24<=12){
ampm='A';
}else ampm='P';

printf("Equivalent 12-hour time: %d:%d%cM", hr12, mins, ampm);
return 0;
}

how do I make it so it prints AM/PM instead of the niggerly workaround I gave it?

Attached: unknown.png (88 KB, 707x714)

Lucas Butler
Lucas Butler

Using an if to check if the 24 hour time is above or below 12 is a fine solution, though you should probably just have ampm = "AM" or "PM" instead of concatenating the m in the end.

Also you should really read up on modulo operations: en.wikipedia.org/wiki/Modulo_operation

hr12 = hr24 % 12, no case statement needed.

Attached: todd.jpg (121 KB, 956x1046)

Ryan Jackson
Ryan Jackson

%

Attached: 1547684487727.png (581 KB, 779x766)

Blake Barnes
Blake Barnes

The AM/PM bit specifically there isn't a super clever way to do it. I don't see this as a niggerly workaround, it's just how you do it.

if (hour <= 12) 'AM' else 'PM'
and that's it. What I'd suggest is learning about modulo to fix your other niggerly workaround, and doing sanity checks like
hr24>=0
right after the scanf instead of haphazardly putting them in the ampm conditional like you did.

Owen Scott
Owen Scott

how do i convert my brain into a c++ code

Asher Richardson
Asher Richardson

I want to get into functional programming. Where should I start? What first language?

Attached: 1534813502760.png (34 KB, 817x443)

Lucas Flores
Lucas Flores

i might be retarded but i am running a bot and would like a little status thing so that i know it's still running. how do i do this in python? like the little spinner ['|', '/', '-', '\\'] or something that says [running... running.. running. running]

pls halp what's the name of this programming trick?

Isaac Price
Isaac Price

Haskell

Landon Harris
Landon Harris

Unironically Haskell. At its core it is maybe not the best beginner language, but Haskell from First Principles alone makes it easier to learn than any other language. And all skills you get from that book will be easily applied to any other functional language, highly recommended.
haskellbook.com/

Jaxson Gray
Jaxson Gray

Haskell.

Maybe Scheme if you want to learn a Lisp while you're at it.

Dominic Foster
Dominic Foster

if you're looking to replace terminal output, you basically reset the pointer back to the start of the line with '\r' and then write your new text.
so you'll print (without newline) \r|, \r/, \r-, \r\

Camden Collins
Camden Collins

haskell because it's a common one and has many resources available.

Camden Wood
Camden Wood

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

Justin Miller
Justin Miller

In bash

while true; do
for spinny in "/" "|" "\\" "-"; do
printf '\r%c' $spinny
sleep 0.5
done
done

You could also use curses but it's overkill. And with curses you have to have a full-terminal interface, which is not what you want.

You might want to look into colorama if you want to disable the cursor in a platform independent way.

Jonathan Bailey
Jonathan Bailey

haskell is worth learning but what do you already know? there might be a language that can easily interoperate with your existing code

Kevin Gonzalez
Kevin Gonzalez

You could also use curses but it's overkill.
Yes. I can't believe I did not know the trick with \r.

Grayson Robinson
Grayson Robinson

i never said that you fucklord
I must be imagining
have never tried formally verifying their haskell code, i.e. haven't used something like liquidhaskell or idris to actually verify their shit.
then?
this is only true if you make extensive use of the heap in java
this is so insanely disingenious, it's baffling. Yes, if you go against the entire idea behind Java (OOP), you can write code that is just as easily verifyable as Haskell code. If you only write pure functions literally all languages are equivalent in how hard they are to verify, but that's just completely disregarding reality. Idiomatic haskell code is just straight up way easier to prove than idiomatic Java code.
imperative code isn't inherently harder than verifying functional code
Theoretically, yes. But this ignores the fact that imperative and functional programming pushes you towards certain design decisions. Mutability and global state just come very easily with imperative programming, which makes it way harder to verify.
java vs haskell type system doesn't make much of a difference either
it makes absolutely no difference. Which is also why Idris and LiquidHaskell can't formally verify programs.
KeY, which has been used to verify the java standard library
KeY is semi-automatic. "automatic verification" tools don't exist, you dolt.
Also, as far as I know only the tiniest sliver of it was verified. Verifying the entire standard library is basically impossible because of OOP.
even the haskell library of it :-)
wow, haskell programs have bugs?!?

and "b-b-but java can be verified too" when faced with the point that haskell tends to be way easier to verify, certainly sounds like defending it to me. At least go for a language like C which is actually used in some real, completely verified systems.

Ayden Martin
Ayden Martin

C++ newb here. How do I delete a private field?

#include <iostream>

class C {
private:
int *X;
int n;
public:
C(int *X, int n);
void print();
~C();
};

int main(void) {
int X[] = { 1, 2, 3 };
C c = C(X, sizeof X / sizeof *X);
c.print();
delete &c;
return 0;
}

C::C(int *X, int n) {
this -> X = X;
this -> n = n;
}

void C::print() {
for (int i = 0; i < n; i++)
std::cout << X[i] << " ";
}

C::~C() {
delete[] X;
}


outputs:
1 2 3
munmap_chunk(): invalid pointer
bash: “./main” terminated by signal SIGABRT (Abort)

Lucas Harris
Lucas Harris

C++
not even once.

You do not need to and you should not delete something that doesn't come from new

Austin Morris
Austin Morris

You only need to delete an object acquired by new.

Blake Hughes
Blake Hughes

//yourBrain is probably void
static_cast<cpp_code> yourBrain

Angel Wilson
Angel Wilson

What do with c.X?

I do my assignments in C but figured out it would be more elegant for one of them to have classes.

Andrew Ramirez
Andrew Ramirez

forgot parentheses

Nathan Murphy
Nathan Murphy

You ignore it. It will go out of scope when main returns, because that's where it was allocated.

Henry Wilson
Henry Wilson

more elegant
Get some taste MIT nigger

Connor Miller
Connor Miller

Learn C++
realize I have nothing to program
Hobby programming is stupid

Benjamin Diaz
Benjamin Diaz

auto main(int argc, char* argv[]) -> int { return 0; }

Easton Watson
Easton Watson

Weird. When I keep the destructor but don't use it I get SIGSEGV but when I remove the destructor from the code completely, suddenly it works.

Ye, better to keep 5 arrays as class fields than pass them all to one function. And I was never a big fan of structs.

Ryan Cook
Ryan Cook

nobody cares
nobody cares

Isaac Moore
Isaac Moore

That's sane behaviour. If you try to delete a pointer that didn't come from new, you get undefined behaviour. Simple as.

Adrian Adams
Adrian Adams

github.com/danistefanovic/build-your-own-x

Joseph Brown
Joseph Brown

I must be imagining
you are, suggesting that dependent types can be used for formal verification does not imply that formal verification and dependent types are equivalent.

If you only write pure functions
you don't need to only write pure functions for e.g. KeY to properly verify code, JML easily allows you to write spec for the heap as well. precisely, i meant that "you need to avoid extensive use of the heap"; KeY can very well deal with your usual OOP, just don't overdo it like an insane madman.

pushes you towards certain design decisions
sounds like software engineering vodoo shit to me, but i'll let it slide

Mutability and global state
mutability isn't an issue, global state can be if used too extensively

KeY is semi-automatic
i don't know what you understand under "automatic verification" but to me writing the spec, and clicking "run" on the autopilot, resulting in a proof with no user interaction, sure sounds automatic to me.
yes, KeY also allows you to step through proofs manually if you need it for debugging or speccing purposes, but quite a bunch of proofs with sufficient spec are entirely automatic.

certainly sounds like defending it to me
providing an example for verification in an imperative language implies that you defend that imperative language, gotcha.

At least go for a language like C which is actually used in some real, completely verified systems.
KeY is being used in the german car industry for "real and completely verified systems".

Grayson King
Grayson King

Yeah, but SIGSEGV happens when I *don't* try to delete anything but keep the destructor. Just the implementation, supposedly dead code.

Gavin Brown
Gavin Brown

I program professionally in C++. Looked up functional programming in C++ but the articles are just fragments and theres no fundamental explanations on what is and why functional programming.

Blake Flores
Blake Flores

if anyone told you some idiot would just say "that's not fp"

Asher Bennett
Asher Bennett

I love these CS graduate memes.

Attached: heh.gif (3.46 MB, 377x372)

Elijah Foster
Elijah Foster

I don't know about you guys but I prefer this style, it makes more senses to have brackets and semicolons aligned like this, you can easily tell if you missed one.

function getCharacterCount(string, character) {
var count ;
for(let i=0; i<string.length; i++) {
if(string.charAt(i) === character) {
count++ ;
}
}
return count ;
}

Jeremiah Lopez
Jeremiah Lopez

What do you mean? Post exact code.

"Functional programming in C++" is a meme. There are small elements that occasionally crop up in C++ like higher order functions but for the most part you cannot learn FP within C++.

Lucas Diaz
Lucas Diaz

If using OOP, organize your bits into logical parts. You have Points, which contain your coordinates, Lines which connect Points, possibly another type a Point that holds a tangent Line for Curves, Shapes, which contain and connect the previously mentioned, etc.

James Evans
James Evans

use spj style

function ...
{ var count
; for (...)
{ if (...) ...

Brandon Carter
Brandon Carter

that's just structured programming, you haven't actually put any logic into those

Asher Walker
Asher Walker

Code in gets SIGABRT. Remove [spoiler]delete &c;[/spoiler] and it gets SIGSEGV. Remove that line *and* the definition and implementation of C::~C, and it finishes with exit code 0.

Carson Smith
Carson Smith

Hi friends!
I posted this in the last thread but got no replies I don't want a solution I just want to know where should I be looking for this shit.

I have a React App and a graphQL API, my database is using MySQL, I don't have any problems calling the API and the API calling the database.

But if I do any change in the database outside of the API, eg. I INSERT or DELETE something using the console and If I refresh my React App which calls the API for every record in the table, the API doesn't return that last insertion and I know this because I print the result in the server side.

I have to shutdown the server and restart it so it can somehow "take notice" of that change. I just don't understand why any changes outside the API server don't seem to be reflected when my API calls the database.

I'm using Bottle py as a server for my graphQL API btw

Thomas Ortiz
Thomas Ortiz

Yes, that makes perfect sense.

Benjamin Cooper
Benjamin Cooper

Guess I'm dumb.

Jayden Roberts
Jayden Roberts

It's like I keep saying. Don't delete something that you didn't get from new. You didn't get c from new, so don't delete it.

Zachary Smith
Zachary Smith

Where am I deleting something when

delete &c;
is removed from the code?

Anthony Taylor
Anthony Taylor

When you call

delete[] X;

Carter Sullivan
Carter Sullivan

#include <stdio.h>

int main(){
int hr24, mins, hr12;
char * ampm;

printf("Enter a 24-hour time: ");
scanf("%2d:%2d", &hr24, &mins);

if(hr24>=0 && hr24<=12){
ampm="AM";
}else ampm="PM";

printf("Equivalent 12-hour time: %d:%d%s\n", hr24%12, mins, ampm);
return 0;
}

Attached: 1541729688655.gif (1.83 MB, 400x300)

Adrian Bennett
Adrian Bennett

Garbage collection?

Easton Wilson
Easton Wilson

are you dumb?

Ethan Morgan
Ethan Morgan

I must be.

Camden Thomas
Camden Thomas

ampm = (hr24 >= 0 && hr24 <= 12) ? "AM" : "PM";

James Hughes
James Hughes

That's pretty neat

Aiden Cooper
Aiden Cooper

appears pretty fine on the ampm front. I'm still unsatisfied about the hr24>=0 part. When would hr24 be < 0 and what's the correct thing to do if that's the case? Your code kinda half-answers this question. And what if it's >=24? And if mins is out of bounds?

Isaiah Foster
Isaiah Foster

develop an application during the weekend
make the back end using .NET Core
make the front end using WPF
can't reference .NET Core libraries from WPF
fucking kill me

Luke Peterson
Luke Peterson

fucking kill me
address?

Colton Ward
Colton Ward

if(hr24>23||hr24<0) {
printf("%d out of range", hr24);
return 0;
} else if(mins>59||mins < 0) {
printf("%d out of range", mins);
return 0;
}

Charles Hill
Charles Hill

unless you happen to live in Urgay I don't think my address will help you

Luis Thompson
Luis Thompson

ampm = "AM\0PM" + hr24 / 12 * 3;

James Clark
James Clark

No. Don't cram your conditionals, use parentheses around compound conditionals, add spaces between numbers and operators, as well as after if and the paren.

I noticed you still did the space after the if conditional, nice try autismo

Kevin Garcia
Kevin Garcia

suggesting that dependent types can be used for formal verification
Idris and LiquidHaskell can only be used for very elementary specifications.
You might as well say that Haskell's type system can be used for formal verification if your specification is just simple enough
you don't need to only write pure functions
you don't need them, but pure functions are easier to prove and work with.
easily allows you to write spec for the heap as well
the issue isn't writing the spec, it's that the proof deduction becomes a lot more difficult for every bit of global state because you have to account for all the possible implications.
mutability isn't an issue, global state can be if used too extensively
mutability is absolutely an issue because you need to account for it or need an immutability invariant.
it's what makes global state so problematic in the first place.
resulting in a proof with no user interaction, sure sounds automatic to me
quite a bunch of proofs with sufficient spec are entirely automatic
If you haven't written specifications complex enough to require some work on your end, you've just been lucky. If we had fully automatic theorem provers nobody would be using proof assistants anymore.
Look up the KeY papers, they even call it semi-automatic themselves.
providing an example for verification in an imperative language implies that you defend that imperative language, gotcha.
yeah, because virtually nobody actually completely verifies Java systems because it'd be an insane workload
KeY is being used in the german car industry for "real and completely verified systems".
Name one of those completely verified systems then.

Jack Parker
Jack Parker

Big think

Joseph King
Joseph King

nice

Jaxson Wood
Jaxson Wood

Hasklel suffers from provability of globals
C doesn't even have globals

Mason Peterson
Mason Peterson

doesn't \0 terminate a string?

Ryder Campbell
Ryder Campbell

Thanks user. You made my day

Attached: squirt.gif (246 KB, 159x85)

Adam Peterson
Adam Peterson

It does, he's altering the offset of the char *, to either start at AM, or start at PM, because they must be relative in memory.

Juan Edwards
Juan Edwards

only know go
made an interpreter in go
built my own lisp in go
implemented minix in go
still not a real programmer according to /dpt/ because go
still not employed

Alexander Morris
Alexander Morris

still not employed because go*

Jeremiah Turner
Jeremiah Turner

she wasn't making games with BASIC in elementary school
she wasn't free lancing as a BASIC programmer in middle school
she wasn't making full fledged programs with 6502 assembly in high school
she didn't get held back and almost kicked out of highschool because she does all her math in hexadecimal
she didn't make a full fledged operating system with internet summer before second senior year
she didn't spend all of senior year skipping class and programming FGPAs
she didn't skip a parent teacher conference about whether she'd graduate so she could finish typesetting her paper on her speedup of a polynomial algorithm
she didn't stop attending school completely so she could work on her proof on an algorithm thought to be NP is actually P.
she didn't lockpick into the teachers lounge to fax this proof
she didn't laugh in the principals face when she got expelled

Never gonna make it

Dylan Cook
Dylan Cook

but i only know Go, Mr. Shekelstein
Shekelstein: "you have to Go, sorry".

Brandon Kelly
Brandon Kelly

daily gogramming thread

Alexander Robinson
Alexander Robinson

I was looking forward to Go replacing python as the brainlet lang, but then it had to go and lose to javascript. Like how hard do you have to fail to lose to fucking javascript.

Ryder Sullivan
Ryder Sullivan

shut up NEET

Nathan Brooks
Nathan Brooks

Why do people that program in C or C++ hate clean code so much?

Most of code tends to be ninja shit filled to the brim with magic numbers and with a bunch of horribly named variables and functions

Logan Thomas
Logan Thomas

Shit like this is why C was a mistake.

Carter Butler
Carter Butler

I have to use python exclusively at work everyday so I was hoping a less brain rot language would get popular. Jokes on me though.

Aiden Mitchell
Aiden Mitchell

I have to use python exclusively at work everyday
for what? data analysis? machine learning?

Gabriel Hill
Gabriel Hill

this code

if (k < m) k += (-1 << magbits) + 1;

is creating the warning
warning: left shift of negative value [-Wshift-negative-value]

i dont know fuckin shit about bitwise operations, what can i change the line to to get rid of the warning and preserve its functionality?

Gavin King
Gavin King

C doesn't even have globals
is this some sort of joke?

Brandon Diaz
Brandon Diaz

Under C89, ones'-complement and sign-magnitude implementations were required to process left shifts of negative values in ways that may not have been the most logical on those platforms. For example, on a ones'-complement platform, C89 defined -1<<1 as -3. The authors of the Standard decided to correct this problem by allowing compiler writers to handle left shifts of negative numbers in any way they saw fit. The fact that they allowed that flexibility to all implementations including two's-complement ones shouldn't be taken to imply that they intended that two's-complement implementations to deviate from the C89 behavior. Much more likely, they intended and expected that the sensible behavior on two's-complement platforms would be sufficiently obvious that compiler writers would figure it out with or without a mandate.

Compilers often squawk about left-shifting negative constants by other constants because x<<y can be simplified when both x and y are constants, but such simplification would require performing the shift at compile time whether or not the code containing the shift is executed. By contrast, given someConstant << nonConstant, no simplification would usually be possible and thus the compiler would simply generate code that does the shift at run-time.

Asher Hill
Asher Hill

Mensan. You don't know my suffering you brainlet.

Attached: cards2.png (156 KB, 2560x1400)

Julian Peterson
Julian Peterson

Generic back end server shit. Python makes sense for data analysis because those guys should be thinking more about generating cool findings rather than language syntax, but from a programmer perspective all the hacky shit that's idiomatic python would be hard compiler errors in any sane language. So many devs are shit because they start in a shit lang and are unable to un-train the awful habits they learned were "correct" programming.

Brody Collins
Brody Collins

tfw my job is basically maintaining ~400k source lines of code worth of legacy Python applications
I know that feel bro. If I had a time machine, I'd go back and kill Guido to stop this blight on the world.

Juan Diaz
Juan Diaz

Some people are willful imbeciles. It's best to ignore them.

Blake Evans
Blake Evans

noooooo dont make me read you nigger

Eli Collins
Eli Collins

In C you explicitly have to share data across source files. There's no way to implicitly share a datatype. It must be extern'd in a header/source file and declared somewhere else in a file-scope at min. It's a weird technicality, because C compilation does not keep a globally permissive state.

Are you trying to crush bits? Use an AND 0xFF or FFFF depending on what you're keeping.

What is negative leftshifting even supposed to do? Just right shift you monkey. You shouldn't be using bit-shifting on signed values at all, unless you guarantee unsignedness or cast.

Noah Murphy
Noah Murphy

tfw I can't learn python

It's just so unreadable. I can't bear to read any of the intro books or make anything

I guess I'm stuck on R

Thomas Peterson
Thomas Peterson

At least go for a language like C which is actually used in some real, completely verified systems.
Examples?

Idris and LiquidHaskell can only be used for very elementary specifications.
Can't you verify sorting algorithms and the like with Idris? I'm sure I've seen something like that before.

Jaxon Bailey
Jaxon Bailey

~400k source lines of code worth of legacy Python applications
doubt.jpg

what are some example of those python apps that have so many lines? do they have a GUI or something?

John Garcia
John Garcia

Nvm, I read that wrong, but the bit-shifting point still stands. Don't shift a negative number. Don't even use bitwise operations on signed numbers.

Camden Kelly
Camden Kelly

Are you trying to crush bits? Use an AND 0xFF or FFFF depending on what you're keeping.
What is negative leftshifting even supposed to do? Just right shift you monkey. You shouldn't be using bit-shifting on signed values at all, unless you guarantee unsignedness or cast.
its not my code, gaylord, i dont know what the fuck its trying to do, i just dont want warnings in my compiler feed

Jason Powell
Jason Powell

I suppose they assume 2's complement and use -1 as an /all bits set/ value. What you should probably do is use

~0 << magbits
but with an unsigned integer type.

Ethan Myers
Ethan Myers

I've looked at R code it and looks way less readable. What aspects of python's syntax make it difficult for you?

Jace Carter
Jace Carter

I don't know if just know it makes my eyes hurt. Also I was very uncomfortable programming in it because I had no idea when things started or ended. Even lua is more clear

Brody Campbell
Brody Campbell

magbits is signed

Leo Roberts
Leo Roberts

That's not magbits' sign that's the problem that's 0 you dipshit

Nathan Martin
Nathan Martin

I don't know what it's trying to do
Well if we put in 0010 0000 and 0000 0001 for example, k < m, magbits on m is 6, -1 << 6 = 1100 0000 on a 16-bit system, and add ones on the left if it's a greater bit system.

Better way of doing it, -1 = ~0 on a two's complement system. Replace -1 with ~0x00 and it should work fine on... most systems. It's likely what the author wanted but didn't know how. Or define a preprocessor derivative, where -1 = whatever bits it is on your system for a given size. i.e. if int32 && two's complement. -1 == 0xFFFF, if int32 && 1's complement, -1 = 0x1001

Camden Russell
Camden Russell

Don’t be a rood dood

Brody Smith
Brody Smith

Cast -1 to an unsigned int. Cast the result back to the signed type of k.

Juan Scott
Juan Scott

Tyvm

Alexander Cox
Alexander Cox

move the negative sign outside the parenthesis

Ryan Howard
Ryan Howard

If you have a disability that makes it hard to see indented blocks, why not have your text editor color them?

Easton Sanchez
Easton Sanchez

Replace -1 with ~0x00 and it should work fine
Unfortunately I got the exact same warning

Juan Morales
Juan Morales

Of fuck off. I have no reason to lie.
Did I mention the legacy-legacy part that is all in C?
The software is collectively a monitoring and report generation system. Parsing log files, snmp traps, an interpreter for in-house DSL to generate reports (which is retarded), downloading shit from clients, etc. There are like four different frameworks for doing anything. It's a fucking mess. Oh, and it is still Python 2.

This is what happens when you hire Python developers straight out of college for 10 years straight.

Attached: thisismyfuckinglife.png (14 KB, 589x132)

Carson Bennett
Carson Bennett

Well it's the negative shifting of a signed value which is the problem, and it's probably being "smart" and interpreting ~0 as a signed value because it eventually gets assigned to a signed value. If k isn't signed, then there's literally no problem with redoing his line, because it is a bug. That line is explicitly a bug.

Robert Diaz
Robert Diaz

Ok, new plan
Is there a g++ flag to suppress warnings only for one specific file?

Noah Butler
Noah Butler

same here. but if you do

~(unsigned long)0
It goes a way. That's at least one step in the right direction because we get the /all bits set/ value. LONG_MAX or
(unsigned long)-1
might work too but idk

Gabriel Johnson
Gabriel Johnson

What's funny is Perl was designed for parsing data on systems and over networks. It even has had native database tools/libraries since like, mid 90s. 40k lines to re-implement something because they don't like another tool that already does it.

Adrian Kelly
Adrian Kelly

R's pipe operator and ggplot2 alone make it 1000x easier to deal with datashit though.

Aiden Wilson
Aiden Wilson

Wait nvm realized how stupid that question was

Jaxson Wilson
Jaxson Wilson

It's literally like --suppress-warnings isn't it?

I wasn't going to reply because I was giggling

Evan Richardson
Evan Richardson

What's funny is Perl was designed for parsing data on systems and over network
But then you're dealing with Perl
Some stuff is unforgivable

Jaxson Garcia
Jaxson Garcia

I realized that g++ doesn’t have flags to suppress warnings, only flags to show warnings (-Wall, -Wextra)
If I don’t want to see warnings all I have to do is not pass those

Ian Mitchell
Ian Mitchell

I don't have a disability for that. I do have an allergy to assholes though.

Brandon Baker
Brandon Baker

Excuse me. PERL IS A SAINT. Blasphemers who don't use strict; use warnings; will be exiled.

Cameron Martinez
Cameron Martinez

Python 2
That's a major grade A Yikers from me dawg.

Gavin Thomas
Gavin Thomas

What is

-Wno-shift-negative-value
?

Angel Wood
Angel Wood

I mean, if want to be 'technical' even Java doesn't have global state. When talking about global state in relation to proofs most people just mean not function scoped.
Examples?
seL4 (microkernel)
wireguard (vpn)
look up compcert (verified c compiler) if you want to know more, but a lot of it isn't all that interesting imo
Can't you verify sorting algorithms and the like with Idris? I'm sure I've seen something like that before.
Specifications like that you can definitely prove, but it's basically limited to smaller utility functions/just ensuring some proportions, not actually verifying the result. It's not bad, but actually proving algorithm is an exercise in futility.

Kevin Thomas
Kevin Thomas

new thread

jowforums.com/thread/69749453/technology
jowforums.com/thread/69749453/technology
jowforums.com/thread/69749453/technology

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit