/dpt/ - Daily Programming Thread:

Old: Working on?

Other urls found in this thread:

github.com/nick-gits/calcupy
recurse.com
isocpp.org/wiki/faq/const-correctness
sweetscape.com/010editor/manual/TemplateVariables.htm)
github.com/Coding/WebIDE
mahapps.com/
blog.rust-lang.org/2016/09/29/Rust-1.12.html
docs.python.org/3/
composingprograms.com/
reddit.com/r/learnpython
twitter.com/AnonBabble

Learn you an esoteric patrician language through memes chapter 5

adjacency list C++ include redundancy detection in b4 smug anime girl image

I have no idea what I'm going to do.

Eh, I just wrote a fairly non-trivial program in Mathematica and Clojure (compute all Dyck paths with a given area below them, apply that to a stat. physics problem I had). The Mathematica solution ended up being both more concise (due to pattern matching, easy hashing) and faster, which spooked me out enough to write that post.

I agree that its scoping rules limit it for large general purpose stuff, but it's still way more useful for general-ish programming than I first gave it credit for. Especially when you go back to it after having played with Haskell and Prolog, so that you are familiar with the techniques you'd use there. It's way more than a simple toolbox for solving equations and plotting.

It would definitely be nice to have an open source alternative to Mathematica, but I'm really not a big fan of Python as the alternative.

Tbh I'd rather have a language that supports multiple programming paradigms and with a syntax designed from the ground up to be good for mathy stuff. Julia seems really promising, though due to its focus on speed it does have some C-like gotchas.

Writing a tokenizer for my C interpreter needed to apply 010Editor Style template files to my ncurses based Hex-Editor.

...

Please keep it up, I'd definitely use this over hexedit.
The bit down the bottom with the *int* might be quite useful.

Do you have a github yet?

>C interpreter

I see.

is there anything wrong with just knowing python if you're a hobbyist and does knowing python make me a programmer? I would be willing to learn another language if it had advantages to python and was CLI only

>gotos
>in 2016

But the Haskell version does allow you to wrap any function that would produce a side effect.

Lisp macros are confined to working on code written in terms of sexpressions. Haskell functions are confined to work on things that are valid Haskell computations. Neither are particularly limiting.

Do monads allow you to destructure the chain of operations that comprise a given monad and modify each of them as you please? You can of course inject basic functionality using fmap etc., but can you take a monadic program as input and predict what it does?

Using Lisp macros, you can take the s-expression (princ "Hello world!") and recognize algorithmically that it prints "Hello world!". But if you take the monadic value putStrLn "Hello world!", you won't be able to break it down in that manner, not natively at least.

>Lisp macros are confined to working on code written in terms of sexpressions.
S-expressions are just parse trees. Any language can be written in terms of s-expressions. What makes Lisp different is the expressiveness that self-referential access to such parse trees (which are much simpler than in other languages, because the code itself is the parse tree) that macros provide.

...

Procrastinating on doing actual work.

Fondling some functional things.

>arguing about literally anything on /dpt/.jpg

>5
>fine

White boi lmaooo

>tfw no semen demon colleague

The Haskell equivalent would be something like a free monad. Looks like regular syntax, but actually builds an AST.

I mean, Lisp is basically a DSL for symbolic computation. Nothing does it better. But with the homoiconicity, you get that it's, well, interpreted and dynamically typed. There's a big tradeoff.

Everyone knows the one true way is
if Condition then
null; -- replace this with actual statement
end if;

Please respond.

>tfw mangafox

I started this as a school project, is there any use for it you think? Like if somebody wants a calculator in their program for some reason? All they would have to do is import this module for the solve() function. I'm kind of depressed because I put a lot of time into understanding translating infix to postfix but I kind of know nobody will ever use this.

github.com/nick-gits/calcupy

Ignore the license and things it was required for the project.

Should I watch new game?

What language would you recommend for me? I'm too smart for C or Python.

>too smart for C
LOL

nice, would star it but my github has my name and face on it

*hugs you*

Yeah I wrote a Hello World and I'm just not intellectually challeneged enough by it to try and make my own AAA indie blockbuster with it, so...

The Either type is a "sum" type. For two types a and b it contains all the values of a plus all the values of b, one each. Think tagged unions in C.

data Either a b = Left a | Right b

x, y :: Either String Int
x = Left "poopy"
y = Right 7

stringify (Left s) = s
stringify (Right n) = show n

intify (Left s) = length s
intify (Right n) = n

frobnicate (Left s) = sum (map fromEnum s)
frobnicate (Right n) = if even n then n/2 else 3*n + 1

Is it bad to have a FizzBuzz on your github this long?
start = int(input("from:"))
end = int(input("to:"))
yes = set(['y'])
no = set(['n'])
print ("Do you want numbers that are not Fizz/Buzz/Fizzbuzz to be printed? [y/n]")

choice = input().lower()
if choice in yes:
print ("")
print ("Doing fizzbuzz from", start, "to ", end)
print ("")
for count in range(start, end+1):
if (count % 5) == 0 and (count % 3) == 0:
print ("Fizzbuzz", count)
elif (count % 3) == 0:
print ("Fizz", count)
elif (count % 5) == 0:
print ("Buzz", count)
else:
print (count)

