[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 29

File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
Previous Thread: >>56169685


What are you working on, /g/?
>>
OOP

Overly
Occurring
Paradigm
s
>>
So if I want to make sure my code runs both under python 2 and python 3 should I use xrange?

I understand there's no xrange in python 3 (or rather the python 3 range works like the python 2 xrange), but if I just use "range" in my code then running it in python 2 increases memory use very significantly.

Should I make some sort of wrapper to run either xrange or range depending on sys.version_info? Or does it already exist?
>>
>>56176377
this.
>>
>>56176377 >>56176510
That's just Python list comprehensions
>>
>>56176465
Inheritance and object oriented programming is a thing. I referenced their specific syntax where you make virtual (c++ language) function calls by invoking functions on a base reference type. Dynamic dispatch, inheritance being required here unless you overload '.'. (i haven't tried)

Member functions is not an OOP thing though. There's no connection other than that member functions and OOP methods which act on the objects share syntax in most languages.
>>56176452
Doesn't warrant response.
>>
>>56176543
Inheritance isn't from OOP, inheritance is just a form of subtyping
>>
So what's wrong with OOP?
>>
How do I stop Pajeet?
>>
>>56176564
Objects passing messages isn't the only form of thinking
>>
>>56176562
Never said it was 'from' OOP. Doesn't matter because OOP requires a inheritance relationship between objects. So inheritance and OOP is a thing. Why are you being so pedantic though?
>>
>>56176564
Too much to detail in a short discussion in /dpt/. Its more efficient to have a proponent say what's good about it and start the discussion from that end.
>>
>>56176611
You can model Cat <: Animal and Dog <: Animal with OOP.
>>
File: IMG_0954.jpg (152KB, 1200x1600px) Image search: [Google]
IMG_0954.jpg
152KB, 1200x1600px
I spent the last two days going though the program I implemented bit by bit and just re-implementing each major fragment in every way I could imagine and benchmarking that on some tests.

I've learned a lot and shaving off fractions of a second here and there I ended up with a ~2x speedup overall.
>>
>>56176367
I don't know any programming, but I just wanted to drop in and say that this is a good picture.
>>
>>56176634
It always surprises me that there are so many of these little 1% boosts that you can double performance

>>56176640
Thank you
>>
>>56176626
I was more thinking in the context of useful programs.. Sure OOP is ok for simply modeling something.
>>
>>56176634
optimization is the root of all evil
>>
>>56176662
Oh. No, I can't come up with anything in that context.
>>
>>56176652
Probably due to efficiency gained from not pulling in data unnecessarily into the cache. If some of those small boosts make them waste less cache space that can be pretty huge.
>>
>>56176581
Good programmers worry about data structures and their relationships, and that's exactly what OOP focuses on.
>>
>>56176626
That's just subtyping, it's not particularly OOP
Row polymorphism and existential types are other forms of subtyping*, usually not present or not recognised by OOP.

*some people will disagree violently

>>56176695
That's not OOP
>>
>>56176500
Write it in C and transpile to Python
>>
>>56176695
OOP focuses on abstraction over data. Code over data especially.
https://youtu.be/rX0ItVEVjHc
Here's a talk by someone who makes games go fast because he thinks about the data.

Try programming OOP with the restrictions he lays out early in the video.
>>
>>56176727
>x oriented y
This is literally the new meme.
I've seen so many examples.
>>
What's a good resource for learning Emacs Lisp? I'm tired of having to google for solutions to make these shitty plugins work, I just want to fix them myself or write my own.

>inb4 read the manual
>>
>>56176564
https://medium.com/@cscalfani/goodbye-object-oriented-programming-a59cda4c0e53#.ij6w8e72f

In short:
Modules > classes
Functions > methods
Interfaces > superclasses
Generics > virtuals
>>
>>56176740
Its a common way of expressing programming principles. Each has to be judged on their own merits. But I agree that applying almost any principle to every situation can be harmful. He's speaking in the context of applications that have to run well in low resource environments. Like phones, consoles, home PC's etc.
>>
>>56176781
first class type classes > type classes > modules > classes
monads > functions > methods
type families > type classes > interfaces > superclasses
existentials > generics > virtuals
>>
>>56176847
Yeah but the stuff I said can actually exist. Nobody knows how to implement a monad in real life.
>>
>>56176874
well you can implement it one of two ways

1) a type class / an interface
2) an effect system

you need functions with the following signatures

a -> m a
(a -> b) -> (m a -> m b)
m (m a) -> m a OR (a -> m b) -> (m a -> m b)
>>
How would you guys go about implementing an SSH client?
Just to send some text-based commands and retrieve responses

Believe it or fucking not, there is no good library for it in Java
>>
File: Screenshot_2016-08-20-17-42-35.png (295KB, 1920x1080px) Image search: [Google]
Screenshot_2016-08-20-17-42-35.png
295KB, 1920x1080px
>>56176782
LOL
>>
File: 1468998276232.png (178KB, 500x500px) Image search: [Google]
1468998276232.png
178KB, 500x500px
>>56176922
>yfw the overwhelming majority of meaningful contributions to software AND hardware where by academics

>yfw modern software developers LITERALLY live in a fairy aether powered by the fevered dreams of CS PhDs
>>
>>56176955
Academics haven't contributed a single thing to hardware OR software that survived to the present day. It's always been engineers working within the demanding environment of industry who got things done.
>>
>>56176955
Shame so much had to be fixed and practically all significant contributions are being replaced for one reason or another.

Making a poor solution early doesn't make you better.
>>
>>56176904
golang has good libs for this, apparently. there are some custom programs made in go:
https://github.com/FiloSottile/whosthere
there are more examples here IIRC
https://news.ycombinator.com/item?id=10004678
>>
>>56176955
>>yfw the overwhelming majority of meaningful contributions to software AND hardware where by academics
hahaha, wtf

>>56177005
this. and phycisists, and sometimes econ people. but mostly EEs
>>
>>56177005
>>56177012

