In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you which Python and JavaScript 2020 you think will go further, concise and easy to understand, and will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.
Python and JavaScript are currently the two most popular programming languages, but which programming language will take its place in 2020?
The following is the translation:
Python and JavaScript are the two most popular programming languages at present. However, they cannot stand forever. In the end, it will fall off the altar like other programming languages. This is likely to happen in the next decade or so.
So what programming language will take its place? Here is my list of candidates!
Dart
Thanks to the approval of the Flutter framework and Google, the language quickly became popular. This is very similar to why the Rails framework makes Ruby popular. If Google's Fuchsia system becomes popular, Dart will benefit the most.
Core advantage: it is a better programming language than JavaScript.
Main disadvantage: having to face the challenge of strong supporters of the JavaScript language and JavaScript.
Mandelbrot set sample:
Class Complex {double _ r quotient; Complex (this._r,this._i); double get r = > _ r; double get i = > _ i; String toString () = > "($rgrappeni)"; Complex operator + (Complex other) = > new Complex (rhombic other.rrecodei); Complex operator * (Complex other) = > new Complex (rhombother. } void main () {double start_x=-1.5; double start_y=-1.0; double step_x=0.03; double step_y=0.1; for (int yearly 0) Y im = minIm + stepY * y Enum.map (0..xsize, fn x-> re = minRe + stepX * x 62-loop (0, re, im, re, im, re*re+im*im) end) | > IO.puts end) end defp loop (n, _) when n > = 30, do: n defp loop (n, _ v) when v > 4.0 Do: do 1 defp loop (n, re, im, zr, zi, _) do a = zr* zr b = zi * zi loop (re 1, re, im, a-b+re, 2*zr*zi+im, aqb) endend Mandelbrot.setGolang
Golang, another Google-supported programming language, has come to the fore thanks to its lightning-fast compilation speed, simplicity and efficient concurrency support. The only thing missing is generic support, but this feature is already planned.
Core advantages: easy to use, excellent support for concurrency.
Main disadvantage: lack of generic support (temporary).
Mandelbrot set sample:
Package main import ("fmt", "image", "image/color", "image/draw", "image/png", "math/cmplx"os") const (maxEsc = 100 rMin =-2. RMax = .5 伊明 =-1. IMax = 1. Width = 750red = 230green = 235blue = 25525) func mandelbrot (a complex128) float64 {I: = 0 for z: = a; cmplx.Abs (z)
< 2 && i < maxEsc; i++ { z = z*z + a } return float64(maxEsc-i) / maxEsc} func main() { scale := width / (rMax - rMin) height := int(scale * (iMax - iMin)) bounds := image.Rect(0, 0, width, height) b := image.NewNRGBA(bounds) draw.Draw(b, bounds, image.NewUniform(color.Black), image.ZP, draw.Src) for x := 0; x < width; x++ { for y := 0; y < height; y++ { fEsc := mandelbrot(complex( float64(x)/scale+rMin, float64(y)/scale+iMin)) b.Set(x, y, color.NRGBA{uint8(red * fEsc), uint8(green * fEsc), uint8(blue * fEsc), 255}) } } f, err := os.Create("mandelbrot.png") if err != nil { fmt.Println(err) return } if err = png.Encode(f, b); err != nil { fmt.Println(err) } if err = f.Close(); err != nil { fmt.Println(err) }}Julia Julia 的优势在于对数学计算的支持非常出色。它对数学的语法支持非常好,堪称数据科学家的福音。假如有任何编程语言可以颠覆 Python, 它将是一个强有力的竞争者。 核心优势:为科学家精心设计。 主要缺点:面临着数据科学之王 Python 的竞争。 曼德布洛特集样本: using Images @inline function hsv2rgb(h, s, v) const c = v * s const x = c * (1 - abs(((h/60) % 2) - 1)) const m = v - c const r,g,b = if h < 60 (c, x, 0) elseif h < 120 (x, c, 0) elseif h < 180 (0, c, x) elseif h < 240 (0, x, c) elseif h < 300 (x, 0, c) else (c, 0, x) end (r + m), (b + m), (g + m)end function mandelbrot() const w, h = 1000, 1000 const zoom = 0.5 const moveX = 0 const moveY = 0 const img = Array{RGB{Float64}}(h, w) const maxIter = 30 for x in 1:w for y in 1:h i = maxIter const c = Complex( (2*x - w) / (w * zoom) + moveX, (2*y - h) / (h * zoom) + moveY ) z = c while abs(z) < 2 && (i -= 1) >0z = z ^ 2 + c end const r maxIter g Kotlin b = hsv2rgb (I / maxIter * 360,1, I / maxIter) img [y Float64 x] = RGB {Float64} end end save ("mandelbrot_set.png", img) end mandelbrot () Kotlin
Kotlin is an upgraded version of Java. In fact, it can completely replace the Java programming language, which Google has made as the language of choice for Android development.
Core advantage: more powerful than Java.
Main drawback: Kotlin is huge, even bigger than Java.
Mandelbrot set sample:
Import java.awt.Graphicsimport java.awt.image.BufferedImageimport javax.swing.JFrame class Mandelbrot: JFrame ("Mandelbrot Set") {companion object {private const val MAX_ITER = 570 private const val ZOOM = 150.0} privateval img: BufferedImage init {setBounds (100,100,800600) isResizable = false defaultCloseOperation = EXIT_ON_CLOSE img = BufferedImage (width, height BufferedImage.TYPE_INT_RGB) for (y in 0 until height) {for (x in 0 until width) {var zx = 0.0 var zy = 0.0 val cX = (x-400) / ZOOM val cY = (y-300) / ZOOM var iter = MAX_ITER while (zx * zx + zy * zy
< 4.0 && iter >0) {val tmp = zx * zx-zy * zy + cX zy = 2.0 * zx * zy + cY zx = tmp iter--} img.setRGB (x, y Iter or (iter shl 7))}} override fun paint (g: Graphics) {g.drawImage (img, 0,0, this)}} fun main (args: Array) {Mandelbrot (). IsVisible = true} Lua
Core strengths: Lua is a compact, simple, fast, embeddable, portable and flexible programming language.
Main disadvantage: Lua has been ignored for 26 years. Can you still make waves now?
Mandelbrot set sample:
< maxIterations ) do as = a * a - b * b; bs = 2 * a * b a = za + as; b = zb + bs if math.abs( a ) + math.abs( b ) >16 then break end cnt = cnt + 1 end if cnt = = maxIterations then clr = 0 else clr = remap (cnt, 0, maxIterations, 0,255) end pts [1] = {I, j, clr, clr, 0,255} love.graphics.points (pts) end endendfunction startFractal () love.graphics.setCanvas (canvas) Love.graphics.clear () love.graphics.setColor (255,255,255) drawMandelbrot (); love.graphics.setCanvas () endfunction love.load () wid, hei = love.graphics.getWidth (), love.graphics.getHeight () canvas = love.graphics.newCanvas (wid, hei) startFractal () endfunction love.mousepressed (x, y, button, istouch) if button = = 1 then startDrag = true; miX = x; miY = y else minX =-2.5 MaxX = 2.5; minY = minX; maxY = maxX startFractal () startDrag = false endendfunction love.mousereleased (x, y, button, istouch) if startDrag then local l if x > miX then mxX = x else l = x; mxX = miX; miX = l end if y > miY then mxY = y else l = y; mxY = miY MiY = l end miX = remap (miX, 0, wid, minX, maxX) mxX = remap (mxX, 0, wid, minX, maxX) miY = remap (miY, 0, hei, minY, maxY) mxY = remap (mxY, 0, hei, minY, maxY) minX = miX; maxX = mxX; minY = miY; maxY = mxY startFractal () endendfunction love.draw () love.graphics.draw (canvas) endPharo
Pharo is a modern version of Smalltalk and is a very efficient object-oriented programming language. In fact, Smalltalk is a model of object-oriented, and almost all other object-oriented programming languages are inspired by it. But no programming language is more object-oriented than Smalltalk.
Pharo is also one of the simplest and most elegant programming languages in the world. It only takes you 15 minutes to master all the syntax of Smalltalk.
Key advantages: the development efficiency is very high, and the programming efficiency can be increased by nearly 5 times.
The main drawback: it requires a different kind of programming thinking. But people are always afraid of change, and it is difficult to accept this kind of programming thinking.
Fractal tree samples:
Object subclass: # FractalTree instanceVariableNames:''classVariableNames:' 'poolDictionaries:' category: 'RosettaCode' "Methods for FractalTree class" tree: aPoint length: aLength angle: anAngle | p a | (aLength > 10) ifTrue: [P: = Pen new. P up. P goto: aPoint. P turn: anAngle. P down. 5 timesRepeat: [p go: aLength / 5. P turn: 5.]. A: = anAngle-30. 3 timesRepeat: [self tree: p location length: aLength * 0.7 angle: a. A: = a + 30. ]]. Draw Display restoreAfter: [Display fillWhite. Self tree: 7000000length: 200angle: 0. ] "Execute" FractalTree new draw.Rust
Rust has won wide recognition because of its memory security feature, the borrowing Checker. This feature virtually eliminates all memory-related errors. Rust provides more secure programming features.
Key advantage: helps to improve the reliability of the software.
Main disadvantage: it is difficult to learn. Borrowing an inspector is complex and difficult to understand.
Mandelbrot set sample:
Extern crate image;extern crate num_complex; use std::fs::File;use num_complex::Complex; fn main () {let max_iterations = 256u16; let img_side = 800u32; let cxmin =-2f32; let cxmax = 1f32; let cymin =-1.5f32; let cymax = 1.5f32; let scalex = (cxmax-cxmin) / img_side as f32; let scaley = (cymax-cymin) / img_side as f32 / / Create a new ImgBuf let mut imgbuf = image::ImageBuffer::new (img_side, img_side); / / Calculate for each pixel for (x, y, pixel) in imgbuf.enumerate_pixels_mut () {let cx = cxmin + x as F32 * scalex; let cy = cymin + y as F32 * scaley; let c = Complex::new (cx, cy); let mut z = Complex::new (0f32, 0f32) Let mut i = 0; for t in 0..max_iterations {if z.norm () > 2.0 {break;} z = z * z + c; I = t;} * pixel = image::Luma ([I as U8]) } / / Save image let fout = & mut File::create ("fractal.png") .unwrap (); image::ImageLuma8 (imgbuf) .save (fout, image::PNG) .unwrap ();} TypeScript
TypeScript is an enhanced version of JavaScript. It mainly adds the feature of static type.
Because TypeScript and JavaScript are fully compatible, the front-end web developers who have mastered JavaScript can easily master TypeScript, so they are very popular.
Core advantage: it is a superset of JavaScript and hasn't changed much for JavaScript developers.
Main disadvantage: because it is the super of JavaScript, it also inherits some of the historical baggage of JavaScript.
Fractal tree samples:
/ Set up canvas for drawingvar canvas: HTMLCanvasElement = document.createElement ('canvas') canvas.width = 600canvas.height = 500document.body.appendChild (canvas) var ctx: CanvasRenderingContext2D = canvas.getContext (' 2d') ctx.fillStyle ='# 000'ctx.lineWidth = 1 / / constantsconst degToRad: number = Math.PI / 180.0const totalDepth: number = 9 / * * Helper function that draws a line on the canvas * / function drawLine (x1: number, y1: number, x2: number, y2: number): void {ctx.moveTo (x1) Y1) ctx.lineTo (x2, y2)} / * * Draws a branch at the given point and angle and then calls itself twice * / function drawTree (x1: number, y1: number, angle: number Depth: number): void {if (depth! = = 0) {let x2: number = x1 + (Math.cos (angle * degToRad) * depth * 10.0) let y2: number = y1 + (Math.sin (angle * degToRad) * depth * 10.0) drawLine (x1, y1, x2, y2) drawTree (x2, y2, angle-20, depth-1) drawTree (x2, y2, angle + 20) Depth-1)}} / / actual drawing of treectx.beginPath () drawTree (300,500,-90, totalDepth) ctx.closePath () ctx.stroke ()
WebAssembly
WebAssembly is a dark horse. In the next decade or so, it is likely to derive a series of programming languages that are expected to top the list of programming languages.
Although WebAssembly is only a compilation target, there is good reason for it to be applied outside the Web domain. Which WebAssembly-based programming language will take the top spot? No one can tell.
The above content is Python and JavaScript 2020 which do you think will go further? have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.