if choice in no:
print ("")
print ("Doing fizzbuzz from", start, "to ", end)
print ("")
for count in range(start,end+1):
if (count % 5) == 0 and (count % 3) == 0:
print ("Fizzbuzz", count)
elif (count % 3) == 0:
print ("Fizz", count)
elif (count % 5) == 0:
print ("Buzz", count)

do you plan on putting more stuff on your github, if so I'll give you a follow

Set-theoretically, it's a disjoint union.

How do I develop software in a corporate/industrial environment?
I have good experience with C, git, vim, valgrind, gdb, I use travisci and stuff, and I know a little C++ (modern C++) though I haven't used it for anything noteworthy, and a little python, and I'm generally good at learning things to a decent standard quickly. But I have no experience actually shipping software, or programming/managing databases or web frontends/backends or with web frameworks.
I want to be a professional but I don't want to be in over my head, I have no formal education regarding the matter and I'm already 19 years old and the time is passing quickly, I have nothing to show for it, nothing official anyway.
Send help.

Lisp doesn't have to be interpreted, and macros in fact work at compile-time, be it JIT or not. You can even disassemble a function in run-time, which prints to the standard output, and pipe the output into a string or other container.
* (with-output-to-string (s)
(let ((*standard-output* s))
(disassemble 'null)))

"; disassembly for NULL
; Size: 37 bytes. Origin: #x1000BCAC38
; 38: 4881FB17001020 CMP RBX, 537919511 ; no-arg-parsing entry point
; 3F: B917001020 MOV ECX, 537919511
; 44: 41BB4F001020 MOV R11D, 537919567 ; T
; 4A: 490F44CB CMOVEQ RCX, R11
; 4E: 488BC1 MOV RAX, RCX
; 51: 488BD0 MOV RDX, RAX
; 54: 488BE5 MOV RSP, RBP
; 57: F8 CLC
; 58: 5D POP RBP
; 59: C3 RET
; 5A: 0F0B10 BREAK 16 ; Invalid argument count trap
"
Make of it whatever you wish. I personally prefer power over safety.

>I'm already 19 years old
m8...

Yeah I have a few projects, some for school and others not that I have saved offline, a "smart" Cred Forums image downloader, that just accepts a list of keywords to search as input, efficient proxy scraper/checker (learning about efficient threading in class now) and other things that are probably way below you, I'm a first year CS student.

I'm 19 years old and have no work experience, how many projects should I have on my github and what certs should I go for if I wanted a job in a tech shop

recurse.com
worth a shot. the application doesn't look long and i've heard good things

>other things that are probably way below you
mate I'm shit at programming, I just lurk these threads and occasionally make stuff

it's comfy

why is everyone 19 years old all of a sudden

im 20 if it makes u feel better

>macros in fact work at compile-time
GHC (which is de facto Haskell itself) has Template Haskell for that.

>You can even disassemble a function in run-time, which prints to the standard output, and pipe the output into a string or other container.
This is kind of an artificial problem. In Haskell, people abide by single responsibility, extensibility, etc. a lot. So there's no need to do this in the first place, since nobody writes a useful function that writes its output to a stream for some reason instead of just returning it.

well I don't know about the other anons but for me it's cause I was born 19 years ago

Also, in that code, with-output-to-string is a classical example of the use of macros for control structures. The argument list that just takes s in that case can also take optional and keyword arguments, which can be destructured and passed as arguments to other functions or macros. Pretty simple for with-output-to-string
* (macroexpand '(with-output-to-string (a b :element-type c) d))

(LET ((A (SB-IMPL::MAKE-FILL-POINTER-OUTPUT-STREAM B)) (#:G600 C))
(DECLARE (IGNORE #:G600))
(UNWIND-PROTECT (PROGN D) (CLOSE A)))
T

what happened to our guy steve yegge

>how many projects should I have on my github
Doesn't matter as much as other hirability factors.

>what certs should I go for if I wanted a job in a tech shop
What the fuck do you even mean by "tech shop"?

You could just go get your A+ and your MCSA in Windows Server and you're immediately hireable at any MSP, making decent money.

If you're looking for a developer job, you'd need to get certs in your specific programming stack.

Java, C#, C++, Python, and C have the most jobs, respectively.

Javascript and SQL are above all of these, but they are a skill generally combined with other things.

by tech shop I mean a local shop (currys/pcworld) that sells computers and stuff like that

Professor gave us an assignment: write a function which reverses the bits of a short integer and returns the new short integer. Someone in my class turned in:

unsigned short reverseBits(const unsigned short &x)
{
unsigned short result = 0u;
for (unsigned char i = 0u; i < 16u; i++)
if(((unsigned short)(x > 15u) > 0u)
result = result | 1

A+

>by tech shop I mean a local shop (currys/pcworld) that sells computers and stuff like that
Software development is completely different from that, which is why it doesn't make sense to ask about certs in the same sentence as github.

...

That feel when you have accomplished literally nothing despite learning programming on and off for several years now, because you're autistic and have to use a low level programming language and write everything from scratch, your own data structures, your own matrix transformation functions, and the only libraries you use are frameworks because your autism gives you anxiety and feeling of disappointment when you use functions that you don't know the exact mechanisms and workings of.
That feel when you start learning a new programming language not through tutorials or reading about the syntax, but by opening the compiler manual.

That feel when in the same time, and with the same effort, other people cobble together Java or Python applications that JEST WERK and are already making money.

That feel when nothing to show for all that time and effort.

That feel when you realize you're an idiot.

>vcu student

hey user i'm a professional programmer in RVA!

i'm not going to help you though, read your book. i will say you shouldn't use unsigned unless you have a good reason.

I know that feel all too well...

yes I do, but I won't give it to you. It's for me only

>nobody writes a useful function that writes its output to a stream for some reason instead of just returning it.
what do you mean?

using std::ostream;
struct Point {
int x, y;
Point(int x = 0, int y = 0) : x(x), y(y) {}
friend ostream &operator

>he fell for the Learn [C/Lisp/ASM] / SICP / K&R memes

the average C programmer

I actually use Object Pascal because I like strong typing.
Tried ada, but it was too autistic even for me.

C++ isn't Haskell.

>But then again, if you gave a shit about efficiency you wouldn't use Haskell, where strings are linked lists for one.
Haskell's inefficient for other reasons. It's recommended to use Text instead of String.

Does C apply the return value optimization?

No.

That's a bit shit innit? It's always safe to apply in C.

...

I once wrote a simple structure viewer/editor just for fun. The template language I used was C-ish, with { } -blocks and all. It worked nicely for simple structures, but I ran out of steam and skills when I tried to get arrays, nested structs and arrays of them to work. I also couldn't figure out how to do it safely, without having maliciously written structures leading to memory hazards and crashes.

I want a language that's in between C and C++

>namespaces
>methods
>maybe RAII
>no exceptions
>templates
>a very small subset of the stl
>no lambdas
>no inheritance

What languages do you shill for in /dpt/ despite never having used?

For me it's D and Nim

There's no reason to make it unsigned. const type &x is for const correctness, which is good practice.

isocpp.org/wiki/faq/const-correctness

>leading to memory hazards and crashes.
valgrind is your friend.

The 010Editor template language is basically just C with the addition of local variables and the special attributes. (sweetscape.com/010editor/manual/TemplateVariables.htm)
And I really don't feel like defining my own template language since I really like the Idea of just using C. Makes everything possible and comes natural to most programmers.

That being said. Is there a legal issue if my program can interpret a file designed for a commercial application?
Like gimp being able to open .psd files, Is there anything to consider?

>no exceptions
Why tho? How else are you going to handle errors, monads?

>no lambdas
I spy with my little eye a brainlet

The way they used to be done.

Lambdas have unacceptable performance costs.

What to learn or rather get deeper into, /dpt/?

Nim, Rust, D, Common Lisp or Erlang (Elixir?) ?

D looks like a faster devtime C++ with some nice improvement/features. I can live with the GC.

Rust is the new player with it's very enforcing rules and fucking shit syntax.

Nim looks like a more dynamic/scripting language, but with some surprises. I like that it can compile to C and that it has a kinda unique "aspect".

Common Lisp would be good to fuck around with metaprogramming, code generation, DSLs, patterns and it can be used to write actual software too. (Maybe Racket?)

Erlang/Elixir has an interesting concurrency model. It looks good to be used in a network (backend) server.

Any thoughts? Please don't turn this into a fucking flamewar, guys.

>MUH CPU CYCLES

#cpucyclesmatter

Prolog and Erlang

>The way they used to be done.
Awful. Why do you insist on leaving out exceptions but embrace other modern inventions like parametric polymorphism and RAII?
>Lambdas have unacceptable performance costs.
What?

always
if(){
}

Exceptions obfuscate control flow and make code more difficult to follow and understand. This is a bad thing.

>not (if condition ... ...)

>not having your truth values be of type (a -> a -> a)

How's programming in rva like? I'm trying to get jobs or internships in nova cause Richmond is too dirty for me.

Rust has lambdas but lambdas don't have any performance issues. It's the exact same or even better than the naive "function pointer + void user pointer" idiom.

>valgrind is your friend.
I wasn't that advanced yet back then. This was some 7-8 years ago. The problems I primary had was how to handle structs that reference each other and what happens if you put a struct inside itself. Endless headaches.

010 templates look pretty advanced. Being able to put 'if' statements in a struct definition is quite amazing feat. I'd love to see their interpreter handles everything.

I don't honestly think anyone's going to come after you for simply decoding files in your own computer.

bump

>tfw thought about posting that you are a bad programmer if you need if statements
>tfw I realised that prolog has if-statements

>you are a bad programmer if
>if
uh-oh

>a standard data type is not recommended for use
Hasklel, everyone

Did the image generator guy ever post again? I recall him having trouble with small images.

>language tries to better itself
Hasklel, everyone.

i stopped using pictures of your penis and have no trouble now

But.. image generators create new images. They don't use existing ones.

what a fucking idiot, he didn't say image editor he said generator

Just found this, thought some of you might like it, I'm sticking with vim but you could run it on a pi and get a nice IDE
github.com/Coding/WebIDE

>tries to
is the key word here

C doesn't apply it because C is a language, not a compiler.

I'm a retard and can't find what .partial does in the Python docs and I wonder if anyone else knows where I can read about it.

I have this piece of code to fetch data, but because my internet is shit I sometimes get IncompleteRead. It's supposed to continue where it left off, from what I've understood, but it really doesn't do anything other than just continuing with just half the data.
try:
page = urllib2.urlopen(url).read()
except http.client.IncompleteRead as e:
page = e.partial

Who said it didn't? It has a better method for textual data than String.

>come up with a killer programming language
>remove generics
>remove operator overloading
>remove any way to do proper error handling
>use a toy language
And you have Go.

In no mainstream language is the string type not recommended for use. Guess that's because they're not autistic enough to force purity and laziness into it, and then backtrack from that mistake by recommending another type.

Other languages already take care of it with the string type.

>use a toy language
s/language/compiler

bump

Linked lists being linked lists has nothing to do with purity or laziness.

Data.Text is the string type of choice, now. String is just an alias for a linked list of characters. Now you're just bikeshedding.

>remove operator overloading
only place where this might've been useful is for math/big
>remove any way to do proper error handling
exceptions are not a good way to deal with error handling by default
you can use panic/defer/recover for programming errors (i.e. errors where it makes sense to use exceptions).
panic/defer/recover being more clumsy than exceptions prevents people from using them as default error handling construct just to keep writing the same shitty code like in the languages they came from.
>toy compiler
wat

>only place where this might've been useful is for math/big
And data structures.
>exceptions are not a good way to deal with error handling by default...
C style error checking isn't either.
>wat
It's a toy from Plan 9 automatically converted to Go. It has just implemented SSA for x86.

r u me?

Sounds almost like Rust.

This. You should use monads instead, then you can have exceptions where you want them and not where you don't.

I'm new to C

How do I make a char array
[ \ ][ n ]

into a single char
''\n'

'\n' is a single character

I understand that, but I have an array that is [\][n] and i need to use that to access the character [\n]

>namespaces
already in c++
>methods
same
>maybe RAII
same
>no exceptions
-fno-exceptions
>templates
in c++
>a very small subset of the stl
I don't even fucking link to this piece of shit, roll your own. Small hint:
compile your c++ with gcc not g++. It won't link to libstdc++. If you get linking errors, apply -fno-rtti. With this you get pure "C with classes" approach.
>no lambdas
don't use them
>no inheritance
don't use it

>exceptions are not a good way to deal with error handling by default
Neither are error codes.

>you can use panic/defer/recover for programming errors (i.e. errors where it makes sense to use exceptions).
This is utterly wrong. There's no reason to be able to recover from a programmer error. Exceptions are for things that, while they shouldn't happen under normal circumstances, are possible, like an expected file not existing. Things that can happen all the time, like improperly-formatted user input, should be done with something lighter than exceptions.

no better way than
if (arr[i] == '\\' && arr[i+1] == 'n')
/* put '\n' somewhere */

if you want to replace [\][n] with [\n] you have to re-order your array afterwards

def longest_palindrome_bottom_up(string, parent):
cache = {}
for left in range(len(string)-1, -1, -1):
for right in range(0, len(string)):
if left > right:
cache[right, left] = 0
parent[right, left] = (None, None)
elif left == right:
cache[right, left] = 1
parent[right, left] = (right, left)
else:
if string[left] == string[right]:
cache[right, left] = 2+cache[right-1, left + 1]
parent[right, left] = (right-1, left+1)
else:
q = cache[right, left + 1]
p = cache[right-1, left]
if q>p:
parent[right, left] = (right, left+1)
cache[right, left] = q
else:
parent[right, left] = (right-1, left)
cache[right, left] = p
return cache[len(string)-1, 0]

def palindrome(string):
if len(string)

Why don't you use the best text editor yet?

>something lighter than exceptions
You mean... error codes?

I already use vim though

Notepad?

Nah, nano.

finds the largest palindrome subsequence in a string
for example palindrome("faggotfaggot") returns "ggogg"

Bad vim plugins.

No, using algebraic data types.

>Calls ada too autistic
>Uses object Pascal
Ummm

Should I give CLion a try?

Not all languages have them.

no, it's slow and bloated
try qtcreator

That's kind of the point.

Why "ggogg" and not "ggtgg", "ggfgg", or "ggagg"?

W3Schools is a hell of a lot more accessible to noob than MDN

Since /wdg/ is dead, /dpt/ gets web dev as well.

...

ordering
decided inside the max() function, where it just returns the first thing

wat

palindrome("character")
returns "carac"

longest palindrome subsequence, not substring

>github.com/nick-gits/calcupy

I gave it a look, very well done user!

arbitrary and stupid

>Now you're just bikeshedding.

There's literally nothing wrong with the default string implementation.

It is bikeshedding. If Data.Text were called String and included in the Prelude, your "argument" would disappear.

explain

...

>String is just an alias for a linked list of characters.

Holy shit

Well, it's true. Complaining about the name is, as I said, bikeshedding.

The web dev general isn't showing up in my search results on Clover. I'm assuming all of us unwanted web developers are going to shit up this general now.

Simply grabbing the first letter you see or the letter highest in the alphabet among choices is arbitrary. In the context of your example, t, f, and a are all just as valid as o.

Something retrieving a subsequence should not reason about the order of the elements.

The function to perform this task should be able to return any number of potential subsequences, and allow the user of the function to then decide which is relevant, if any, to her business case.

sound incredibly inefficient

Make a new webdev thread then, or don't you know enough programming to be able to do that?

not when you have lazy evaluation and list fusion

Not like anyone posts in /wdg/ anyway. It's slower than

they built their own forum using the latest technologies

the spec is "it returns A maximal subsequence if there are more than one, and the one if there is just one"

i see your point though

This, I don't get the hate for it.

You mean they copy and pasted javascript from stackoverflow.

>And data structures.
which?
>C style error checking isn't either.
why?

>There's no reason to be able to recover from a programmer error.
yeah i'd also like my server to crash without survivors when something goes wrong
either you've got something similar to supervisors or you're attempting to imitate supervisors.
non trivial applications shouldn't crash when something goes wrong.
>Exceptions are for things that, while they shouldn't happen under normal circumstances, are possible, like an expected file not existing. Things that can happen all the time, like improperly-formatted user input, should be done with something lighter than exceptions.
this statement is the perfect example for why using exceptions as primary error handling mechanism is a bad idea. there's no clear line, people randomly mix exceptions with error values, eventually ending up using exceptions for control flow.
why is a file not found error rare, but improperly formatted user input isn't? because some lang uses exceptions for one and error values for the other?

algebraic types aren't lighter than error values, they're just a slightly more type safe version of error values in go

D or Nim?

No, I might just have to ask you how to do that. What is your special snowflake algorithm btw? My name is Vihaan. Are you Indian too?

Can someone explain git and version control to me?

How does it work and how do i use it correctly?

D

Why is PHP so fucking bad? It's unbearable

>which?
Anything that isn't part of the Go standard library. Binary search trees, etc.
>why?
Try debugging sentinel errors.

>non trivial applications shouldn't crash when something goes wrong.
What else do you propose doing when something is pure programmer error?

>this statement is the perfect example for why using exceptions as primary error handling mechanism is a bad idea. there's no clear line, people randomly mix exceptions with error values, eventually ending up using exceptions for control flow.
>it's bad because you have to think

>why is a file not found error rare, but improperly formatted user input isn't?
If it's a specific file that is supposed to exist, it's rare that it doesn't exist. It's very normal for a user to accidentally give invalid input. If the invalid input means asking to do something to a file that doesn't exist, it's not exception-worthy.

>algebraic types aren't lighter than error values
I said lighter than exceptions. Algebraic types are just as light as a tuple of an error code and a value, or even lighter since the value doesn't need to be initialized if the call isn't successful.

A co-worker wanted to combine some CSV files.

Sure, I could have given him a single line of code to run.

But what's the fun in that?

What would be the five programming languges for a beginner natural learning progression?

I'm just going to nod my head and pretend to understand what you're talking about.

Cute UI. Is it just WPF?

That GUI is fucking disgusting. You should be ashamed of yourself

Assembly
Lisp
C
Haskell
Scala

C
Python
...

Five languages for a beginner? Hell, i've been focusing in C++ for 5 years and i'm stilla a noob.

That's because C++ is garbage

WPF/MahApps, or as I've taken to calling it, WPF + MahApps.

mahapps.com/
install-package MahApps.Metro

What are your preferences in a GUI, user?

>What are your preferences in a GUI, user?
A GUI that looks native and not like a smartphone app

Good point.

I'll refactor it into a UWP application so it looks native on desktop and mobile.

... Should we tell him about windows 10, guys?

shit, same

lazy evaluation means the data is only evaluated (or becomes the actual data) when it's needed (i.e. when you need to examine it)

list fusion is a set of rewrite rules that tell the compiler that if you use the certain functions, it can remove list allocations - potentially the list you're abstractly thinking of might never even be created, for instance in the case

foldr (+) 0 [1..1000]

since [1..1000] can be thought of as a yielding for loop

for (int i = 1; i

Windows 10 looks awful but this is just ridiculous. I mean his program could actually look pretty good if everything wasn't so huge

I knew you'd say that.

you mean using foo[bar] for bsts?
yeah okay, i'll give you that

>Try debugging sentinel errors.
found debugging by other people in go a lot easier because when jumping to a piece of code i can immediately see where an error can originate. the error handling code is explicit at every level. yes this is noisy, yes this takes longer to write, but it certainly makes debugging easier.
having error values and stack traces at once also isn't impossible.

>What else do you propose doing when something is pure programmer error?
programming errors can be isolated. error occurs when dealing with some client connection? terminate the client connection, but not the entire server.
this is basically what supervisors are all about, and they work really well (and i'd argue that supervisors are a lot better than raw error handling, although i prefer error values over exceptions).

>it's bad because you have to think
no, it's bad because you gotta guess and cannot come with a consistent and clear guideline when to use which.
you're making assumptions about how often a user will make a certain mistake.
not for good code, but merely for performance reasons, and that alone should ring alarm bells.
okay, you pushed files into one camp and invalid string input into the other one. other people do it completly differently, and together, it results in an inconsistent mess.
i've seen so much bullshit code where people wrap exceptions in error values because it didn't fit their current idea or where people wrap error values with exceptions because it didn't.
not even arguing in favor of go's way to do error handling anymore, just error values vs exceptions in general.
exceptions make sense for when an error was identified as programming error.
crash the program or explicitly isolate the error with a try-catch.
user errors shouldn't use a different control flow, they should be handled like regular code, because it is regular code, there's nothing special about it.

>error occurs when dealing with some client connection? terminate the client connection, but not the entire server.
Right. That's just crashing the client and having the server be able to react to a dropped client. And clients could be dropped for many other reasons that have nothing to do with programmer error.

>no, it's bad because you gotta guess and cannot come with a consistent and clear guideline when to use which.
Because it's up to the use case? The difference between the two is that e.g. algebraic error handling has a small overhead either way you go, and with exceptions it's free when they're not thrown but expensive when they are.

In a decent language, you can abstract over the method of error propagation so that the control flow is the same either way.

homoiconicity doesn't mean interpreted though.

lisp has had compilers for decades, literally longer than haskell was a figment of imagination in some british guys head.

>so traversing them is like traversing a linked list.
Still sounds inefficient.

Does gcc have extensions for unicode or do i have to craft it myself?

Yeah, but it's often only done once
It would be nice if GHC optimised literals into arrays or something, I don't know if they do

basically it's efficient when you do list-y things with strings, but not when you do things that you'd do with a text-oriented data structure.

>Lisp macros are confined to working on code written in terms of sexpressions


negative.

you can work on sexpressions that aren't valid code and transform them to valid code.

and with reader macros, you are only confined to arbitrary string tokens

>Right. That's just crashing the client and having the server be able to react to a dropped client.
i'm talking about dealing with an error related to a specific client connection on the server side.
in many cases, "fatal" errors can be isolated. that's what exceptions and try catch are useful for.

>Because it's up to the use case
there's no advantage when using error values in terms of code except for having to write less code, which reduces clarity. i wouldn't want all my control flow to be monadic just to reduce code usage, just like i wouldn't want shit like comefrom to reduce code.

>exceptions it's free when they're not thrown but expensive when they are.
try has an overhead

Rust 1.12 has just been released: blog.rust-lang.org/2016/09/29/Rust-1.12.html

Why aren't you using Rust yet, /dpt/?

Lazy evaluation carries with itself an additional stack overhead.

Lazy evluation is good for linked lists

So is ur mum

i find it annoying to deal with lifetimes feature

i find it easier to just manage memory the C way

though i like the pointer discipline in rust

stack overhead?
depends on whether those thunks are stack allocated or heap allocated, or just not allocated at all due to optimization

Cause it's not very good

>still no hkts

The "C way" is just keeping the lifetime stuff in your head and not having it machine-checked, though.

i have a gf

Maybe another one for a different purpose?

You still have to deal lifetimes, the difference being you can name them in Rust.

It's kinda meh.
The horrible syntax does not make up for the 'memory safety' you get. I'd rather use C++ with *_ptr and run valgrind if I have leaks.

you can write rust without any of that right? just using pointers?

Yes, but I don't know why you'd want to.

Yes.

it's decent. obviously not as big as nova. there are dirty parts of richmond but there's also nice parts. it's "historic". almost everyone i know here drinks heavily and takes drugs. you can easily get away with doing 2 hours of work a day as a programmer here.

Like what?
The things you need for different purposes are C/C++, HTML/JS and ShellScript.

Whats the best python resource?

>Common Lisp would be good to fuck around with metaprogramming, code generation, DSLs, patterns and it can be used to write actual software too. (Maybe Racket?)

What about Rascal? If that's the shit you want to do then Rascal is definetly the way to go.

That seems rather limited

And assembly, if you're hard core, which i'm not.

Please elucidate.

docs.python.org/3/
composingprograms.com/
reddit.com/r/learnpython

C++
why is my input file stream reading the last line of data twice? using
while (inFile) {...}
loop

I have a vague idea why this might be. I've seen this problem before.

Post your read loop code.

>reddit.com/r/learnpython
Official tutorial. I'm learinng from it right now.
Official resources are always the best, because they are guaranteed to be competent.

Probably because you are a retard

found the problem. just added
if (inFile.eof()) break;
after my output

Mhmm, good old nih.

*after my input

My dad is an old cobol programmer who wants to automate some things (he never told me what), would python/perl be good for him?

sh for systems
js for web
c/c++ for everything else

Is that what you meant, isn't it?

I had the impression that there are more things that can't be generalized in the "everything else" category

>tfw no programming dad
and yes

his dragon dildos

Didn't mean to greentext what I greentexted.

>python
>perl

What?

>be 60s-80s cobol programmer
>raise son to program
>he becomes a python scriptkiddie
>he tries to get you into python

There is no God

I think I'm too dumb for this shit /dpt/
I started with Java 3 months ago and feel like I've gone nowhere.

I know the simple shit, logic, loops, variables, classes, objects. What I don't know is how to use this shit.

When do I make a class?
When do I just make a method?
When do I just stick to main() and go there?
I tried doing some algorithm shit on HackerRank but it's really tough for me and I barely slip through without looking at comments for exercises.

What more can I do?
What more can I read or watch to get better?
Am I just too stupid?

>There is no God
agreed

He wants to just automate something you autistic (((((((((((((((((((((sperg

I remember I had a guest lecture from Fred Brooks in school. He told us about a project where there was one pair of programmers doing all the writing, and all the other developers served solely as support, brains to pick, and code review. The project -- I think some central cog in a banking mainframe -- was stable, filled all its expectations with aplomb and was on/ahead of schedule, but management just couldn't swallow so many people going "underutilized" and scrapped the idea moving forward.

>python is bad meme
can we stop?

>When do I make a class?
>When do I make a method?
Never, OOP is shit.

learn some CS

> Assembly and a microcontroller
> Arduino

Do you have class?

Write some actual programs. All that shit only becomes relevant once you start having to write enough code that you see things being duplicated, you have to change things, etc.

Nothing

Code a fucking software jesus.
You will never learn if you do some stupid academic shit that can actually be coded just in main.
That's why you don't know when to use classes.
Try to code something bigger, a real world application, and code it in main if it's easier for you.
You will very quickly see why and when you should use classes and all the other shit.

Thanks, I'll take a look.

should he write a gaeeaeaeem or a gooey calculator

you dont need to be aprogrammer to do that

>gooey
You're a jiffag aren't you

Alright senpai.
What should I program?
I've been trying to make a To-Do list with GUI but I hit a dead end with JFrames and shit.

Do you say Jewey?

It's Gwy

no im just trying to make fun of your suggestion

i might be wrong but i think he should learn how to program instead of making "cool" gui "software" and memorizing java libraries

dude just look at mit ocw, they have courses where they teach a ton of CS and have programming assignments

Maybe there are. I can't think of any.
Sure there may be some specialized use cases where something else may be warranted. Matlab, Mathematica, R, Lua. But in general i think my list covers most things.

gwee

What does cum taste like?

salty
i cum in my mouth regularly

Maybe you could use my mouth instead

Playing with Processing

Shouldn't be hard to find out.

>I think he should learn how to program
>instead of making software
Well which is it?
Yeah CS knowlege is important, but he ain't gonna learn to create software by writing a bunch of algorithms, but by... guess what, creating software.

>In no mainstream language is the string type not recommended for use
>what is C++

I like the colours and the fade.

i could if we knew eachother and were in the same country
you're probably right especially if he finds some project that he himself will use and really find it interesting

Anyone have any good tutorials on chat programs for C#? I really liked the Roguesharp for learning a bit more about classes and objects, but it ended up being a bit much to manage. The least pajeet-looking "getting started" article dates back to 2006; I assume that the concepts themselves haven't changed much over the last decade?

Here's the code if you wanna play around
boolean looping = true;
float x0 = 100, y0 = 100;
float h = 0;

void clearBg() {
background(340);
}

void setup() {
size(600, 600);

colorMode(HSB, 360, 100, 100);
clearBg();
}

void draw() {
// Redraw background with slight transparency -- fades old lines
noStroke();
fill(340, 5);
rect(0, 0, width, height);

// New direction differentials
float dx = 20 - random(40);
float dy = 20 - random(40);

float x1 = x0 + dx;
float y1 = y0 + dy;

// Bounce off borders
if (x1 < 0 || x1 > width)
x1 = x0 - dx;
if (y1 < 0 || y1 > height)
y1 = y0 - dy;

// Roll hue
h += 5 * dist(x0, y0, x1, y1) / (20 * sqrt(2));
h %= 360;

// Draw the coloured trace
strokeWeight(1);
stroke(h, 60, 80);
line(x0, y0, x1, y1);

// Draw endpoints
strokeWeight(4);
point(x1, y1);

x0 = x1;
y0 = y1;
}

void keyPressed() {
if (key == 's') {
saveFrame("frame-####.png");
} else if (key == ' ') {
if (looping) noLoop(); else loop();
looping = !looping;
} else if (key == 'q') {
exit();
}
}

wrote helloworldd in c how do i go about making my own os now?

>on chat programs for C#
shouldn't this be pretty much the same for any language, you could find an explanation or some pseudocode and research C# things line by line

install gentoo

Make whatever you want (Just not too big, it's easy to be over ambitious with projects)
What do you mean dead end? Programming is about solving problems (i. e. googling them most of the time).
You hit a problem? Solve it. That's literally what programming is.

Where you from bby

ive nver really made a chat, but you can just use a library that provides you with the capability to listen on a socket using TCP or something and people will be connecting to the port using TCP clients and sending strings

boom

c'mon, Cred Forums
(if conditional
then
else)

Oh. Thanks!

Why do C programmers put author and shit in const char arrays?

Im guessing its there so when someone tries to reverse engineer binary they will see that user made this.

Why isnt this optimized out of the binary?

srsly?
bool_elim : (P : bool → Type) → P true → P false → (b : bool) → P b

Sounds like a plan. I was just curious to see if anyone knew of anything like the Roguesharp walkthrough since I enjoyed that in terms of reading and getting something out of it.

That's how the non-pajeet getting started article phrased it. I guess it hasn't changed.

What manner of chat program are you attempting to make?

A cross-platform desktop application? Windows-only? Web application? Mobile?

??
T = λx.λy.x
F = λx.λy.y
result = (( ) )

Bool : Type
Bool = (A : Type) -> A -> A -> A

false : Bool
false A f t = f

true : Bool
true A f t = t

elimBool : (F : Bool -> Type) -> F false -> F true -> (x : Bool) -> F x
elimBool =

>using untyped languages

Most likely a Windows-only desktop application since I'm still a big programming newfag and I still don't have a whole lot of experience writing things outside of textbook exercises outside of one program I made for work.

"dependent elimination of Church encoded data" guy strikes again

if (b != null && b.equals(new Boolean(True)) == true) then {
...
}
else throw new RemoteException();

>Why isnt this optimized out of the binary?
volatile?

all me

jz A
B: ... then
jmp C
A: ... else
C: ...

Hey /dpt/ I'm fairly new here (and to coding as well.) I can't upload the code I'm working on as I'm on mobile rn but I'll try my best to explain.

I'm working on some code that scans in input from a DS4 controller (acceleration in the x,y,z & gyroscope in the x,y,z). I'm using the gyroscope data (In a function called Orientation) to determine the orientation of the controller (LEFT, RIGHT, TOP, BOTTOM, FRONT, BACK) and printing that out to the console. I'm using the accelerometer data in a function called Mag for magnitude (to determine if the controller is moving.) My main function consists of the scanf for the accelerometer and gyroscope input, A while (TRUE) statement that loops forever. In the while loop I have a printf statement that says "Orientation is: " and then I call my Orientation function (void) that determines the orientation and prints it out ("FRONT") for example. I then have an if statement that ends the program if I press the TRIANGLE button on the controller. The while loop then loops back to the beginning, printing out Orientation is: .

My problem is this: I only want the code to print out "BOTTOM", "RIGHT" etc. only if it's a new orientation (as it is now, the while loop runs over and over and keeps printing out "TOP" "TOP "TOP" etc.)

Any help? Sorry again for not being able to post code. I will in about 2 hours when I get off work. Thanks

If you want a fairly easy GUI-driven experience, try to search for WPF client + server chat programs samples.

If you properly design the server side of things (no GUI except for configuration if you want), then the client (WPF for desktop, Xamarin for mobile) can be designed to simply interface with the endpoint you've created.

At the end of the day, your server side will be using something like SslStream, and any client you create can consume and interact with whatever their socket implementation is, like StreamSockets.

javascript is not a programming language

Wouldn't it just be
elimBool F p q x = x (F x) p q

Global variables by default are extern
If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external
other sources can access them, so they won't be optimised away

if you declared this string as static, then it will be optimised away. And on the hand, declaring them volatile will more explicitly prevent optimisation.

a hacky solution would be to have a value prev that remembers the previous stuff
while true
if(current != prev)
print current
prev = current

No. You don't know that x == false in the false branch and x == true in the true branch, and you can't prove this without internalized parametricity.

define a programming language

Not JS

e := x | \x.e | e e

Well, in that case, it seems that you've satisfied your own definition.

Congratulations?

not javascript
javascript is some webdev frontent hmtl tier bs

but html is a programming language, its not javascript

javascript is a congramming language

js is Turing complete, isn't it?

So my dick is a programming language?

Yo mamma is, too.

Compile in my mouth papi

yes

no, you name something

i decide if it's a programming language

javascript, your dick and my mom, html and css aren't

:}

thnx

javascript is a coding language, but not a programming one

like html

python for ex is a scripting language, not programming either

>your dick and my mom
why did you put these two together

my dick ∪ your mom

>like html
html is a markup language, otherwise it would be htcl.

;/

not everything is in the name dummy

java is called java, doesnt mean people living on java speak java

if any of you boys have big dicks you can have her

thats what i meant, subconsciously

System dot out dot printline open-paren quotation mark I am from Java and find this offensive quotation mark close-paren semicolon!

Best C++ IDE for Windows?

syntax error at line 1
>!
..^

gvim

Cool I'll try something like this when I get back. I'll also post the code just to make things a bit clearer. Thanks.

You forgot to put this post in a class

Visual Studio

I hope you're not being serious. That would make you an idiot.

>how to crash a thread in a single post
>you won't believe how triggered Cred Forums can get over a simple statement
>click here for more info

I don't understand, where is your class and main? I can't find them

Visual Studio, honestly.

What?

github.com/Coding/WebIDE

t. buttnuked frontent webdev

Are you calling me an idiot?

>honestly
It's quite telling that clarifiers like this are often used when referring to a genuinely good product made by Microsoft.

I've mentally separated their development tools from their consumer products, because the former is consistently fantastic, especially in the last two years, and the latter is...what people think of when they see Microsoft.

I don't know. Depends on if you were being serious or you were just taking the piss.

...

Bad habits from English

On Java we say our boilerplate prayers in the morning and evening, so everything we say during the day is part of our main method.

did you remember to catch badenglishexception

>On Java we say our boilerplate prayers in the morning and evening, so everything we say during the day is part of our main method.
I like you.

lmao madman

Idiot.

t. buttbombed frontend web dev

whats that function in haskell that
takes something like
Just (Just 4)
and returns Just 4

or generaly
:: m m a -> m a
i searched in hoogle, but nothing

join

thanks senpai

New thread:

Don't make fun, that's how my super crashed, right into the javac on his way back from the FactoryFactory.

you can also bind into id
Just (Just 3) >>= id

19 years old and being conscious of it puts you ahead of most people

I'm working as a junior software dev on a product in a corporate environment. I kinda lucked out as I'm pretty young, but here's what I did.

>Go on job postings, look up "software"/"computer science"/etc
>Look at what companies are looking for skills for junior programmer/intern positions
>Learn that shit, practice and make up bullshit projects
>Apply to literally every place you have a sliver of chance to get
>Practice interview shit from the internet

Once you got your foot in the door, you're good. Just learn from the more senior guys (if they know what they're doing)

>frogposter
I would never hire you

they really shouldn't have I'm a terrible programmer