>Aristotle
>Archimedes
...
>Newton
>Descartes
...
>Church
>Turing
>Ritchie
>McCarthy
...
>>
>>56177005
>>56177012
>>56177052
>endless shelves upon shelves of papers on data structures, algorithms, processor systems, parallelisation strategies, etc, etc, etc, etc, etc
>>
>>56177074
You don't understand. He uses Python, a language untouched by the last 30 years of research.
>>
like how people think academics don't run programming

microsoft research Cambridge dudes literally put generics in C# and then later linq
>>
>>56177058
>virtually all cryptography
>everything dijkstra ever did
>99% of https://en.wikipedia.org/wiki/List_of_algorithms

Literally everything.
Academics.
>>
Guyses how do I make a client server program in C over IPv6?
>>
>>56177144
what kinda question is that
just learn into sockets fagit
>>
>>56177113
>Python
As if. I use C, because I've got a pair.
>>
>>56177058
>fevered PhD students
Also those more recent ones are infact being replaced where people care. Not for poor effort honestly. But there's so incredibly much junk that you CS retards throw at software in a non productive way. FP being one of those things. Certainly one of the smallest problems. But memory being cheap is simply a lie. Storage is cheap. Active memory isn't. If you have a problem that suits those constraints that's fine. But you generally don't.
>>56177074
>parallelisation strategies
Which solve nothing because they're effectively pseudo code software written for the software aether. Try implementing that stuff and then realise how a naive strategy which just considers the situation you're in solves the problem much better. Even if I think you're being retarded I have enough faith in you to beat that trivial standard.
>data structures, algorithms
Most of which prove to be entirely useless for anything but the most trivial cases. Go down a list of the most popular algorithms and datastructures and you find that aside from a few like a hashmap they're largely useless. And in the case of things similar to a hashmap they offer convenience aside from predictability (which can be very useful in real time platforms, super specific)
>processor systems
Don't know enough about that to comment. But with how much happens in CPU tech (if that's relevant), I kinda doubt the source is academia rather than engineers themselves.
>>
>>56177197
>I got a pair
I hope you're being sexist because there's no bragging about using C. That's all we got because you infiltrated the language development field and took over.
Disgusting anon. I thought they had you expelled for saying this kind of crap at university.
>>
>>56177212
I hate to break it to you, but

1) Academic doesn't mean FP.
2) FP doesn't mean careless about memory.
3) Data structures are not useless.
4) Algorithms are not useless.
5) Virtually everyone you call an "engineer" has a masters.
6) There are endless other examples. You couldn't begin to read every paper that has contributed significantly to programming.
7) >parallelisation strategies >aether; SIMD, AVX?
>>
>>56177212
And every comment you've made has no doubt been made by someone else about something you consider important.
>>
>>56177234
I read your post four times and there wasn't a single coherent thought I could get out of it. Maybe you should write your posts in English on an English-language imageboard.
>>
Sure is Blub paradox in here
>>
>>56177234
C was invented by a man far more intelligent than you, it wasn't a trivial invention and the developments since then weren't trivial either

You're standing on the shoulders of giants, mocking them
>>
If I had a nickel for every time someone said that a specific set of features didn't constitute OOP, I'd have quite a collection of nickels.
>>
>>56177338
and then they invented Go
>>
>>56177386
OOP doesn't actually exist.
>>
>>56177386
OOP is a chimera and a frankenstein of features stolen from everything

The only thing unique to OOP is "design everything as objects passing messages"
>>
>>56177390
Which was a colossal mistake.
>>
>>56176725
for what pvrpose?
>>
>>56177442
It's a language specifically designed for writing servers in large teams and code bases and is great for that.
>>
>>56177282
>attributes SIMD to academia
>engineers have PhDs
So? They do engineering. They apply engineering. Everyone I know regret taking a degree to some degree. With good reason. Better ways to learn, better things to learn. You get to know the wrong people. Tends to be the common complaints.
>FP is not academia
No FP is not all of academia. Its a fine example of academic ideas though.
>datastructures and algorithms are not useless
Perhaps this wasn't communicated well... They don't solve problems well at all. They're obviously not 'useless' since you can apply them. They reach a goal eventually. But that doesn't make them good. And that was my complaint.
>FP doesn't mean careless about memory
That's not my experience with functional programming languages, functional programmers and 'memory is cheap' is certainly something I hear mentioned a lot.
Makes it hard to believe these people touch computers in the real world >> I conclude they're probably academics
>many examples
Yes and we can't go through them all. But I've written software for a long time now and aside from how impressive compiler optimization can be there's very little I can feasibly attribute academia in my day to day life. Pure math people, they're a group of people I thank a lot. But CS PhD's. Not so much.
>>56177315
I did write English. Perhaps elaborate on what you didn't understand? This just looks like a petty insult from the point of view of someone who knows what he said.
>>56177293
Likely. But that doesn't make them right. And it doesn't make you less wrong.
>>56177338
I'm not mocking C at all. It was appropriate for its time. But that's a great example of a poor engineering job. We need something better now and it's not like they couldn't have thought of it. Perhaps it was never intended to last. I can forgive that.
>>
Does anyone know if there's a way with classic higher order functions to just sum a list from left to right until I hit a limit?

For example, lets say I have the list (1, 2, 3, 4, 5) and I want to sum until the sum is greater than five, it should return 1 + 2 + 3 = 6. It doesn't have to be a list, could be a stream or any other traversable collection.

I couldn't think of any reasonable way with map/reduce/filter and such. I'm just wondering what the best functional way to do it is, since the imperative way is both very simple and very efficient.
>>
>>56177504
>it was appropriate for its time
Well. I take back this immediately. I don't know if it was. But that's the excuse I can give it.
>>
>>56177548
>trivial problem
>has to ask /dpt/
Here's your answer: They have no answers that are better than simply writing a trivial implementation yourself.
>>
My current obsession is to get bluetooth headset working without pulseaudio and of course with the bluez5. Since such a feature has been dropped from the current bluez I'm making a rebirth of this functionality as a standalone application. Here is the code: https://github.com/Arkq/bluez-alsa

What do you think about this? Any suggestions, notes? Is it worth spending some more time on it?

I'm just spreading a word, maybe someone will find it useful.
>>
>>56177504
>>engineers have PhDs
>So? They do engineering.
no reply needed

>attributes SIMD to academia
>Single instruction, multiple data (SIMD), is a class of parallel computers in Flynn's taxonomy
I guarantee that the overwhelming majority of developments made by engineers are the product of some form of research, or of spontaneous ideas by people who've been well educated

>That's not my experience with functional programming languages, functional programmers and 'memory is cheap' is certainly something I hear mentioned a lot.
>Makes it hard to believe these people touch computers in the real world >> I conclude they're probably academics
Have you considered that _maybe_ they aren't doing the same tasks as you? Maybe the things you do aren't the entirety of the real world"?
Also you're saying you don't like academics because if you see something you don't like you blame academics

>it was appropriate for its time
>poor engineering job
pick one
>>
>>56177585
I'd welcome Bluetooth sans Poetteringware.
>>
>>56177581
I don't think you read my question. I can trivially implement a solution with imperative constructs, or an equivalent recursively defined function.

My question is: am I simply overlooking an abstraction for this? Why is something like reduceUntilCondition not a commonly used higher order function?
>>
>>56177504
>>56177609

Oh, and there's no reason you couldn't construct a functional language that strongly restricts memory usage, boxing (if it has any), etc.

There are millions of optimisations and methods employed by engineers that have their bases in academics.
>>
>>56177668
Because it's just not that commonly needed? It's not rocket science anon
>>
>>56177668
last . takeWhile (<n) . scanl (+) 0
>>
>>56177746
This is what I was looking for.
>>56177711
Don't accept leaky abstraction.
>>
>>56177817
be careful if you're not using a lazy language
>>
I wrote some AIs for turn-based games before but never one for a game with double blind simultaneous resolution. How do you even approach something like that?
>>
>>56177824
strictfags BTFO
>>
>>56177817
>>56177824
because in haskell, because it's lazy

>last will forcibly evaluate an entire list to evaluate in order to get the last element
>takeWhile will only evaluate elements up until it gets a False
>scanl will lazily evaluate over an entire list producing a new list

hence you end up with:
takeWhile will call scanl to get a new element from the (potentially infinite) list, "last" will evaluate it until it terminates (when takeWhile gets a False)

so obviously it won't work with infinite lists in a strict language, but the issue is that in a strict language it's inefficient if it's not recognised and optimised
>>
>>56177867
"""infinite"""
>>
>>56177867
basically in a strict language, scanl will go over the entire list
>>
>>56177882
obviously limited by memory, storage and registers

obviously limited by memory, storage and registers is what I was going to say but then I realised you could be operating on infinite input, e.g. reading data from the environment & producing an output continually
>>
File: MVI_0291.webm (3MB, 1280x720px) Image search: [Google]
MVI_0291.webm
3MB, 1280x720px
lewk
>>
>>56177926
Hva er det? Kan du gi meg en forklaring?
>>
>>56177991
yes, poo in the loo.
>>
>>56178002
xD
>>
>>56178002
Jeg har allerede gjort det i dag. Nå foler jeg meg tom.
>>
So what's the best way to find all the position of all occurrences of a string in a longer text in Python?

mystring_pos = [match.start() for match in re.finditer(mystring, mytext)]


This seems to work quite well, but is there a better approach?
>>
>>56178198
Use norsk# instead of Python.
>>
>>56178237
Never heard of it.

And I'm working on an existing code base.
>>
>>56178253
It's really easy to port programs to it, and it runs on .NET so it has great performance.
>>
>>56177991
Das ist ein RGB-LED-Streifen, welchen ich über ein Arduino nano ansteure.
Da der mehr als 5V benötigt nutze ich ein motor controller der für 12v funktioniert und ich so auch den µC versorgen kann damit
>>
OOP IN LOO
>>
>>56178343
xDDDDDDDDDDDD
>>
>>56178320
kys
>>
File: tlj.jpg (58KB, 594x439px) Image search: [Google]
tlj.jpg
58KB, 594x439px
>>56178320
>it runs on .NET so it has great performance
>>
>>56178198
There's
re.findall()
>>
>>56178359
That returns matches, not their positions so I would just get a list of my string repeated several times.
>>
How do I diff a changed file in the staging area on my local master branch against the same file on the remote origin/master branch?
>>
Vilket språk är bäst för att programmera Rpi med? Jag har köpt en touchscreen och vill göra en interaktiv 'app' där man kan lägga upp 'jobb' som sedan kan checkas av när de är klara.
Tänker mig att jag lär behöva 5+, så de skulle nog behöva en slags server som tar emot 'jobb' och skickar ut dem till alla enheter.

Skall jag skriva programmen i C eller Python? Vilket lämpar sig bäst tror ni?
>>
>>56178381
Just make it a set() afterwards to remove dupes :P
>>
>>56178389
Never mind, I got it it's
 git diff --staged filename
>>
File: omg.jpg (48KB, 848x480px) Image search: [Google]
omg.jpg
48KB, 848x480px
Friendly reminder to practice everyday or else you lose your powers!

Even if it's something dumb like a hex converter.
>>
>>56178449
>hex converter
completely redundant in the modern era
>>
>>56178403
Norsk#
>>
File: 1468276272685.jpg (341KB, 1200x2000px) Image search: [Google]
1468276272685.jpg
341KB, 1200x2000px
I am calling glViewPort on every window resize event, attempting to keep change the viewport accordingly but without stretching anything on screen.
Currently there is stretching.
How do I stop the stretching?

How do people typically make things in a scene smaller without fucking with the aspect ratio?
>>
File: 2016-08-20-183507_64x97_scrot.png (484B, 64x97px) Image search: [Google]
2016-08-20-183507_64x97_scrot.png
484B, 64x97px
>>56178449
Post last 5 weeks
>>
>>56178489
Mine is all white.
I haven't written anything substantial in a month because I have no ideas.
>>
>>56178489
>github

>>56178486
If the height:width changes you have to change the aspect ratio, that's what it is
>>
>make a simple python script
>add test coverage >90% using py.test
>add tox to test all python versions and support everything from 2.7 up, jython and pypy
>add continuous integration using travis
>add changelog
>keep semantic versioning
>github tags + releases
>git flow version control workflow
>full documentation and API hosted on readthedocs and generated by sphinx
>flake and pylint for code quality

>0 stars
>1 contributor

i don't even care
>>
>>56178599
forgot > pip packaging but that's a given
>>
File: 83421.png (14KB, 203x248px) Image search: [Google]
83421.png
14KB, 203x248px
>>56178599
>>make a simple python script
>>
>>56178599
If you're looking for stars, look on the sky or watch a movie.
>>
>>56178449
I just run hexadecimal numbers through AWK to get the decimal representation.
>>
>>56178514
No, you don't, that is, if you keep the difference between width and height a constant value then the aspect ratio never changes.
Now, is there a way to do this using glViewPort, or perhaps something else I should use such as glTranslate etc?
>>
>>56178669
cheating

>>56178656
you called?
>>
>>56177386
>a collection of nickels

Don't talk about collections here. Just pass the Iterator.
>>
>>56177386
>>56178687
Is an empty collection still a collection?
>>
>>56178599
Can you give the link anon? I'm curious
>>
>>56178687
>iterators

A shit.
>>
>>56178772
this

prefer comonads
>>
>>56178821

Is there anything you cannot do with comonads? I think not.
>>
>>56176395
What?
>>
>>56178821
I'm more an arrows person myself, I prefer not to get bogged down in implementation details
>>
>>56178746
I'm curious too, how a ~simple~ script can have an API and not yet a 100% coverage. It's like waxing a fender of your car but not touching the hood.
>>
>>56178697
is nothing still a thing?
>>
>>56178836
the nice thing about comonads is that you can duplicate/cojoin and extract/coreturn, so you can both add and remove structure / decorate and peel

>>56178866
if you start from nothing you can make anything, that's why nothing is not allowed

>>56178849
arrows are the shitty brother of applicatives
>>
>>56178879
Don't talk to me or my wife's arrow ever again
>>
File: vs.png (29KB, 527x501px) Image search: [Google]
vs.png
29KB, 527x501px
>trying to add something to my PATH
>continuously get "Error: This path variable is too large!"
>open up environment variables
>see this

Am I just fucked? Did Visual Studio fuck me?
>>
>>56178879
if anything can be made from nothing then there are only nothing
>>
>>56178932
absurd :: ⊥ -> forall a. a
>>
Started to do more server stuff. Thinking to migrate from DO to AWS or Linode.
plus, right now, learning some py scripting. Want to do some easy automation, like creating mysql dumps after a day and send them to a different computer.
>>
>>56178921
VS isn't on my path at all
>>
what keyboards do you fags use?

i've been using a microsoft reclusa for like 7-8 years but i'm thinking of switching to pic related

do you prefer backlights or no backlights? do you think black keyboards without backlights are fine to use in the dark?
>>
>>56178989
Why do you need lights? It's a keyboard
>>
>>56178978
AWS is overpriced, go with Digital Ocean if you're looking for a VPS, or OVH if you're looking for a dedicated server.
>>
>>56178921
>uses Haskell
>thinks it is VS that fucked him
>>
>>56179022
>thinks anything that can be typed on a keyboard must be meaningful or funny
>>
>>56179010
>not azure
you fags probably don't even do deep learning enjoy being left behind in the wake of automation
>>
File: Kinesis-Freestyle2-for-PC-91.jpg (26KB, 510x344px) Image search: [Google]
Kinesis-Freestyle2-for-PC-91.jpg
26KB, 510x344px
>>56178989
Kinesis Freestyle 2
>>
>>56179005
if you have RGB lights you can set it to a certain pattern which acts as a visual guide to help you place your hands on it and hit the right keys. even if you don't look at it directly you can still see it subconsciously in your peripheral vision. you can get a similar effect without lights by getting different colored keycaps but i'd be using this with standard black keycaps only
>>
>>56179062
why not just learn where the keys are
>>
>>56178989
Logitech K120. Simple, durable keyboard with no frills. Comes in a kit with a nice basic optical mouse for $20. I used to carry around a case of them in the truck to replace nasty keyboards at client sites.
>>
>>56178989 >>56179005 >>56179047
>>56179049 >>56179074
this isn't the thread for keyboard masturbation
it probably has its own thread on /g/, go there
>>
>>56179105
why te fuck did you quote me noob
>>
>>56179105
those fags aren't programmers
>>
>>56176904
From a quick google I found http://www.jcraft.com/jsch/
>>
Jesus christ, is 64 bit MinGW still a total clusterfuck? I'm trying to get Clang set up and it's absolutely retarded.
>>
>>56179355
>no documentation
>shit API
>not using NIO
it's fucking trash
>>
File: ash.jpg (420KB, 851x1223px) Image search: [Google]
ash.jpg
420KB, 851x1223px
>mfw I just made a commit replacing two somewhat readable regular expressions with a single completely incomprehensible one because it gave a 30% improvement in speed

I don't envy whoever gets to maintain this.

I hope it isn't me.
>>
>>56178989
PPOO IN LLOO
>>
>>56179421
fucktard search for NUWEN in google or whatever retarded shit you use.
>>
>>56178599
>doing all this shit for a simple python script
I don't believe you
>>
anyone here know shit about compiling c++11 stuff for mac.

When my code runs in someone else's machine it either works completely fine or seems to crash with the callstack looking like

(anonymous namespace)::SignalHandler(int, __siginfo*, void*)
_sigtramp
std::basic_string<unsigned short, std::char_traits<unsigned short>, dvacore::utility::SmallBlockAllocator::STLAllocator<unsigned short> >::_Rep::_S_empty_rep_storage


i figure its _Rep::_S_empty_rep_storage not linking properly or some libc++ errors but I can't find shit on this and there seems to be no way to link libc++ statically.
>>
File: 1262976827548.jpg (35KB, 605x474px) Image search: [Google]
1262976827548.jpg
35KB, 605x474px
>>56179488
>he prematurely optimizes
>whores_giggling.mpeg
>>
>>56179585
>prematurely
The code has been running our service back-end for more than a year now.

I'm just fixing a bit which was made by someone else in a very rushed way (there was a deadline to meet) because it's been causing some lag even though it has no business to. I couldn't be arsed to rewrite it, I have my own work to do.

Why am I doing it on a weekend I couldn't say.
>>
>>56179421
Install Gentoo (or some kind of Linux in a VM)
>>
>>56179585
good luck optimizing when your code base is several millions of LOC
>>
File: j.gif (844KB, 800x786px) Image search: [Google]
j.gif
844KB, 800x786px
>/g/ can't even invert a binary tree in C
>>
>>56179488
post it
>>
>>56179656
>committing shit on a weekend
have fun when they start demanding free overtime from you
>>
>>56179656
>>56179488
Why don't you leave the original expressions in a comment?
>>
>>56179687
#include "my_binary_tree.h"

int main(int argc, char *argv[])
{
bin_tree *tree = make_tree();
invert_tree(tree);
return 0;
}
>>
>>56179540
pls respond
>>
>>56179531
I do all of this for all my projects and I shipped over 20 python project, but most of them are closed source cause I did them for my job. So I keep the same workflow for my open source ones even though it may be overkill and unnecessary
>>
>>56179717
#include "dont_call_us_we_ll_call_you.h"
>>
>>56179696

>>56179694
Proprietary code, sorry.

>>56179702
They're already in the commit history anyway. I've added a comment saying "I'll admit readability suffers slightly... "

Also basically what the two regular expressions did was looking for the start and end of a somewhat complex pattern, then extracting the text in between and doing some further checks inside the program to verify if it is the pattern of not. Gnarly stuff.

I sat down and made a "proper" regex for the pattern it was supposed to look for but it looks horrible in itself. I wrote it 20 minutes ago and I'm already baffled looking at it again.
>>
>>56179771
Awesome, look forward to working with you!
>>
>>56179781
>Proprietary code, sorry.
Lol
>>
Fuck /dpt/

I dream of a codebase where declared architectural standards are strictly adhered to, everything is well-documented, pull requests are thoroughly reviewed and every single change is commented on, with an issue tracker key in every commit and relevant comment, and of course >95% unit and integration test coverage.

an easily readable, perfectly maintainable, clean and fast codebase, despite having millions of LOC
does such a thing even exist, /dpt/?
>>
>>56179818
The Linux kernel is well documented, high quality code, and obviously very maintainable.
>>
>>56179739
>though it may be overkill and unnecessary
yeah

unless you're making a large-scale framework or library, don't do this
>>
>>56179818
Perfect is the enemy of good.
>>
>>56179846
if i don't aim high i'll never get better
>>
>>56179838
I only write scalable code :^)
>>
>>56179901
If you aim for perfection you'll never get anything done.
>>
>>56179818

No.
>>
>>56179818
>unit testing
web shitter detected
>>
>>56179818
>>56179901
Imperfect software which gets released beats perfect software which never does 10 out of 10 times.
>>
>>56179837
wow, you weren't kidding
good stuff

>>56179918
perfection in code is pretty easy to achieve compared to basically anything else in life
there's only so much you can do
>>
>>56179924
thanks mr net
>>
>>56179934
>thinks unit testing is only used in front end monkeying
unemployed double digit IQ retard detected
>>
Is F* the new Idris? Its multimonadic effects and the Dijkstra-monadic semilattice are really cool features.
>>
>>56179955
>perfection in code is pretty easy to achieve
Evidently not.

Source: real life
>>
>>56179818
>95% unit and integration test coverage
Why not 100% formally verified instead?
>>
>>56180014
muh theorems
>>
Anyone else see the announcement that Microsoft has open-sourced Powershell and released an alph a version for *nix?
>>
>>56180019
much SMT
>>
>>56180014

This is why we need to push functional programming. The program itself is the proof!
>>
>>56180046
Not always.
>>
>>56180046
does not help against bugs
>>
>>56180100

That's the fault of unsafe imperative holdovers, though. We need purely functional languages. Emphasis on "pure".
>>
>>56180102
It completely eliminates implementation bugs.
>>
does anybody know of an x86 emulator useful for learning assembly without fucking your computer over?
>>
>>56180171
qemu? What's your computer architecture?
>>
>>56180198
x65
>>
>>56179488
this: >>56179702
if the code is hard to read just leave an explanation or a more readable version of the code in the comments
>>
>>56179739
>I shipped over 20 python project
If your project isn't a standalone application or a fully fledged library which offers features no other library does.

Don't add another god damned choice.
>>
>>56176670
you missed like half of that quote
>>
>>56180280
99% of the time optimization is a huge waste of expensive programmer man-hours
>>
>>56180306
tappaa itsesi
>>
>>56180118
Who are you and what have you done with SharpShill?
>>
ReQL is pretty powerful, once you get the hang of it. This will make the database search for posts that have been open for more than 30 minutes, automatically close them and commit to the replication log, that subscribed clients are listening to. All done atomically, in one query and distributed efficiently over the cluster.
r
.db("meguca")
.table("threads")
.update(thread =>
thread("posts")
.values()
.filter(post =>
post("editing")
.and(
post("time")
.lt(
r.now()
.toEpochTime()
.sub(1800))))
.map(post =>
post
("id")
.coerceTo("string"))
.do(ids =>
ids
.count()
.eq(0)
.branch({}, {
log:
thread("log")
.append(
ids
.map(id =>
r.expr("06")
.add(id)
.coerceTo("binary"))
.reduce((a, b) =>
a.append(b))),
posts:
ids
.map(id =>
[id, {editing: false}])
.coerceTo("object")
})))
>>
>>56180323

I'm still me, I'm just half-baiting & half-telling-the-truth-unintentionally.
>>
>>56180343
absolutely unreadable

could make a simple PL/SQL script for that
>>
>>56180343
that's disgusting
>>
File: 1409341824328.gif (1MB, 335x293px) Image search: [Google]
1409341824328.gif
1MB, 335x293px
>>56179540
pls respond
>>
>>56180449
how about you google the error?
>>
>>56180321
Back to the sauna Pekka, nobody gets your language.
>>
>>56179540
How can people even ead error messages like that.
Is there no line or whatever?
>>
Has anyone ever used a compiled language as a scripting language for sys admin tasks considering languages like Swift, Haskell, Ocaml, etc are interpreted?
>>
>>56180695
Yes.
You can compile any language. Python the only one I've done so with but generally you don't need to so why bother with it.
>>
>>56178403
>>>/diy/ohm

>>56180306
absolut äckligt
>>
>>56180198

It doesn't really matter I just want to learn assembly. maybe something with a debugger or register viewer
>>
>>56179818
Its time to dump the "GNU operating system" (which are just copies of unix utlities) and redesign all the file handling utlities from scratch using a safe language like Go. Go is very C-like in its simplicity but eliminates all the buffer overflow and pointer problems of C. The libc standard itself has to be eliminated as that is the main wrapper to OS sys calls and so forces the C standard onto the rest of the user base apps.
>>
>>56180790
good luck
>>
>>56180716
Python gets transpiled to C with Cython, that doesnt count
>>
>>56180731
Man använder inte C utan anledning. Det är bara dumt.
>>
>>56180833
There's other software that compiles it directly
http://nuitka.net/pages/overview.html
>>
>>56180835
pyton är äckelpäckel
>>
>>56180867
Du är ett äckel din tönt.
>>
>>56180833
>>56180863
Nevermind, I didn't read closely. It looks like this goes through C++
>>
>>56180406
But will that script run atomically?
>>
>>56180819
I bet it'd be very easy...
>>
>>56180833
>transpiled
>doesn't count
How so? That seems like a pointless and retarded limitation to place on yourself.
>>
>>56181050
go for it
i have high hopes
>>
>>56181198
Having used languages like Clojure it becomes a pain in the ass to debug as you end up having to look at the real code and then match it up to whatever the original code was
>>
>>56180790
https://golang.org/doc/faq#garbage_collection
While that would be nice, Go is a garbage collected language which would prevent an operating system to run properly in real time. If you opt to do manual memory management in Go you have just defeated the purpose of using it rather than C in this case. While writing interfaces to the OS in Go could be a good thing, using it for the actual OS would not be.
>>
>>56180539
there are no relevant results

>>56180686
its just a callstack and ::_Rep::_S_empty_rep_storage is the static "blank string" which I dont understand how the error is happening there. As if it was writing to the blank string there or something which it isn't.
>>
File: fuckery.png (70KB, 1410x638px) Image search: [Google]
fuckery.png
70KB, 1410x638px
Anyone here have experience with OpenGL?

I am trying to go through learnopengl.com's coordinate tutorial but i am running into an odd issue that is bugging me.

Picture related, left is expected, right is what i'm getting.

I've tried using the entire source code for the halfway point in the tutorial and it is still occurring (http://learnopengl.com/code_viewer.php?code=getting-started/coordinate_systems)

Gist:

https://gist.github.com/anonymous/5c091f1172a23497c308a94f7761c210

Greatly appreciated if someone does take a look.
>>
File: 1469467715207.png (217KB, 502x442px) Image search: [Google]
1469467715207.png
217KB, 502x442px
>tfw your completely retarded hack works perfectly
>>
>>56181321
my guess is that google is already doing it, if they didn't yet (they released some new OS recently)
also, if *I* had to do it, I'd license it GPL3 ;^)
>>
>>56176922
>software does not run in a magic fairy aether powered by the fevered dreams of CS PhDs

>and the butthurt attempts at counter example
>data structures, algorithms, strategies, generics, linq, cryptography
>list of academics who weren't CS PhDs

Protip: Software runs on a chunk of silicon with impurities added so that it processes analog signals in a way that approximates a finite state machine.

If your abstraction or paradigm doesn't translate well to machine code that piece of silicon can run well it's not going to be worth a damn. Since it is a finite state machine and assembly tells it to change state in an imperative manner with built in support for functions your shit better translate well to the imperative functional paradigm where your only abstractions are types that silicon can handle natively.

So with all your syntactic sugar you still can't forget about functional imperative. Whether you're using functional, declarative, OOP, or any type of data structure, you can either forget about the fact you're using a functional imperative language or you can write good software.
>>
With GWT's validation systm, how the hell does it achieve realtime correction in frontent?
Are the annotations in the models literally translated into javascript for the client or what the heck?
>>
>>56181635
https://github.com/cmahon/learn-opengl/tree/master/texture-combined
>>
So I'm a self-taught cpp twat, and I'm trying to code something, anything but even when trying to program something as simple as console-based tetris from scratch I hit a giant wall.
See, I consider myself reasonably (for someone whose all knowledge of programming comes from reading absolute cpp by Walter savitch and playing colobot as a kid) competent in knowing cpp as a language, but the moment I'm considering a project spanning more than one cpp file, I don't know even where to start. Do I start by writing a "here's a matrix of points that will be used to store what blocks have already fallen", or "this is a class that handles a single Falling block", or do I start writing the main file first, like int main() {get input, update the board, render, repeat}
I just have no clue.

Tl;dr I know one programming language but I have no clue on how to actually program anything beyond a simple algorithm. What books should I read?
>>
>>56181777
Look at code for how other people did it in that language. It sounds to me like you don't really understand how to plan and use objects.
>>
>>56181672
This is entirely a myth brought about by old self taught programmers who are too stupid to realize that the code they write in any high level language never touches registers. The compiler completely optimises any code you write out of order to match the machine language of whatever platform its compiled too. The operating system will have its own way of handling data in the file format of the binary that you have no control over. And the CPU itself does multibranching pre-fetching of code and can execute code out of order to match its branch predictions. We need to ignore the C fizzbuzzers on here who still think their languages is 'high level assembly' that can some how be hand optimized with pointers, its not, C compiler optimize code just the same as they would a functional language.
>>
>>56181654
me 24/7
>>
I'm trying to learn javascript and am getting kind of bored just working through my book and doing exercises and examples and stuff.

What's a good simple web programming project for just jumping in with?
>>
Why does everyone here use Python?
>>
>>56182022
kys
>>
>>56182395
they're summerfags who should fuck off to reddit
>>
>>56182395
It's actually a good language for many tasks despite being a garbage language.
>>
File: Wgt2Gcn.gif (2MB, 500x282px) Image search: [Google]
Wgt2Gcn.gif
2MB, 500x282px
>>56179540
help
>>
>>56182022
This. Micro-optimizations should be left to the compiler. In fact, high-level languages with strong type systems are much easier for the compiler to micro-optimize.

Worthwhile optimizations are things like laying out memory so that accesses are good on the cache, organizing code to reduce branch mispredictions, etc. Plenty of high-level languages give you opportunities.
>>
>>56179702
>>56180239
It's people like you that truly suck.

Now there's two things to maintain, and comprehend.

// Actually means /[^kjsh]/\.*/ and then /...*\\\\\//
/?[{+=4\/\/\/\/?abfhbkjdhkl<![CDATA*(*&(879/

Good luck with that.
>>
>>56182395
Easy to make small programms fast.

E.g. i need to make a programm to format and analyze a few gbs of measurement data. I will never use it again after it did its job and building something onto it later makes no sense as the task are extremly specific so there is no reason to do a "clean" and good job with C++ or any other language.
>>
Why are regular expressions written like they are? Why aren't they written as a structured, readable DSL or constructed directly as an AST?
>>
>>56182545
>small programms
>I will never use it again after it did its job and building something onto it later makes no sense as the task are extremly specific
Scripts. Python is a scripting language. The problem is when people use it for actual programming.
>>
>>56182657
>The problem is when people use it for actual programming.
Why is it a problem?
>>
>>56182521
Do you guys parse XML with regex at work? lol
>>
>>56182591
Convention ? RE's kind of became ... well, standard is stretching the truth a little, let's say pervasive.

But, hey, one CAN write it as an AST.

not(e) => "[^" + e + "]"
any() => "."
atleastzeroof(e) => e + "*"
atleastoneof(e) => e + "+"

Not sure it would improve readability tho :)
>>
>>56182698
Don't joke about such things, people actually implement their own XML parsers and I have had to work with these fucktards.
>>
>>56182683
You said it yourself. Scripts don't have to be maintained. Python isn't good for writing code that needs to be maintained, or code that needs to be run many more times than it is written.
>>
>>56182727
>Python isn't good for writing code that needs to be maintained, or code that needs to be run many more times than it is written.
Why not? It's a general purpose programming language.
>>
>>56182807
General-purpose is in contrast to domain-specific. You can have a general-purpose scripting language. Why is it bad for writing actual programs? It's interpreted and dynamically typed (despite still using classes instead of at least prototypes).
>>
>>56182847
What do you consider a good programming language for writing "actual" programs, then? And how do you define "actual" programs?
>>
>>56182521
who even uses regex anyway it's just a """"comfy"""" quick tool for scripts not actual programs
>>
File: hachikuji.png (507KB, 3840x2160px) Image search: [Google]
hachikuji.png
507KB, 3840x2160px
>inherit project at new job
>open a source file
>try catch... try catch everywhere

what do?
>>
>>56182876
>What do you consider a good programming language for writing "actual" programs, then?
For starters, a language where types are checked at compile time.

>And how do you define "actual" programs?
Something that isn't single-use like a script.

>>56182891
Unfortunately, a lot of people.
>>
File: 1467471051704.gif (177KB, 180x218px) Image search: [Google]
1467471051704.gif
177KB, 180x218px
>>56182891
>actual programs
>>
File: 1409192122292.png (198KB, 500x504px) Image search: [Google]
1409192122292.png
198KB, 500x504px
>>56182912
>handling exceptions
>smug anime face
>>
>>56182914
>For starters, a language where types are checked at compile time.
Assembly language doesn't check types yet there have been many hugely successful programs written in Assembly.
Try again.
>>
Is it just me or is Ponylang a meme with source that looks like keyword salad?
>>
>>56182949
There have been successful programs written in Python. That doesn't make it good for programming.
>>
>>56182912
>open php file
> starts with >300 line of sql query and it includes tons of other php files with really bad naming
>no functions, everything is top level
>>
>>56182960
You still have to define "actual program".
>>
>>56182912
>inherit project at new job
You don't need to say any more
>>
>>56182973
Try reading.
>>
>>56182985
Except your definition was invalid because there are things out there that have been written in Python that are not just "single-use scripts".
>>
>>56182971
That was my job for 3 years: maintaining a large spaghetti code PHP site that had grown over 10 years. The horror fades quickly and you just keep the ball of band-aids running.
>>
>>56183007
>There have been successful programs written in Python.
>>
>>56182914
Why is static typing somehow better than dynamic typing?
>>
File: 1466508721978.png (102KB, 269x287px) Image search: [Google]
1466508721978.png
102KB, 269x287px
>>56182912
>inherit large Haskell project
>beautiful, strong types everywhere
>pure code clearly separated from effectful computations using monads
>maintenance is a breeze
>>
>>56183028
Because it's easier. Actual programming language is code for "easy enough for me" :^)
>>
File: 1453663443104.jpg (1MB, 1920x1080px) Image search: [Google]
1453663443104.jpg
1MB, 1920x1080px
>>56182971
>300 line of sql query
>>
>>56183028
You don't have to run the (obviously) incorrect code to find out that it's incorrect.
>>
>>56181635
>opengl
>windows
>>
>>56183059
So don't write incorrect code.
>>
>>56183014
Flask? Django? Powerline? YouTube?
>>
>>56183059
Sounds to me like you just suck at programming and are too lazy to debug your code.
>>
>>56183086
I mean ACTUAL programs like FizzBuzz in C#
>>
>>56183085
>>56183087
If you're so good at programming, why would you use Python and not assembly?

>>56183086
I'm quoting myself. The fact that there are successful programs written in Python does not make Python a good language for writing programs. It makes it just capable.
>>
>>56180790

>what is rust?
>>
>>56183105
>good language for writing programs
So far the only criterion we have is:

* Statically typed because writing correct code is hard otherwise.

Not very convincing.
>>
>>56183105
Who the fuck uses assembly in 2016? Why would you even need to use assembly in 2016? Why are you even using assembly as a metric of programming ability when talking about high level scripting languages?
>>
>>56183118
a systems language, not a userspace language
>>
>>56183105
what a fucking idiot
>>
>>56183166
>implying there is no strongly typed assembly language
>>
>>56182912
>inherit Java project in its early stages
>very little code written
>it's already beyond redemption
fuck just fuck

and I can't even make any big changes because existing functionality would be broken
>>
>>56183145
It is hard (read: time consuming) if you're writing a large program, especially when you're working with other people.

>>56183166
Because with assembly, a perfect programmer can write perfectly efficient code.
>>
>>56183166
Drivers, compilers, VM's, hardware emulators, os kernels. all of that unimportant stuff
>>
>>56183219
>Drivers
Mostly C. The majority of Linux drivers don't have a single line of Assembly code.
>OS kernels
Mostly C
>>
>>56183238
Obviously. They still will use/require assembly.
>>
>>56183216
Unless you're an autistic savant, a compiler will almost certainly output more efficient code than you could write in assembly. Try again.

>>56183197
Who cares, if you're getting that close to the metal you should be using C

>>56183219
Most of this is currently written in C
>>
>>56183219
lol
>>
>>56183257
They will still use assembly.I didn't write "they are only written in assembly" ;)
>>
>>56183257
Unless you're an autistic savant, you will almost certainly make mistakes while programming anything non-trivial. I'd rather the compiler tell me right away than have them turn up months later when a user finds a corner case.
>>
>>56183257
>compiler will almost certainly output more efficient code than you could write in assembly
Unless you're autistic, you'll understand what he meant by 'perfect programmer'.
>>
>>56183287
>implying compilers catch all errors
You really havn't written anything nontrivial, have you?
>>
>>56183327
Have you ever heard of Coq, Agda, Idris, ATS, etc.?
>>
File: Unbenannt.jpg (83KB, 694x571px) Image search: [Google]
Unbenannt.jpg
83KB, 694x571px
Combining imdb and kinox.to

// ==UserScript==
// @name imdb - kinox link
// @namespace write_something_here
// @include http://www.imdb.com/title/*
// @version 1
// @grant none
// ==/UserScript==

var movieId = document.querySelector("meta[property='pageId']").getAttribute('content');

var kinox = document.createElement("div");

kinox.setAttribute('title', 'Kinox');
kinox.setAttribute('class', 'watch-option secondary-watch-option has-watchoptions');
kinox.setAttribute('data-href', '');
kinox.setAttribute('data-optiontype', 'instant');
kinox.setAttribute('onClick', "javascript:window.open('http://kinox.to/Search.html?q="+movieId+"', '_blank')");

kinox.innerHTML =`
<div class="watch-icon instant"></div>
<div class="secondary-info">KINOX</div>
`;

document.querySelector('.showtime.full-table').appendChild(kinox);
>>
File: Kr2W6BF.gif (462KB, 254x238px) Image search: [Google]
Kr2W6BF.gif
462KB, 254x238px
>>56179540
>>
>>56183327
>>56183344
Also, catching most errors or even just some errors is infinitely better than catching NO errors.
>>
>>56183388
You can catch errors by reading the code.
>>
>>56183403
Why look for an error yourself if the computer can find it?
>>
>>56183377
nice
>>
New thread: >>56183463
>>
>>56183422
That just leads to sloppy, unreflected programming.
You should understand the existing code fully before you add anything new.
>>
>>56183471
i hate you
>>
>>56183476
Yes, and the type checker won't let you compile until you understand the types enough to satisfy it. And with a strong enough system, types are all you need.
>>
File: capture(1).png (284KB, 1013x347px) Image search: [Google]
capture(1).png
284KB, 1013x347px
>>56183377

And for themoviedb.org

http://pastebin.com/pQPE54wE

It looks messy, but it works.

They changed something on the website recently, so you have to right click and open in new tab, for it to work.
>>
>>56180626
>nobody gets your language

The projection is hard with this one.
>>
>>56183909
perkele
>>
>>56182022
>high level language never touches registers
Sorry but almost nothing gets done without touching a register.

>The compiler completely optimises any code you write out of order to match the machine language of whatever platform its compiled too.

Do you have an alogorithm for deterining if compiled code is "completely optimized"? I haven't seen one. Optimized doesn't even mean the same thing every time.

>This is entirely a myth brought about by old self taught programmers
Programs run on silicon approximations of finite state machines is a myth. Good to know. I'll never buy another computer with logic gates again.

Every abstraction comes at a cost. Using pointer arithmetic to look up an element in an array comes at a cost. C comes at a cost. C++ comes at a cost. Bytecode C# and Java comes at a cost. Interpretted comes at a cost. Garbage collection comes at a cost.

If you're not considering how your abstraction or paradigm is translated in to a functional imperative language it is much harder to make an analysis of that cost.
>>
>>56184086
hey man do you have a quick reference book or good video set for understanding registers? I am trying to migrate from python to C++ and would like to understand the Windows/regular OS.

Anyone have a free compiler that is not copyleft that they can recommend? Everything I see seems to be copyleft or copyright and requires pay.[C++]
>>
>>56185648
self facepalm of shame.

I just read the second paragraph of the GPL and a couple of other sources to confirm commercial use of the GPL.

In short, if I write code I want to be able to re-use a 'utility' library if I write it and spent the time on it. Cool. Feeling a lot less cornered now.
>contribute:
>>56183105
Python is good for certain things and has a good practice of centralizing libraries to the mainstream for re-use and contribution. Something other languages could learn from for sure.
Use the right tool for the job, given resources and deadlines. I speak from experience.
Thread posts: 315
Thread images: 29


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.